Prefer const in test files (#1117)

* Removed all instances of var.

* Sorted eslintrc rules.

* Made eslint rule severity explicit.

* Now prefering const over let.
pull/1121/head
Nicolás Venturo 7 years ago committed by GitHub
parent 6e19ed47be
commit 567b773242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 47
      .eslintrc
  2. 4
      test/AutoIncrementing.test.js
  3. 2
      test/Bounty.test.js
  4. 38
      test/LimitBalance.test.js
  5. 4
      test/ReentrancyGuard.test.js
  6. 6
      test/crowdsale/AllowanceCrowdsale.test.js
  7. 8
      test/crowdsale/CappedCrowdsale.test.js
  8. 2
      test/crowdsale/Crowdsale.test.js
  9. 8
      test/crowdsale/IndividuallyCappedCrowdsale.test.js
  10. 2
      test/crowdsale/MintedCrowdsale.behaviour.js
  11. 10
      test/crowdsale/WhitelistedCrowdsale.test.js
  12. 4
      test/helpers/increaseTime.js
  13. 2
      test/helpers/sendTransaction.js
  14. 2
      test/helpers/sign.js
  15. 14
      test/helpers/transactionMined.js
  16. 2
      test/introspection/SupportsInterface.behavior.js
  17. 14
      test/library/ECRecovery.test.js
  18. 26
      test/library/Math.test.js
  19. 2
      test/library/MerkleProof.test.js
  20. 8
      test/lifecycle/Destructible.test.js
  21. 12
      test/lifecycle/Pausable.test.js
  22. 30
      test/lifecycle/TokenDestructible.test.js
  23. 10
      test/ownership/Claimable.test.js
  24. 8
      test/ownership/Contactable.test.js
  25. 50
      test/ownership/DelayedClaimable.test.js
  26. 10
      test/ownership/HasNoEther.test.js
  27. 10
      test/ownership/Ownable.behaviour.js
  28. 6
      test/ownership/Whitelist.test.js
  29. 2
      test/payment/RefundEscrow.test.js
  30. 2
      test/token/ERC20/CappedToken.behaviour.js
  31. 2
      test/token/ERC20/CappedToken.test.js

@ -21,31 +21,34 @@
"rules": { "rules": {
// Strict mode // Strict mode
"strict": [2, "global"], "strict": ["error", "global"],
// Code style // Code style
"indent": [2, 2], "camelcase": ["error", {"properties": "always"}],
"quotes": [2, "single"], "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"], "semi": ["error", "always"],
"space-before-function-paren": ["error", "always"], "space-before-function-paren": ["error", "always"],
"no-use-before-define": 0,
"eqeqeq": [2, "smart"], "promise/always-return": "off",
"dot-notation": [2, {"allowKeywords": true, "allowPattern": ""}], "promise/avoid-new": "off",
"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
} }
} }

