From 86628468386b2ed19b74101fa65529b45bdb8b8c Mon Sep 17 00:00:00 2001 From: Matt Condon Date: Fri, 24 Nov 2017 14:31:52 +0200 Subject: [PATCH] feat: apply eslint --fix across project --- .eslintrc | 2 + migrations/1_initial_migration.js | 4 +- migrations/2_deploy_contracts.js | 6 +- package-lock.json | 955 +++++++++++++++++++++++++++++- test/BasicToken.js | 20 +- test/Bounty.js | 48 +- test/BurnableToken.js | 49 +- test/CanReclaimToken.js | 14 +- test/CappedCrowdsale.js | 108 ++-- test/CappedToken.js | 26 +- test/Claimable.js | 26 +- test/Contactable.js | 16 +- test/Crowdsale.js | 193 +++--- test/DayLimit.js | 32 +- test/DelayedClaimble.js | 20 +- test/Destructible.js | 17 +- test/DetailedERC20.js | 8 +- test/ECRecovery.js | 18 +- test/FinalizableCrowdsale.js | 77 ++- test/HasNoContracts.js | 10 +- test/HasNoEther.js | 24 +- test/HasNoTokens.js | 12 +- test/LimitBalance.js | 34 +- test/MerkleProof.js | 38 +- test/MintableToken.js | 16 +- test/Ownable.js | 23 +- test/Pausable.js | 24 +- test/PausableToken.js | 20 +- test/PullPayment.js | 25 +- test/ReentrancyGuard.js | 12 +- test/RefundVault.js | 68 ++- test/RefundableCrowdsale.js | 104 ++-- test/SafeERC20.js | 1 - test/SafeMath.js | 32 +- test/SampleCrowdsale.js | 39 +- test/SplitPayment.js | 90 +-- test/StandardToken.js | 53 +- test/TokenDestructible.js | 17 +- test/TokenTimelock.js | 71 ++- test/TokenVesting.js | 10 +- test/helpers/EVMRevert.js | 2 +- test/helpers/EVMThrow.js | 2 +- test/helpers/advanceToBlock.js | 14 +- test/helpers/assertJump.js | 4 +- test/helpers/assertRevert.js | 4 +- test/helpers/ether.js | 4 +- test/helpers/expectThrow.js | 2 +- test/helpers/hashMessage.js | 4 +- test/helpers/increaseTime.js | 32 +- test/helpers/latestTime.js | 2 +- test/helpers/merkleTree.js | 36 +- test/helpers/transactionMined.js | 9 +- truffle-config.js | 22 +- 53 files changed, 1692 insertions(+), 807 deletions(-) diff --git a/.eslintrc b/.eslintrc index 3bb95571e21..a6e8618d110 100644 --- a/.eslintrc +++ b/.eslintrc @@ -26,6 +26,8 @@ // Code style "indent": [2, 2], "quotes": [2, "single"], + "semi": ["error", "always"], + "space-before-function-paren": ["error", "always"], "no-use-before-define": 0, "eqeqeq": [2, "smart"], "dot-notation": [2, {"allowKeywords": true, "allowPattern": ""}], diff --git a/migrations/1_initial_migration.js b/migrations/1_initial_migration.js index 4d5f3f9b02e..a4725fe7163 100644 --- a/migrations/1_initial_migration.js +++ b/migrations/1_initial_migration.js @@ -1,5 +1,5 @@ -var Migrations = artifacts.require("./Migrations.sol"); +var Migrations = artifacts.require('./Migrations.sol'); -module.exports = function(deployer) { +module.exports = function (deployer) { deployer.deploy(Migrations); }; diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index dd7257eb4f8..19ce1ca5c9b 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -1,9 +1,9 @@ -//var Ownable = artifacts.require("ownership/Ownable.sol"); +// var Ownable = artifacts.require("ownership/Ownable.sol"); // NOTE: Use this file to easily deploy the contracts you're writing. // (but make sure to reset this file before committing // with `git checkout HEAD -- migrations/2_deploy_contracts.js`) -module.exports = function(deployer) { - //deployer.deploy(Ownable); +module.exports = function (deployer) { + // deployer.deploy(Ownable); }; diff --git a/package-lock.json b/package-lock.json index 435e645dbc9..5cf3e0e29ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,6 +42,23 @@ } } }, + "acorn-jsx": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "dev": true, + "requires": { + "acorn": "3.3.0" + }, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", + "dev": true + } + } + }, "aes-js": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-0.2.4.tgz", @@ -83,6 +100,12 @@ "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "dev": true }, + "ansi-escapes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.0.0.tgz", + "integrity": "sha512-O/klc27mWNUigtv0F8NJWbLF00OcegQalkqKURWdosW08YZKi4m6CnSUSvIZG1otNJbTWhN01Hhz389DW7mvDQ==", + "dev": true + }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -145,12 +168,33 @@ "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", "dev": true }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, + "requires": { + "array-uniq": "1.0.3" + } + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true + }, "array-unique": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", "dev": true }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, "asn1": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", @@ -1249,6 +1293,21 @@ "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", "dev": true }, + "caller-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", + "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", + "dev": true, + "requires": { + "callsites": "0.2.0" + } + }, + "callsites": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", + "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", + "dev": true + }, "camelcase": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", @@ -1313,6 +1372,12 @@ "supports-color": "2.0.0" } }, + "chardet": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", + "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", + "dev": true + }, "check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", @@ -1361,6 +1426,27 @@ "safe-buffer": "5.1.1" } }, + "circular-json": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", + "dev": true + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "2.0.0" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, "cliui": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", @@ -1408,6 +1494,21 @@ } } }, + "color-convert": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, "combined-stream": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", @@ -1429,6 +1530,17 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, + "concat-stream": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", + "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.3.3", + "typedarray": "0.0.6" + } + }, "console-browserify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", @@ -1450,6 +1562,12 @@ "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", "dev": true }, + "contains-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", + "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", + "dev": true + }, "convert-source-map": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.0.tgz", @@ -1702,6 +1820,21 @@ "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", "dev": true }, + "del": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", + "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", + "dev": true, + "requires": { + "globby": "5.0.0", + "is-path-cwd": "1.0.0", + "is-path-in-cwd": "1.0.0", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "rimraf": "2.6.1" + } + }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -1750,6 +1883,15 @@ "randombytes": "2.0.5" } }, + "doctrine": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.2.tgz", + "integrity": "sha512-y0tm5Pq6ywp3qSTZ1vPgVdAnbDEoeoc5wlOHXoY1c4Wug/a7JvqHIl7BTvwodaHmejWkK/9dSb3sCYfyo/om8A==", + "dev": true, + "requires": { + "esutils": "2.0.2" + } + }, "dom-walk": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz", @@ -1762,6 +1904,11 @@ "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=", "dev": true }, + "dotenv": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-4.0.0.tgz", + "integrity": "sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0=" + }, "drbg.js": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz", @@ -2005,12 +2152,356 @@ } } }, + "eslint": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.12.0.tgz", + "integrity": "sha512-Ohv4NU0FffkEe4so8DBrdfRUbGUtM4XnBTDll2pY7OdW3VkjBOZPerx3Bmuhg6S6D6r8+cli0EezN0xawUfYwg==", + "dev": true, + "requires": { + "ajv": "5.5.0", + "babel-code-frame": "6.22.0", + "chalk": "2.3.0", + "concat-stream": "1.6.0", + "cross-spawn": "5.1.0", + "debug": "3.1.0", + "doctrine": "2.0.2", + "eslint-scope": "3.7.1", + "espree": "3.5.2", + "esquery": "1.0.0", + "estraverse": "4.2.0", + "esutils": "2.0.2", + "file-entry-cache": "2.0.0", + "functional-red-black-tree": "1.0.1", + "glob": "7.1.2", + "globals": "11.0.1", + "ignore": "3.3.7", + "imurmurhash": "0.1.4", + "inquirer": "3.3.0", + "is-resolvable": "1.0.0", + "js-yaml": "3.10.0", + "json-stable-stringify-without-jsonify": "1.0.1", + "levn": "0.3.0", + "lodash": "4.17.4", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "natural-compare": "1.4.0", + "optionator": "0.8.2", + "path-is-inside": "1.0.2", + "pluralize": "7.0.0", + "progress": "2.0.0", + "require-uncached": "1.0.3", + "semver": "5.4.1", + "strip-ansi": "4.0.0", + "strip-json-comments": "2.0.1", + "table": "4.0.2", + "text-table": "0.2.0" + }, + "dependencies": { + "ajv": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.0.tgz", + "integrity": "sha1-6yhAdG6dxIvV4GOjbj/UAMXqtak=", + "dev": true, + "requires": { + "co": "4.6.0", + "fast-deep-equal": "1.0.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" + } + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "esprima": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", + "dev": true + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + }, + "globals": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.0.1.tgz", + "integrity": "sha1-Eqh7sBDlFUOWrMU14eQ/x1Ow5eg=", + "dev": true + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "js-yaml": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz", + "integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==", + "dev": true, + "requires": { + "argparse": "1.0.9", + "esprima": "4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, + "eslint-config-standard": { + "version": "10.2.1", + "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-10.2.1.tgz", + "integrity": "sha1-wGHk0GbzedwXzVYsZOgZtN1FRZE=", + "dev": true + }, + "eslint-import-resolver-node": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.1.tgz", + "integrity": "sha512-yUtXS15gIcij68NmXmP9Ni77AQuCN0itXbCc/jWd8C6/yKZaSNXicpC8cgvjnxVdmfsosIXrjpzFq7GcDryb6A==", + "dev": true, + "requires": { + "debug": "2.6.8", + "resolve": "1.4.0" + } + }, + "eslint-module-utils": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.1.1.tgz", + "integrity": "sha512-jDI/X5l/6D1rRD/3T43q8Qgbls2nq5km5KSqiwlyUbGo5+04fXhMKdCPhjwbqAa6HXWaMxj8Q4hQDIh7IadJQw==", + "dev": true, + "requires": { + "debug": "2.6.8", + "pkg-dir": "1.0.0" + } + }, + "eslint-plugin-import": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.8.0.tgz", + "integrity": "sha512-Rf7dfKJxZ16QuTgVv1OYNxkZcsu/hULFnC+e+w0Gzi6jMC3guQoWQgxYxc54IDRinlb6/0v5z/PxxIKmVctN+g==", + "dev": true, + "requires": { + "builtin-modules": "1.1.1", + "contains-path": "0.1.0", + "debug": "2.6.8", + "doctrine": "1.5.0", + "eslint-import-resolver-node": "0.3.1", + "eslint-module-utils": "2.1.1", + "has": "1.0.1", + "lodash.cond": "4.5.2", + "minimatch": "3.0.4", + "read-pkg-up": "2.0.0" + }, + "dependencies": { + "doctrine": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", + "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", + "dev": true, + "requires": { + "esutils": "2.0.2", + "isarray": "1.0.0" + } + }, + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "2.0.0" + } + }, + "load-json-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "parse-json": "2.2.0", + "pify": "2.3.0", + "strip-bom": "3.0.0" + } + }, + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "dev": true, + "requires": { + "pify": "2.3.0" + } + }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "dev": true, + "requires": { + "load-json-file": "2.0.0", + "normalize-package-data": "2.4.0", + "path-type": "2.0.0" + } + }, + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "dev": true, + "requires": { + "find-up": "2.1.0", + "read-pkg": "2.0.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + } + } + }, + "eslint-plugin-node": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-5.2.1.tgz", + "integrity": "sha512-xhPXrh0Vl/b7870uEbaumb2Q+LxaEcOQ3kS1jtIXanBAwpMre1l5q/l2l/hESYJGEFKuI78bp6Uw50hlpr7B+g==", + "dev": true, + "requires": { + "ignore": "3.3.7", + "minimatch": "3.0.4", + "resolve": "1.4.0", + "semver": "5.3.0" + }, + "dependencies": { + "semver": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", + "dev": true + } + } + }, + "eslint-plugin-promise": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-3.6.0.tgz", + "integrity": "sha512-YQzM6TLTlApAr7Li8vWKR+K3WghjwKcYzY0d2roWap4SLK+kzuagJX/leTetIDWsFcTFnKNJXWupDCD6aZkP2Q==", + "dev": true + }, + "eslint-plugin-standard": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-3.0.1.tgz", + "integrity": "sha1-NNDJFbRe3G8BA5PH7vOCOwhWXPI=", + "dev": true + }, + "eslint-scope": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz", + "integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=", + "dev": true, + "requires": { + "esrecurse": "4.2.0", + "estraverse": "4.2.0" + }, + "dependencies": { + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + } + } + }, + "espree": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.2.tgz", + "integrity": "sha512-sadKeYwaR/aJ3stC2CdvgXu1T16TdYN+qwCpcWbMnGJ8s0zNWemzrvb2GbD4OhmJ/fwpJjudThAlLobGbWZbCQ==", + "dev": true, + "requires": { + "acorn": "5.2.1", + "acorn-jsx": "3.0.1" + }, + "dependencies": { + "acorn": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.2.1.tgz", + "integrity": "sha512-jG0u7c4Ly+3QkkW18V+NRDN+4bWHdln30NL1ZL2AvFZZmQe/BfopYCtghCKKVBUSetZ4QKcyA0pY6/4Gw8Pv8w==", + "dev": true + } + } + }, "esprima": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", "dev": true }, + "esquery": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.0.tgz", + "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=", + "dev": true, + "requires": { + "estraverse": "4.2.0" + }, + "dependencies": { + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + } + } + }, "esrecurse": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.0.tgz", @@ -2317,6 +2808,17 @@ "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", "dev": true }, + "external-editor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz", + "integrity": "sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA==", + "dev": true, + "requires": { + "chardet": "0.4.2", + "iconv-lite": "0.4.18", + "tmp": "0.0.33" + } + }, "extglob": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", @@ -2347,12 +2849,37 @@ "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", "dev": true }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "dev": true, + "requires": { + "escape-string-regexp": "1.0.5" + } + }, + "file-entry-cache": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", + "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "dev": true, + "requires": { + "flat-cache": "1.3.0", + "object-assign": "4.1.1" + } + }, "filename-regex": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", @@ -2382,6 +2909,18 @@ "pinkie-promise": "2.0.1" } }, + "flat-cache": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", + "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", + "dev": true, + "requires": { + "circular-json": "0.3.3", + "del": "2.2.2", + "graceful-fs": "4.1.11", + "write": "0.2.1" + } + }, "for-each": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.2.tgz", @@ -2451,7 +2990,7 @@ "fsevents": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz", - "integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==", + "integrity": "sha1-EfgjGPX+e7LNIpZaEI6TBiCCFtg=", "dev": true, "optional": true, "requires": { @@ -3485,6 +4024,20 @@ "integrity": "sha1-qjiWs+abSH8X4x7SFD1pqOMMLYo=", "dev": true }, + "globby": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", + "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", + "dev": true, + "requires": { + "array-union": "1.0.2", + "arrify": "1.0.1", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + } + }, "graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", @@ -3677,12 +4230,24 @@ "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=", "dev": true }, + "ignore": { + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", + "dev": true + }, "immediate": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.2.3.tgz", "integrity": "sha1-0UD6j2FGWb1lQSMwl92qwlzdmRw=", "dev": true }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, "indexof": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", @@ -3711,6 +4276,96 @@ "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", "dev": true }, + "inquirer": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", + "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", + "dev": true, + "requires": { + "ansi-escapes": "3.0.0", + "chalk": "2.3.0", + "cli-cursor": "2.1.0", + "cli-width": "2.2.0", + "external-editor": "2.1.0", + "figures": "2.0.0", + "lodash": "4.17.4", + "mute-stream": "0.0.7", + "run-async": "2.3.0", + "rx-lite": "4.0.8", + "rx-lite-aggregates": "4.0.8", + "string-width": "2.1.1", + "strip-ansi": "4.0.0", + "through": "2.3.8" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, "interpret": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.3.tgz", @@ -3861,6 +4516,30 @@ "kind-of": "3.2.2" } }, + "is-path-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", + "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", + "dev": true + }, + "is-path-in-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz", + "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", + "dev": true, + "requires": { + "is-path-inside": "1.0.0" + } + }, + "is-path-inside": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz", + "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", + "dev": true, + "requires": { + "path-is-inside": "1.0.2" + } + }, "is-posix-bracket": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", @@ -3873,6 +4552,12 @@ "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", "dev": true }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "dev": true + }, "is-property": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", @@ -3888,6 +4573,15 @@ "has": "1.0.1" } }, + "is-resolvable": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz", + "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=", + "dev": true, + "requires": { + "tryit": "1.0.3" + } + }, "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", @@ -4087,6 +4781,12 @@ "jsonify": "0.0.0" } }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", @@ -4425,6 +5125,12 @@ "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=", "dev": true }, + "lodash.cond": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/lodash.cond/-/lodash.cond-4.5.2.tgz", + "integrity": "sha1-9HGh2khr5g9quVXRcRVSPdHSVdU=", + "dev": true + }, "lodash.create": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz", @@ -4754,12 +5460,24 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "dev": true + }, "nan": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/nan/-/nan-2.6.2.tgz", "integrity": "sha1-5P805slf37WuzAjeZZb0NgWn20U=", "dev": true }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, "node-abi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.1.0.tgz", @@ -4927,6 +5645,15 @@ "wrappy": "1.0.2" } }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "1.1.0" + } + }, "optimist": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", @@ -5084,6 +5811,12 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", @@ -5153,6 +5886,21 @@ "pinkie": "2.0.4" } }, + "pkg-dir": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz", + "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", + "dev": true, + "requires": { + "find-up": "1.1.2" + } + }, + "pluralize": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", + "dev": true + }, "prebuild-install": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-2.2.2.tgz", @@ -5222,6 +5970,12 @@ "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", "dev": true }, + "progress": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", + "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", + "dev": true + }, "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", @@ -5558,6 +6312,24 @@ "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", "dev": true }, + "require-uncached": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "dev": true, + "requires": { + "caller-path": "0.1.0", + "resolve-from": "1.0.1" + }, + "dependencies": { + "resolve-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", + "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "dev": true + } + } + }, "resolve": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", @@ -5573,6 +6345,16 @@ "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=", "dev": true }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "2.0.1", + "signal-exit": "3.0.2" + } + }, "resumer": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", @@ -5616,6 +6398,30 @@ "integrity": "sha1-nbOE/0uJqPYVY9kjldhiWxjzr7A=", "dev": true }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "2.1.0" + } + }, + "rx-lite": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", + "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", + "dev": true + }, + "rx-lite-aggregates": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", + "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "dev": true, + "requires": { + "rx-lite": "4.0.8" + } + }, "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", @@ -5770,6 +6576,23 @@ "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", "dev": true }, + "slice-ansi": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + } + } + }, "sntp": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", @@ -6077,6 +6900,100 @@ "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", "dev": true }, + "table": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", + "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", + "dev": true, + "requires": { + "ajv": "5.5.0", + "ajv-keywords": "2.1.0", + "chalk": "2.3.0", + "lodash": "4.17.4", + "slice-ansi": "1.0.0", + "string-width": "2.1.1" + }, + "dependencies": { + "ajv": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.0.tgz", + "integrity": "sha1-6yhAdG6dxIvV4GOjbj/UAMXqtak=", + "dev": true, + "requires": { + "co": "4.6.0", + "fast-deep-equal": "1.0.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" + } + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, "tapable": { "version": "0.2.8", "resolved": "https://registry.npmjs.org/tapable/-/tapable-0.2.8.tgz", @@ -6136,6 +7053,12 @@ "xtend": "4.0.1" } }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -6152,6 +7075,15 @@ "setimmediate": "1.0.5" } }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "requires": { + "os-tmpdir": "1.0.2" + } + }, "to-arraybuffer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", @@ -6371,6 +7303,12 @@ } } }, + "tryit": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz", + "integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics=", + "dev": true + }, "tty-browserify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", @@ -6405,6 +7343,12 @@ "integrity": "sha1-Dj8mcLRAmbC0bChNE2p+9Jx0wuo=", "dev": true }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, "uglify-js": { "version": "2.8.29", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", @@ -6867,6 +7811,15 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, + "write": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "dev": true, + "requires": { + "mkdirp": "0.5.1" + } + }, "xhr": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/xhr/-/xhr-2.4.0.tgz", diff --git a/test/BasicToken.js b/test/BasicToken.js index 4694ddfbf01..91d755257a1 100644 --- a/test/BasicToken.js +++ b/test/BasicToken.js @@ -1,17 +1,16 @@ const assertRevert = require('./helpers/assertRevert'); -var BasicTokenMock = artifacts.require("./helpers/BasicTokenMock.sol"); +var BasicTokenMock = artifacts.require('./helpers/BasicTokenMock.sol'); -contract('BasicToken', function(accounts) { - - it("should return the correct totalSupply after construction", async function() { +contract('BasicToken', function (accounts) { + it('should return the correct totalSupply after construction', async function () { let token = await BasicTokenMock.new(accounts[0], 100); let totalSupply = await token.totalSupply(); assert.equal(totalSupply, 100); - }) + }); - it("should return correct balances after transfer", async function(){ + it('should return correct balances after transfer', async function () { let token = await BasicTokenMock.new(accounts[0], 100); let transfer = await token.transfer(accounts[1], 100); @@ -22,24 +21,23 @@ contract('BasicToken', function(accounts) { assert.equal(secondAccountBalance, 100); }); - it('should throw an error when trying to transfer more than balance', async function() { + it('should throw an error when trying to transfer more than balance', async function () { let token = await BasicTokenMock.new(accounts[0], 100); try { let transfer = await token.transfer(accounts[1], 101); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } }); - it('should throw an error when trying to transfer to 0x0', async function() { + it('should throw an error when trying to transfer to 0x0', async function () { let token = await BasicTokenMock.new(accounts[0], 100); try { let transfer = await token.transfer(0x0, 100); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } }); - }); diff --git a/test/Bounty.js b/test/Bounty.js index 26b020fcbb7..4e67db7a020 100644 --- a/test/Bounty.js +++ b/test/Bounty.js @@ -1,18 +1,17 @@ -'use strict'; -let sendReward = function(sender, receiver, value){ +let sendReward = function (sender, receiver, value) { web3.eth.sendTransaction({ - from:sender, - to:receiver, - value: value + from: sender, + to: receiver, + value: value, }); }; var SecureTargetBounty = artifacts.require('helpers/SecureTargetBounty.sol'); var InsecureTargetBounty = artifacts.require('helpers/InsecureTargetBounty.sol'); -function awaitEvent(event, handler) { +function awaitEvent (event, handler) { return new Promise((resolve, reject) => { - function wrappedHandler(...args) { + function wrappedHandler (...args) { Promise.resolve(handler(...args)).then(resolve).catch(reject); } @@ -20,9 +19,8 @@ function awaitEvent(event, handler) { }); } -contract('Bounty', function(accounts) { - - it('sets reward', async function() { +contract('Bounty', function (accounts) { + it('sets reward', async function () { let owner = accounts[0]; let reward = web3.toWei(1, 'ether'); let bounty = await SecureTargetBounty.new(); @@ -31,7 +29,7 @@ contract('Bounty', function(accounts) { assert.equal(reward, web3.eth.getBalance(bounty.address).toNumber()); }); - it('empties itself when destroyed', async function(){ + it('empties itself when destroyed', async function () { let owner = accounts[0]; let reward = web3.toWei(1, 'ether'); let bounty = await SecureTargetBounty.new(); @@ -43,16 +41,15 @@ contract('Bounty', function(accounts) { assert.equal(0, web3.eth.getBalance(bounty.address).toNumber()); }); - describe('Against secure contract', function(){ - - it('cannot claim reward', async function(){ + describe('Against secure contract', function () { + it('cannot claim reward', async function () { let owner = accounts[0]; let researcher = accounts[1]; let reward = web3.toWei(1, 'ether'); let bounty = await SecureTargetBounty.new(); let event = bounty.TargetCreated({}); - let watcher = async function(err, result) { + let watcher = async function (err, result) { event.stopWatching(); if (err) { throw err; } @@ -63,35 +60,34 @@ contract('Bounty', function(accounts) { web3.eth.getBalance(bounty.address).toNumber()); try { - await bounty.claim(targetAddress, {from:researcher}); + await bounty.claim(targetAddress, { from: researcher }); assert.isTrue(false); // should never reach here - } catch(error) { + } catch (error) { let reClaimedBounty = await bounty.claimed.call(); assert.isFalse(reClaimedBounty); - } try { - await bounty.withdrawPayments({from:researcher}); + await bounty.withdrawPayments({ from: researcher }); assert.isTrue(false); // should never reach here } catch (err) { assert.equal(reward, web3.eth.getBalance(bounty.address).toNumber()); } }; - bounty.createTarget({from:researcher}); + bounty.createTarget({ from: researcher }); await awaitEvent(event, watcher); }); }); - describe('Against broken contract', function(){ - it('claims reward', async function() { + describe('Against broken contract', function () { + it('claims reward', async function () { let owner = accounts[0]; let researcher = accounts[1]; let reward = web3.toWei(1, 'ether'); let bounty = await InsecureTargetBounty.new(); let event = bounty.TargetCreated({}); - let watcher = async function(err, result) { + let watcher = async function (err, result) { event.stopWatching(); if (err) { throw err; } let targetAddress = result.args.createdAddress; @@ -99,16 +95,16 @@ contract('Bounty', function(accounts) { assert.equal(reward, web3.eth.getBalance(bounty.address).toNumber()); - await bounty.claim(targetAddress, {from:researcher}); + await bounty.claim(targetAddress, { from: researcher }); let claim = await bounty.claimed.call(); assert.isTrue(claim); - await bounty.withdrawPayments({from:researcher}); + await bounty.withdrawPayments({ from: researcher }); assert.equal(0, web3.eth.getBalance(bounty.address).toNumber()); }; - bounty.createTarget({from:researcher}); + bounty.createTarget({ from: researcher }); await awaitEvent(event, watcher); }); }); diff --git a/test/BurnableToken.js b/test/BurnableToken.js index d196b8c3733..6658b24535d 100644 --- a/test/BurnableToken.js +++ b/test/BurnableToken.js @@ -1,39 +1,38 @@ -'use strict' -const EVMRevert = require('./helpers/EVMRevert.js') -const BurnableTokenMock = artifacts.require("./helpers/BurnableTokenMock.sol") -const BigNumber = web3.BigNumber +const EVMRevert = require('./helpers/EVMRevert.js'); +const BurnableTokenMock = artifacts.require('./helpers/BurnableTokenMock.sol'); +const BigNumber = web3.BigNumber; require('chai') .use(require('chai-as-promised')) .use(require('chai-bignumber')(BigNumber)) - .should() + .should(); -const expect = require('chai').expect +const expect = require('chai').expect; contract('BurnableToken', function (accounts) { - let token - let expectedTokenSupply = new BigNumber(999) + let token; + let expectedTokenSupply = new BigNumber(999); - beforeEach(async function () { - token = await BurnableTokenMock.new(accounts[0], 1000) - }) + beforeEach(async function () { + token = await BurnableTokenMock.new(accounts[0], 1000); + }); - it('owner should be able to burn tokens', async function () { - const { logs } = await token.burn(1, { from: accounts[0] }) + it('owner should be able to burn tokens', async function () { + const { logs } = await token.burn(1, { from: accounts[0] }); - const balance = await token.balanceOf(accounts[0]) - balance.should.be.bignumber.equal(expectedTokenSupply) + const balance = await token.balanceOf(accounts[0]); + balance.should.be.bignumber.equal(expectedTokenSupply); - const totalSupply = await token.totalSupply() - totalSupply.should.be.bignumber.equal(expectedTokenSupply) + const totalSupply = await token.totalSupply(); + totalSupply.should.be.bignumber.equal(expectedTokenSupply); - const event = logs.find(e => e.event === 'Burn') - expect(event).to.exist - }) + const event = logs.find(e => e.event === 'Burn'); + expect(event).to.exist; + }); - it('cannot burn more tokens than your balance', async function () { - await token.burn(2000, { from: accounts[0] }) - .should.be.rejectedWith(EVMRevert) - }) -}) + it('cannot burn more tokens than your balance', async function () { + await token.burn(2000, { from: accounts[0] }) + .should.be.rejectedWith(EVMRevert); + }); +}); diff --git a/test/CanReclaimToken.js b/test/CanReclaimToken.js index b8efceea486..a6f4055ad7a 100644 --- a/test/CanReclaimToken.js +++ b/test/CanReclaimToken.js @@ -1,14 +1,14 @@ -'use strict'; + import expectThrow from './helpers/expectThrow'; import toPromise from './helpers/toPromise'; const CanReclaimToken = artifacts.require('../contracts/ownership/CanReclaimToken.sol'); -const BasicTokenMock = artifacts.require("./helpers/BasicTokenMock.sol"); +const BasicTokenMock = artifacts.require('./helpers/BasicTokenMock.sol'); -contract('CanReclaimToken', function(accounts) { +contract('CanReclaimToken', function (accounts) { let token = null; let canReclaimToken = null; - beforeEach(async function() { + beforeEach(async function () { // Create contract and token token = await BasicTokenMock.new(accounts[0], 100); canReclaimToken = await CanReclaimToken.new(); @@ -18,7 +18,7 @@ contract('CanReclaimToken', function(accounts) { assert.equal(startBalance, 10); }); - it('should allow owner to reclaim tokens', async function() { + it('should allow owner to reclaim tokens', async function () { const ownerStartBalance = await token.balanceOf(accounts[0]); await canReclaimToken.reclaimToken(token.address); const ownerFinalBalance = await token.balanceOf(accounts[0]); @@ -27,9 +27,9 @@ contract('CanReclaimToken', function(accounts) { assert.equal(ownerFinalBalance - ownerStartBalance, 10); }); - it('should allow only owner to reclaim tokens', async function() { + it('should allow only owner to reclaim tokens', async function () { await expectThrow( - canReclaimToken.reclaimToken(token.address, {from: accounts[1]}), + canReclaimToken.reclaimToken(token.address, { from: accounts[1] }), ); }); }); diff --git a/test/CappedCrowdsale.js b/test/CappedCrowdsale.js index 85c6b0e92ca..dbbff6e79ac 100644 --- a/test/CappedCrowdsale.js +++ b/test/CappedCrowdsale.js @@ -1,96 +1,88 @@ -import ether from './helpers/ether' -import {advanceBlock} from './helpers/advanceToBlock' -import {increaseTimeTo, duration} from './helpers/increaseTime' -import latestTime from './helpers/latestTime' -import EVMRevert from './helpers/EVMRevert' +import ether from './helpers/ether'; +import { advanceBlock } from './helpers/advanceToBlock'; +import { increaseTimeTo, duration } from './helpers/increaseTime'; +import latestTime from './helpers/latestTime'; +import EVMRevert from './helpers/EVMRevert'; -const BigNumber = web3.BigNumber +const BigNumber = web3.BigNumber; require('chai') .use(require('chai-as-promised')) .use(require('chai-bignumber')(BigNumber)) - .should() + .should(); -const CappedCrowdsale = artifacts.require('./helpers/CappedCrowdsaleImpl.sol') -const MintableToken = artifacts.require('MintableToken') +const CappedCrowdsale = artifacts.require('./helpers/CappedCrowdsaleImpl.sol'); +const MintableToken = artifacts.require('MintableToken'); contract('CappedCrowdsale', function ([_, wallet]) { + const rate = new BigNumber(1000); - const rate = new BigNumber(1000) + const cap = ether(300); + const lessThanCap = ether(60); - const cap = ether(300) - const lessThanCap = ether(60) - - before(async function() { - //Advance to the next block to correctly read time in the solidity "now" function interpreted by testrpc - await advanceBlock() - }) + before(async function () { + // Advance to the next block to correctly read time in the solidity "now" function interpreted by testrpc + await advanceBlock(); + }); beforeEach(async function () { this.startTime = latestTime() + duration.weeks(1); - this.endTime = this.startTime + duration.weeks(1); + this.endTime = this.startTime + duration.weeks(1); - this.crowdsale = await CappedCrowdsale.new(this.startTime, this.endTime, rate, wallet, cap) + this.crowdsale = await CappedCrowdsale.new(this.startTime, this.endTime, rate, wallet, cap); - this.token = MintableToken.at(await this.crowdsale.token()) - }) + this.token = MintableToken.at(await this.crowdsale.token()); + }); describe('creating a valid crowdsale', function () { - it('should fail with zero cap', async function () { await CappedCrowdsale.new(this.startTime, this.endTime, rate, wallet, 0).should.be.rejectedWith(EVMRevert); - }) - + }); }); describe('accepting payments', function () { - beforeEach(async function () { - await increaseTimeTo(this.startTime) - }) + await increaseTimeTo(this.startTime); + }); it('should accept payments within cap', async function () { - await this.crowdsale.send(cap.minus(lessThanCap)).should.be.fulfilled - await this.crowdsale.send(lessThanCap).should.be.fulfilled - }) + await this.crowdsale.send(cap.minus(lessThanCap)).should.be.fulfilled; + await this.crowdsale.send(lessThanCap).should.be.fulfilled; + }); it('should reject payments outside cap', async function () { - await this.crowdsale.send(cap) - await this.crowdsale.send(1).should.be.rejectedWith(EVMRevert) - }) + await this.crowdsale.send(cap); + await this.crowdsale.send(1).should.be.rejectedWith(EVMRevert); + }); it('should reject payments that exceed cap', async function () { - await this.crowdsale.send(cap.plus(1)).should.be.rejectedWith(EVMRevert) - }) - - }) + await this.crowdsale.send(cap.plus(1)).should.be.rejectedWith(EVMRevert); + }); + }); describe('ending', function () { - beforeEach(async function () { - await increaseTimeTo(this.startTime) - }) + await increaseTimeTo(this.startTime); + }); it('should not be ended if under cap', async function () { - let hasEnded = await this.crowdsale.hasEnded() - hasEnded.should.equal(false) - await this.crowdsale.send(lessThanCap) - hasEnded = await this.crowdsale.hasEnded() - hasEnded.should.equal(false) - }) + let hasEnded = await this.crowdsale.hasEnded(); + hasEnded.should.equal(false); + await this.crowdsale.send(lessThanCap); + hasEnded = await this.crowdsale.hasEnded(); + hasEnded.should.equal(false); + }); it('should not be ended if just under cap', async function () { - await this.crowdsale.send(cap.minus(1)) - let hasEnded = await this.crowdsale.hasEnded() - hasEnded.should.equal(false) - }) + await this.crowdsale.send(cap.minus(1)); + let hasEnded = await this.crowdsale.hasEnded(); + hasEnded.should.equal(false); + }); it('should be ended if cap reached', async function () { - await this.crowdsale.send(cap) - let hasEnded = await this.crowdsale.hasEnded() - hasEnded.should.equal(true) - }) - - }) - -}) + await this.crowdsale.send(cap); + let hasEnded = await this.crowdsale.hasEnded(); + hasEnded.should.equal(true); + }); + }); +}); diff --git a/test/CappedToken.js b/test/CappedToken.js index 55d99840429..f8335e20263 100644 --- a/test/CappedToken.js +++ b/test/CappedToken.js @@ -1,39 +1,37 @@ -'use strict'; import expectThrow from './helpers/expectThrow'; import ether from './helpers/ether'; var CappedToken = artifacts.require('../contracts/Tokens/CappedToken.sol'); -const BigNumber = web3.BigNumber +const BigNumber = web3.BigNumber; -contract('Capped', function(accounts) { +contract('Capped', function (accounts) { const cap = ether(1000); let token; - beforeEach(async function() { + beforeEach(async function () { token = await CappedToken.new(cap); - }) + }); - it('should start with the correct cap', async function() { + it('should start with the correct cap', async function () { let _cap = await token.cap(); assert(cap.eq(_cap)); - }) + }); - it('should mint when amount is less than cap', async function() { + it('should mint when amount is less than cap', async function () { const result = await token.mint(accounts[0], 100); assert.equal(result.logs[0].event, 'Mint'); - }) + }); - it('should fail to mint if the ammount exceeds the cap', async function() { + it('should fail to mint if the ammount exceeds the cap', async function () { await token.mint(accounts[0], cap.sub(1)); await expectThrow(token.mint(accounts[0], 100)); - }) + }); - it('should fail to mint after cap is reached', async function() { + it('should fail to mint after cap is reached', async function () { await token.mint(accounts[0], cap); await expectThrow(token.mint(accounts[0], 1)); - }) - + }); }); diff --git a/test/Claimable.js b/test/Claimable.js index 8a62d0aeb4d..1004e512ced 100644 --- a/test/Claimable.js +++ b/test/Claimable.js @@ -1,21 +1,21 @@ -'use strict'; + const assertRevert = require('./helpers/assertRevert'); var Claimable = artifacts.require('../contracts/ownership/Claimable.sol'); -contract('Claimable', function(accounts) { +contract('Claimable', function (accounts) { let claimable; - beforeEach(async function() { + beforeEach(async function () { claimable = await Claimable.new(); }); - it('should have an owner', async function() { + it('should have an owner', async function () { let owner = await claimable.owner(); assert.isTrue(owner !== 0); }); - it('changes pendingOwner after transfer', async function() { + it('changes pendingOwner after transfer', async function () { let newOwner = accounts[1]; await claimable.transferOwnership(newOwner); let pendingOwner = await claimable.pendingOwner(); @@ -23,23 +23,23 @@ contract('Claimable', function(accounts) { assert.isTrue(pendingOwner === newOwner); }); - it('should prevent to claimOwnership from no pendingOwner', async function() { + it('should prevent to claimOwnership from no pendingOwner', async function () { try { - await claimable.claimOwnership({from: accounts[2]}); + await claimable.claimOwnership({ from: accounts[2] }); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } }); - it('should prevent non-owners from transfering', async function() { + it('should prevent non-owners from transfering', async function () { const other = accounts[2]; const owner = await claimable.owner.call(); assert.isTrue(owner !== other); try { - await claimable.transferOwnership(other, {from: other}); + await claimable.transferOwnership(other, { from: other }); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } }); @@ -52,8 +52,8 @@ contract('Claimable', function(accounts) { await claimable.transferOwnership(newOwner); }); - it('changes allow pending owner to claim ownership', async function() { - await claimable.claimOwnership({from: newOwner}); + it('changes allow pending owner to claim ownership', async function () { + await claimable.claimOwnership({ from: newOwner }); let owner = await claimable.owner(); assert.isTrue(owner === newOwner); diff --git a/test/Contactable.js b/test/Contactable.js index 789da6c3298..9893e3a979a 100644 --- a/test/Contactable.js +++ b/test/Contactable.js @@ -1,30 +1,30 @@ -'use strict'; + const assertRevert = require('./helpers/assertRevert'); var Contactable = artifacts.require('../contracts/ownership/Contactable.sol'); -contract('Contactable', function(accounts) { +contract('Contactable', function (accounts) { let contactable; - beforeEach(async function() { + beforeEach(async function () { contactable = await Contactable.new(); }); - it('should have an empty contact info', async function() { + it('should have an empty contact info', async function () { let info = await contactable.contactInformation(); - assert.isTrue(info == ""); + assert.isTrue(info == ''); }); describe('after setting the contact information', function () { - let contactInfo = "contact information" + let contactInfo = 'contact information'; beforeEach(async function () { await contactable.setContactInformation(contactInfo); }); - it('should return the setted contact information', async function() { + it('should return the setted contact information', async function () { let info = await contactable.contactInformation(); assert.isTrue(info === contactInfo); - }); + }); }); }); diff --git a/test/Crowdsale.js b/test/Crowdsale.js index 3df75ba3223..7d8555e5f11 100644 --- a/test/Crowdsale.js +++ b/test/Crowdsale.js @@ -1,152 +1,143 @@ -import ether from './helpers/ether' -import {advanceBlock} from './helpers/advanceToBlock' -import {increaseTimeTo, duration} from './helpers/increaseTime' -import latestTime from './helpers/latestTime' -import EVMRevert from './helpers/EVMRevert' +import ether from './helpers/ether'; +import { advanceBlock } from './helpers/advanceToBlock'; +import { increaseTimeTo, duration } from './helpers/increaseTime'; +import latestTime from './helpers/latestTime'; +import EVMRevert from './helpers/EVMRevert'; -const BigNumber = web3.BigNumber +const BigNumber = web3.BigNumber; const should = require('chai') .use(require('chai-as-promised')) .use(require('chai-bignumber')(BigNumber)) - .should() + .should(); -const Crowdsale = artifacts.require('Crowdsale') -const MintableToken = artifacts.require('MintableToken') +const Crowdsale = artifacts.require('Crowdsale'); +const MintableToken = artifacts.require('MintableToken'); contract('Crowdsale', function ([_, investor, wallet, purchaser]) { + const rate = new BigNumber(1000); + const value = ether(42); - const rate = new BigNumber(1000) - const value = ether(42) + const expectedTokenAmount = rate.mul(value); - const expectedTokenAmount = rate.mul(value) - - before(async function() { - //Advance to the next block to correctly read time in the solidity "now" function interpreted by testrpc - await advanceBlock() - }) + before(async function () { + // Advance to the next block to correctly read time in the solidity "now" function interpreted by testrpc + await advanceBlock(); + }); beforeEach(async function () { this.startTime = latestTime() + duration.weeks(1); - this.endTime = this.startTime + duration.weeks(1); - this.afterEndTime = this.endTime + duration.seconds(1) - + this.endTime = this.startTime + duration.weeks(1); + this.afterEndTime = this.endTime + duration.seconds(1); - this.crowdsale = await Crowdsale.new(this.startTime, this.endTime, rate, wallet) + this.crowdsale = await Crowdsale.new(this.startTime, this.endTime, rate, wallet); - this.token = MintableToken.at(await this.crowdsale.token()) - }) + this.token = MintableToken.at(await this.crowdsale.token()); + }); it('should be token owner', async function () { - const owner = await this.token.owner() - owner.should.equal(this.crowdsale.address) - }) + const owner = await this.token.owner(); + owner.should.equal(this.crowdsale.address); + }); it('should be ended only after end', async function () { - let ended = await this.crowdsale.hasEnded() - ended.should.equal(false) - await increaseTimeTo(this.afterEndTime) - ended = await this.crowdsale.hasEnded() - ended.should.equal(true) - }) + let ended = await this.crowdsale.hasEnded(); + ended.should.equal(false); + await increaseTimeTo(this.afterEndTime); + ended = await this.crowdsale.hasEnded(); + ended.should.equal(true); + }); describe('accepting payments', function () { - it('should reject payments before start', async function () { - await this.crowdsale.send(value).should.be.rejectedWith(EVMRevert) - await this.crowdsale.buyTokens(investor, {from: purchaser, value: value}).should.be.rejectedWith(EVMRevert) - }) + await this.crowdsale.send(value).should.be.rejectedWith(EVMRevert); + await this.crowdsale.buyTokens(investor, { from: purchaser, value: value }).should.be.rejectedWith(EVMRevert); + }); it('should accept payments after start', async function () { - await increaseTimeTo(this.startTime) - await this.crowdsale.send(value).should.be.fulfilled - await this.crowdsale.buyTokens(investor, {value: value, from: purchaser}).should.be.fulfilled - }) + await increaseTimeTo(this.startTime); + await this.crowdsale.send(value).should.be.fulfilled; + await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }).should.be.fulfilled; + }); it('should reject payments after end', async function () { - await increaseTimeTo(this.afterEndTime) - await this.crowdsale.send(value).should.be.rejectedWith(EVMRevert) - await this.crowdsale.buyTokens(investor, {value: value, from: purchaser}).should.be.rejectedWith(EVMRevert) - }) - - }) + await increaseTimeTo(this.afterEndTime); + await this.crowdsale.send(value).should.be.rejectedWith(EVMRevert); + await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }).should.be.rejectedWith(EVMRevert); + }); + }); describe('high-level purchase', function () { - - beforeEach(async function() { - await increaseTimeTo(this.startTime) - }) + beforeEach(async function () { + await increaseTimeTo(this.startTime); + }); it('should log purchase', async function () { - const {logs} = await this.crowdsale.sendTransaction({value: value, from: investor}) + const { logs } = await this.crowdsale.sendTransaction({ value: value, from: investor }); - const event = logs.find(e => e.event === 'TokenPurchase') + const event = logs.find(e => e.event === 'TokenPurchase'); - should.exist(event) - event.args.purchaser.should.equal(investor) - event.args.beneficiary.should.equal(investor) - event.args.value.should.be.bignumber.equal(value) - event.args.amount.should.be.bignumber.equal(expectedTokenAmount) - }) + should.exist(event); + event.args.purchaser.should.equal(investor); + event.args.beneficiary.should.equal(investor); + event.args.value.should.be.bignumber.equal(value); + event.args.amount.should.be.bignumber.equal(expectedTokenAmount); + }); it('should increase totalSupply', async function () { - await this.crowdsale.send(value) - const totalSupply = await this.token.totalSupply() - totalSupply.should.be.bignumber.equal(expectedTokenAmount) - }) + await this.crowdsale.send(value); + const totalSupply = await this.token.totalSupply(); + totalSupply.should.be.bignumber.equal(expectedTokenAmount); + }); it('should assign tokens to sender', async function () { - await this.crowdsale.sendTransaction({value: value, from: investor}) + await this.crowdsale.sendTransaction({ value: value, from: investor }); let balance = await this.token.balanceOf(investor); - balance.should.be.bignumber.equal(expectedTokenAmount) - }) + balance.should.be.bignumber.equal(expectedTokenAmount); + }); it('should forward funds to wallet', async function () { - const pre = web3.eth.getBalance(wallet) - await this.crowdsale.sendTransaction({value, from: investor}) - const post = web3.eth.getBalance(wallet) - post.minus(pre).should.be.bignumber.equal(value) - }) - - }) + const pre = web3.eth.getBalance(wallet); + await this.crowdsale.sendTransaction({ value, from: investor }); + const post = web3.eth.getBalance(wallet); + post.minus(pre).should.be.bignumber.equal(value); + }); + }); describe('low-level purchase', function () { - - beforeEach(async function() { - await increaseTimeTo(this.startTime) - }) + beforeEach(async function () { + await increaseTimeTo(this.startTime); + }); it('should log purchase', async function () { - const {logs} = await this.crowdsale.buyTokens(investor, {value: value, from: purchaser}) + const { logs } = await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }); - const event = logs.find(e => e.event === 'TokenPurchase') + const event = logs.find(e => e.event === 'TokenPurchase'); - should.exist(event) - event.args.purchaser.should.equal(purchaser) - event.args.beneficiary.should.equal(investor) - event.args.value.should.be.bignumber.equal(value) - event.args.amount.should.be.bignumber.equal(expectedTokenAmount) - }) + should.exist(event); + event.args.purchaser.should.equal(purchaser); + event.args.beneficiary.should.equal(investor); + event.args.value.should.be.bignumber.equal(value); + event.args.amount.should.be.bignumber.equal(expectedTokenAmount); + }); it('should increase totalSupply', async function () { - await this.crowdsale.buyTokens(investor, {value, from: purchaser}) - const totalSupply = await this.token.totalSupply() - totalSupply.should.be.bignumber.equal(expectedTokenAmount) - }) + await this.crowdsale.buyTokens(investor, { value, from: purchaser }); + const totalSupply = await this.token.totalSupply(); + totalSupply.should.be.bignumber.equal(expectedTokenAmount); + }); it('should assign tokens to beneficiary', async function () { - await this.crowdsale.buyTokens(investor, {value, from: purchaser}) - const balance = await this.token.balanceOf(investor) - balance.should.be.bignumber.equal(expectedTokenAmount) - }) + await this.crowdsale.buyTokens(investor, { value, from: purchaser }); + const balance = await this.token.balanceOf(investor); + balance.should.be.bignumber.equal(expectedTokenAmount); + }); it('should forward funds to wallet', async function () { - const pre = web3.eth.getBalance(wallet) - await this.crowdsale.buyTokens(investor, {value, from: purchaser}) - const post = web3.eth.getBalance(wallet) - post.minus(pre).should.be.bignumber.equal(value) - }) - - }) - -}) + const pre = web3.eth.getBalance(wallet); + await this.crowdsale.buyTokens(investor, { value, from: purchaser }); + const post = web3.eth.getBalance(wallet); + post.minus(pre).should.be.bignumber.equal(value); + }); + }); +}); diff --git a/test/DayLimit.js b/test/DayLimit.js index da3e6fdfd77..9b14409d951 100644 --- a/test/DayLimit.js +++ b/test/DayLimit.js @@ -1,26 +1,25 @@ -'use strict'; + const assertRevert = require('./helpers/assertRevert'); -import latestTime from './helpers/latestTime' -import {increaseTimeTo, duration} from './helpers/increaseTime' +import latestTime from './helpers/latestTime'; +import { increaseTimeTo, duration } from './helpers/increaseTime'; var DayLimitMock = artifacts.require('./helpers/DayLimitMock.sol'); -contract('DayLimit', function(accounts) { - +contract('DayLimit', function (accounts) { let dayLimit; let initLimit = 10; - beforeEach( async function() { + beforeEach(async function () { this.startTime = latestTime(); dayLimit = await DayLimitMock.new(initLimit); }); - it('should construct with the passed daily limit', async function() { + it('should construct with the passed daily limit', async function () { let dailyLimit = await dayLimit.dailyLimit(); assert.equal(initLimit, dailyLimit); }); - it('should be able to spend if daily limit is not reached', async function() { + it('should be able to spend if daily limit is not reached', async function () { await dayLimit.attemptSpend(8); let spentToday = await dayLimit.spentToday(); assert.equal(spentToday, 8); @@ -30,7 +29,7 @@ contract('DayLimit', function(accounts) { assert.equal(spentToday, 10); }); - it('should prevent spending if daily limit is reached', async function() { + it('should prevent spending if daily limit is reached', async function () { await dayLimit.attemptSpend(8); let spentToday = await dayLimit.spentToday(); assert.equal(spentToday, 8); @@ -38,12 +37,12 @@ contract('DayLimit', function(accounts) { try { await dayLimit.attemptSpend(3); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } }); - it('should allow spending if daily limit is reached and then set higher', async function() { + it('should allow spending if daily limit is reached and then set higher', async function () { await dayLimit.attemptSpend(8); let spentToday = await dayLimit.spentToday(); assert.equal(spentToday, 8); @@ -51,7 +50,7 @@ contract('DayLimit', function(accounts) { try { await dayLimit.attemptSpend(3); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } spentToday = await dayLimit.spentToday(); @@ -63,7 +62,7 @@ contract('DayLimit', function(accounts) { assert.equal(spentToday, 11); }); - it('should allow spending if daily limit is reached and then amount spent is reset', async function() { + it('should allow spending if daily limit is reached and then amount spent is reset', async function () { await dayLimit.attemptSpend(8); let spentToday = await dayLimit.spentToday(); assert.equal(spentToday, 8); @@ -71,7 +70,7 @@ contract('DayLimit', function(accounts) { try { await dayLimit.attemptSpend(3); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } spentToday = await dayLimit.spentToday(); @@ -83,7 +82,7 @@ contract('DayLimit', function(accounts) { assert.equal(spentToday, 3); }); - it('should allow spending if daily limit is reached and then the next has come', async function() { + it('should allow spending if daily limit is reached and then the next has come', async function () { let limit = 10; let dayLimit = await DayLimitMock.new(limit); @@ -94,7 +93,7 @@ contract('DayLimit', function(accounts) { try { await dayLimit.attemptSpend(3); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } spentToday = await dayLimit.spentToday(); @@ -106,5 +105,4 @@ contract('DayLimit', function(accounts) { spentToday = await dayLimit.spentToday(); assert.equal(spentToday, 3); }); - }); diff --git a/test/DelayedClaimble.js b/test/DelayedClaimble.js index fc00a6be1db..8f7a8637d40 100644 --- a/test/DelayedClaimble.js +++ b/test/DelayedClaimble.js @@ -1,17 +1,16 @@ -'use strict'; var DelayedClaimable = artifacts.require('../contracts/ownership/DelayedClaimable.sol'); -contract('DelayedClaimable', function(accounts) { +contract('DelayedClaimable', function (accounts) { var delayedClaimable; - beforeEach(function() { - return DelayedClaimable.new().then(function(deployed) { + beforeEach(function () { + return DelayedClaimable.new().then(function (deployed) { delayedClaimable = deployed; }); }); - it('can set claim blocks', async function() { + it('can set claim blocks', async function () { await delayedClaimable.transferOwnership(accounts[2]); await delayedClaimable.setLimits(0, 1000); let end = await delayedClaimable.end(); @@ -20,7 +19,7 @@ contract('DelayedClaimable', function(accounts) { assert.equal(start, 0); }); - it('changes pendingOwner after transfer successful', async function() { + it('changes pendingOwner after transfer successful', async function () { await delayedClaimable.transferOwnership(accounts[2]); await delayedClaimable.setLimits(0, 1000); let end = await delayedClaimable.end(); @@ -29,12 +28,12 @@ contract('DelayedClaimable', function(accounts) { assert.equal(start, 0); let pendingOwner = await delayedClaimable.pendingOwner(); assert.equal(pendingOwner, accounts[2]); - await delayedClaimable.claimOwnership({from: accounts[2]}); + await delayedClaimable.claimOwnership({ from: accounts[2] }); let owner = await delayedClaimable.owner(); assert.equal(owner, accounts[2]); }); - it('changes pendingOwner after transfer fails', async function() { + it('changes pendingOwner after transfer fails', async function () { await delayedClaimable.transferOwnership(accounts[1]); await delayedClaimable.setLimits(100, 110); let end = await delayedClaimable.end(); @@ -45,7 +44,7 @@ contract('DelayedClaimable', function(accounts) { assert.equal(pendingOwner, accounts[1]); var err = null; try { - await delayedClaimable.claimOwnership({from: accounts[1]}); + await delayedClaimable.claimOwnership({ from: accounts[1] }); } catch (error) { err = error; } @@ -54,7 +53,7 @@ contract('DelayedClaimable', function(accounts) { assert.isTrue(owner !== accounts[1]); }); - it('set end and start invalid values fail', async function() { + it('set end and start invalid values fail', async function () { await delayedClaimable.transferOwnership(accounts[1]); var err = null; try { @@ -64,5 +63,4 @@ contract('DelayedClaimable', function(accounts) { } assert.isFalse(err.message.search('revert') === -1); }); - }); diff --git a/test/Destructible.js b/test/Destructible.js index 34a7d2be569..da02021f299 100644 --- a/test/Destructible.js +++ b/test/Destructible.js @@ -1,26 +1,23 @@ -'use strict'; var Destructible = artifacts.require('../contracts/lifecycle/Destructible.sol'); require('./helpers/transactionMined.js'); -contract('Destructible', function(accounts) { - - it('should send balance to owner after destruction', async function() { - let destructible = await Destructible.new({from: accounts[0], value: web3.toWei('10','ether')}); +contract('Destructible', function (accounts) { + it('should send balance to owner after destruction', async function () { + let destructible = await Destructible.new({ from: accounts[0], value: web3.toWei('10', 'ether') }); let owner = await destructible.owner(); let initBalance = web3.eth.getBalance(owner); - await destructible.destroy({from: owner}); + await destructible.destroy({ from: owner }); let newBalance = web3.eth.getBalance(owner); assert.isTrue(newBalance > initBalance); }); - it('should send balance to recepient after destruction', async function() { - let destructible = await Destructible.new({from: accounts[0], value: web3.toWei('10','ether')}); + it('should send balance to recepient after destruction', async function () { + let destructible = await Destructible.new({ from: accounts[0], value: web3.toWei('10', 'ether') }); let owner = await destructible.owner(); let initBalance = web3.eth.getBalance(accounts[1]); - await destructible.destroyAndSend(accounts[1], {from: owner} ); + await destructible.destroyAndSend(accounts[1], { from: owner }); let newBalance = web3.eth.getBalance(accounts[1]); assert.isTrue(newBalance.greaterThan(initBalance)); }); - }); diff --git a/test/DetailedERC20.js b/test/DetailedERC20.js index ce8f43920cd..0510f023ea5 100644 --- a/test/DetailedERC20.js +++ b/test/DetailedERC20.js @@ -10,11 +10,11 @@ const DetailedERC20Mock = artifacts.require('./helpers/DetailedERC20Mock.sol'); contract('DetailedERC20', accounts => { let detailedERC20 = null; - const _name = "My Detailed ERC20"; - const _symbol = "MDT"; + const _name = 'My Detailed ERC20'; + const _symbol = 'MDT'; const _decimals = 18; - beforeEach(async function() { + beforeEach(async function () { detailedERC20 = await DetailedERC20Mock.new(_name, _symbol, _decimals); }); @@ -30,6 +30,6 @@ contract('DetailedERC20', accounts => { it('has an amount of decimals', async function () { const decimals = await detailedERC20.decimals(); - decimals.should.be.bignumber.equal(_decimals) + decimals.should.be.bignumber.equal(_decimals); }); }); diff --git a/test/ECRecovery.js b/test/ECRecovery.js index d2d7950dcdc..983816f7fbc 100644 --- a/test/ECRecovery.js +++ b/test/ECRecovery.js @@ -1,16 +1,15 @@ -var ECRecovery = artifacts.require("../contracts/ECRecovery.sol"); +var ECRecovery = artifacts.require('../contracts/ECRecovery.sol'); var utils = require('ethereumjs-util'); var hashMessage = require('./helpers/hashMessage.js'); -contract('ECRecovery', function(accounts) { - +contract('ECRecovery', function (accounts) { let ecrecovery; - before(async function() { + before(async function () { ecrecovery = await ECRecovery.new(); }); - it("recover v0", async function() { + it('recover v0', async function () { // Signature generated outside testrpc with method web3.eth.sign(signer, message) let signer = '0x2cc1166f6212628a0deef2b33befb2187d35b86c'; let message = '0x7dbaf558b0a1a5dc7a67202117ab143c1d8605a983e4a743bc06fcc03162dc0d'; // web3.sha3('OpenZeppelin') @@ -18,7 +17,7 @@ contract('ECRecovery', function(accounts) { assert.equal(signer, await ecrecovery.recover(message, signature)); }); - it("recover v1", async function() { + it('recover v1', async function () { // Signature generated outside testrpc with method web3.eth.sign(signer, message) let signer = '0x1e318623ab09fe6de3c9b8672098464aeda9100e'; let message = '0x7dbaf558b0a1a5dc7a67202117ab143c1d8605a983e4a743bc06fcc03162dc0d'; // web3.sha3('OpenZeppelin') @@ -26,7 +25,7 @@ contract('ECRecovery', function(accounts) { assert.equal(signer, await ecrecovery.recover(message, signature)); }); - it("recover using web3.eth.sign()", async function() { + it('recover using web3.eth.sign()', async function () { // Create the signature using account[0] const signature = web3.eth.sign(web3.eth.accounts[0], web3.sha3('OpenZeppelin')); @@ -34,7 +33,7 @@ contract('ECRecovery', function(accounts) { assert.equal(web3.eth.accounts[0], await ecrecovery.recover(hashMessage('OpenZeppelin'), signature)); }); - it("recover using web3.eth.sign() should return wrong signer", async function() { + it('recover using web3.eth.sign() should return wrong signer', async function () { // Create the signature using account[0] const signature = web3.eth.sign(web3.eth.accounts[0], web3.sha3('OpenZeppelin')); @@ -42,7 +41,7 @@ contract('ECRecovery', function(accounts) { assert.notEqual(web3.eth.accounts[0], await ecrecovery.recover(hashMessage('Test'), signature)); }); - it("recover should fail when a wrong hash is sent", async function() { + it('recover should fail when a wrong hash is sent', async function () { // Create the signature using account[0] let signature = web3.eth.sign(web3.eth.accounts[0], web3.sha3('OpenZeppelin')); @@ -51,5 +50,4 @@ contract('ECRecovery', function(accounts) { await ecrecovery.recover(hashMessage('OpenZeppelin').substring(2), signature) ); }); - }); diff --git a/test/FinalizableCrowdsale.js b/test/FinalizableCrowdsale.js index 775a12445a7..b07313d86c6 100644 --- a/test/FinalizableCrowdsale.js +++ b/test/FinalizableCrowdsale.js @@ -1,63 +1,60 @@ -import {advanceBlock} from './helpers/advanceToBlock' -import {increaseTimeTo, duration} from './helpers/increaseTime' -import latestTime from './helpers/latestTime' -import EVMRevert from './helpers/EVMRevert' +import { advanceBlock } from './helpers/advanceToBlock'; +import { increaseTimeTo, duration } from './helpers/increaseTime'; +import latestTime from './helpers/latestTime'; +import EVMRevert from './helpers/EVMRevert'; -const BigNumber = web3.BigNumber +const BigNumber = web3.BigNumber; const should = require('chai') .use(require('chai-as-promised')) .use(require('chai-bignumber')(BigNumber)) - .should() + .should(); -const FinalizableCrowdsale = artifacts.require('./helpers/FinalizableCrowdsaleImpl.sol') -const MintableToken = artifacts.require('MintableToken') +const FinalizableCrowdsale = artifacts.require('./helpers/FinalizableCrowdsaleImpl.sol'); +const MintableToken = artifacts.require('MintableToken'); contract('FinalizableCrowdsale', function ([_, owner, wallet, thirdparty]) { + const rate = new BigNumber(1000); - const rate = new BigNumber(1000) - - before(async function() { - //Advance to the next block to correctly read time in the solidity "now" function interpreted by testrpc - await advanceBlock() - }) + before(async function () { + // Advance to the next block to correctly read time in the solidity "now" function interpreted by testrpc + await advanceBlock(); + }); beforeEach(async function () { - this.startTime = latestTime() + duration.weeks(1) - this.endTime = this.startTime + duration.weeks(1) - this.afterEndTime = this.endTime + duration.seconds(1) - + this.startTime = latestTime() + duration.weeks(1); + this.endTime = this.startTime + duration.weeks(1); + this.afterEndTime = this.endTime + duration.seconds(1); - this.crowdsale = await FinalizableCrowdsale.new(this.startTime, this.endTime, rate, wallet, {from: owner}) + this.crowdsale = await FinalizableCrowdsale.new(this.startTime, this.endTime, rate, wallet, { from: owner }); - this.token = MintableToken.at(await this.crowdsale.token()) - }) + this.token = MintableToken.at(await this.crowdsale.token()); + }); it('cannot be finalized before ending', async function () { - await this.crowdsale.finalize({from: owner}).should.be.rejectedWith(EVMRevert) - }) + await this.crowdsale.finalize({ from: owner }).should.be.rejectedWith(EVMRevert); + }); it('cannot be finalized by third party after ending', async function () { - await increaseTimeTo(this.afterEndTime) - await this.crowdsale.finalize({from: thirdparty}).should.be.rejectedWith(EVMRevert) - }) + await increaseTimeTo(this.afterEndTime); + await this.crowdsale.finalize({ from: thirdparty }).should.be.rejectedWith(EVMRevert); + }); it('can be finalized by owner after ending', async function () { - await increaseTimeTo(this.afterEndTime) - await this.crowdsale.finalize({from: owner}).should.be.fulfilled - }) + await increaseTimeTo(this.afterEndTime); + await this.crowdsale.finalize({ from: owner }).should.be.fulfilled; + }); it('cannot be finalized twice', async function () { - await increaseTimeTo(this.afterEndTime) - await this.crowdsale.finalize({from: owner}) - await this.crowdsale.finalize({from: owner}).should.be.rejectedWith(EVMRevert) - }) + await increaseTimeTo(this.afterEndTime); + await this.crowdsale.finalize({ from: owner }); + await this.crowdsale.finalize({ from: owner }).should.be.rejectedWith(EVMRevert); + }); it('logs finalized', async function () { - await increaseTimeTo(this.afterEndTime) - const {logs} = await this.crowdsale.finalize({from: owner}) - const event = logs.find(e => e.event === 'Finalized') - should.exist(event) - }) - -}) + await increaseTimeTo(this.afterEndTime); + const { logs } = await this.crowdsale.finalize({ from: owner }); + const event = logs.find(e => e.event === 'Finalized'); + should.exist(event); + }); +}); diff --git a/test/HasNoContracts.js b/test/HasNoContracts.js index cfe879ad41f..384e1d5abc8 100644 --- a/test/HasNoContracts.js +++ b/test/HasNoContracts.js @@ -1,4 +1,4 @@ -'use strict'; + import expectThrow from './helpers/expectThrow'; import toPromise from './helpers/toPromise'; const Ownable = artifacts.require('../contracts/ownership/Ownable.sol'); @@ -6,7 +6,7 @@ const HasNoContracts = artifacts.require( '../contracts/ownership/HasNoContracts.sol', ); -contract('HasNoContracts', function(accounts) { +contract('HasNoContracts', function (accounts) { let hasNoContracts = null; let ownable = null; @@ -21,15 +21,15 @@ contract('HasNoContracts', function(accounts) { assert.equal(owner, hasNoContracts.address); }); - it('should allow owner to reclaim contracts', async function() { + it('should allow owner to reclaim contracts', async function () { await hasNoContracts.reclaimContract(ownable.address); const owner = await ownable.owner(); assert.equal(owner, accounts[0]); }); - it('should allow only owner to reclaim contracts', async function() { + it('should allow only owner to reclaim contracts', async function () { await expectThrow( - hasNoContracts.reclaimContract(ownable.address, {from: accounts[1]}), + hasNoContracts.reclaimContract(ownable.address, { from: accounts[1] }), ); }); }); diff --git a/test/HasNoEther.js b/test/HasNoEther.js index 573de1d21f5..5b77a82f5f4 100644 --- a/test/HasNoEther.js +++ b/test/HasNoEther.js @@ -1,22 +1,22 @@ -'use strict'; + import expectThrow from './helpers/expectThrow'; import toPromise from './helpers/toPromise'; const HasNoEther = artifacts.require('../contracts/lifecycle/HasNoEther.sol'); const HasNoEtherTest = artifacts.require('../helpers/HasNoEtherTest.sol'); const ForceEther = artifacts.require('../helpers/ForceEther.sol'); -contract('HasNoEther', function(accounts) { +contract('HasNoEther', function (accounts) { const amount = web3.toWei('1', 'ether'); - it('should be constructorable', async function() { + it('should be constructorable', async function () { let hasNoEther = await HasNoEtherTest.new(); }); - it('should not accept ether in constructor', async function() { - await expectThrow(HasNoEtherTest.new({value: amount})); + it('should not accept ether in constructor', async function () { + await expectThrow(HasNoEtherTest.new({ value: amount })); }); - it('should not accept ether', async function() { + it('should not accept ether', async function () { let hasNoEther = await HasNoEtherTest.new(); await expectThrow( @@ -28,14 +28,14 @@ contract('HasNoEther', function(accounts) { ); }); - it('should allow owner to reclaim ether', async function() { + it('should allow owner to reclaim ether', async function () { // Create contract let hasNoEther = await HasNoEtherTest.new(); const startBalance = await web3.eth.getBalance(hasNoEther.address); assert.equal(startBalance, 0); // Force ether into it - let forceEther = await ForceEther.new({value: amount}); + let forceEther = await ForceEther.new({ value: amount }); await forceEther.destroyAndSend(hasNoEther.address); const forcedBalance = await web3.eth.getBalance(hasNoEther.address); assert.equal(forcedBalance, amount); @@ -49,17 +49,17 @@ contract('HasNoEther', function(accounts) { assert.isAbove(ownerFinalBalance, ownerStartBalance); }); - it('should allow only owner to reclaim ether', async function() { + it('should allow only owner to reclaim ether', async function () { // Create contract - let hasNoEther = await HasNoEtherTest.new({from: accounts[0]}); + let hasNoEther = await HasNoEtherTest.new({ from: accounts[0] }); // Force ether into it - let forceEther = await ForceEther.new({value: amount}); + let forceEther = await ForceEther.new({ value: amount }); await forceEther.destroyAndSend(hasNoEther.address); const forcedBalance = await web3.eth.getBalance(hasNoEther.address); assert.equal(forcedBalance, amount); // Reclaim - await expectThrow(hasNoEther.reclaimEther({from: accounts[1]})); + await expectThrow(hasNoEther.reclaimEther({ from: accounts[1] })); }); }); diff --git a/test/HasNoTokens.js b/test/HasNoTokens.js index 5afe29ef088..6f6ee0e71c2 100644 --- a/test/HasNoTokens.js +++ b/test/HasNoTokens.js @@ -1,10 +1,10 @@ -'use strict'; + import expectThrow from './helpers/expectThrow'; import toPromise from './helpers/toPromise'; const HasNoTokens = artifacts.require('../contracts/lifecycle/HasNoTokens.sol'); const ERC23TokenMock = artifacts.require('./helpers/ERC23TokenMock.sol'); -contract('HasNoTokens', function(accounts) { +contract('HasNoTokens', function (accounts) { let hasNoTokens = null; let token = null; @@ -19,11 +19,11 @@ contract('HasNoTokens', function(accounts) { assert.equal(startBalance, 10); }); - it('should not accept ERC23 tokens', async function() { + it('should not accept ERC23 tokens', async function () { await expectThrow(token.transferERC23(hasNoTokens.address, 10, '')); }); - it('should allow owner to reclaim tokens', async function() { + it('should allow owner to reclaim tokens', async function () { const ownerStartBalance = await token.balanceOf(accounts[0]); await hasNoTokens.reclaimToken(token.address); const ownerFinalBalance = await token.balanceOf(accounts[0]); @@ -32,9 +32,9 @@ contract('HasNoTokens', function(accounts) { assert.equal(ownerFinalBalance - ownerStartBalance, 10); }); - it('should allow only owner to reclaim tokens', async function() { + it('should allow only owner to reclaim tokens', async function () { await expectThrow( - hasNoTokens.reclaimToken(token.address, {from: accounts[1]}), + hasNoTokens.reclaimToken(token.address, { from: accounts[1] }), ); }); }); diff --git a/test/LimitBalance.js b/test/LimitBalance.js index b80275d7929..0a0edff991d 100644 --- a/test/LimitBalance.js +++ b/test/LimitBalance.js @@ -1,61 +1,59 @@ -'use strict'; var LimitBalanceMock = artifacts.require('helpers/LimitBalanceMock.sol'); const assertRevert = require('./helpers/assertRevert'); -contract('LimitBalance', function(accounts) { +contract('LimitBalance', function (accounts) { let lb; - beforeEach(async function() { + beforeEach(async function () { lb = await LimitBalanceMock.new(); }); let LIMIT = 1000; - it('should expose limit', async function() { + it('should expose limit', async function () { let limit = await lb.limit(); assert.equal(limit, LIMIT); }); - it('should allow sending below limit', async function() { + it('should allow sending below limit', async function () { let amount = 1; - await lb.limitedDeposit({value: amount}); + await lb.limitedDeposit({ value: amount }); assert.equal(web3.eth.getBalance(lb.address), amount); }); - it('shouldnt allow sending above limit', async function() { + it('shouldnt allow sending above limit', async function () { let amount = 1110; try { - await lb.limitedDeposit({value: amount}); + await lb.limitedDeposit({ value: amount }); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } }); - it('should allow multiple sends below limit', async function() { + it('should allow multiple sends below limit', async function () { let amount = 500; - await lb.limitedDeposit({value: amount}); + await lb.limitedDeposit({ value: amount }); assert.equal(web3.eth.getBalance(lb.address), amount); - await lb.limitedDeposit({value: amount}); - assert.equal(web3.eth.getBalance(lb.address), amount*2); + await lb.limitedDeposit({ value: amount }); + assert.equal(web3.eth.getBalance(lb.address), amount * 2); }); - it('shouldnt allow multiple sends above limit', async function() { + it('shouldnt allow multiple sends above limit', async function () { let amount = 500; - await lb.limitedDeposit({value: amount}); + await lb.limitedDeposit({ value: amount }); assert.equal(web3.eth.getBalance(lb.address), amount); try { - await lb.limitedDeposit({value: amount+1}); + await lb.limitedDeposit({ value: amount + 1 }); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } }); - }); diff --git a/test/MerkleProof.js b/test/MerkleProof.js index 7f449b43190..c0109398df7 100644 --- a/test/MerkleProof.js +++ b/test/MerkleProof.js @@ -1,18 +1,18 @@ -var MerkleProof = artifacts.require("./MerkleProof.sol"); +var MerkleProof = artifacts.require('./MerkleProof.sol'); -import MerkleTree from "./helpers/merkleTree.js"; -import { sha3, bufferToHex } from "ethereumjs-util"; +import MerkleTree from './helpers/merkleTree.js'; +import { sha3, bufferToHex } from 'ethereumjs-util'; -contract('MerkleProof', function(accounts) { +contract('MerkleProof', function (accounts) { let merkleProof; - before(async function() { + before(async function () { merkleProof = await MerkleProof.new(); }); - describe("verifyProof", function() { - it("should return true for a valid Merkle proof", async function() { - const elements = ["a", "b", "c", "d"]; + describe('verifyProof', function () { + it('should return true for a valid Merkle proof', async function () { + const elements = ['a', 'b', 'c', 'd']; const merkleTree = new MerkleTree(elements); const root = merkleTree.getHexRoot(); @@ -22,28 +22,28 @@ contract('MerkleProof', function(accounts) { const leaf = bufferToHex(sha3(elements[0])); const result = await merkleProof.verifyProof(proof, root, leaf); - assert.isOk(result, "verifyProof did not return true for a valid proof"); + assert.isOk(result, 'verifyProof did not return true for a valid proof'); }); - it("should return false for an invalid Merkle proof", async function() { - const correctElements = ["a", "b", "c"] + it('should return false for an invalid Merkle proof', async function () { + const correctElements = ['a', 'b', 'c']; const correctMerkleTree = new MerkleTree(correctElements); const correctRoot = correctMerkleTree.getHexRoot(); const correctLeaf = bufferToHex(sha3(correctElements[0])); - const badElements = ["d", "e", "f"] - const badMerkleTree = new MerkleTree(badElements) + const badElements = ['d', 'e', 'f']; + const badMerkleTree = new MerkleTree(badElements); - const badProof = badMerkleTree.getHexProof(badElements[0]) + const badProof = badMerkleTree.getHexProof(badElements[0]); const result = await merkleProof.verifyProof(badProof, correctRoot, correctLeaf); - assert.isNotOk(result, "verifyProof did not return false for an invalid proof"); + assert.isNotOk(result, 'verifyProof did not return false for an invalid proof'); }); - it("should return false for a Merkle proof of invalid length", async function() { - const elements = ["a", "b", "c"] + it('should return false for a Merkle proof of invalid length', async function () { + const elements = ['a', 'b', 'c']; const merkleTree = new MerkleTree(elements); const root = merkleTree.getHexRoot(); @@ -54,7 +54,7 @@ contract('MerkleProof', function(accounts) { const leaf = bufferToHex(sha3(elements[0])); const result = await merkleProof.verifyProof(badProof, root, leaf); - assert.isNotOk(result, "verifyProof did not return false for proof of invalid length"); - }) + assert.isNotOk(result, 'verifyProof did not return false for proof of invalid length'); + }); }); }); diff --git a/test/MintableToken.js b/test/MintableToken.js index 453628c514e..ba287a3672e 100644 --- a/test/MintableToken.js +++ b/test/MintableToken.js @@ -1,28 +1,27 @@ -'use strict'; import expectThrow from './helpers/expectThrow'; var MintableToken = artifacts.require('../contracts/Tokens/MintableToken.sol'); -contract('Mintable', function(accounts) { +contract('Mintable', function (accounts) { let token; - beforeEach(async function() { + beforeEach(async function () { token = await MintableToken.new(); }); - it('should start with a totalSupply of 0', async function() { + it('should start with a totalSupply of 0', async function () { let totalSupply = await token.totalSupply(); assert.equal(totalSupply, 0); }); - it('should return mintingFinished false after construction', async function() { + it('should return mintingFinished false after construction', async function () { let mintingFinished = await token.mintingFinished(); assert.equal(mintingFinished, false); }); - it('should mint a given amount of tokens to a given address', async function() { + it('should mint a given amount of tokens to a given address', async function () { const result = await token.mint(accounts[0], 100); assert.equal(result.logs[0].event, 'Mint'); assert.equal(result.logs[0].args.to.valueOf(), accounts[0]); @@ -35,12 +34,11 @@ contract('Mintable', function(accounts) { let totalSupply = await token.totalSupply(); assert(totalSupply, 100); - }) + }); it('should fail to mint after call to finishMinting', async function () { await token.finishMinting(); assert.equal(await token.mintingFinished(), true); await expectThrow(token.mint(accounts[0], 100)); - }) - + }); }); diff --git a/test/Ownable.js b/test/Ownable.js index 01da683aa59..e1920602ef5 100644 --- a/test/Ownable.js +++ b/test/Ownable.js @@ -1,21 +1,21 @@ -'use strict'; + const assertRevert = require('./helpers/assertRevert'); var Ownable = artifacts.require('../contracts/ownership/Ownable.sol'); -contract('Ownable', function(accounts) { +contract('Ownable', function (accounts) { let ownable; - beforeEach(async function() { + beforeEach(async function () { ownable = await Ownable.new(); }); - it('should have an owner', async function() { + it('should have an owner', async function () { let owner = await ownable.owner(); assert.isTrue(owner !== 0); }); - it('changes owner after transfer', async function() { + it('changes owner after transfer', async function () { let other = accounts[1]; await ownable.transferOwnership(other); let owner = await ownable.owner(); @@ -23,26 +23,25 @@ contract('Ownable', function(accounts) { assert.isTrue(owner === other); }); - it('should prevent non-owners from transfering', async function() { + it('should prevent non-owners from transfering', async function () { const other = accounts[2]; const owner = await ownable.owner.call(); assert.isTrue(owner !== other); try { - await ownable.transferOwnership(other, {from: other}); + await ownable.transferOwnership(other, { from: other }); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } }); - it('should guard ownership against stuck state', async function() { + it('should guard ownership against stuck state', async function () { let originalOwner = await ownable.owner(); try { - await ownable.transferOwnership(null, {from: originalOwner}); + await ownable.transferOwnership(null, { from: originalOwner }); assert.fail(); - } catch(error) { + } catch (error) { assertRevert(error); } }); - }); diff --git a/test/Pausable.js b/test/Pausable.js index 87c122cbae6..e10e7c9e89c 100644 --- a/test/Pausable.js +++ b/test/Pausable.js @@ -1,11 +1,9 @@ -'use strict'; const assertRevert = require('./helpers/assertRevert'); const PausableMock = artifacts.require('helpers/PausableMock.sol'); -contract('Pausable', function(accounts) { - - it('can perform normal process in non-pause', async function() { +contract('Pausable', function (accounts) { + it('can perform normal process in non-pause', async function () { let Pausable = await PausableMock.new(); let count0 = await Pausable.count(); assert.equal(count0, 0); @@ -15,7 +13,7 @@ contract('Pausable', function(accounts) { assert.equal(count1, 1); }); - it('can not perform normal process in pause', async function() { + it('can not perform normal process in pause', async function () { let Pausable = await PausableMock.new(); await Pausable.pause(); let count0 = await Pausable.count(); @@ -24,27 +22,26 @@ contract('Pausable', function(accounts) { try { await Pausable.normalProcess(); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } let count1 = await Pausable.count(); assert.equal(count1, 0); }); - - it('can not take drastic measure in non-pause', async function() { + it('can not take drastic measure in non-pause', async function () { let Pausable = await PausableMock.new(); try { await Pausable.drasticMeasure(); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } const drasticMeasureTaken = await Pausable.drasticMeasureTaken(); assert.isFalse(drasticMeasureTaken); }); - it('can take a drastic measure in a pause', async function() { + it('can take a drastic measure in a pause', async function () { let Pausable = await PausableMock.new(); await Pausable.pause(); await Pausable.drasticMeasure(); @@ -53,7 +50,7 @@ contract('Pausable', function(accounts) { assert.isTrue(drasticMeasureTaken); }); - it('should resume allowing normal process after pause is over', async function() { + it('should resume allowing normal process after pause is over', async function () { let Pausable = await PausableMock.new(); await Pausable.pause(); await Pausable.unpause(); @@ -63,19 +60,18 @@ contract('Pausable', function(accounts) { assert.equal(count0, 1); }); - it('should prevent drastic measure after pause is over', async function() { + it('should prevent drastic measure after pause is over', async function () { let Pausable = await PausableMock.new(); await Pausable.pause(); await Pausable.unpause(); try { await Pausable.drasticMeasure(); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } const drasticMeasureTaken = await Pausable.drasticMeasureTaken(); assert.isFalse(drasticMeasureTaken); }); - }); diff --git a/test/PausableToken.js b/test/PausableToken.js index 540d0df7e4b..8da1c926b6f 100644 --- a/test/PausableToken.js +++ b/test/PausableToken.js @@ -3,27 +3,27 @@ const assertRevert = require('./helpers/assertRevert'); var PausableTokenMock = artifacts.require('./helpers/PausableTokenMock.sol'); -contract('PausableToken', function(accounts) { +contract('PausableToken', function (accounts) { let token; - beforeEach(async function() { + beforeEach(async function () { token = await PausableTokenMock.new(accounts[0], 100); }); - it('should return paused false after construction', async function() { + it('should return paused false after construction', async function () { let paused = await token.paused(); assert.equal(paused, false); }); - it('should return paused true after pause', async function() { + it('should return paused true after pause', async function () { await token.pause(); let paused = await token.paused(); assert.equal(paused, true); }); - it('should return paused false after pause and unpause', async function() { + it('should return paused false after pause and unpause', async function () { await token.pause(); await token.unpause(); let paused = await token.paused(); @@ -31,7 +31,7 @@ contract('PausableToken', function(accounts) { assert.equal(paused, false); }); - it('should be able to transfer if transfers are unpaused', async function() { + it('should be able to transfer if transfers are unpaused', async function () { await token.transfer(accounts[1], 100); let balance0 = await token.balanceOf(accounts[0]); assert.equal(balance0, 0); @@ -40,7 +40,7 @@ contract('PausableToken', function(accounts) { assert.equal(balance1, 100); }); - it('should be able to transfer after transfers are paused and unpaused', async function() { + it('should be able to transfer after transfers are paused and unpaused', async function () { await token.pause(); await token.unpause(); await token.transfer(accounts[1], 100); @@ -51,7 +51,7 @@ contract('PausableToken', function(accounts) { assert.equal(balance1, 100); }); - it('should throw an error trying to transfer while transactions are paused', async function() { + it('should throw an error trying to transfer while transactions are paused', async function () { await token.pause(); try { await token.transfer(accounts[1], 100); @@ -61,7 +61,7 @@ contract('PausableToken', function(accounts) { } }); - it('should throw an error trying to transfer from another account while transactions are paused', async function() { + it('should throw an error trying to transfer from another account while transactions are paused', async function () { await token.pause(); try { await token.transferFrom(accounts[0], accounts[1], 100); @@ -70,4 +70,4 @@ contract('PausableToken', function(accounts) { assertRevert(error); } }); -}) +}); diff --git a/test/PullPayment.js b/test/PullPayment.js index 26d7ac5e580..aa002f42c90 100644 --- a/test/PullPayment.js +++ b/test/PullPayment.js @@ -1,18 +1,18 @@ -var PullPaymentMock = artifacts.require("./helpers/PullPaymentMock.sol"); +var PullPaymentMock = artifacts.require('./helpers/PullPaymentMock.sol'); -contract('PullPayment', function(accounts) { +contract('PullPayment', function (accounts) { let ppce; - let amount = 17*1e18; + let amount = 17 * 1e18; - beforeEach(async function() { - ppce = await PullPaymentMock.new({value: amount}); + beforeEach(async function () { + ppce = await PullPaymentMock.new({ value: amount }); }); - it("can't call asyncSend externally", async function() { + it('can\'t call asyncSend externally', async function () { assert.isUndefined(ppce.asyncSend); }); - it("can record an async payment correctly", async function() { + it('can record an async payment correctly', async function () { let AMOUNT = 100; let callSend = await ppce.callSend(accounts[0], AMOUNT); let paymentsToAccount0 = await ppce.payments(accounts[0]); @@ -22,7 +22,7 @@ contract('PullPayment', function(accounts) { assert.equal(paymentsToAccount0, AMOUNT); }); - it("can add multiple balances on one account", async function() { + it('can add multiple balances on one account', async function () { let call1 = await ppce.callSend(accounts[0], 200); let call2 = await ppce.callSend(accounts[0], 300); let paymentsToAccount0 = await ppce.payments(accounts[0]); @@ -32,7 +32,7 @@ contract('PullPayment', function(accounts) { assert.equal(paymentsToAccount0, 500); }); - it("can add balances on multiple accounts", async function() { + it('can add balances on multiple accounts', async function () { let call1 = await ppce.callSend(accounts[0], 200); let call2 = await ppce.callSend(accounts[1], 300); @@ -46,7 +46,7 @@ contract('PullPayment', function(accounts) { assert.equal(totalPayments, 500); }); - it("can withdraw payment", async function() { + it('can withdraw payment', async function () { let payee = accounts[1]; let initialBalance = web3.eth.getBalance(payee); @@ -58,7 +58,7 @@ contract('PullPayment', function(accounts) { let totalPayments = await ppce.totalPayments(); assert.equal(totalPayments, amount); - let withdraw = await ppce.withdrawPayments({from: payee}); + let withdraw = await ppce.withdrawPayments({ from: payee }); let payment2 = await ppce.payments(payee); assert.equal(payment2, 0); @@ -66,7 +66,6 @@ contract('PullPayment', function(accounts) { assert.equal(totalPayments, 0); let balance = web3.eth.getBalance(payee); - assert(Math.abs(balance-initialBalance-amount) < 1e16); + assert(Math.abs(balance - initialBalance - amount) < 1e16); }); - }); diff --git a/test/ReentrancyGuard.js b/test/ReentrancyGuard.js index b3145df1d2e..ae1446c9a33 100644 --- a/test/ReentrancyGuard.js +++ b/test/ReentrancyGuard.js @@ -1,18 +1,18 @@ -'use strict'; + import expectThrow from './helpers/expectThrow'; const ReentrancyMock = artifacts.require('./helper/ReentrancyMock.sol'); const ReentrancyAttack = artifacts.require('./helper/ReentrancyAttack.sol'); -contract('ReentrancyGuard', function(accounts) { +contract('ReentrancyGuard', function (accounts) { let reentrancyMock; - beforeEach(async function() { + beforeEach(async function () { reentrancyMock = await ReentrancyMock.new(); let initialCounter = await reentrancyMock.counter(); assert.equal(initialCounter, 0); }); - it('should not allow remote callback', async function() { + it('should not allow remote callback', async function () { let attacker = await ReentrancyAttack.new(); await expectThrow(reentrancyMock.countAndCall(attacker.address)); }); @@ -21,11 +21,11 @@ contract('ReentrancyGuard', function(accounts) { // I put them here as documentation, and to monitor any changes // in the side-effects. - it('should not allow local recursion', async function() { + it('should not allow local recursion', async function () { await expectThrow(reentrancyMock.countLocalRecursive(10)); }); - it('should not allow indirect local recursion', async function() { + it('should not allow indirect local recursion', async function () { await expectThrow(reentrancyMock.countThisRecursive(10)); }); }); diff --git a/test/RefundVault.js b/test/RefundVault.js index 4dc8a080752..fb22ded8ffe 100644 --- a/test/RefundVault.js +++ b/test/RefundVault.js @@ -1,61 +1,59 @@ -const BigNumber = web3.BigNumber +const BigNumber = web3.BigNumber; require('chai') .use(require('chai-as-promised')) .use(require('chai-bignumber')(BigNumber)) - .should() + .should(); -import ether from './helpers/ether' -import EVMRevert from './helpers/EVMRevert' +import ether from './helpers/ether'; +import EVMRevert from './helpers/EVMRevert'; -const RefundVault = artifacts.require('RefundVault') +const RefundVault = artifacts.require('RefundVault'); contract('RefundVault', function ([_, owner, wallet, investor]) { - - const value = ether(42) + const value = ether(42); beforeEach(async function () { - this.vault = await RefundVault.new(wallet, {from: owner}) - }) + this.vault = await RefundVault.new(wallet, { from: owner }); + }); it('should accept contributions', async function () { - await this.vault.deposit(investor, {value, from: owner}).should.be.fulfilled - }) + await this.vault.deposit(investor, { value, from: owner }).should.be.fulfilled; + }); it('should not refund contribution during active state', async function () { - await this.vault.deposit(investor, {value, from: owner}) - await this.vault.refund(investor).should.be.rejectedWith(EVMRevert) - }) + await this.vault.deposit(investor, { value, from: owner }); + await this.vault.refund(investor).should.be.rejectedWith(EVMRevert); + }); it('only owner can enter refund mode', async function () { - await this.vault.enableRefunds({from: _}).should.be.rejectedWith(EVMRevert) - await this.vault.enableRefunds({from: owner}).should.be.fulfilled - }) + await this.vault.enableRefunds({ from: _ }).should.be.rejectedWith(EVMRevert); + await this.vault.enableRefunds({ from: owner }).should.be.fulfilled; + }); it('should refund contribution after entering refund mode', async function () { - await this.vault.deposit(investor, {value, from: owner}) - await this.vault.enableRefunds({from: owner}) + await this.vault.deposit(investor, { value, from: owner }); + await this.vault.enableRefunds({ from: owner }); - const pre = web3.eth.getBalance(investor) - await this.vault.refund(investor) - const post = web3.eth.getBalance(investor) + const pre = web3.eth.getBalance(investor); + await this.vault.refund(investor); + const post = web3.eth.getBalance(investor); - post.minus(pre).should.be.bignumber.equal(value) - }) + post.minus(pre).should.be.bignumber.equal(value); + }); it('only owner can close', async function () { - await this.vault.close({from: _}).should.be.rejectedWith(EVMRevert) - await this.vault.close({from: owner}).should.be.fulfilled - }) + await this.vault.close({ from: _ }).should.be.rejectedWith(EVMRevert); + await this.vault.close({ from: owner }).should.be.fulfilled; + }); it('should forward funds to wallet after closing', async function () { - await this.vault.deposit(investor, {value, from: owner}) - - const pre = web3.eth.getBalance(wallet) - await this.vault.close({from: owner}) - const post = web3.eth.getBalance(wallet) + await this.vault.deposit(investor, { value, from: owner }); - post.minus(pre).should.be.bignumber.equal(value) - }) + const pre = web3.eth.getBalance(wallet); + await this.vault.close({ from: owner }); + const post = web3.eth.getBalance(wallet); -}) + post.minus(pre).should.be.bignumber.equal(value); + }); +}); diff --git a/test/RefundableCrowdsale.js b/test/RefundableCrowdsale.js index 55818db4a30..d34f1d9458e 100644 --- a/test/RefundableCrowdsale.js +++ b/test/RefundableCrowdsale.js @@ -1,83 +1,79 @@ -import ether from './helpers/ether' -import {advanceBlock} from './helpers/advanceToBlock' -import {increaseTimeTo, duration} from './helpers/increaseTime' -import latestTime from './helpers/latestTime' -import EVMRevert from './helpers/EVMRevert' +import ether from './helpers/ether'; +import { advanceBlock } from './helpers/advanceToBlock'; +import { increaseTimeTo, duration } from './helpers/increaseTime'; +import latestTime from './helpers/latestTime'; +import EVMRevert from './helpers/EVMRevert'; -const BigNumber = web3.BigNumber +const BigNumber = web3.BigNumber; require('chai') .use(require('chai-as-promised')) .use(require('chai-bignumber')(BigNumber)) - .should() + .should(); -const RefundableCrowdsale = artifacts.require('./helpers/RefundableCrowdsaleImpl.sol') +const RefundableCrowdsale = artifacts.require('./helpers/RefundableCrowdsaleImpl.sol'); contract('RefundableCrowdsale', function ([_, owner, wallet, investor]) { + const rate = new BigNumber(1000); + const goal = ether(800); + const lessThanGoal = ether(750); - const rate = new BigNumber(1000) - const goal = ether(800) - const lessThanGoal = ether(750) - - before(async function() { - //Advance to the next block to correctly read time in the solidity "now" function interpreted by testrpc - await advanceBlock() - }) + before(async function () { + // Advance to the next block to correctly read time in the solidity "now" function interpreted by testrpc + await advanceBlock(); + }); beforeEach(async function () { - this.startTime = latestTime() + duration.weeks(1) - this.endTime = this.startTime + duration.weeks(1) - this.afterEndTime = this.endTime + duration.seconds(1) + this.startTime = latestTime() + duration.weeks(1); + this.endTime = this.startTime + duration.weeks(1); + this.afterEndTime = this.endTime + duration.seconds(1); - this.crowdsale = await RefundableCrowdsale.new(this.startTime, this.endTime, rate, wallet, goal, {from: owner}) - }) + this.crowdsale = await RefundableCrowdsale.new(this.startTime, this.endTime, rate, wallet, goal, { from: owner }); + }); describe('creating a valid crowdsale', function () { - it('should fail with zero goal', async function () { - await RefundableCrowdsale.new(this.startTime, this.endTime, rate, wallet, 0, {from: owner}).should.be.rejectedWith(EVMRevert); - }) - + await RefundableCrowdsale.new(this.startTime, this.endTime, rate, wallet, 0, { from: owner }).should.be.rejectedWith(EVMRevert); + }); }); it('should deny refunds before end', async function () { - await this.crowdsale.claimRefund({from: investor}).should.be.rejectedWith(EVMRevert) - await increaseTimeTo(this.startTime) - await this.crowdsale.claimRefund({from: investor}).should.be.rejectedWith(EVMRevert) - }) + await this.crowdsale.claimRefund({ from: investor }).should.be.rejectedWith(EVMRevert); + await increaseTimeTo(this.startTime); + await this.crowdsale.claimRefund({ from: investor }).should.be.rejectedWith(EVMRevert); + }); it('should deny refunds after end if goal was reached', async function () { - await increaseTimeTo(this.startTime) - await this.crowdsale.sendTransaction({value: goal, from: investor}) - await increaseTimeTo(this.afterEndTime) - await this.crowdsale.claimRefund({from: investor}).should.be.rejectedWith(EVMRevert) - }) + await increaseTimeTo(this.startTime); + await this.crowdsale.sendTransaction({ value: goal, from: investor }); + await increaseTimeTo(this.afterEndTime); + await this.crowdsale.claimRefund({ from: investor }).should.be.rejectedWith(EVMRevert); + }); it('should allow refunds after end if goal was not reached', async function () { - await increaseTimeTo(this.startTime) - await this.crowdsale.sendTransaction({value: lessThanGoal, from: investor}) - await increaseTimeTo(this.afterEndTime) + await increaseTimeTo(this.startTime); + await this.crowdsale.sendTransaction({ value: lessThanGoal, from: investor }); + await increaseTimeTo(this.afterEndTime); - await this.crowdsale.finalize({from: owner}) + await this.crowdsale.finalize({ from: owner }); - const pre = web3.eth.getBalance(investor) - await this.crowdsale.claimRefund({from: investor, gasPrice: 0}) - .should.be.fulfilled - const post = web3.eth.getBalance(investor) + const pre = web3.eth.getBalance(investor); + await this.crowdsale.claimRefund({ from: investor, gasPrice: 0 }) + .should.be.fulfilled; + const post = web3.eth.getBalance(investor); - post.minus(pre).should.be.bignumber.equal(lessThanGoal) - }) + post.minus(pre).should.be.bignumber.equal(lessThanGoal); + }); it('should forward funds to wallet after end if goal was reached', async function () { - await increaseTimeTo(this.startTime) - await this.crowdsale.sendTransaction({value: goal, from: investor}) - await increaseTimeTo(this.afterEndTime) + await increaseTimeTo(this.startTime); + await this.crowdsale.sendTransaction({ value: goal, from: investor }); + await increaseTimeTo(this.afterEndTime); - const pre = web3.eth.getBalance(wallet) - await this.crowdsale.finalize({from: owner}) - const post = web3.eth.getBalance(wallet) + const pre = web3.eth.getBalance(wallet); + await this.crowdsale.finalize({ from: owner }); + const post = web3.eth.getBalance(wallet); - post.minus(pre).should.be.bignumber.equal(goal) - }) - -}) + post.minus(pre).should.be.bignumber.equal(goal); + }); +}); diff --git a/test/SafeERC20.js b/test/SafeERC20.js index 46b9ad1c02a..38d98099e22 100644 --- a/test/SafeERC20.js +++ b/test/SafeERC20.js @@ -7,7 +7,6 @@ require('chai') const SafeERC20Helper = artifacts.require('./helpers/SafeERC20Helper.sol'); contract('SafeERC20', function () { - beforeEach(async function () { this.helper = await SafeERC20Helper.new(); }); diff --git a/test/SafeMath.js b/test/SafeMath.js index a6831144932..09450e4f5c0 100644 --- a/test/SafeMath.js +++ b/test/SafeMath.js @@ -1,72 +1,70 @@ const assertRevert = require('./helpers/assertRevert'); const assertJump = require('./helpers/assertJump'); -var SafeMathMock = artifacts.require("./helpers/SafeMathMock.sol"); - -contract('SafeMath', function(accounts) { +var SafeMathMock = artifacts.require('./helpers/SafeMathMock.sol'); +contract('SafeMath', function (accounts) { let safeMath; - before(async function() { + before(async function () { safeMath = await SafeMathMock.new(); }); - it("multiplies correctly", async function() { + it('multiplies correctly', async function () { let a = 5678; let b = 1234; let mult = await safeMath.multiply(a, b); let result = await safeMath.result(); - assert.equal(result, a*b); + assert.equal(result, a * b); }); - it("adds correctly", async function() { + it('adds correctly', async function () { let a = 5678; let b = 1234; let add = await safeMath.add(a, b); let result = await safeMath.result(); - assert.equal(result, a+b); + assert.equal(result, a + b); }); - it("subtracts correctly", async function() { + it('subtracts correctly', async function () { let a = 5678; let b = 1234; let subtract = await safeMath.subtract(a, b); let result = await safeMath.result(); - assert.equal(result, a-b); + assert.equal(result, a - b); }); - it("should throw an error if subtraction result would be negative", async function () { + it('should throw an error if subtraction result would be negative', async function () { let a = 1234; let b = 5678; try { let subtract = await safeMath.subtract(a, b); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertJump(error); } }); - it("should throw an error on addition overflow", async function() { + it('should throw an error on addition overflow', async function () { let a = 115792089237316195423570985008687907853269984665640564039457584007913129639935; let b = 1; try { let add = await safeMath.add(a, b); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } }); - it("should throw an error on multiplication overflow", async function() { + it('should throw an error on multiplication overflow', async function () { let a = 115792089237316195423570985008687907853269984665640564039457584007913129639933; let b = 2; try { let multiply = await safeMath.multiply(a, b); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } }); - }); diff --git a/test/SampleCrowdsale.js b/test/SampleCrowdsale.js index f90e5ad9c67..cb904e07b07 100644 --- a/test/SampleCrowdsale.js +++ b/test/SampleCrowdsale.js @@ -1,8 +1,8 @@ -import ether from './helpers/ether' -import {advanceBlock} from './helpers/advanceToBlock' -import {increaseTimeTo, duration} from './helpers/increaseTime' -import latestTime from './helpers/latestTime' -import EVMRevert from './helpers/EVMRevert' +import ether from './helpers/ether'; +import { advanceBlock } from './helpers/advanceToBlock'; +import { increaseTimeTo, duration } from './helpers/increaseTime'; +import latestTime from './helpers/latestTime'; +import EVMRevert from './helpers/EVMRevert'; const BigNumber = web3.BigNumber; @@ -15,26 +15,24 @@ const SampleCrowdsale = artifacts.require('SampleCrowdsale'); const SampleCrowdsaleToken = artifacts.require('SampleCrowdsaleToken'); contract('Crowdsale', function ([owner, wallet, investor]) { - const RATE = new BigNumber(10); const GOAL = ether(10); - const CAP = ether(20); + const CAP = ether(20); - before(async function() { - //Advance to the next block to correctly read time in the solidity "now" function interpreted by testrpc - await advanceBlock() - }) + before(async function () { + // Advance to the next block to correctly read time in the solidity "now" function interpreted by testrpc + await advanceBlock(); + }); beforeEach(async function () { this.startTime = latestTime() + duration.weeks(1); - this.endTime = this.startTime + duration.weeks(1); + this.endTime = this.startTime + duration.weeks(1); this.afterEndTime = this.endTime + duration.seconds(1); this.crowdsale = await SampleCrowdsale.new(this.startTime, this.endTime, RATE, GOAL, CAP, wallet); this.token = SampleCrowdsaleToken.at(await this.crowdsale.token()); }); - it('should create crowdsale with correct parameters', async function () { this.crowdsale.should.exist; this.token.should.exist; @@ -49,7 +47,7 @@ contract('Crowdsale', function ([owner, wallet, investor]) { it('should not accept payments before start', async function () { await this.crowdsale.send(ether(1)).should.be.rejectedWith(EVMRevert); - await this.crowdsale.buyTokens(investor, {from: investor, value: ether(1)}).should.be.rejectedWith(EVMRevert); + await this.crowdsale.buyTokens(investor, { from: investor, value: ether(1) }).should.be.rejectedWith(EVMRevert); }); it('should accept payments during the sale', async function () { @@ -57,7 +55,7 @@ contract('Crowdsale', function ([owner, wallet, investor]) { const expectedTokenAmount = RATE.mul(investmentAmount); await increaseTimeTo(this.startTime); - await this.crowdsale.buyTokens(investor, {value: investmentAmount, from: investor}).should.be.fulfilled; + await this.crowdsale.buyTokens(investor, { value: investmentAmount, from: investor }).should.be.fulfilled; (await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount); (await this.token.totalSupply()).should.be.bignumber.equal(expectedTokenAmount); @@ -66,7 +64,7 @@ contract('Crowdsale', function ([owner, wallet, investor]) { it('should reject payments after end', async function () { await increaseTimeTo(this.afterEnd); await this.crowdsale.send(ether(1)).should.be.rejectedWith(EVMRevert); - await this.crowdsale.buyTokens(investor, {value: ether(1), from: investor}).should.be.rejectedWith(EVMRevert); + await this.crowdsale.buyTokens(investor, { value: ether(1), from: investor }).should.be.rejectedWith(EVMRevert); }); it('should reject payments over cap', async function () { @@ -81,7 +79,7 @@ contract('Crowdsale', function ([owner, wallet, investor]) { const beforeFinalization = web3.eth.getBalance(wallet); await increaseTimeTo(this.afterEndTime); - await this.crowdsale.finalize({from: owner}); + await this.crowdsale.finalize({ from: owner }); const afterFinalization = web3.eth.getBalance(wallet); afterFinalization.minus(beforeFinalization).should.be.bignumber.equal(GOAL); @@ -91,14 +89,13 @@ contract('Crowdsale', function ([owner, wallet, investor]) { const balanceBeforeInvestment = web3.eth.getBalance(investor); await increaseTimeTo(this.startTime); - await this.crowdsale.sendTransaction({value: ether(1), from: investor, gasPrice: 0}); + await this.crowdsale.sendTransaction({ value: ether(1), from: investor, gasPrice: 0 }); await increaseTimeTo(this.afterEndTime); - await this.crowdsale.finalize({from: owner}); - await this.crowdsale.claimRefund({from: investor, gasPrice: 0}).should.be.fulfilled; + await this.crowdsale.finalize({ from: owner }); + await this.crowdsale.claimRefund({ from: investor, gasPrice: 0 }).should.be.fulfilled; const balanceAfterRefund = web3.eth.getBalance(investor); balanceBeforeInvestment.should.be.bignumber.equal(balanceAfterRefund); }); - }); diff --git a/test/SplitPayment.js b/test/SplitPayment.js index c7bafdcc3df..3658d7f2f44 100644 --- a/test/SplitPayment.js +++ b/test/SplitPayment.js @@ -1,78 +1,78 @@ -const BigNumber = web3.BigNumber +const BigNumber = web3.BigNumber; const should = require('chai') .use(require('chai-as-promised')) .use(require('chai-bignumber')(BigNumber)) - .should() + .should(); -const EVMThrow = require('./helpers/EVMThrow.js') -const SplitPayment = artifacts.require('../contracts/payment/SplitPayment.sol') +const EVMThrow = require('./helpers/EVMThrow.js'); +const SplitPayment = artifacts.require('../contracts/payment/SplitPayment.sol'); contract('SplitPayment', function ([owner, payee1, payee2, payee3, nonpayee1, payer1]) { - const amount = web3.toWei(1.0, 'ether') + const amount = web3.toWei(1.0, 'ether'); beforeEach(async function () { - this.payees = [payee1, payee2, payee3] - this.shares = [20, 10, 70] + this.payees = [payee1, payee2, payee3]; + this.shares = [20, 10, 70]; - this.contract = await SplitPayment.new(this.payees, this.shares) - }) + this.contract = await SplitPayment.new(this.payees, this.shares); + }); it('should accept payments', async function () { - await web3.eth.sendTransaction({ from: owner, to: this.contract.address, value: amount }) + await web3.eth.sendTransaction({ from: owner, to: this.contract.address, value: amount }); - const balance = web3.eth.getBalance(this.contract.address) - balance.should.be.bignumber.equal(amount) - }) + const balance = web3.eth.getBalance(this.contract.address); + balance.should.be.bignumber.equal(amount); + }); it('should store shares if address is payee', async function () { - const shares = await this.contract.shares.call(payee1) - shares.should.be.bignumber.not.equal(0) - }) + const shares = await this.contract.shares.call(payee1); + shares.should.be.bignumber.not.equal(0); + }); it('should not store shares if address is not payee', async function () { - const shares = await this.contract.shares.call(nonpayee1) - shares.should.be.bignumber.equal(0) - }) + const shares = await this.contract.shares.call(nonpayee1); + shares.should.be.bignumber.equal(0); + }); it('should throw if no funds to claim', async function () { - await this.contract.claim({from: payee1}).should.be.rejectedWith(EVMThrow) - }) + await this.contract.claim({ from: payee1 }).should.be.rejectedWith(EVMThrow); + }); it('should throw if non-payee want to claim', async function () { - await web3.eth.sendTransaction({from: payer1, to: this.contract.address, value: amount}) - await this.contract.claim({from: nonpayee1}).should.be.rejectedWith(EVMThrow) - }) + await web3.eth.sendTransaction({ from: payer1, to: this.contract.address, value: amount }); + await this.contract.claim({ from: nonpayee1 }).should.be.rejectedWith(EVMThrow); + }); it('should distribute funds to payees', async function () { - await web3.eth.sendTransaction({from: payer1, to: this.contract.address, value: amount}) + await web3.eth.sendTransaction({ from: payer1, to: this.contract.address, value: amount }); // receive funds - const initBalance = web3.eth.getBalance(this.contract.address) - initBalance.should.be.bignumber.equal(amount) + const initBalance = web3.eth.getBalance(this.contract.address); + initBalance.should.be.bignumber.equal(amount); // distribute to payees - const initAmount1 = web3.eth.getBalance(payee1) - await this.contract.claim({from: payee1}) - const profit1 = web3.eth.getBalance(payee1) - initAmount1 - assert(Math.abs(profit1 - web3.toWei(0.20, 'ether')) < 1e16) + const initAmount1 = web3.eth.getBalance(payee1); + await this.contract.claim({ from: payee1 }); + const profit1 = web3.eth.getBalance(payee1) - initAmount1; + assert(Math.abs(profit1 - web3.toWei(0.20, 'ether')) < 1e16); - const initAmount2 = web3.eth.getBalance(payee2) - await this.contract.claim({from: payee2}) - const profit2 = web3.eth.getBalance(payee2) - initAmount2 - assert(Math.abs(profit2 - web3.toWei(0.10, 'ether')) < 1e16) + const initAmount2 = web3.eth.getBalance(payee2); + await this.contract.claim({ from: payee2 }); + const profit2 = web3.eth.getBalance(payee2) - initAmount2; + assert(Math.abs(profit2 - web3.toWei(0.10, 'ether')) < 1e16); - const initAmount3 = web3.eth.getBalance(payee3) - await this.contract.claim({from: payee3}) - const profit3 = web3.eth.getBalance(payee3) - initAmount3 - assert(Math.abs(profit3 - web3.toWei(0.70, 'ether')) < 1e16) + const initAmount3 = web3.eth.getBalance(payee3); + await this.contract.claim({ from: payee3 }); + const profit3 = web3.eth.getBalance(payee3) - initAmount3; + assert(Math.abs(profit3 - web3.toWei(0.70, 'ether')) < 1e16); // end balance should be zero - const endBalance = web3.eth.getBalance(this.contract.address) - endBalance.should.be.bignumber.equal(0) + const endBalance = web3.eth.getBalance(this.contract.address); + endBalance.should.be.bignumber.equal(0); // check correct funds released accounting - const totalReleased = await this.contract.totalReleased.call() - totalReleased.should.be.bignumber.equal(initBalance) - }) -}) + const totalReleased = await this.contract.totalReleased.call(); + totalReleased.should.be.bignumber.equal(initBalance); + }); +}); diff --git a/test/StandardToken.js b/test/StandardToken.js index 5bc949e14b2..48f9f3d5067 100644 --- a/test/StandardToken.js +++ b/test/StandardToken.js @@ -1,24 +1,22 @@ -'use strict'; const assertRevert = require('./helpers/assertRevert'); const expectThrow = require('./helpers/expectThrow'); var StandardTokenMock = artifacts.require('./helpers/StandardTokenMock.sol'); -contract('StandardToken', function(accounts) { - +contract('StandardToken', function (accounts) { let token; - beforeEach(async function() { + beforeEach(async function () { token = await StandardTokenMock.new(accounts[0], 100); }); - it('should return the correct totalSupply after construction', async function() { + it('should return the correct totalSupply after construction', async function () { let totalSupply = await token.totalSupply(); assert.equal(totalSupply, 100); }); - it('should return the correct allowance amount after approval', async function() { + it('should return the correct allowance amount after approval', async function () { let token = await StandardTokenMock.new(); await token.approve(accounts[1], 100); let allowance = await token.allowance(accounts[0], accounts[1]); @@ -26,7 +24,7 @@ contract('StandardToken', function(accounts) { assert.equal(allowance, 100); }); - it('should return correct balances after transfer', async function() { + it('should return correct balances after transfer', async function () { let token = await StandardTokenMock.new(accounts[0], 100); await token.transfer(accounts[1], 100); let balance0 = await token.balanceOf(accounts[0]); @@ -36,20 +34,20 @@ contract('StandardToken', function(accounts) { assert.equal(balance1, 100); }); - it('should throw an error when trying to transfer more than balance', async function() { + it('should throw an error when trying to transfer more than balance', async function () { let token = await StandardTokenMock.new(accounts[0], 100); try { await token.transfer(accounts[1], 101); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } }); - it('should return correct balances after transfering from another account', async function() { + it('should return correct balances after transfering from another account', async function () { let token = await StandardTokenMock.new(accounts[0], 100); await token.approve(accounts[1], 100); - await token.transferFrom(accounts[0], accounts[2], 100, {from: accounts[1]}); + await token.transferFrom(accounts[0], accounts[2], 100, { from: accounts[1] }); let balance0 = await token.balanceOf(accounts[0]); assert.equal(balance0, 0); @@ -61,71 +59,70 @@ contract('StandardToken', function(accounts) { assert.equal(balance2, 0); }); - it('should throw an error when trying to transfer more than allowed', async function() { + it('should throw an error when trying to transfer more than allowed', async function () { await token.approve(accounts[1], 99); try { - await token.transferFrom(accounts[0], accounts[2], 100, {from: accounts[1]}); + await token.transferFrom(accounts[0], accounts[2], 100, { from: accounts[1] }); assert.fail('should have thrown before'); } catch (error) { assertRevert(error); } }); - it('should throw an error when trying to transferFrom more than _from has', async function() { + it('should throw an error when trying to transferFrom more than _from has', async function () { let balance0 = await token.balanceOf(accounts[0]); await token.approve(accounts[1], 99); try { - await token.transferFrom(accounts[0], accounts[2], balance0+1, {from: accounts[1]}); + await token.transferFrom(accounts[0], accounts[2], balance0 + 1, { from: accounts[1] }); assert.fail('should have thrown before'); } catch (error) { assertRevert(error); } }); - describe('validating allowance updates to spender', function() { + describe('validating allowance updates to spender', function () { let preApproved; - it('should start with zero', async function() { + it('should start with zero', async function () { preApproved = await token.allowance(accounts[0], accounts[1]); assert.equal(preApproved, 0); - }) + }); - it('should increase by 50 then decrease by 10', async function() { + it('should increase by 50 then decrease by 10', async function () { await token.increaseApproval(accounts[1], 50); let postIncrease = await token.allowance(accounts[0], accounts[1]); preApproved.plus(50).should.be.bignumber.equal(postIncrease); await token.decreaseApproval(accounts[1], 10); let postDecrease = await token.allowance(accounts[0], accounts[1]); postIncrease.minus(10).should.be.bignumber.equal(postDecrease); - }) + }); }); - it('should increase by 50 then set to 0 when decreasing by more than 50', async function() { + it('should increase by 50 then set to 0 when decreasing by more than 50', async function () { await token.approve(accounts[1], 50); await token.decreaseApproval(accounts[1], 60); let postDecrease = await token.allowance(accounts[0], accounts[1]); postDecrease.should.be.bignumber.equal(0); -}); + }); - it('should throw an error when trying to transfer to 0x0', async function() { + it('should throw an error when trying to transfer to 0x0', async function () { let token = await StandardTokenMock.new(accounts[0], 100); try { let transfer = await token.transfer(0x0, 100); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } }); - it('should throw an error when trying to transferFrom to 0x0', async function() { + it('should throw an error when trying to transferFrom to 0x0', async function () { let token = await StandardTokenMock.new(accounts[0], 100); await token.approve(accounts[1], 100); try { - let transfer = await token.transferFrom(accounts[0], 0x0, 100, {from: accounts[1]}); + let transfer = await token.transferFrom(accounts[0], 0x0, 100, { from: accounts[1] }); assert.fail('should have thrown before'); - } catch(error) { + } catch (error) { assertRevert(error); } }); - }); diff --git a/test/TokenDestructible.js b/test/TokenDestructible.js index f43f08a1dbd..c534367ff12 100644 --- a/test/TokenDestructible.js +++ b/test/TokenDestructible.js @@ -1,32 +1,31 @@ -'use strict'; var TokenDestructible = artifacts.require('../contracts/lifecycle/TokenDestructible.sol'); -var StandardTokenMock = artifacts.require("./helpers/StandardTokenMock.sol"); +var StandardTokenMock = artifacts.require('./helpers/StandardTokenMock.sol'); require('./helpers/transactionMined.js'); -contract('TokenDestructible', function(accounts) { +contract('TokenDestructible', function (accounts) { let destructible; - beforeEach(async function() { - destructible = await TokenDestructible.new({fron: accounts[0], value: web3.toWei('10', 'ether')}); + beforeEach(async function () { + destructible = await TokenDestructible.new({ fron: accounts[0], value: web3.toWei('10', 'ether') }); }); - it('should send balance to owner after destruction', async function() { + it('should send balance to owner after destruction', async function () { let owner = await destructible.owner(); let initBalance = web3.eth.getBalance(owner); - await destructible.destroy([], {from: owner}); + await destructible.destroy([], { from: owner }); let newBalance = web3.eth.getBalance(owner); assert.isTrue(newBalance > initBalance); }); - it('should send tokens to owner after destruction', async function() { + it('should send tokens to owner after destruction', async function () { let owner = await destructible.owner(); let token = await StandardTokenMock.new(destructible.address, 100); let initContractBalance = await token.balanceOf(destructible.address); let initOwnerBalance = await token.balanceOf(owner); assert.equal(initContractBalance, 100); assert.equal(initOwnerBalance, 0); - await destructible.destroy([token.address], {from: owner}); + await destructible.destroy([token.address], { from: owner }); let newContractBalance = await token.balanceOf(destructible.address); let newOwnerBalance = await token.balanceOf(owner); assert.equal(newContractBalance, 0); diff --git a/test/TokenTimelock.js b/test/TokenTimelock.js index bbe431d3d21..c745edccdba 100644 --- a/test/TokenTimelock.js +++ b/test/TokenTimelock.js @@ -1,57 +1,54 @@ -const BigNumber = web3.BigNumber +const BigNumber = web3.BigNumber; require('chai') .use(require('chai-as-promised')) .use(require('chai-bignumber')(BigNumber)) - .should() + .should(); +import latestTime from './helpers/latestTime'; +import { increaseTimeTo, duration } from './helpers/increaseTime'; -import latestTime from './helpers/latestTime' -import {increaseTimeTo, duration} from './helpers/increaseTime' - -const MintableToken = artifacts.require('MintableToken') -const TokenTimelock = artifacts.require('TokenTimelock') +const MintableToken = artifacts.require('MintableToken'); +const TokenTimelock = artifacts.require('TokenTimelock'); contract('TokenTimelock', function ([_, owner, beneficiary]) { - - const amount = new BigNumber(100) + const amount = new BigNumber(100); beforeEach(async function () { - this.token = await MintableToken.new({from: owner}) - this.releaseTime = latestTime() + duration.years(1) - this.timelock = await TokenTimelock.new(this.token.address, beneficiary, this.releaseTime) - await this.token.mint(this.timelock.address, amount, {from: owner}) - }) + this.token = await MintableToken.new({ from: owner }); + this.releaseTime = latestTime() + duration.years(1); + this.timelock = await TokenTimelock.new(this.token.address, beneficiary, this.releaseTime); + await this.token.mint(this.timelock.address, amount, { from: owner }); + }); it('cannot be released before time limit', async function () { - await this.timelock.release().should.be.rejected - }) + await this.timelock.release().should.be.rejected; + }); it('cannot be released just before time limit', async function () { - await increaseTimeTo(this.releaseTime - duration.seconds(3)) - await this.timelock.release().should.be.rejected - }) + await increaseTimeTo(this.releaseTime - duration.seconds(3)); + await this.timelock.release().should.be.rejected; + }); it('can be released just after limit', async function () { - await increaseTimeTo(this.releaseTime + duration.seconds(1)) - await this.timelock.release().should.be.fulfilled - const balance = await this.token.balanceOf(beneficiary) - balance.should.be.bignumber.equal(amount) - }) + await increaseTimeTo(this.releaseTime + duration.seconds(1)); + await this.timelock.release().should.be.fulfilled; + const balance = await this.token.balanceOf(beneficiary); + balance.should.be.bignumber.equal(amount); + }); it('can be released after time limit', async function () { - await increaseTimeTo(this.releaseTime + duration.years(1)) - await this.timelock.release().should.be.fulfilled - const balance = await this.token.balanceOf(beneficiary) - balance.should.be.bignumber.equal(amount) - }) + await increaseTimeTo(this.releaseTime + duration.years(1)); + await this.timelock.release().should.be.fulfilled; + const balance = await this.token.balanceOf(beneficiary); + balance.should.be.bignumber.equal(amount); + }); it('cannot be released twice', async function () { - await increaseTimeTo(this.releaseTime + duration.years(1)) - await this.timelock.release().should.be.fulfilled - await this.timelock.release().should.be.rejected - const balance = await this.token.balanceOf(beneficiary) - balance.should.be.bignumber.equal(amount) - }) - -}) + await increaseTimeTo(this.releaseTime + duration.years(1)); + await this.timelock.release().should.be.fulfilled; + await this.timelock.release().should.be.rejected; + const balance = await this.token.balanceOf(beneficiary); + balance.should.be.bignumber.equal(amount); + }); +}); diff --git a/test/TokenVesting.js b/test/TokenVesting.js index cc8f0715bd6..361037d47a9 100644 --- a/test/TokenVesting.js +++ b/test/TokenVesting.js @@ -1,19 +1,18 @@ -const BigNumber = web3.BigNumber +const BigNumber = web3.BigNumber; require('chai') .use(require('chai-as-promised')) .use(require('chai-bignumber')(BigNumber)) .should(); -import EVMRevert from './helpers/EVMRevert' +import EVMRevert from './helpers/EVMRevert'; import latestTime from './helpers/latestTime'; -import {increaseTimeTo, duration} from './helpers/increaseTime'; +import { increaseTimeTo, duration } from './helpers/increaseTime'; const MintableToken = artifacts.require('MintableToken'); const TokenVesting = artifacts.require('TokenVesting'); contract('TokenVesting', function ([_, owner, beneficiary]) { - const amount = new BigNumber(1000); beforeEach(async function () { @@ -75,7 +74,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { }); it('should fail to be revoked by owner if revocable not set', async function () { - const vesting = await TokenVesting.new(beneficiary, this.start, this.cliff, this.duration, false, { from: owner } ); + const vesting = await TokenVesting.new(beneficiary, this.start, this.cliff, this.duration, false, { from: owner }); await vesting.revoke(this.token.address, { from: owner }).should.be.rejectedWith(EVMRevert); }); @@ -111,5 +110,4 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { await this.vesting.revoke(this.token.address, { from: owner }).should.be.rejectedWith(EVMRevert); }); - }); diff --git a/test/helpers/EVMRevert.js b/test/helpers/EVMRevert.js index cae7feac2e5..9edcc9d5470 100644 --- a/test/helpers/EVMRevert.js +++ b/test/helpers/EVMRevert.js @@ -1 +1 @@ -export default 'revert' +export default 'revert'; diff --git a/test/helpers/EVMThrow.js b/test/helpers/EVMThrow.js index c75924f5209..abdbd4ef330 100644 --- a/test/helpers/EVMThrow.js +++ b/test/helpers/EVMThrow.js @@ -1 +1 @@ -export default 'invalid opcode' +export default 'invalid opcode'; diff --git a/test/helpers/advanceToBlock.js b/test/helpers/advanceToBlock.js index 97d723f19e3..a11dc92b9a5 100644 --- a/test/helpers/advanceToBlock.js +++ b/test/helpers/advanceToBlock.js @@ -1,22 +1,22 @@ -export function advanceBlock() { +export function advanceBlock () { return new Promise((resolve, reject) => { web3.currentProvider.sendAsync({ jsonrpc: '2.0', method: 'evm_mine', id: Date.now(), }, (err, res) => { - return err ? reject(err) : resolve(res) - }) - }) + return err ? reject(err) : resolve(res); + }); + }); } // Advances the block number so that the last mined block is `number`. -export default async function advanceToBlock(number) { +export default async function advanceToBlock (number) { if (web3.eth.blockNumber > number) { - throw Error(`block number ${number} is in the past (current is ${web3.eth.blockNumber})`) + throw Error(`block number ${number} is in the past (current is ${web3.eth.blockNumber})`); } while (web3.eth.blockNumber < number) { - await advanceBlock() + await advanceBlock(); } } diff --git a/test/helpers/assertJump.js b/test/helpers/assertJump.js index 63b50f5adee..bba098b0740 100644 --- a/test/helpers/assertJump.js +++ b/test/helpers/assertJump.js @@ -1,3 +1,3 @@ -module.exports = function(error) { +module.exports = function (error) { assert.isAbove(error.message.search('invalid opcode'), -1, 'Invalid opcode error must be returned'); -} +}; diff --git a/test/helpers/assertRevert.js b/test/helpers/assertRevert.js index fbb307c8a3d..2e44d775f22 100644 --- a/test/helpers/assertRevert.js +++ b/test/helpers/assertRevert.js @@ -1,3 +1,3 @@ -module.exports = function(error) { +module.exports = function (error) { assert.isAbove(error.message.search('revert'), -1, 'Error containing "revert" must be returned'); -} +}; diff --git a/test/helpers/ether.js b/test/helpers/ether.js index e35f9032073..3b5d13f7dfe 100644 --- a/test/helpers/ether.js +++ b/test/helpers/ether.js @@ -1,3 +1,3 @@ -export default function ether(n) { - return new web3.BigNumber(web3.toWei(n, 'ether')) +export default function ether (n) { + return new web3.BigNumber(web3.toWei(n, 'ether')); } diff --git a/test/helpers/expectThrow.js b/test/helpers/expectThrow.js index c6641e66fa0..eafcad24067 100644 --- a/test/helpers/expectThrow.js +++ b/test/helpers/expectThrow.js @@ -13,7 +13,7 @@ export default async promise => { const revert = error.message.search('revert') >= 0; assert( invalidOpcode || outOfGas || revert, - "Expected throw, got '" + error + "' instead", + 'Expected throw, got \'' + error + '\' instead', ); return; } diff --git a/test/helpers/hashMessage.js b/test/helpers/hashMessage.js index 2b20c58a2ab..c97340b64a9 100644 --- a/test/helpers/hashMessage.js +++ b/test/helpers/hashMessage.js @@ -1,8 +1,8 @@ import utils from 'ethereumjs-util'; // Hash and add same prefix to the hash that testrpc use. -module.exports = function(message) { +module.exports = function (message) { const messageHex = new Buffer(utils.sha3(message).toString('hex'), 'hex'); const prefix = utils.toBuffer('\u0019Ethereum Signed Message:\n' + messageHex.length.toString()); - return utils.bufferToHex( utils.sha3(Buffer.concat([prefix, messageHex])) ); + return utils.bufferToHex(utils.sha3(Buffer.concat([prefix, messageHex]))); }; diff --git a/test/helpers/increaseTime.js b/test/helpers/increaseTime.js index af1dd358486..a445fd4684c 100644 --- a/test/helpers/increaseTime.js +++ b/test/helpers/increaseTime.js @@ -1,8 +1,8 @@ -import latestTime from './latestTime' +import latestTime from './latestTime'; // Increases testrpc time by the passed duration in seconds -export default function increaseTime(duration) { - const id = Date.now() +export default function increaseTime (duration) { + const id = Date.now(); return new Promise((resolve, reject) => { web3.currentProvider.sendAsync({ @@ -11,17 +11,17 @@ export default function increaseTime(duration) { params: [duration], id: id, }, err1 => { - if (err1) return reject(err1) + if (err1) return reject(err1); web3.currentProvider.sendAsync({ jsonrpc: '2.0', method: 'evm_mine', - id: id+1, + id: id + 1, }, (err2, res) => { - return err2 ? reject(err2) : resolve(res) - }) - }) - }) + return err2 ? reject(err2) : resolve(res); + }); + }); + }); } /** @@ -31,7 +31,7 @@ export default function increaseTime(duration) { * * @param target time in seconds */ -export function increaseTimeTo(target) { +export function increaseTimeTo (target) { let now = latestTime(); if (target < now) throw Error(`Cannot increase current time(${now}) to a moment in the past(${target})`); let diff = target - now; @@ -39,10 +39,10 @@ export function increaseTimeTo(target) { } export const duration = { - seconds: function(val) { return val}, - minutes: function(val) { return val * this.seconds(60) }, - hours: function(val) { return val * this.minutes(60) }, - days: function(val) { return val * this.hours(24) }, - weeks: function(val) { return val * this.days(7) }, - years: function(val) { return val * this.days(365)} + seconds: function (val) { return val; }, + minutes: function (val) { return val * this.seconds(60); }, + hours: function (val) { return val * this.minutes(60); }, + days: function (val) { return val * this.hours(24); }, + weeks: function (val) { return val * this.days(7); }, + years: function (val) { return val * this.days(365); }, }; diff --git a/test/helpers/latestTime.js b/test/helpers/latestTime.js index bdc97053aa5..219b54c74d5 100644 --- a/test/helpers/latestTime.js +++ b/test/helpers/latestTime.js @@ -1,4 +1,4 @@ // Returns the time of the last mined block in seconds -export default function latestTime() { +export default function latestTime () { return web3.eth.getBlock('latest').timestamp; } diff --git a/test/helpers/merkleTree.js b/test/helpers/merkleTree.js index 0de95eb156e..ae5a914c311 100644 --- a/test/helpers/merkleTree.js +++ b/test/helpers/merkleTree.js @@ -1,7 +1,7 @@ -import { sha3, bufferToHex } from "ethereumjs-util"; +import { sha3, bufferToHex } from 'ethereumjs-util'; export default class MerkleTree { - constructor(elements) { + constructor (elements) { // Filter empty strings and hash elements this.elements = elements.filter(el => el).map(el => sha3(el)); @@ -14,9 +14,9 @@ export default class MerkleTree { this.layers = this.getLayers(this.elements); } - getLayers(elements) { + getLayers (elements) { if (elements.length == 0) { - return [[""]]; + return [['']]; } const layers = []; @@ -30,7 +30,7 @@ export default class MerkleTree { return layers; } - getNextLayer(elements) { + getNextLayer (elements) { return elements.reduce((layer, el, idx, arr) => { if (idx % 2 === 0) { // Hash the current element with its pair element @@ -41,26 +41,26 @@ export default class MerkleTree { }, []); } - combinedHash(first, second) { + combinedHash (first, second) { if (!first) { return second; } if (!second) { return first; } return sha3(this.sortAndConcat(first, second)); } - getRoot() { + getRoot () { return this.layers[this.layers.length - 1][0]; } - getHexRoot() { + getHexRoot () { return bufferToHex(this.getRoot()); } - getProof(el) { + getProof (el) { let idx = this.bufIndexOf(el, this.elements); if (idx === -1) { - throw new Error("Element does not exist in Merkle tree"); + throw new Error('Element does not exist in Merkle tree'); } return this.layers.reduce((proof, layer) => { @@ -76,13 +76,13 @@ export default class MerkleTree { }, []); } - getHexProof(el) { + getHexProof (el) { const proof = this.getProof(el); return this.bufArrToHex(proof); } - getPairElement(idx, layer) { + getPairElement (idx, layer) { const pairIdx = idx % 2 === 0 ? idx + 1 : idx - 1; if (pairIdx < layer.length) { @@ -92,7 +92,7 @@ export default class MerkleTree { } } - bufIndexOf(el, arr) { + bufIndexOf (el, arr) { let hash; // Convert element to 32 byte hash if it is not one already @@ -111,21 +111,21 @@ export default class MerkleTree { return -1; } - bufDedup(elements) { + bufDedup (elements) { return elements.filter((el, idx) => { return this.bufIndexOf(el, elements) === idx; }); } - bufArrToHex(arr) { + bufArrToHex (arr) { if (arr.some(el => !Buffer.isBuffer(el))) { - throw new Error("Array is not an array of buffers"); + throw new Error('Array is not an array of buffers'); } - return "0x" + arr.map(el => el.toString("hex")).join(""); + return '0x' + arr.map(el => el.toString('hex')).join(''); } - sortAndConcat(...args) { + sortAndConcat (...args) { return Buffer.concat([...args].sort(Buffer.compare)); } } diff --git a/test/helpers/transactionMined.js b/test/helpers/transactionMined.js index 416809b0eec..45fadfbd3db 100644 --- a/test/helpers/transactionMined.js +++ b/test/helpers/transactionMined.js @@ -1,10 +1,9 @@ -'use strict'; -//from https://gist.github.com/xavierlepretre/88682e871f4ad07be4534ae560692ee6 +// from https://gist.github.com/xavierlepretre/88682e871f4ad07be4534ae560692ee6 module.export = web3.eth.transactionMined = function (txnHash, interval) { var transactionReceiptAsync; - interval = interval ? interval : 500; - transactionReceiptAsync = function(txnHash, resolve, reject) { + interval = interval || 500; + transactionReceiptAsync = function (txnHash, resolve, reject) { try { var receipt = web3.eth.getTransactionReceipt(txnHash); if (receipt === null) { @@ -14,7 +13,7 @@ module.export = web3.eth.transactionMined = function (txnHash, interval) { } else { resolve(receipt); } - } catch(e) { + } catch (e) { reject(e); } }; diff --git a/truffle-config.js b/truffle-config.js index 8b0f41df3e2..7fb6af361ba 100644 --- a/truffle-config.js +++ b/truffle-config.js @@ -5,44 +5,44 @@ require('babel-polyfill'); const HDWalletProvider = require('truffle-hdwallet-provider'); const providerWithMnemonic = (mnemonic, rpcEndpoint) => - new HDWalletProvider(mnemonic, rpcEndpoint) + new HDWalletProvider(mnemonic, rpcEndpoint); const infuraProvider = network => providerWithMnemonic( process.env.MNEMONIC, `https://${network}.infura.io/${process.env.INFURA_API_KEY}` -) +); const ropstenProvider = process.env.SOLIDITY_COVERAGE ? undefined - : infuraProvider('ropsten') + : infuraProvider('ropsten'); module.exports = { networks: { development: { host: 'localhost', port: 8545, - network_id: '*' + network_id: '*', }, ropsten: { provider: ropstenProvider, - network_id: 3 // official id of the ropsten network + network_id: 3, // official id of the ropsten network }, coverage: { - host: "localhost", - network_id: "*", + host: 'localhost', + network_id: '*', port: 8555, gas: 0xfffffffffff, - gasPrice: 0x01 + gasPrice: 0x01, }, testrpc: { host: 'localhost', port: 8545, - network_id: '*' + network_id: '*', }, ganache: { host: 'localhost', port: 7545, - network_id: '*' + network_id: '*', }, - } + }, };