diff --git a/.eslintrc b/.eslintrc index a6e8618d1..6ec76ed7d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -21,31 +21,34 @@ "rules": { // Strict mode - "strict": [2, "global"], + "strict": ["error", "global"], // Code style - "indent": [2, 2], - "quotes": [2, "single"], + "camelcase": ["error", {"properties": "always"}], + "comma-dangle": ["warn", "always-multiline"], + "comma-spacing": ["error", {"before": false, "after": true}], + "dot-notation": ["error", {"allowKeywords": true, "allowPattern": ""}], + "eol-last": "warn", + "eqeqeq": ["error", "smart"], + "generator-star-spacing": ["error", "before"], + "indent": ["error", 2], + "max-len": ["error", 120, 2], + "no-debugger": "off", + "no-dupe-args": "error", + "no-dupe-keys": "error", + "no-mixed-spaces-and-tabs": ["error", "smart-tabs"], + "no-redeclare": ["error", {"builtinGlobals": true}], + "no-trailing-spaces": ["error", { "skipBlankLines": true }], + "no-undef": "error", + "no-use-before-define": "off", + "no-var": "error", + "object-curly-spacing": ["error", "always"], + "prefer-const": "error", + "quotes": ["error", "single"], "semi": ["error", "always"], "space-before-function-paren": ["error", "always"], - "no-use-before-define": 0, - "eqeqeq": [2, "smart"], - "dot-notation": [2, {"allowKeywords": true, "allowPattern": ""}], - "no-redeclare": [2, {"builtinGlobals": true}], - "no-trailing-spaces": [2, { "skipBlankLines": true }], - "eol-last": 1, - "comma-spacing": [2, {"before": false, "after": true}], - "camelcase": [2, {"properties": "always"}], - "no-mixed-spaces-and-tabs": [2, "smart-tabs"], - "comma-dangle": [1, "always-multiline"], - "no-dupe-args": 2, - "no-dupe-keys": 2, - "no-debugger": 0, - "no-undef": 2, - "object-curly-spacing": [2, "always"], - "max-len": [2, 120, 2], - "generator-star-spacing": ["error", "before"], - "promise/avoid-new": 0, - "promise/always-return": 0 + + "promise/always-return": "off", + "promise/avoid-new": "off", } } diff --git a/test/AutoIncrementing.test.js b/test/AutoIncrementing.test.js index 6ac433a0b..3743387b4 100644 --- a/test/AutoIncrementing.test.js +++ b/test/AutoIncrementing.test.js @@ -17,7 +17,7 @@ contract('AutoIncrementing', function ([_, owner]) { context('custom key', async function () { it('should return expected values', async function () { - for (let expectedId of EXPECTED) { + for (const expectedId of EXPECTED) { await this.mock.doThing(KEY1, { from: owner }); const actualId = await this.mock.theId(); actualId.should.be.bignumber.eq(expectedId); @@ -27,7 +27,7 @@ contract('AutoIncrementing', function ([_, owner]) { context('parallel keys', async function () { it('should return expected values for each counter', async function () { - for (let expectedId of EXPECTED) { + for (const expectedId of EXPECTED) { await this.mock.doThing(KEY1, { from: owner }); let actualId = await this.mock.theId(); actualId.should.be.bignumber.eq(expectedId); diff --git a/test/Bounty.test.js b/test/Bounty.test.js index 8417e17d1..9be57582a 100644 --- a/test/Bounty.test.js +++ b/test/Bounty.test.js @@ -25,7 +25,7 @@ contract('Bounty', function ([_, owner, researcher]) { it('can set reward', async function () { await sendReward(owner, this.bounty.address, reward); - + const balance = await ethGetBalance(this.bounty.address); balance.should.be.bignumber.eq(reward); }); diff --git a/test/LimitBalance.test.js b/test/LimitBalance.test.js index 4659090c8..7029d6047 100644 --- a/test/LimitBalance.test.js +++ b/test/LimitBalance.test.js @@ -1,53 +1,53 @@ const { assertRevert } = require('./helpers/assertRevert'); const { ethGetBalance } = require('./helpers/web3'); -var LimitBalanceMock = artifacts.require('LimitBalanceMock'); +const LimitBalanceMock = artifacts.require('LimitBalanceMock'); contract('LimitBalance', function (accounts) { - let lb; + let limitBalance; beforeEach(async function () { - lb = await LimitBalanceMock.new(); + limitBalance = await LimitBalanceMock.new(); }); - let LIMIT = 1000; + const LIMIT = 1000; it('should expose limit', async function () { - let limit = await lb.limit(); + const limit = await limitBalance.limit(); assert.equal(limit, LIMIT); }); it('should allow sending below limit', async function () { - let amount = 1; - await lb.limitedDeposit({ value: amount }); + const amount = 1; + await limitBalance.limitedDeposit({ value: amount }); - const balance = await ethGetBalance(lb.address); + const balance = await ethGetBalance(limitBalance.address); assert.equal(balance, amount); }); it('shouldnt allow sending above limit', async function () { - let amount = 1110; - await assertRevert(lb.limitedDeposit({ value: amount })); + const amount = 1110; + await assertRevert(limitBalance.limitedDeposit({ value: amount })); }); it('should allow multiple sends below limit', async function () { - let amount = 500; - await lb.limitedDeposit({ value: amount }); + const amount = 500; + await limitBalance.limitedDeposit({ value: amount }); - const balance = await ethGetBalance(lb.address); + const balance = await ethGetBalance(limitBalance.address); assert.equal(balance, amount); - await lb.limitedDeposit({ value: amount }); - const updatedBalance = await ethGetBalance(lb.address); + await limitBalance.limitedDeposit({ value: amount }); + const updatedBalance = await ethGetBalance(limitBalance.address); assert.equal(updatedBalance, amount * 2); }); it('shouldnt allow multiple sends above limit', async function () { - let amount = 500; - await lb.limitedDeposit({ value: amount }); + const amount = 500; + await limitBalance.limitedDeposit({ value: amount }); - const balance = await ethGetBalance(lb.address); + const balance = await ethGetBalance(limitBalance.address); assert.equal(balance, amount); - await assertRevert(lb.limitedDeposit({ value: amount + 1 })); + await assertRevert(limitBalance.limitedDeposit({ value: amount + 1 })); }); }); diff --git a/test/ReentrancyGuard.test.js b/test/ReentrancyGuard.test.js index a99dcff72..8a6e4ccf9 100644 --- a/test/ReentrancyGuard.test.js +++ b/test/ReentrancyGuard.test.js @@ -7,12 +7,12 @@ contract('ReentrancyGuard', function (accounts) { beforeEach(async function () { reentrancyMock = await ReentrancyMock.new(); - let initialCounter = await reentrancyMock.counter(); + const initialCounter = await reentrancyMock.counter(); assert.equal(initialCounter, 0); }); it('should not allow remote callback', async function () { - let attacker = await ReentrancyAttack.new(); + const attacker = await ReentrancyAttack.new(); await expectThrow(reentrancyMock.countAndCall(attacker.address)); }); diff --git a/test/crowdsale/AllowanceCrowdsale.test.js b/test/crowdsale/AllowanceCrowdsale.test.js index a7d8b92fd..da95d296c 100644 --- a/test/crowdsale/AllowanceCrowdsale.test.js +++ b/test/crowdsale/AllowanceCrowdsale.test.js @@ -47,7 +47,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW it('should assign tokens to sender', async function () { await this.crowdsale.sendTransaction({ value: value, from: investor }); - let balance = await this.token.balanceOf(investor); + const balance = await this.token.balanceOf(investor); balance.should.be.bignumber.equal(expectedTokenAmount); }); @@ -61,9 +61,9 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW describe('check remaining allowance', function () { it('should report correct allowace left', async function () { - let remainingAllowance = tokenAllowance - expectedTokenAmount; + const remainingAllowance = tokenAllowance - expectedTokenAmount; await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }); - let tokensRemaining = await this.crowdsale.remainingTokens(); + const tokensRemaining = await this.crowdsale.remainingTokens(); tokensRemaining.should.be.bignumber.equal(remainingAllowance); }); }); diff --git a/test/crowdsale/CappedCrowdsale.test.js b/test/crowdsale/CappedCrowdsale.test.js index 720016dd2..6d9b7b75f 100644 --- a/test/crowdsale/CappedCrowdsale.test.js +++ b/test/crowdsale/CappedCrowdsale.test.js @@ -56,22 +56,20 @@ contract('CappedCrowdsale', function ([_, wallet]) { describe('ending', function () { it('should not reach cap if sent under cap', async function () { - let capReached = await this.crowdsale.capReached(); - capReached.should.equal(false); await this.crowdsale.send(lessThanCap); - capReached = await this.crowdsale.capReached(); + const capReached = await this.crowdsale.capReached(); capReached.should.equal(false); }); it('should not reach cap if sent just under cap', async function () { await this.crowdsale.send(cap.minus(1)); - let capReached = await this.crowdsale.capReached(); + const capReached = await this.crowdsale.capReached(); capReached.should.equal(false); }); it('should reach cap if cap sent', async function () { await this.crowdsale.send(cap); - let capReached = await this.crowdsale.capReached(); + const capReached = await this.crowdsale.capReached(); capReached.should.equal(true); }); }); diff --git a/test/crowdsale/Crowdsale.test.js b/test/crowdsale/Crowdsale.test.js index 3d28711b6..154de95a9 100644 --- a/test/crowdsale/Crowdsale.test.js +++ b/test/crowdsale/Crowdsale.test.js @@ -42,7 +42,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { it('should assign tokens to sender', async function () { await this.crowdsale.sendTransaction({ value: value, from: investor }); - let balance = await this.token.balanceOf(investor); + const balance = await this.token.balanceOf(investor); balance.should.be.bignumber.equal(expectedTokenAmount); }); diff --git a/test/crowdsale/IndividuallyCappedCrowdsale.test.js b/test/crowdsale/IndividuallyCappedCrowdsale.test.js index 9dc2eb86e..21212f173 100644 --- a/test/crowdsale/IndividuallyCappedCrowdsale.test.js +++ b/test/crowdsale/IndividuallyCappedCrowdsale.test.js @@ -56,13 +56,13 @@ contract('IndividuallyCappedCrowdsale', function ([_, wallet, alice, bob, charli describe('reporting state', function () { it('should report correct cap', async function () { - let retrievedCap = await this.crowdsale.getUserCap(alice); + const retrievedCap = await this.crowdsale.getUserCap(alice); retrievedCap.should.be.bignumber.equal(capAlice); }); it('should report actual contribution', async function () { await this.crowdsale.buyTokens(alice, { value: lessThanCapAlice }); - let retrievedContribution = await this.crowdsale.getUserContribution(alice); + const retrievedContribution = await this.crowdsale.getUserContribution(alice); retrievedContribution.should.be.bignumber.equal(lessThanCapAlice); }); }); @@ -97,9 +97,9 @@ contract('IndividuallyCappedCrowdsale', function ([_, wallet, alice, bob, charli describe('reporting state', function () { it('should report correct cap', async function () { - let retrievedCapBob = await this.crowdsale.getUserCap(bob); + const retrievedCapBob = await this.crowdsale.getUserCap(bob); retrievedCapBob.should.be.bignumber.equal(capBob); - let retrievedCapCharlie = await this.crowdsale.getUserCap(charlie); + const retrievedCapCharlie = await this.crowdsale.getUserCap(charlie); retrievedCapCharlie.should.be.bignumber.equal(capBob); }); }); diff --git a/test/crowdsale/MintedCrowdsale.behaviour.js b/test/crowdsale/MintedCrowdsale.behaviour.js index 7e7d0d06e..68454d4f1 100644 --- a/test/crowdsale/MintedCrowdsale.behaviour.js +++ b/test/crowdsale/MintedCrowdsale.behaviour.js @@ -30,7 +30,7 @@ function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate it('should assign tokens to sender', async function () { await this.crowdsale.sendTransaction({ value: value, from: investor }); - let balance = await this.token.balanceOf(investor); + const balance = await this.token.balanceOf(investor); balance.should.be.bignumber.equal(expectedTokenAmount); }); diff --git a/test/crowdsale/WhitelistedCrowdsale.test.js b/test/crowdsale/WhitelistedCrowdsale.test.js index e59dd8620..2335d87dd 100644 --- a/test/crowdsale/WhitelistedCrowdsale.test.js +++ b/test/crowdsale/WhitelistedCrowdsale.test.js @@ -43,9 +43,9 @@ contract('WhitelistedCrowdsale', function ([_, wallet, authorized, unauthorized, describe('reporting whitelisted', function () { it('should correctly report whitelisted addresses', async function () { - let isAuthorized = await this.crowdsale.whitelist(authorized); + const isAuthorized = await this.crowdsale.whitelist(authorized); isAuthorized.should.equal(true); - let isntAuthorized = await this.crowdsale.whitelist(unauthorized); + const isntAuthorized = await this.crowdsale.whitelist(unauthorized); isntAuthorized.should.equal(false); }); }); @@ -82,11 +82,11 @@ contract('WhitelistedCrowdsale', function ([_, wallet, authorized, unauthorized, describe('reporting whitelisted', function () { it('should correctly report whitelisted addresses', async function () { - let isAuthorized = await this.crowdsale.whitelist(authorized); + const isAuthorized = await this.crowdsale.whitelist(authorized); isAuthorized.should.equal(true); - let isAnotherAuthorized = await this.crowdsale.whitelist(anotherAuthorized); + const isAnotherAuthorized = await this.crowdsale.whitelist(anotherAuthorized); isAnotherAuthorized.should.equal(true); - let isntAuthorized = await this.crowdsale.whitelist(unauthorized); + const isntAuthorized = await this.crowdsale.whitelist(unauthorized); isntAuthorized.should.equal(false); }); }); diff --git a/test/helpers/increaseTime.js b/test/helpers/increaseTime.js index a8cfc6007..b22ba6b04 100644 --- a/test/helpers/increaseTime.js +++ b/test/helpers/increaseTime.js @@ -32,10 +32,10 @@ function increaseTime (duration) { * @param target time in seconds */ async function increaseTimeTo (target) { - let now = (await latestTime()); + const now = (await latestTime()); if (target < now) throw Error(`Cannot increase current time(${now}) to a moment in the past(${target})`); - let diff = target - now; + const diff = target - now; return increaseTime(diff); } diff --git a/test/helpers/sendTransaction.js b/test/helpers/sendTransaction.js index 647474115..741063209 100644 --- a/test/helpers/sendTransaction.js +++ b/test/helpers/sendTransaction.js @@ -2,7 +2,7 @@ const _ = require('lodash'); const ethjsABI = require('ethjs-abi'); function findMethod (abi, name, args) { - for (var i = 0; i < abi.length; i++) { + for (let i = 0; i < abi.length; i++) { const methodArgs = _.map(abi[i].inputs, 'type').join(','); if ((abi[i].name === name) && (methodArgs === args)) { return abi[i]; diff --git a/test/helpers/sign.js b/test/helpers/sign.js index a991d10a3..4e14d71be 100644 --- a/test/helpers/sign.js +++ b/test/helpers/sign.js @@ -29,7 +29,7 @@ const transformToFullName = function (json) { return json.name; } - var typeName = json.inputs.map(function (i) { return i.type; }).join(); + const typeName = json.inputs.map(function (i) { return i.type; }).join(); return json.name + '(' + typeName + ')'; }; diff --git a/test/helpers/transactionMined.js b/test/helpers/transactionMined.js index d98b225ed..77401ead6 100644 --- a/test/helpers/transactionMined.js +++ b/test/helpers/transactionMined.js @@ -1,10 +1,9 @@ // From https://gist.github.com/xavierlepretre/88682e871f4ad07be4534ae560692ee6 function transactionMined (txnHash, interval) { - var transactionReceiptAsync; interval = interval || 500; - transactionReceiptAsync = function (txnHash, resolve, reject) { + const transactionReceiptAsync = function (txnHash, resolve, reject) { try { - var receipt = web3.eth.getTransactionReceipt(txnHash); + const receipt = web3.eth.getTransactionReceipt(txnHash); if (receipt === null) { setTimeout(function () { transactionReceiptAsync(txnHash, resolve, reject); @@ -18,12 +17,9 @@ function transactionMined (txnHash, interval) { }; if (Array.isArray(txnHash)) { - var promises = []; - txnHash.forEach(function (oneTxHash) { - promises.push( - web3.eth.getTransactionReceiptMined(oneTxHash, interval)); - }); - return Promise.all(promises); + return Promise.all(txnHash.map(hash => + web3.eth.getTransactionReceiptMined(hash, interval) + )); } else { return new Promise(function (resolve, reject) { transactionReceiptAsync(txnHash, resolve, reject); diff --git a/test/introspection/SupportsInterface.behavior.js b/test/introspection/SupportsInterface.behavior.js index 429281f1f..0018792f4 100644 --- a/test/introspection/SupportsInterface.behavior.js +++ b/test/introspection/SupportsInterface.behavior.js @@ -36,7 +36,7 @@ function shouldSupportInterfaces (interfaces = []) { this.thing = this.mock || this.token; }); - for (let k of interfaces) { + for (const k of interfaces) { const interfaceId = INTERFACE_IDS[k]; describe(k, function () { it('should use less than 30k gas', async function () { diff --git a/test/library/ECRecovery.test.js b/test/library/ECRecovery.test.js index 0c51ae0bd..75551eef6 100644 --- a/test/library/ECRecovery.test.js +++ b/test/library/ECRecovery.test.js @@ -16,20 +16,20 @@ contract('ECRecovery', function (accounts) { it('recover v0', async function () { // Signature generated outside ganache with method web3.eth.sign(signer, message) - let signer = '0x2cc1166f6212628a0deef2b33befb2187d35b86c'; - let message = web3.sha3(TEST_MESSAGE); + const signer = '0x2cc1166f6212628a0deef2b33befb2187d35b86c'; + const message = web3.sha3(TEST_MESSAGE); // eslint-disable-next-line max-len - let signature = '0x5d99b6f7f6d1f73d1a26497f2b1c89b24c0993913f86e9a2d02cd69887d9c94f3c880358579d811b21dd1b7fd9bb01c1d81d10e69f0384e675c32b39643be89200'; + const signature = '0x5d99b6f7f6d1f73d1a26497f2b1c89b24c0993913f86e9a2d02cd69887d9c94f3c880358579d811b21dd1b7fd9bb01c1d81d10e69f0384e675c32b39643be89200'; const addrRecovered = await ecrecovery.recover(message, signature); addrRecovered.should.eq(signer); }); it('recover v1', async function () { // Signature generated outside ganache with method web3.eth.sign(signer, message) - let signer = '0x1e318623ab09fe6de3c9b8672098464aeda9100e'; - let message = web3.sha3(TEST_MESSAGE); + const signer = '0x1e318623ab09fe6de3c9b8672098464aeda9100e'; + const message = web3.sha3(TEST_MESSAGE); // eslint-disable-next-line max-len - let signature = '0x331fe75a821c982f9127538858900d87d3ec1f9f737338ad67cad133fa48feff48e6fa0c18abc62e42820f05943e47af3e9fbe306ce74d64094bdf1691ee53e001'; + const signature = '0x331fe75a821c982f9127538858900d87d3ec1f9f737338ad67cad133fa48feff48e6fa0c18abc62e42820f05943e47af3e9fbe306ce74d64094bdf1691ee53e001'; const addrRecovered = await ecrecovery.recover(message, signature); addrRecovered.should.eq(signer); }); @@ -57,7 +57,7 @@ contract('ECRecovery', function (accounts) { it('recover should revert when a small hash is sent', async function () { // Create the signature using account[0] - let signature = signMessage(accounts[0], TEST_MESSAGE); + const signature = signMessage(accounts[0], TEST_MESSAGE); try { await expectThrow( ecrecovery.recover(hashMessage(TEST_MESSAGE).substring(2), signature) diff --git a/test/library/Math.test.js b/test/library/Math.test.js index fdecda4d3..f00878764 100644 --- a/test/library/Math.test.js +++ b/test/library/Math.test.js @@ -1,4 +1,4 @@ -var MathMock = artifacts.require('MathMock'); +const MathMock = artifacts.require('MathMock'); contract('Math', function (accounts) { let math; @@ -8,35 +8,35 @@ contract('Math', function (accounts) { }); it('returns max64 correctly', async function () { - let a = 5678; - let b = 1234; + const a = 5678; + const b = 1234; await math.max64(a, b); - let result = await math.result64(); + const result = await math.result64(); assert.equal(result, a); }); it('returns min64 correctly', async function () { - let a = 5678; - let b = 1234; + const a = 5678; + const b = 1234; await math.min64(a, b); - let result = await math.result64(); + const result = await math.result64(); assert.equal(result, b); }); it('returns max256 correctly', async function () { - let a = 5678; - let b = 1234; + const a = 5678; + const b = 1234; await math.max256(a, b); - let result = await math.result256(); + const result = await math.result256(); assert.equal(result, a); }); it('returns min256 correctly', async function () { - let a = 5678; - let b = 1234; + const a = 5678; + const b = 1234; await math.min256(a, b); - let result = await math.result256(); + const result = await math.result256(); assert.equal(result, b); }); diff --git a/test/library/MerkleProof.test.js b/test/library/MerkleProof.test.js index 6ee36888f..7a9e56c05 100644 --- a/test/library/MerkleProof.test.js +++ b/test/library/MerkleProof.test.js @@ -1,7 +1,7 @@ const { MerkleTree } = require('../helpers/merkleTree.js'); const { sha3, bufferToHex } = require('ethereumjs-util'); -var MerkleProofWrapper = artifacts.require('MerkleProofWrapper'); +const MerkleProofWrapper = artifacts.require('MerkleProofWrapper'); contract('MerkleProof', function (accounts) { let merkleProof; diff --git a/test/lifecycle/Destructible.test.js b/test/lifecycle/Destructible.test.js index 469cc7e4a..74d5910ac 100644 --- a/test/lifecycle/Destructible.test.js +++ b/test/lifecycle/Destructible.test.js @@ -14,16 +14,16 @@ contract('Destructible', function (accounts) { }); it('should send balance to owner after destruction', async function () { - let initBalance = await ethGetBalance(this.owner); + const initBalance = await ethGetBalance(this.owner); await this.destructible.destroy({ from: this.owner }); - let newBalance = await ethGetBalance(this.owner); + const newBalance = await ethGetBalance(this.owner); assert.isTrue(newBalance > initBalance); }); it('should send balance to recepient after destruction', async function () { - let initBalance = await ethGetBalance(accounts[1]); + const initBalance = await ethGetBalance(accounts[1]); await this.destructible.destroyAndSend(accounts[1], { from: this.owner }); - let newBalance = await ethGetBalance(accounts[1]); + const newBalance = await ethGetBalance(accounts[1]); assert.isTrue(newBalance.greaterThan(initBalance)); }); }); diff --git a/test/lifecycle/Pausable.test.js b/test/lifecycle/Pausable.test.js index fa0b3c594..1c33e2d01 100644 --- a/test/lifecycle/Pausable.test.js +++ b/test/lifecycle/Pausable.test.js @@ -7,21 +7,21 @@ contract('Pausable', function (accounts) { }); it('can perform normal process in non-pause', async function () { - let count0 = await this.Pausable.count(); + const count0 = await this.Pausable.count(); assert.equal(count0, 0); await this.Pausable.normalProcess(); - let count1 = await this.Pausable.count(); + const count1 = await this.Pausable.count(); assert.equal(count1, 1); }); it('can not perform normal process in pause', async function () { await this.Pausable.pause(); - let count0 = await this.Pausable.count(); + const count0 = await this.Pausable.count(); assert.equal(count0, 0); await assertRevert(this.Pausable.normalProcess()); - let count1 = await this.Pausable.count(); + const count1 = await this.Pausable.count(); assert.equal(count1, 0); }); @@ -34,7 +34,7 @@ contract('Pausable', function (accounts) { it('can take a drastic measure in a pause', async function () { await this.Pausable.pause(); await this.Pausable.drasticMeasure(); - let drasticMeasureTaken = await this.Pausable.drasticMeasureTaken(); + const drasticMeasureTaken = await this.Pausable.drasticMeasureTaken(); assert.isTrue(drasticMeasureTaken); }); @@ -43,7 +43,7 @@ contract('Pausable', function (accounts) { await this.Pausable.pause(); await this.Pausable.unpause(); await this.Pausable.normalProcess(); - let count0 = await this.Pausable.count(); + const count0 = await this.Pausable.count(); assert.equal(count0, 1); }); diff --git a/test/lifecycle/TokenDestructible.test.js b/test/lifecycle/TokenDestructible.test.js index 3eb6ba5f3..f9ec04ded 100644 --- a/test/lifecycle/TokenDestructible.test.js +++ b/test/lifecycle/TokenDestructible.test.js @@ -1,37 +1,39 @@ const { ethGetBalance } = require('../helpers/web3'); -var TokenDestructible = artifacts.require('TokenDestructible'); -var StandardTokenMock = artifacts.require('StandardTokenMock'); +const TokenDestructible = artifacts.require('TokenDestructible'); +const StandardTokenMock = artifacts.require('StandardTokenMock'); contract('TokenDestructible', function (accounts) { - let destructible; + let tokenDestructible; let owner; beforeEach(async function () { - destructible = await TokenDestructible.new({ + tokenDestructible = await TokenDestructible.new({ from: accounts[0], value: web3.toWei('10', 'ether'), }); - owner = await destructible.owner(); + owner = await tokenDestructible.owner(); }); it('should send balance to owner after destruction', async function () { - let initBalance = await ethGetBalance(owner); - await destructible.destroy([], { from: owner }); - let newBalance = await ethGetBalance(owner); + const initBalance = await ethGetBalance(owner); + await tokenDestructible.destroy([], { from: owner }); + + const newBalance = await ethGetBalance(owner); assert.isTrue(newBalance > initBalance); }); it('should send tokens to owner after destruction', async function () { - let token = await StandardTokenMock.new(destructible.address, 100); - let initContractBalance = await token.balanceOf(destructible.address); - let initOwnerBalance = await token.balanceOf(owner); + const token = await StandardTokenMock.new(tokenDestructible.address, 100); + const initContractBalance = await token.balanceOf(tokenDestructible.address); + const initOwnerBalance = await token.balanceOf(owner); assert.equal(initContractBalance, 100); assert.equal(initOwnerBalance, 0); - await destructible.destroy([token.address], { from: owner }); - let newContractBalance = await token.balanceOf(destructible.address); - let newOwnerBalance = await token.balanceOf(owner); + + await tokenDestructible.destroy([token.address], { from: owner }); + const newContractBalance = await token.balanceOf(tokenDestructible.address); + const newOwnerBalance = await token.balanceOf(owner); assert.equal(newContractBalance, 0); assert.equal(newOwnerBalance, 100); }); diff --git a/test/ownership/Claimable.test.js b/test/ownership/Claimable.test.js index e0b394a07..b9e3d6a7d 100644 --- a/test/ownership/Claimable.test.js +++ b/test/ownership/Claimable.test.js @@ -1,6 +1,6 @@ const { assertRevert } = require('../helpers/assertRevert'); -var Claimable = artifacts.require('Claimable'); +const Claimable = artifacts.require('Claimable'); contract('Claimable', function (accounts) { let claimable; @@ -10,14 +10,14 @@ contract('Claimable', function (accounts) { }); it('should have an owner', async function () { - let owner = await claimable.owner(); + const owner = await claimable.owner(); assert.isTrue(owner !== 0); }); it('changes pendingOwner after transfer', async function () { - let newOwner = accounts[1]; + const newOwner = accounts[1]; await claimable.transferOwnership(newOwner); - let pendingOwner = await claimable.pendingOwner(); + const pendingOwner = await claimable.pendingOwner(); assert.isTrue(pendingOwner === newOwner); }); @@ -44,7 +44,7 @@ contract('Claimable', function (accounts) { it('changes allow pending owner to claim ownership', async function () { await claimable.claimOwnership({ from: newOwner }); - let owner = await claimable.owner(); + const owner = await claimable.owner(); assert.isTrue(owner === newOwner); }); diff --git a/test/ownership/Contactable.test.js b/test/ownership/Contactable.test.js index 11a8f2999..0d1de0fc7 100644 --- a/test/ownership/Contactable.test.js +++ b/test/ownership/Contactable.test.js @@ -1,4 +1,4 @@ -var Contactable = artifacts.require('Contactable'); +const Contactable = artifacts.require('Contactable'); contract('Contactable', function (accounts) { let contactable; @@ -8,19 +8,19 @@ contract('Contactable', function (accounts) { }); it('should have an empty contact info', async function () { - let info = await contactable.contactInformation(); + const info = await contactable.contactInformation(); assert.isTrue(info === ''); }); describe('after setting the contact information', function () { - let contactInfo = 'contact information'; + const contactInfo = 'contact information'; beforeEach(async function () { await contactable.setContactInformation(contactInfo); }); it('should return the setted contact information', async function () { - let info = await contactable.contactInformation(); + const info = await contactable.contactInformation(); assert.isTrue(info === contactInfo); }); }); diff --git a/test/ownership/DelayedClaimable.test.js b/test/ownership/DelayedClaimable.test.js index 193a9c3d8..64b5293be 100644 --- a/test/ownership/DelayedClaimable.test.js +++ b/test/ownership/DelayedClaimable.test.js @@ -1,55 +1,51 @@ const { assertRevert } = require('../helpers/assertRevert'); -var DelayedClaimable = artifacts.require('DelayedClaimable'); +const DelayedClaimable = artifacts.require('DelayedClaimable'); contract('DelayedClaimable', function (accounts) { - var delayedClaimable; - - beforeEach(function () { - return DelayedClaimable.new().then(function (deployed) { - delayedClaimable = deployed; - }); + beforeEach(async function () { + this.delayedClaimable = await DelayedClaimable.new(); }); it('can set claim blocks', async function () { - await delayedClaimable.transferOwnership(accounts[2]); - await delayedClaimable.setLimits(0, 1000); - let end = await delayedClaimable.end(); + await this.delayedClaimable.transferOwnership(accounts[2]); + await this.delayedClaimable.setLimits(0, 1000); + const end = await this.delayedClaimable.end(); assert.equal(end, 1000); - let start = await delayedClaimable.start(); + const start = await this.delayedClaimable.start(); assert.equal(start, 0); }); it('changes pendingOwner after transfer successful', async function () { - await delayedClaimable.transferOwnership(accounts[2]); - await delayedClaimable.setLimits(0, 1000); - let end = await delayedClaimable.end(); + await this.delayedClaimable.transferOwnership(accounts[2]); + await this.delayedClaimable.setLimits(0, 1000); + const end = await this.delayedClaimable.end(); assert.equal(end, 1000); - let start = await delayedClaimable.start(); + const start = await this.delayedClaimable.start(); assert.equal(start, 0); - let pendingOwner = await delayedClaimable.pendingOwner(); + const pendingOwner = await this.delayedClaimable.pendingOwner(); assert.equal(pendingOwner, accounts[2]); - await delayedClaimable.claimOwnership({ from: accounts[2] }); - let owner = await delayedClaimable.owner(); + await this.delayedClaimable.claimOwnership({ from: accounts[2] }); + const owner = await this.delayedClaimable.owner(); assert.equal(owner, accounts[2]); }); it('changes pendingOwner after transfer fails', async function () { - await delayedClaimable.transferOwnership(accounts[1]); - await delayedClaimable.setLimits(100, 110); - let end = await delayedClaimable.end(); + await this.delayedClaimable.transferOwnership(accounts[1]); + await this.delayedClaimable.setLimits(100, 110); + const end = await this.delayedClaimable.end(); assert.equal(end, 110); - let start = await delayedClaimable.start(); + const start = await this.delayedClaimable.start(); assert.equal(start, 100); - let pendingOwner = await delayedClaimable.pendingOwner(); + const pendingOwner = await this.delayedClaimable.pendingOwner(); assert.equal(pendingOwner, accounts[1]); - await assertRevert(delayedClaimable.claimOwnership({ from: accounts[1] })); - let owner = await delayedClaimable.owner(); + await assertRevert(this.delayedClaimable.claimOwnership({ from: accounts[1] })); + const owner = await this.delayedClaimable.owner(); assert.isTrue(owner !== accounts[1]); }); it('set end and start invalid values fail', async function () { - await delayedClaimable.transferOwnership(accounts[1]); - await assertRevert(delayedClaimable.setLimits(1001, 1000)); + await this.delayedClaimable.transferOwnership(accounts[1]); + await assertRevert(this.delayedClaimable.setLimits(1001, 1000)); }); }); diff --git a/test/ownership/HasNoEther.test.js b/test/ownership/HasNoEther.test.js index cf38787dc..b5634955f 100644 --- a/test/ownership/HasNoEther.test.js +++ b/test/ownership/HasNoEther.test.js @@ -16,7 +16,7 @@ contract('HasNoEther', function (accounts) { }); it('should not accept ether', async function () { - let hasNoEther = await HasNoEtherTest.new(); + const hasNoEther = await HasNoEtherTest.new(); await expectThrow( ethSendTransaction({ @@ -29,12 +29,12 @@ contract('HasNoEther', function (accounts) { it('should allow owner to reclaim ether', async function () { // Create contract - let hasNoEther = await HasNoEtherTest.new(); + const hasNoEther = await HasNoEtherTest.new(); const startBalance = await ethGetBalance(hasNoEther.address); assert.equal(startBalance, 0); // Force ether into it - let forceEther = await ForceEther.new({ value: amount }); + const forceEther = await ForceEther.new({ value: amount }); await forceEther.destroyAndSend(hasNoEther.address); const forcedBalance = await ethGetBalance(hasNoEther.address); assert.equal(forcedBalance, amount); @@ -50,10 +50,10 @@ contract('HasNoEther', function (accounts) { it('should allow only owner to reclaim ether', async function () { // Create contract - let hasNoEther = await HasNoEtherTest.new({ from: accounts[0] }); + const hasNoEther = await HasNoEtherTest.new({ from: accounts[0] }); // Force ether into it - let forceEther = await ForceEther.new({ value: amount }); + const forceEther = await ForceEther.new({ value: amount }); await forceEther.destroyAndSend(hasNoEther.address); const forcedBalance = await ethGetBalance(hasNoEther.address); assert.equal(forcedBalance, amount); diff --git a/test/ownership/Ownable.behaviour.js b/test/ownership/Ownable.behaviour.js index fa4bc512f..c45cde7e4 100644 --- a/test/ownership/Ownable.behaviour.js +++ b/test/ownership/Ownable.behaviour.js @@ -9,14 +9,14 @@ require('chai') function shouldBehaveLikeOwnable (accounts) { describe('as an ownable', function () { it('should have an owner', async function () { - let owner = await this.ownable.owner(); + const owner = await this.ownable.owner(); owner.should.not.eq(ZERO_ADDRESS); }); it('changes owner after transfer', async function () { - let other = accounts[1]; + const other = accounts[1]; await this.ownable.transferOwnership(other); - let owner = await this.ownable.owner(); + const owner = await this.ownable.owner(); owner.should.eq(other); }); @@ -29,13 +29,13 @@ function shouldBehaveLikeOwnable (accounts) { }); it('should guard ownership against stuck state', async function () { - let originalOwner = await this.ownable.owner(); + const originalOwner = await this.ownable.owner(); await expectThrow(this.ownable.transferOwnership(null, { from: originalOwner }), EVMRevert); }); it('loses owner after renouncement', async function () { await this.ownable.renounceOwnership(); - let owner = await this.ownable.owner(); + const owner = await this.ownable.owner(); owner.should.eq(ZERO_ADDRESS); }); diff --git a/test/ownership/Whitelist.test.js b/test/ownership/Whitelist.test.js index 84c3ac1b1..812e560cf 100644 --- a/test/ownership/Whitelist.test.js +++ b/test/ownership/Whitelist.test.js @@ -38,7 +38,7 @@ contract('Whitelist', function (accounts) { 'RoleAdded', { role: this.role }, ); - for (let addr of whitelistedAddresses) { + for (const addr of whitelistedAddresses) { const isWhitelisted = await this.mock.whitelist(addr); isWhitelisted.should.be.equal(true); } @@ -50,7 +50,7 @@ contract('Whitelist', function (accounts) { 'RoleRemoved', { role: this.role }, ); - let isWhitelisted = await this.mock.whitelist(whitelistedAddress1); + const isWhitelisted = await this.mock.whitelist(whitelistedAddress1); isWhitelisted.should.be.equal(false); }); @@ -60,7 +60,7 @@ contract('Whitelist', function (accounts) { 'RoleRemoved', { role: this.role }, ); - for (let addr of whitelistedAddresses) { + for (const addr of whitelistedAddresses) { const isWhitelisted = await this.mock.whitelist(addr); isWhitelisted.should.be.equal(false); } diff --git a/test/payment/RefundEscrow.test.js b/test/payment/RefundEscrow.test.js index a7d201e91..524a5e306 100644 --- a/test/payment/RefundEscrow.test.js +++ b/test/payment/RefundEscrow.test.js @@ -90,7 +90,7 @@ contract('RefundEscrow', function ([owner, beneficiary, refundee1, refundee2]) { }); it('refunds refundees', async function () { - for (let refundee of [refundee1, refundee2]) { + for (const refundee of [refundee1, refundee2]) { const refundeeInitialBalance = await ethGetBalance(refundee); await this.escrow.withdraw(refundee); const refundeeFinalBalance = await ethGetBalance(refundee); diff --git a/test/token/ERC20/CappedToken.behaviour.js b/test/token/ERC20/CappedToken.behaviour.js index d2586929d..bc63f2292 100644 --- a/test/token/ERC20/CappedToken.behaviour.js +++ b/test/token/ERC20/CappedToken.behaviour.js @@ -5,7 +5,7 @@ function shouldBehaveLikeCappedToken ([owner, anotherAccount, minter, cap]) { const from = minter; it('should start with the correct cap', async function () { - let _cap = await this.token.cap(); + const _cap = await this.token.cap(); assert(cap.eq(_cap)); }); diff --git a/test/token/ERC20/CappedToken.test.js b/test/token/ERC20/CappedToken.test.js index cc27f2edd..39da808ef 100644 --- a/test/token/ERC20/CappedToken.test.js +++ b/test/token/ERC20/CappedToken.test.js @@ -2,7 +2,7 @@ const { ether } = require('../../helpers/ether'); const { shouldBehaveLikeMintableToken } = require('./MintableToken.behaviour'); const { shouldBehaveLikeCappedToken } = require('./CappedToken.behaviour'); -var CappedToken = artifacts.require('CappedToken'); +const CappedToken = artifacts.require('CappedToken'); contract('Capped', function ([owner, anotherAccount]) { const _cap = ether(1000);