@ -17,7 +17,7 @@ contract('AutoIncrementing', function ([_, owner]) {
context('custom key', async function () { context('custom key', async function () {
it('should return expected values', 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 }); await this.mock.doThing(KEY1, { from: owner });
const actualId = await this.mock.theId(); const actualId = await this.mock.theId();
actualId.should.be.bignumber.eq(expectedId); actualId.should.be.bignumber.eq(expectedId);
@ -27,7 +27,7 @@ contract('AutoIncrementing', function ([_, owner]) {
context('parallel keys', async function () { context('parallel keys', async function () {
it('should return expected values for each counter', 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 }); await this.mock.doThing(KEY1, { from: owner });
let actualId = await this.mock.theId(); let actualId = await this.mock.theId();
actualId.should.be.bignumber.eq(expectedId); actualId.should.be.bignumber.eq(expectedId);

@ -25,7 +25,7 @@ contract('Bounty', function ([_, owner, researcher]) {
it('can set reward', async function () { it('can set reward', async function () {
await sendReward(owner, this.bounty.address, reward); await sendReward(owner, this.bounty.address, reward);
const balance = await ethGetBalance(this.bounty.address); const balance = await ethGetBalance(this.bounty.address);
balance.should.be.bignumber.eq(reward); balance.should.be.bignumber.eq(reward);
}); });

@ -1,53 +1,53 @@
const { assertRevert } = require('./helpers/assertRevert'); const { assertRevert } = require('./helpers/assertRevert');
const { ethGetBalance } = require('./helpers/web3'); const { ethGetBalance } = require('./helpers/web3');
var LimitBalanceMock = artifacts.require('LimitBalanceMock'); const LimitBalanceMock = artifacts.require('LimitBalanceMock');
contract('LimitBalance', function (accounts) { contract('LimitBalance', function (accounts) {
let lb; let limitBalance;
beforeEach(async function () { beforeEach(async function () {
lb = await LimitBalanceMock.new(); limitBalance = await LimitBalanceMock.new();
}); });
let LIMIT = 1000; const LIMIT = 1000;
it('should expose limit', async function () { it('should expose limit', async function () {
let limit = await lb.limit(); const limit = await limitBalance.limit();
assert.equal(limit, LIMIT); assert.equal(limit, LIMIT);
}); });
it('should allow sending below limit', async function () { it('should allow sending below limit', async function () {
let amount = 1; const amount = 1;
await lb.limitedDeposit({ value: amount }); await limitBalance.limitedDeposit({ value: amount });
const balance = await ethGetBalance(lb.address); const balance = await ethGetBalance(limitBalance.address);
assert.equal(balance, amount); assert.equal(balance, amount);
}); });
it('shouldnt allow sending above limit', async function () { it('shouldnt allow sending above limit', async function () {
let amount = 1110; const amount = 1110;
await assertRevert(lb.limitedDeposit({ value: amount })); await assertRevert(limitBalance.limitedDeposit({ value: amount }));
}); });
it('should allow multiple sends below limit', async function () { it('should allow multiple sends below limit', async function () {
let amount = 500; const amount = 500;
await lb.limitedDeposit({ value: amount }); await limitBalance.limitedDeposit({ value: amount });
const balance = await ethGetBalance(lb.address); const balance = await ethGetBalance(limitBalance.address);
assert.equal(balance, amount); assert.equal(balance, amount);
await lb.limitedDeposit({ value: amount }); await limitBalance.limitedDeposit({ value: amount });
const updatedBalance = await ethGetBalance(lb.address); const updatedBalance = await ethGetBalance(limitBalance.address);
assert.equal(updatedBalance, amount * 2); assert.equal(updatedBalance, amount * 2);
}); });
it('shouldnt allow multiple sends above limit', async function () { it('shouldnt allow multiple sends above limit', async function () {
let amount = 500; const amount = 500;
await lb.limitedDeposit({ value: amount }); await limitBalance.limitedDeposit({ value: amount });
const balance = await ethGetBalance(lb.address); const balance = await ethGetBalance(limitBalance.address);
assert.equal(balance, amount); assert.equal(balance, amount);
await assertRevert(lb.limitedDeposit({ value: amount + 1 })); await assertRevert(limitBalance.limitedDeposit({ value: amount + 1 }));
}); });
}); });

@ -7,12 +7,12 @@ contract('ReentrancyGuard', function (accounts) {
beforeEach(async function () { beforeEach(async function () {
reentrancyMock = await ReentrancyMock.new(); reentrancyMock = await ReentrancyMock.new();
let initialCounter = await reentrancyMock.counter(); const initialCounter = await reentrancyMock.counter();
assert.equal(initialCounter, 0); 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(); const attacker = await ReentrancyAttack.new();
await expectThrow(reentrancyMock.countAndCall(attacker.address)); await expectThrow(reentrancyMock.countAndCall(attacker.address));
}); });

@ -47,7 +47,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
it('should assign tokens to sender', async function () { 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); const balance = await this.token.balanceOf(investor);
balance.should.be.bignumber.equal(expectedTokenAmount); balance.should.be.bignumber.equal(expectedTokenAmount);
}); });
@ -61,9 +61,9 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
describe('check remaining allowance', function () { describe('check remaining allowance', function () {
it('should report correct allowace left', async 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 }); 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); tokensRemaining.should.be.bignumber.equal(remainingAllowance);
}); });
}); });

@ -56,22 +56,20 @@ contract('CappedCrowdsale', function ([_, wallet]) {
describe('ending', function () { describe('ending', function () {
it('should not reach cap if sent under cap', async 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); await this.crowdsale.send(lessThanCap);
capReached = await this.crowdsale.capReached(); const capReached = await this.crowdsale.capReached();
capReached.should.equal(false); capReached.should.equal(false);
}); });
it('should not reach cap if sent just under cap', async function () { it('should not reach cap if sent just under cap', async function () {
await this.crowdsale.send(cap.minus(1)); await this.crowdsale.send(cap.minus(1));
let capReached = await this.crowdsale.capReached(); const capReached = await this.crowdsale.capReached();
capReached.should.equal(false); capReached.should.equal(false);
}); });
it('should reach cap if cap sent', async function () { it('should reach cap if cap sent', async function () {
await this.crowdsale.send(cap); await this.crowdsale.send(cap);
let capReached = await this.crowdsale.capReached(); const capReached = await this.crowdsale.capReached();
capReached.should.equal(true); capReached.should.equal(true);
}); });
}); });

@ -42,7 +42,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
it('should assign tokens to sender', async function () { 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); const balance = await this.token.balanceOf(investor);
balance.should.be.bignumber.equal(expectedTokenAmount); balance.should.be.bignumber.equal(expectedTokenAmount);
}); });

