Skip to content

Commit

Permalink
feat: manually fix linting errors across tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shrugs committed Dec 1, 2017
1 parent 227a335 commit d07bdcc
Show file tree
Hide file tree
Showing 23 changed files with 70 additions and 63 deletions.
6 changes: 3 additions & 3 deletions test/BasicToken.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/CanReclaimToken.test.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
3 changes: 1 addition & 2 deletions test/CappedToken.test.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
4 changes: 1 addition & 3 deletions test/Contactable.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

const assertRevert = require('./helpers/assertRevert');

var Contactable = artifacts.require('../contracts/ownership/Contactable.sol');

contract('Contactable', function (accounts) {
Expand All @@ -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 () {
Expand Down
5 changes: 3 additions & 2 deletions test/DayLimit.test.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion test/ECRecovery.test.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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));
});
Expand All @@ -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));
});
Expand Down
2 changes: 1 addition & 1 deletion test/HasNoContracts.test.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
3 changes: 1 addition & 2 deletions test/HasNoEther.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

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');

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 () {
Expand Down
2 changes: 1 addition & 1 deletion test/HasNoTokens.test.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
3 changes: 2 additions & 1 deletion test/MerkleProof.test.js
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
14 changes: 7 additions & 7 deletions test/PullPayment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand All @@ -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);
Expand All @@ -50,15 +50,15 @@ 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);

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

Expand Down
6 changes: 3 additions & 3 deletions test/RefundVault.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import ether from './helpers/ether';
import EVMRevert from './helpers/EVMRevert';

const BigNumber = web3.BigNumber;

require('chai')
.use(require('chai-as-promised'))
.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]) {
Expand Down
3 changes: 2 additions & 1 deletion test/RefundableCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down
12 changes: 6 additions & 6 deletions test/SafeMath.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ 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);
});

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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
23 changes: 15 additions & 8 deletions test/SampleCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ 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();

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);
Expand All @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion test/SplitPayment.test.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
6 changes: 3 additions & 3 deletions test/StandardToken.test.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions test/TokenTimelock.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import latestTime from './helpers/latestTime';
import { increaseTimeTo, duration } from './helpers/increaseTime';

const BigNumber = web3.BigNumber;

require('chai')
.use(require('chai-as-promised'))
.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');

Expand Down
10 changes: 5 additions & 5 deletions test/TokenVesting.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import EVMRevert from './helpers/EVMRevert';
import latestTime from './helpers/latestTime';
import { increaseTimeTo, duration } from './helpers/increaseTime';

const BigNumber = web3.BigNumber;

require('chai')
.use(require('chai-as-promised'))
.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');

Expand Down Expand Up @@ -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 });

Expand Down
Loading

0 comments on commit d07bdcc

Please sign in to comment.