feat: manually fix linting errors across tests

This commit is contained in:
Matt Condon
2017-11-24 15:37:36 +02:00
parent 227a335399
commit d07bdccc0c
23 changed files with 70 additions and 63 deletions

View File

@ -12,7 +12,7 @@ contract('BasicToken', function (accounts) {
it('should return correct balances after transfer', async function () {
let token = await BasicTokenMock.new(accounts[0], 100);
let transfer = await token.transfer(accounts[1], 100);
await token.transfer(accounts[1], 100);
let firstAccountBalance = await token.balanceOf(accounts[0]);
assert.equal(firstAccountBalance, 0);
@ -24,7 +24,7 @@ contract('BasicToken', function (accounts) {
it('should throw an error when trying to transfer more than balance', async function () {
let token = await BasicTokenMock.new(accounts[0], 100);
try {
let transfer = await token.transfer(accounts[1], 101);
await token.transfer(accounts[1], 101);
assert.fail('should have thrown before');
} catch (error) {
assertRevert(error);
@ -34,7 +34,7 @@ contract('BasicToken', function (accounts) {
it('should throw an error when trying to transfer to 0x0', async function () {
let token = await BasicTokenMock.new(accounts[0], 100);
try {
let transfer = await token.transfer(0x0, 100);
await token.transfer(0x0, 100);
assert.fail('should have thrown before');
} catch (error) {
assertRevert(error);

View File

@ -1,6 +1,6 @@
import expectThrow from './helpers/expectThrow';
import toPromise from './helpers/toPromise';
const CanReclaimToken = artifacts.require('../contracts/ownership/CanReclaimToken.sol');
const BasicTokenMock = artifacts.require('./mocks/BasicTokenMock.sol');

View File

@ -1,9 +1,8 @@
import expectThrow from './helpers/expectThrow';
import ether from './helpers/ether';
var CappedToken = artifacts.require('../contracts/Tokens/CappedToken.sol');
const BigNumber = web3.BigNumber;
var CappedToken = artifacts.require('../contracts/Tokens/CappedToken.sol');
contract('Capped', function (accounts) {
const cap = ether(1000);

View File

@ -1,6 +1,4 @@
const assertRevert = require('./helpers/assertRevert');
var Contactable = artifacts.require('../contracts/ownership/Contactable.sol');
contract('Contactable', function (accounts) {
@ -12,7 +10,7 @@ contract('Contactable', function (accounts) {
it('should have an empty contact info', async function () {
let info = await contactable.contactInformation();
assert.isTrue(info == '');
assert.isTrue(info === '');
});
describe('after setting the contact information', function () {

View File

@ -1,9 +1,10 @@
const assertRevert = require('./helpers/assertRevert');
import latestTime from './helpers/latestTime';
import { increaseTimeTo, duration } from './helpers/increaseTime';
var DayLimitMock = artifacts.require('./mocks/DayLimitMock.sol');
const assertRevert = require('./helpers/assertRevert');
const DayLimitMock = artifacts.require('./mocks/DayLimitMock.sol');
contract('DayLimit', function (accounts) {
let dayLimit;

View File

@ -1,5 +1,4 @@
var ECRecovery = artifacts.require('../contracts/ECRecovery.sol');
var utils = require('ethereumjs-util');
var hashMessage = require('./helpers/hashMessage.js');
contract('ECRecovery', function (accounts) {
@ -13,6 +12,7 @@ contract('ECRecovery', function (accounts) {
// Signature generated outside testrpc with method web3.eth.sign(signer, message)
let signer = '0x2cc1166f6212628a0deef2b33befb2187d35b86c';
let message = '0x7dbaf558b0a1a5dc7a67202117ab143c1d8605a983e4a743bc06fcc03162dc0d'; // web3.sha3('OpenZeppelin')
// eslint-disable-next-line max-len
let signature = '0x5d99b6f7f6d1f73d1a26497f2b1c89b24c0993913f86e9a2d02cd69887d9c94f3c880358579d811b21dd1b7fd9bb01c1d81d10e69f0384e675c32b39643be89200';
assert.equal(signer, await ecrecovery.recover(message, signature));
});
@ -21,6 +21,7 @@ contract('ECRecovery', function (accounts) {
// Signature generated outside testrpc with method web3.eth.sign(signer, message)
let signer = '0x1e318623ab09fe6de3c9b8672098464aeda9100e';
let message = '0x7dbaf558b0a1a5dc7a67202117ab143c1d8605a983e4a743bc06fcc03162dc0d'; // web3.sha3('OpenZeppelin')
// eslint-disable-next-line max-len
let signature = '0x331fe75a821c982f9127538858900d87d3ec1f9f737338ad67cad133fa48feff48e6fa0c18abc62e42820f05943e47af3e9fbe306ce74d64094bdf1691ee53e001';
assert.equal(signer, await ecrecovery.recover(message, signature));
});

View File

@ -1,6 +1,6 @@
import expectThrow from './helpers/expectThrow';
import toPromise from './helpers/toPromise';
const Ownable = artifacts.require('../contracts/ownership/Ownable.sol');
const HasNoContracts = artifacts.require(
'../contracts/ownership/HasNoContracts.sol',

View File

@ -1,7 +1,6 @@
import expectThrow from './helpers/expectThrow';
import toPromise from './helpers/toPromise';
const HasNoEther = artifacts.require('../contracts/lifecycle/HasNoEther.sol');
const HasNoEtherTest = artifacts.require('../mocks/HasNoEtherTest.sol');
const ForceEther = artifacts.require('../mocks/ForceEther.sol');
@ -9,7 +8,7 @@ contract('HasNoEther', function (accounts) {
const amount = web3.toWei('1', 'ether');
it('should be constructorable', async function () {
let hasNoEther = await HasNoEtherTest.new();
await HasNoEtherTest.new();
});
it('should not accept ether in constructor', async function () {

View File

@ -1,6 +1,6 @@
import expectThrow from './helpers/expectThrow';
import toPromise from './helpers/toPromise';
const HasNoTokens = artifacts.require('../contracts/lifecycle/HasNoTokens.sol');
const ERC23TokenMock = artifacts.require('./mocks/ERC23TokenMock.sol');

View File

@ -1,8 +1,9 @@
var MerkleProof = artifacts.require('./MerkleProof.sol');
import MerkleTree from './helpers/merkleTree.js';
import { sha3, bufferToHex } from 'ethereumjs-util';
var MerkleProof = artifacts.require('./MerkleProof.sol');
contract('MerkleProof', function (accounts) {
let merkleProof;

View File

@ -14,7 +14,7 @@ contract('PullPayment', function (accounts) {
it('can record an async payment correctly', async function () {
let AMOUNT = 100;
let callSend = await ppce.callSend(accounts[0], AMOUNT);
await ppce.callSend(accounts[0], AMOUNT);
let paymentsToAccount0 = await ppce.payments(accounts[0]);
let totalPayments = await ppce.totalPayments();
@ -23,8 +23,8 @@ contract('PullPayment', function (accounts) {
});
it('can add multiple balances on one account', async function () {
let call1 = await ppce.callSend(accounts[0], 200);
let call2 = await ppce.callSend(accounts[0], 300);
await ppce.callSend(accounts[0], 200);
await ppce.callSend(accounts[0], 300);
let paymentsToAccount0 = await ppce.payments(accounts[0]);
let totalPayments = await ppce.totalPayments();
@ -33,8 +33,8 @@ contract('PullPayment', function (accounts) {
});
it('can add balances on multiple accounts', async function () {
let call1 = await ppce.callSend(accounts[0], 200);
let call2 = await ppce.callSend(accounts[1], 300);
await ppce.callSend(accounts[0], 200);
await ppce.callSend(accounts[1], 300);
let paymentsToAccount0 = await ppce.payments(accounts[0]);
assert.equal(paymentsToAccount0, 200);
@ -50,7 +50,7 @@ contract('PullPayment', function (accounts) {
let payee = accounts[1];
let initialBalance = web3.eth.getBalance(payee);
let call1 = await ppce.callSend(payee, amount);
await ppce.callSend(payee, amount);
let payment1 = await ppce.payments(payee);
assert.equal(payment1, amount);
@ -58,7 +58,7 @@ contract('PullPayment', function (accounts) {
let totalPayments = await ppce.totalPayments();
assert.equal(totalPayments, amount);
let withdraw = await ppce.withdrawPayments({ from: payee });
await ppce.withdrawPayments({ from: payee });
let payment2 = await ppce.payments(payee);
assert.equal(payment2, 0);

View File

@ -1,3 +1,6 @@
import ether from './helpers/ether';
import EVMRevert from './helpers/EVMRevert';
const BigNumber = web3.BigNumber;
require('chai')
@ -5,9 +8,6 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
import ether from './helpers/ether';
import EVMRevert from './helpers/EVMRevert';
const RefundVault = artifacts.require('RefundVault');
contract('RefundVault', function ([_, owner, wallet, investor]) {

View File

@ -33,7 +33,8 @@ contract('RefundableCrowdsale', function ([_, owner, wallet, investor]) {
describe('creating a valid crowdsale', function () {
it('should fail with zero goal', async function () {
await RefundableCrowdsale.new(this.startTime, this.endTime, rate, wallet, 0, { from: owner }).should.be.rejectedWith(EVMRevert);
await RefundableCrowdsale.new(this.startTime, this.endTime, rate, wallet, 0, { from: owner })
.should.be.rejectedWith(EVMRevert);
});
});

View File

@ -12,7 +12,7 @@ contract('SafeMath', function (accounts) {
it('multiplies correctly', async function () {
let a = 5678;
let b = 1234;
let mult = await safeMath.multiply(a, b);
await safeMath.multiply(a, b);
let result = await safeMath.result();
assert.equal(result, a * b);
});
@ -20,7 +20,7 @@ contract('SafeMath', function (accounts) {
it('adds correctly', async function () {
let a = 5678;
let b = 1234;
let add = await safeMath.add(a, b);
await safeMath.add(a, b);
let result = await safeMath.result();
assert.equal(result, a + b);
@ -29,7 +29,7 @@ contract('SafeMath', function (accounts) {
it('subtracts correctly', async function () {
let a = 5678;
let b = 1234;
let subtract = await safeMath.subtract(a, b);
await safeMath.subtract(a, b);
let result = await safeMath.result();
assert.equal(result, a - b);
@ -39,7 +39,7 @@ contract('SafeMath', function (accounts) {
let a = 1234;
let b = 5678;
try {
let subtract = await safeMath.subtract(a, b);
await safeMath.subtract(a, b);
assert.fail('should have thrown before');
} catch (error) {
assertJump(error);
@ -50,7 +50,7 @@ contract('SafeMath', function (accounts) {
let a = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
let b = 1;
try {
let add = await safeMath.add(a, b);
await safeMath.add(a, b);
assert.fail('should have thrown before');
} catch (error) {
assertRevert(error);
@ -61,7 +61,7 @@ contract('SafeMath', function (accounts) {
let a = 115792089237316195423570985008687907853269984665640564039457584007913129639933;
let b = 2;
try {
let multiply = await safeMath.multiply(a, b);
await safeMath.multiply(a, b);
assert.fail('should have thrown before');
} catch (error) {
assertRevert(error);

View File

@ -6,7 +6,7 @@ import EVMRevert from './helpers/EVMRevert';
const BigNumber = web3.BigNumber;
const should = require('chai')
require('chai')
.use(require('chai-as-promised'))
.use(require('chai-bignumber')(BigNumber))
.should();
@ -14,7 +14,7 @@ const should = require('chai')
const SampleCrowdsale = artifacts.require('SampleCrowdsale');
const SampleCrowdsaleToken = artifacts.require('SampleCrowdsaleToken');
contract('Crowdsale', function ([owner, wallet, investor]) {
contract('SampleCrowdsale', function ([owner, wallet, investor]) {
const RATE = new BigNumber(10);
const GOAL = ether(10);
const CAP = ether(20);
@ -37,12 +37,19 @@ contract('Crowdsale', function ([owner, wallet, investor]) {
this.crowdsale.should.exist;
this.token.should.exist;
(await this.crowdsale.startTime()).should.be.bignumber.equal(this.startTime);
(await this.crowdsale.endTime()).should.be.bignumber.equal(this.endTime);
(await this.crowdsale.rate()).should.be.bignumber.equal(RATE);
(await this.crowdsale.wallet()).should.be.equal(wallet);
(await this.crowdsale.goal()).should.be.bignumber.equal(GOAL);
(await this.crowdsale.cap()).should.be.bignumber.equal(CAP);
const startTime = await this.crowdsale.startTime();
const endTime = await this.crowdsale.endTime();
const rate = await this.crowdsale.rate();
const walletAddress = await this.crowdsale.wallet();
const goal = await this.crowdsale.goal();
const cap = await this.crowdsale.cap();
startTime.should.be.bignumber.equal(this.startTime);
endTime.should.be.bignumber.equal(this.endTime);
rate.should.be.bignumber.equal(RATE);
walletAddress.should.be.equal(wallet);
goal.should.be.bignumber.equal(GOAL);
cap.should.be.bignumber.equal(CAP);
});
it('should not accept payments before start', async function () {

View File

@ -1,6 +1,6 @@
const BigNumber = web3.BigNumber;
const should = require('chai')
require('chai')
.use(require('chai-as-promised'))
.use(require('chai-bignumber')(BigNumber))
.should();

View File

@ -1,6 +1,6 @@
const assertRevert = require('./helpers/assertRevert');
const expectThrow = require('./helpers/expectThrow');
var StandardTokenMock = artifacts.require('./mocks/StandardTokenMock.sol');
contract('StandardToken', function (accounts) {
@ -108,7 +108,7 @@ contract('StandardToken', function (accounts) {
it('should throw an error when trying to transfer to 0x0', async function () {
let token = await StandardTokenMock.new(accounts[0], 100);
try {
let transfer = await token.transfer(0x0, 100);
await token.transfer(0x0, 100);
assert.fail('should have thrown before');
} catch (error) {
assertRevert(error);
@ -119,7 +119,7 @@ contract('StandardToken', function (accounts) {
let token = await StandardTokenMock.new(accounts[0], 100);
await token.approve(accounts[1], 100);
try {
let transfer = await token.transferFrom(accounts[0], 0x0, 100, { from: accounts[1] });
await token.transferFrom(accounts[0], 0x0, 100, { from: accounts[1] });
assert.fail('should have thrown before');
} catch (error) {
assertRevert(error);

View File

@ -1,3 +1,6 @@
import latestTime from './helpers/latestTime';
import { increaseTimeTo, duration } from './helpers/increaseTime';
const BigNumber = web3.BigNumber;
require('chai')
@ -5,9 +8,6 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
import latestTime from './helpers/latestTime';
import { increaseTimeTo, duration } from './helpers/increaseTime';
const MintableToken = artifacts.require('MintableToken');
const TokenTimelock = artifacts.require('TokenTimelock');

View File

@ -1,3 +1,7 @@
import EVMRevert from './helpers/EVMRevert';
import latestTime from './helpers/latestTime';
import { increaseTimeTo, duration } from './helpers/increaseTime';
const BigNumber = web3.BigNumber;
require('chai')
@ -5,10 +9,6 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
import EVMRevert from './helpers/EVMRevert';
import latestTime from './helpers/latestTime';
import { increaseTimeTo, duration } from './helpers/increaseTime';
const MintableToken = artifacts.require('MintableToken');
const TokenVesting = artifacts.require('TokenVesting');
@ -104,7 +104,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
it('should fail to be revoked a second time', async function () {
await increaseTimeTo(this.start + this.cliff + duration.weeks(12));
const vested = await this.vesting.vestedAmount(this.token.address);
await this.vesting.vestedAmount(this.token.address);
await this.vesting.revoke(this.token.address, { from: owner });

View File

@ -2,7 +2,7 @@ import utils from 'ethereumjs-util';
// Hash and add same prefix to the hash that testrpc use.
module.exports = function (message) {
const messageHex = new Buffer(utils.sha3(message).toString('hex'), 'hex');
const messageHex = Buffer.from(utils.sha3(message).toString('hex'), 'hex');
const prefix = utils.toBuffer('\u0019Ethereum Signed Message:\n' + messageHex.length.toString());
return utils.bufferToHex(utils.sha3(Buffer.concat([prefix, messageHex])));
};

View File

@ -15,7 +15,7 @@ export default class MerkleTree {
}
getLayers (elements) {
if (elements.length == 0) {
if (elements.length === 0) {
return [['']];
}

View File

@ -1,4 +1,4 @@
export default func =>
(...args) =>
new Promise((accept, reject) =>
func(...args, (error, data) => error ? reject(error) : accept(data)));
new Promise((resolve, reject) =>
func(...args, (error, data) => error ? reject(error) : resolve(data)));

View File

@ -21,15 +21,15 @@ module.exports = {
development: {
host: 'localhost',
port: 8545,
network_id: '*',
network_id: '*', // eslint-disable-line camelcase
},
ropsten: {
provider: ropstenProvider,
network_id: 3, // official id of the ropsten network
network_id: 3, // eslint-disable-line camelcase
},
coverage: {
host: 'localhost',
network_id: '*',
network_id: '*', // eslint-disable-line camelcase
port: 8555,
gas: 0xfffffffffff,
gasPrice: 0x01,
@ -37,12 +37,12 @@ module.exports = {
testrpc: {
host: 'localhost',
port: 8545,
network_id: '*',
network_id: '*', // eslint-disable-line camelcase
},
ganache: {
host: 'localhost',
port: 7545,
network_id: '*',
network_id: '*', // eslint-disable-line camelcase
},
},
};