@ -56,13 +56,13 @@ contract('IndividuallyCappedCrowdsale', function ([_, wallet, alice, bob, charli
describe('reporting state', function () { describe('reporting state', function () {
it('should report correct cap', async 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); retrievedCap.should.be.bignumber.equal(capAlice);
}); });
it('should report actual contribution', async function () { it('should report actual contribution', async function () {
await this.crowdsale.buyTokens(alice, { value: lessThanCapAlice }); 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); retrievedContribution.should.be.bignumber.equal(lessThanCapAlice);
}); });
}); });
@ -97,9 +97,9 @@ contract('IndividuallyCappedCrowdsale', function ([_, wallet, alice, bob, charli
describe('reporting state', function () { describe('reporting state', function () {
it('should report correct cap', async 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); 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); retrievedCapCharlie.should.be.bignumber.equal(capBob);
}); });
}); });

@ -30,7 +30,7 @@ function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate
it('should assign tokens to sender', async function () { 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); const balance = await this.token.balanceOf(investor);
balance.should.be.bignumber.equal(expectedTokenAmount); balance.should.be.bignumber.equal(expectedTokenAmount);
}); });

@ -43,9 +43,9 @@ contract('WhitelistedCrowdsale', function ([_, wallet, authorized, unauthorized,
describe('reporting whitelisted', function () { describe('reporting whitelisted', function () {
it('should correctly report whitelisted addresses', async 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); isAuthorized.should.equal(true);
let isntAuthorized = await this.crowdsale.whitelist(unauthorized); const isntAuthorized = await this.crowdsale.whitelist(unauthorized);
isntAuthorized.should.equal(false); isntAuthorized.should.equal(false);
}); });
}); });
@ -82,11 +82,11 @@ contract('WhitelistedCrowdsale', function ([_, wallet, authorized, unauthorized,
describe('reporting whitelisted', function () { describe('reporting whitelisted', function () {
it('should correctly report whitelisted addresses', async 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); isAuthorized.should.equal(true);
let isAnotherAuthorized = await this.crowdsale.whitelist(anotherAuthorized); const isAnotherAuthorized = await this.crowdsale.whitelist(anotherAuthorized);
isAnotherAuthorized.should.equal(true); isAnotherAuthorized.should.equal(true);
let isntAuthorized = await this.crowdsale.whitelist(unauthorized); const isntAuthorized = await this.crowdsale.whitelist(unauthorized);
isntAuthorized.should.equal(false); isntAuthorized.should.equal(false);
}); });
}); });

