Browse Source

Prefer const in test files (#1117)

* Removed all instances of var.

* Sorted eslintrc rules.

* Made eslint rule severity explicit.

* Now prefering const over let.
Nicolás Venturo 7 years ago
parent
commit
567b773242

+ 25 - 22
.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",
   }
 }

+ 2 - 2
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);

+ 1 - 1
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);
     });

+ 19 - 19
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 }));
   });
 });

+ 2 - 2
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));
   });
 

+ 3 - 3
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);
     });
   });

+ 3 - 5
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);
     });
   });

+ 1 - 1
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);
     });
 

+ 4 - 4
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);
       });
     });

+ 1 - 1
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);
       });
 

+ 5 - 5
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);
       });
     });

+ 2 - 2
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);
 }
 

+ 1 - 1
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];

+ 1 - 1
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 + ')';
 };
 

+ 5 - 9
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);

+ 1 - 1
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 () {

+ 7 - 7
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)

+ 13 - 13
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);
   });

+ 1 - 1
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;

+ 4 - 4
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));
   });
 });

+ 6 - 6
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);
   });

+ 16 - 14
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);
   });

+ 5 - 5
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);
     });

+ 4 - 4
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);
     });
   });

+ 23 - 27
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));
   });
 });

+ 5 - 5
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);

+ 5 - 5
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);
     });

+ 3 - 3
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);
       }

+ 1 - 1
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);

+ 1 - 1
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));
     });

+ 1 - 1
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);