@ -32,10 +32,10 @@ function increaseTime (duration) {
* @param target time in seconds * @param target time in seconds
*/ */
async function increaseTimeTo (target) { 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})`); 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); return increaseTime(diff);
} }

@ -2,7 +2,7 @@ const _ = require('lodash');
const ethjsABI = require('ethjs-abi'); const ethjsABI = require('ethjs-abi');
function findMethod (abi, name, args) { 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(','); const methodArgs = _.map(abi[i].inputs, 'type').join(',');
if ((abi[i].name === name) && (methodArgs === args)) { if ((abi[i].name === name) && (methodArgs === args)) {
return abi[i]; return abi[i];

@ -29,7 +29,7 @@ const transformToFullName = function (json) {
return json.name; 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 + ')'; return json.name + '(' + typeName + ')';
}; };

@ -1,10 +1,9 @@
// From https://gist.github.com/xavierlepretre/88682e871f4ad07be4534ae560692ee6 // From https://gist.github.com/xavierlepretre/88682e871f4ad07be4534ae560692ee6
function transactionMined (txnHash, interval) { function transactionMined (txnHash, interval) {
var transactionReceiptAsync;
interval = interval || 500; interval = interval || 500;
transactionReceiptAsync = function (txnHash, resolve, reject) { const transactionReceiptAsync = function (txnHash, resolve, reject) {
try { try {
var receipt = web3.eth.getTransactionReceipt(txnHash); const receipt = web3.eth.getTransactionReceipt(txnHash);
if (receipt === null) { if (receipt === null) {
setTimeout(function () { setTimeout(function () {
transactionReceiptAsync(txnHash, resolve, reject); transactionReceiptAsync(txnHash, resolve, reject);
@ -18,12 +17,9 @@ function transactionMined (txnHash, interval) {
}; };
if (Array.isArray(txnHash)) { if (Array.isArray(txnHash)) {
var promises = []; return Promise.all(txnHash.map(hash =>
txnHash.forEach(function (oneTxHash) { web3.eth.getTransactionReceiptMined(hash, interval)
promises.push( ));
web3.eth.getTransactionReceiptMined(oneTxHash, interval));
});
return Promise.all(promises);
} else { } else {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
transactionReceiptAsync(txnHash, resolve, reject); transactionReceiptAsync(txnHash, resolve, reject);

@ -36,7 +36,7 @@ function shouldSupportInterfaces (interfaces = []) {
this.thing = this.mock || this.token; this.thing = this.mock || this.token;
}); });
for (let k of interfaces) { for (const k of interfaces) {
const interfaceId = INTERFACE_IDS[k]; const interfaceId = INTERFACE_IDS[k];
describe(k, function () { describe(k, function () {
it('should use less than 30k gas', async function () { it('should use less than 30k gas', async function () {

@ -16,20 +16,20 @@ contract('ECRecovery', function (accounts) {
it('recover v0', async function () { it('recover v0', async function () {
// Signature generated outside ganache with method web3.eth.sign(signer, message) // Signature generated outside ganache with method web3.eth.sign(signer, message)
let signer = '0x2cc1166f6212628a0deef2b33befb2187d35b86c'; const signer = '0x2cc1166f6212628a0deef2b33befb2187d35b86c';
let message = web3.sha3(TEST_MESSAGE); const message = web3.sha3(TEST_MESSAGE);
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
let signature = '0x5d99b6f7f6d1f73d1a26497f2b1c89b24c0993913f86e9a2d02cd69887d9c94f3c880358579d811b21dd1b7fd9bb01c1d81d10e69f0384e675c32b39643be89200'; const signature = '0x5d99b6f7f6d1f73d1a26497f2b1c89b24c0993913f86e9a2d02cd69887d9c94f3c880358579d811b21dd1b7fd9bb01c1d81d10e69f0384e675c32b39643be89200';
const addrRecovered = await ecrecovery.recover(message, signature); const addrRecovered = await ecrecovery.recover(message, signature);
addrRecovered.should.eq(signer); addrRecovered.should.eq(signer);
}); });
it('recover v1', async function () { it('recover v1', async function () {
// Signature generated outside ganache with method web3.eth.sign(signer, message) // Signature generated outside ganache with method web3.eth.sign(signer, message)
let signer = '0x1e318623ab09fe6de3c9b8672098464aeda9100e'; const signer = '0x1e318623ab09fe6de3c9b8672098464aeda9100e';
let message = web3.sha3(TEST_MESSAGE); const message = web3.sha3(TEST_MESSAGE);
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
let signature = '0x331fe75a821c982f9127538858900d87d3ec1f9f737338ad67cad133fa48feff48e6fa0c18abc62e42820f05943e47af3e9fbe306ce74d64094bdf1691ee53e001'; const signature = '0x331fe75a821c982f9127538858900d87d3ec1f9f737338ad67cad133fa48feff48e6fa0c18abc62e42820f05943e47af3e9fbe306ce74d64094bdf1691ee53e001';
const addrRecovered = await ecrecovery.recover(message, signature); const addrRecovered = await ecrecovery.recover(message, signature);
addrRecovered.should.eq(signer); addrRecovered.should.eq(signer);
}); });
@ -57,7 +57,7 @@ contract('ECRecovery', function (accounts) {
it('recover should revert when a small hash is sent', async function () { it('recover should revert when a small hash is sent', async function () {
// Create the signature using account[0] // Create the signature using account[0]
let signature = signMessage(accounts[0], TEST_MESSAGE); const signature = signMessage(accounts[0], TEST_MESSAGE);
try { try {
await expectThrow( await expectThrow(
ecrecovery.recover(hashMessage(TEST_MESSAGE).substring(2), signature) ecrecovery.recover(hashMessage(TEST_MESSAGE).substring(2), signature)

@ -1,4 +1,4 @@
var MathMock = artifacts.require('MathMock'); const MathMock = artifacts.require('MathMock');
contract('Math', function (accounts) { contract('Math', function (accounts) {
let math; let math;
@ -8,35 +8,35 @@ contract('Math', function (accounts) {
}); });
it('returns max64 correctly', async function () { it('returns max64 correctly', async function () {
let a = 5678; const a = 5678;
let b = 1234; const b = 1234;
await math.max64(a, b); await math.max64(a, b);
let result = await math.result64(); const result = await math.result64();
assert.equal(result, a); assert.equal(result, a);
}); });
it('returns min64 correctly', async function () { it('returns min64 correctly', async function () {
let a = 5678; const a = 5678;
let b = 1234; const b = 1234;
await math.min64(a, b); await math.min64(a, b);
let result = await math.result64(); const result = await math.result64();
assert.equal(result, b); assert.equal(result, b);
}); });
it('returns max256 correctly', async function () { it('returns max256 correctly', async function () {
let a = 5678; const a = 5678;
let b = 1234; const b = 1234;
await math.max256(a, b); await math.max256(a, b);
let result = await math.result256(); const result = await math.result256();
assert.equal(result, a); assert.equal(result, a);
}); });
it('returns min256 correctly', async function () { it('returns min256 correctly', async function () {
let a = 5678; const a = 5678;
let b = 1234; const b = 1234;
await math.min256(a, b); await math.min256(a, b);
let result = await math.result256(); const result = await math.result256();
assert.equal(result, b); assert.equal(result, b);
}); });

@ -1,7 +1,7 @@
const { MerkleTree } = require('../helpers/merkleTree.js'); const { MerkleTree } = require('../helpers/merkleTree.js');
const { sha3, bufferToHex } = require('ethereumjs-util'); const { sha3, bufferToHex } = require('ethereumjs-util');
var MerkleProofWrapper = artifacts.require('MerkleProofWrapper'); const MerkleProofWrapper = artifacts.require('MerkleProofWrapper');
contract('MerkleProof', function (accounts) { contract('MerkleProof', function (accounts) {
let merkleProof; let merkleProof;

@ -14,16 +14,16 @@ contract('Destructible', function (accounts) {
}); });
it('should send balance to owner after destruction', async function () { 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 }); await this.destructible.destroy({ from: this.owner });
let newBalance = await ethGetBalance(this.owner); const newBalance = await ethGetBalance(this.owner);
assert.isTrue(newBalance > initBalance); assert.isTrue(newBalance > initBalance);
}); });
it('should send balance to recepient after destruction', async function () { 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 }); 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)); assert.isTrue(newBalance.greaterThan(initBalance));
}); });
}); });

@ -7,21 +7,21 @@ contract('Pausable', function (accounts) {
}); });
it('can perform normal process in non-pause', async function () { 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); assert.equal(count0, 0);
await this.Pausable.normalProcess(); await this.Pausable.normalProcess();
let count1 = await this.Pausable.count(); const count1 = await this.Pausable.count();
assert.equal(count1, 1); assert.equal(count1, 1);
}); });
it('can not perform normal process in pause', async function () { it('can not perform normal process in pause', async function () {
await this.Pausable.pause(); await this.Pausable.pause();
let count0 = await this.Pausable.count(); const count0 = await this.Pausable.count();
assert.equal(count0, 0); assert.equal(count0, 0);
await assertRevert(this.Pausable.normalProcess()); await assertRevert(this.Pausable.normalProcess());
let count1 = await this.Pausable.count(); const count1 = await this.Pausable.count();
assert.equal(count1, 0); assert.equal(count1, 0);
}); });
@ -34,7 +34,7 @@ contract('Pausable', function (accounts) {
it('can take a drastic measure in a pause', async function () { it('can take a drastic measure in a pause', async function () {
await this.Pausable.pause(); await this.Pausable.pause();
await this.Pausable.drasticMeasure(); await this.Pausable.drasticMeasure();
let drasticMeasureTaken = await this.Pausable.drasticMeasureTaken(); const drasticMeasureTaken = await this.Pausable.drasticMeasureTaken();
assert.isTrue(drasticMeasureTaken); assert.isTrue(drasticMeasureTaken);
}); });
@ -43,7 +43,7 @@ contract('Pausable', function (accounts) {
await this.Pausable.pause(); await this.Pausable.pause();
await this.Pausable.unpause(); await this.Pausable.unpause();
await this.Pausable.normalProcess(); await this.Pausable.normalProcess();
let count0 = await this.Pausable.count(); const count0 = await this.Pausable.count();
assert.equal(count0, 1); assert.equal(count0, 1);
}); });

@ -1,37 +1,39 @@
const { ethGetBalance } = require('../helpers/web3'); const { ethGetBalance } = require('../helpers/web3');
var TokenDestructible = artifacts.require('TokenDestructible'); const TokenDestructible = artifacts.require('TokenDestructible');
var StandardTokenMock = artifacts.require('StandardTokenMock'); const StandardTokenMock = artifacts.require('StandardTokenMock');
contract('TokenDestructible', function (accounts) { contract('TokenDestructible', function (accounts) {
let destructible; let tokenDestructible;
let owner; let owner;
beforeEach(async function () { beforeEach(async function () {
destructible = await TokenDestructible.new({ tokenDestructible = await TokenDestructible.new({
from: accounts[0], from: accounts[0],
value: web3.toWei('10', 'ether'), value: web3.toWei('10', 'ether'),
}); });
owner = await destructible.owner(); owner = await tokenDestructible.owner();
}); });
it('should send balance to owner after destruction', async function () { it('should send balance to owner after destruction', async function () {
let initBalance = await ethGetBalance(owner); const initBalance = await ethGetBalance(owner);
await destructible.destroy([], { from: owner }); await tokenDestructible.destroy([], { from: owner });
let newBalance = await ethGetBalance(owner);
const newBalance = await ethGetBalance(owner);
assert.isTrue(newBalance > initBalance); 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 token = await StandardTokenMock.new(destructible.address, 100); const token = await StandardTokenMock.new(tokenDestructible.address, 100);
let initContractBalance = await token.balanceOf(destructible.address); const initContractBalance = await token.balanceOf(tokenDestructible.address);
let initOwnerBalance = await token.balanceOf(owner); const initOwnerBalance = await token.balanceOf(owner);
assert.equal(initContractBalance, 100); assert.equal(initContractBalance, 100);
assert.equal(initOwnerBalance, 0); assert.equal(initOwnerBalance, 0);
await destructible.destroy([token.address], { from: owner });
let newContractBalance = await token.balanceOf(destructible.address); await tokenDestructible.destroy([token.address], { from: owner });
let newOwnerBalance = await token.balanceOf(owner); const newContractBalance = await token.balanceOf(tokenDestructible.address);
const newOwnerBalance = await token.balanceOf(owner);
assert.equal(newContractBalance, 0); assert.equal(newContractBalance, 0);
assert.equal(newOwnerBalance, 100); assert.equal(newOwnerBalance, 100);
}); });

@ -1,6 +1,6 @@
const { assertRevert } = require('../helpers/assertRevert'); const { assertRevert } = require('../helpers/assertRevert');
var Claimable = artifacts.require('Claimable'); const Claimable = artifacts.require('Claimable');
contract('Claimable', function (accounts) { contract('Claimable', function (accounts) {
let claimable; let claimable;
@ -10,14 +10,14 @@ contract('Claimable', function (accounts) {
}); });
it('should have an owner', async function () { it('should have an owner', async function () {
let owner = await claimable.owner(); const owner = await claimable.owner();
assert.isTrue(owner !== 0); assert.isTrue(owner !== 0);
}); });
it('changes pendingOwner after transfer', async function () { it('changes pendingOwner after transfer', async function () {
let newOwner = accounts[1]; const newOwner = accounts[1];
await claimable.transferOwnership(newOwner); await claimable.transferOwnership(newOwner);
let pendingOwner = await claimable.pendingOwner(); const pendingOwner = await claimable.pendingOwner();
assert.isTrue(pendingOwner === newOwner); assert.isTrue(pendingOwner === newOwner);
}); });
@ -44,7 +44,7 @@ contract('Claimable', function (accounts) {
it('changes allow pending owner to claim ownership', async function () { it('changes allow pending owner to claim ownership', async function () {
await claimable.claimOwnership({ from: newOwner }); await claimable.claimOwnership({ from: newOwner });
let owner = await claimable.owner(); const owner = await claimable.owner();
assert.isTrue(owner === newOwner); assert.isTrue(owner === newOwner);
}); });

@ -1,4 +1,4 @@
var Contactable = artifacts.require('Contactable'); const Contactable = artifacts.require('Contactable');
contract('Contactable', function (accounts) { contract('Contactable', function (accounts) {
let contactable; let contactable;
@ -8,19 +8,19 @@ contract('Contactable', function (accounts) {
}); });
it('should have an empty contact info', async function () { it('should have an empty contact info', async function () {
let info = await contactable.contactInformation(); const info = await contactable.contactInformation();
assert.isTrue(info === ''); assert.isTrue(info === '');
}); });
describe('after setting the contact information', function () { describe('after setting the contact information', function () {
let contactInfo = 'contact information'; const contactInfo = 'contact information';
beforeEach(async function () { beforeEach(async function () {
await contactable.setContactInformation(contactInfo); 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(); const info = await contactable.contactInformation();
assert.isTrue(info === contactInfo); assert.isTrue(info === contactInfo);
}); });
}); });

@ -1,55 +1,51 @@
const { assertRevert } = require('../helpers/assertRevert'); const { assertRevert } = require('../helpers/assertRevert');
var DelayedClaimable = artifacts.require('DelayedClaimable'); const DelayedClaimable = artifacts.require('DelayedClaimable');
contract('DelayedClaimable', function (accounts) { contract('DelayedClaimable', function (accounts) {
var delayedClaimable; beforeEach(async function () {
this.delayedClaimable = await DelayedClaimable.new();
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 this.delayedClaimable.transferOwnership(accounts[2]);
await delayedClaimable.setLimits(0, 1000); await this.delayedClaimable.setLimits(0, 1000);
let end = await delayedClaimable.end(); const end = await this.delayedClaimable.end();
assert.equal(end, 1000); assert.equal(end, 1000);
let start = await delayedClaimable.start(); const start = await this.delayedClaimable.start();
assert.equal(start, 0); 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 this.delayedClaimable.transferOwnership(accounts[2]);
await delayedClaimable.setLimits(0, 1000); await this.delayedClaimable.setLimits(0, 1000);
let end = await delayedClaimable.end(); const end = await this.delayedClaimable.end();
assert.equal(end, 1000); assert.equal(end, 1000);
let start = await delayedClaimable.start(); const start = await this.delayedClaimable.start();
assert.equal(start, 0); assert.equal(start, 0);
let pendingOwner = await delayedClaimable.pendingOwner(); const pendingOwner = await this.delayedClaimable.pendingOwner();
assert.equal(pendingOwner, accounts[2]); assert.equal(pendingOwner, accounts[2]);
await delayedClaimable.claimOwnership({ from: accounts[2] }); await this.delayedClaimable.claimOwnership({ from: accounts[2] });
let owner = await delayedClaimable.owner(); const owner = await this.delayedClaimable.owner();
assert.equal(owner, accounts[2]); 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 this.delayedClaimable.transferOwnership(accounts[1]);
await delayedClaimable.setLimits(100, 110); await this.delayedClaimable.setLimits(100, 110);
let end = await delayedClaimable.end(); const end = await this.delayedClaimable.end();
assert.equal(end, 110); assert.equal(end, 110);
let start = await delayedClaimable.start(); const start = await this.delayedClaimable.start();
assert.equal(start, 100); assert.equal(start, 100);
let pendingOwner = await delayedClaimable.pendingOwner(); const pendingOwner = await this.delayedClaimable.pendingOwner();
assert.equal(pendingOwner, accounts[1]); assert.equal(pendingOwner, accounts[1]);
await assertRevert(delayedClaimable.claimOwnership({ from: accounts[1] })); await assertRevert(this.delayedClaimable.claimOwnership({ from: accounts[1] }));
let owner = await delayedClaimable.owner(); const owner = await this.delayedClaimable.owner();
assert.isTrue(owner !== accounts[1]); 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]); await this.delayedClaimable.transferOwnership(accounts[1]);
await assertRevert(delayedClaimable.setLimits(1001, 1000)); await assertRevert(this.delayedClaimable.setLimits(1001, 1000));
}); });
}); });

@ -16,7 +16,7 @@ contract('HasNoEther', function (accounts) {
}); });
it('should not accept ether', async function () { it('should not accept ether', async function () {
let hasNoEther = await HasNoEtherTest.new(); const hasNoEther = await HasNoEtherTest.new();
await expectThrow( await expectThrow(
ethSendTransaction({ ethSendTransaction({
@ -29,12 +29,12 @@ contract('HasNoEther', function (accounts) {
it('should allow owner to reclaim ether', async function () { it('should allow owner to reclaim ether', async function () {
// Create contract // Create contract
let hasNoEther = await HasNoEtherTest.new(); const hasNoEther = await HasNoEtherTest.new();
const startBalance = await ethGetBalance(hasNoEther.address); const startBalance = await ethGetBalance(hasNoEther.address);
assert.equal(startBalance, 0); assert.equal(startBalance, 0);
// Force ether into it // Force ether into it
let forceEther = await ForceEther.new({ value: amount }); const forceEther = await ForceEther.new({ value: amount });
await forceEther.destroyAndSend(hasNoEther.address); await forceEther.destroyAndSend(hasNoEther.address);
const forcedBalance = await ethGetBalance(hasNoEther.address); const forcedBalance = await ethGetBalance(hasNoEther.address);
assert.equal(forcedBalance, amount); assert.equal(forcedBalance, amount);
@ -50,10 +50,10 @@ contract('HasNoEther', function (accounts) {
it('should allow only owner to reclaim ether', async function () { it('should allow only owner to reclaim ether', async function () {
// Create contract // Create contract
let hasNoEther = await HasNoEtherTest.new({ from: accounts[0] }); const hasNoEther = await HasNoEtherTest.new({ from: accounts[0] });
// Force ether into it // Force ether into it
let forceEther = await ForceEther.new({ value: amount }); const forceEther = await ForceEther.new({ value: amount });
await forceEther.destroyAndSend(hasNoEther.address); await forceEther.destroyAndSend(hasNoEther.address);
const forcedBalance = await ethGetBalance(hasNoEther.address); const forcedBalance = await ethGetBalance(hasNoEther.address);
assert.equal(forcedBalance, amount); assert.equal(forcedBalance, amount);

@ -9,14 +9,14 @@ require('chai')
function shouldBehaveLikeOwnable (accounts) { function shouldBehaveLikeOwnable (accounts) {
describe('as an ownable', function () { describe('as an ownable', function () {
it('should have an owner', async 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); owner.should.not.eq(ZERO_ADDRESS);
}); });
it('changes owner after transfer', async function () { it('changes owner after transfer', async function () {
let other = accounts[1]; const other = accounts[1];
await this.ownable.transferOwnership(other); await this.ownable.transferOwnership(other);
let owner = await this.ownable.owner(); const owner = await this.ownable.owner();
owner.should.eq(other); owner.should.eq(other);
}); });
@ -29,13 +29,13 @@ function shouldBehaveLikeOwnable (accounts) {
}); });
it('should guard ownership against stuck state', async function () { 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); await expectThrow(this.ownable.transferOwnership(null, { from: originalOwner }), EVMRevert);
}); });
it('loses owner after renouncement', async function () { it('loses owner after renouncement', async function () {
await this.ownable.renounceOwnership(); await this.ownable.renounceOwnership();
let owner = await this.ownable.owner(); const owner = await this.ownable.owner();
owner.should.eq(ZERO_ADDRESS); owner.should.eq(ZERO_ADDRESS);
}); });

@ -38,7 +38,7 @@ contract('Whitelist', function (accounts) {
'RoleAdded', 'RoleAdded',
{ role: this.role }, { role: this.role },
); );
for (let addr of whitelistedAddresses) { for (const addr of whitelistedAddresses) {
const isWhitelisted = await this.mock.whitelist(addr); const isWhitelisted = await this.mock.whitelist(addr);
isWhitelisted.should.be.equal(true); isWhitelisted.should.be.equal(true);
} }
@ -50,7 +50,7 @@ contract('Whitelist', function (accounts) {
'RoleRemoved', 'RoleRemoved',
{ role: this.role }, { role: this.role },
); );
let isWhitelisted = await this.mock.whitelist(whitelistedAddress1); const isWhitelisted = await this.mock.whitelist(whitelistedAddress1);
isWhitelisted.should.be.equal(false); isWhitelisted.should.be.equal(false);
}); });
@ -60,7 +60,7 @@ contract('Whitelist', function (accounts) {
'RoleRemoved', 'RoleRemoved',
{ role: this.role }, { role: this.role },
); );
for (let addr of whitelistedAddresses) { for (const addr of whitelistedAddresses) {
const isWhitelisted = await this.mock.whitelist(addr); const isWhitelisted = await this.mock.whitelist(addr);
isWhitelisted.should.be.equal(false); isWhitelisted.should.be.equal(false);
} }

@ -90,7 +90,7 @@ contract('RefundEscrow', function ([owner, beneficiary, refundee1, refundee2]) {
}); });
it('refunds refundees', async function () { it('refunds refundees', async function () {
for (let refundee of [refundee1, refundee2]) { for (const refundee of [refundee1, refundee2]) {
const refundeeInitialBalance = await ethGetBalance(refundee); const refundeeInitialBalance = await ethGetBalance(refundee);
await this.escrow.withdraw(refundee); await this.escrow.withdraw(refundee);
const refundeeFinalBalance = await ethGetBalance(refundee); const refundeeFinalBalance = await ethGetBalance(refundee);

@ -5,7 +5,7 @@ function shouldBehaveLikeCappedToken ([owner, anotherAccount, minter, cap]) {
const from = minter; const from = minter;
it('should start with the correct cap', async function () { 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)); assert(cap.eq(_cap));
}); });

@ -2,7 +2,7 @@ const { ether } = require('../../helpers/ether');
const { shouldBehaveLikeMintableToken } = require('./MintableToken.behaviour'); const { shouldBehaveLikeMintableToken } = require('./MintableToken.behaviour');
const { shouldBehaveLikeCappedToken } = require('./CappedToken.behaviour'); const { shouldBehaveLikeCappedToken } = require('./CappedToken.behaviour');
var CappedToken = artifacts.require('CappedToken'); const CappedToken = artifacts.require('CappedToken');
contract('Capped', function ([owner, anotherAccount]) { contract('Capped', function ([owner, anotherAccount]) {
const _cap = ether(1000); const _cap = ether(1000);

Loading…
Cancel
Save