Commit ac91af9a by Nicolás Venturo Committed by Francisco Giordano

Replace all asserts with chai.should (#1183)

* Moving towards chai.should.

* Fixed failing tests.

* Fixed linter errors.

* Revert package-lock.json changes.

* Fixed failing tests.

* s/eq/equal

* Addressed review comment
parent a2e71038
...@@ -20,7 +20,7 @@ contract('AutoIncrementing', function ([_, owner]) { ...@@ -20,7 +20,7 @@ contract('AutoIncrementing', function ([_, owner]) {
for (const 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.equal(expectedId);
} }
}); });
}); });
...@@ -30,11 +30,11 @@ contract('AutoIncrementing', function ([_, owner]) { ...@@ -30,11 +30,11 @@ contract('AutoIncrementing', function ([_, owner]) {
for (const 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.equal(expectedId);
await this.mock.doThing(KEY2, { from: owner }); await this.mock.doThing(KEY2, { from: owner });
actualId = await this.mock.theId(); actualId = await this.mock.theId();
actualId.should.be.bignumber.eq(expectedId); actualId.should.be.bignumber.equal(expectedId);
} }
}); });
}); });
......
...@@ -27,7 +27,7 @@ contract('Bounty', function ([_, owner, researcher]) { ...@@ -27,7 +27,7 @@ contract('Bounty', function ([_, owner, researcher]) {
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.equal(reward);
}); });
context('with reward', function () { context('with reward', function () {
...@@ -40,7 +40,7 @@ contract('Bounty', function ([_, owner, researcher]) { ...@@ -40,7 +40,7 @@ contract('Bounty', function ([_, owner, researcher]) {
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.equal(reward);
}); });
it('cannot claim reward', async function () { it('cannot claim reward', async function () {
...@@ -76,10 +76,10 @@ contract('Bounty', function ([_, owner, researcher]) { ...@@ -76,10 +76,10 @@ contract('Bounty', function ([_, owner, researcher]) {
await this.bounty.withdrawPayments({ from: researcher, gasPrice: gasPrice }); await this.bounty.withdrawPayments({ from: researcher, gasPrice: gasPrice });
const updatedBalance = await ethGetBalance(this.bounty.address); const updatedBalance = await ethGetBalance(this.bounty.address);
updatedBalance.should.be.bignumber.eq(0); updatedBalance.should.be.bignumber.equal(0);
const researcherCurrBalance = await ethGetBalance(researcher); const researcherCurrBalance = await ethGetBalance(researcher);
researcherCurrBalance.sub(researcherPrevBalance).should.be.bignumber.eq(reward.sub(gasCost)); researcherCurrBalance.sub(researcherPrevBalance).should.be.bignumber.equal(reward.sub(gasCost));
}); });
context('reward claimed', function () { context('reward claimed', function () {
......
...@@ -6,26 +6,25 @@ const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'; ...@@ -6,26 +6,25 @@ const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
const Heritable = artifacts.require('Heritable'); const Heritable = artifacts.require('Heritable');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('Heritable', function ([_, owner, heir, anyone]) { contract('Heritable', function ([_, owner, heir, anyone]) {
const heartbeatTimeout = 4141;
let heritable; let heritable;
beforeEach(async function () { beforeEach(async function () {
heritable = await Heritable.new(4141, { from: owner }); heritable = await Heritable.new(heartbeatTimeout, { from: owner });
}); });
it('should start off with an owner, but without heir', async function () { it('should start off with an owner, but without heir', async function () {
const heir = await heritable.heir(); const heir = await heritable.heir();
assert.equal(typeof (owner), 'string'); owner.should.be.a('string').that.is.not.equal(NULL_ADDRESS);
assert.equal(typeof (heir), 'string'); heir.should.be.a('string').that.is.equal(NULL_ADDRESS);
assert.notStrictEqual(
owner, NULL_ADDRESS,
'Owner shouldn\'t be the null address'
);
assert.isTrue(
heir === NULL_ADDRESS,
'Heir should be the null address'
);
}); });
it('only owner should set heir', async function () { it('only owner should set heir', async function () {
...@@ -39,10 +38,10 @@ contract('Heritable', function ([_, owner, heir, anyone]) { ...@@ -39,10 +38,10 @@ contract('Heritable', function ([_, owner, heir, anyone]) {
it('owner can remove heir', async function () { it('owner can remove heir', async function () {
await heritable.setHeir(heir, { from: owner }); await heritable.setHeir(heir, { from: owner });
assert.equal(await heritable.heir(), heir); (await heritable.heir()).should.eq(heir);
await heritable.removeHeir({ from: owner }); await heritable.removeHeir({ from: owner });
assert.equal(await heritable.heir(), NULL_ADDRESS); (await heritable.heir()).should.eq(NULL_ADDRESS);
}); });
it('heir can claim ownership only if owner is dead and timeout was reached', async function () { it('heir can claim ownership only if owner is dead and timeout was reached', async function () {
...@@ -53,9 +52,9 @@ contract('Heritable', function ([_, owner, heir, anyone]) { ...@@ -53,9 +52,9 @@ contract('Heritable', function ([_, owner, heir, anyone]) {
await increaseTime(1); await increaseTime(1);
await expectThrow(heritable.claimHeirOwnership({ from: heir })); await expectThrow(heritable.claimHeirOwnership({ from: heir }));
await increaseTime(4141); await increaseTime(heartbeatTimeout);
await heritable.claimHeirOwnership({ from: heir }); await heritable.claimHeirOwnership({ from: heir });
assert.isTrue(await heritable.heir() === heir); (await heritable.heir()).should.eq(heir);
}); });
it('only heir can proclaim death', async function () { it('only heir can proclaim death', async function () {
...@@ -77,7 +76,7 @@ contract('Heritable', function ([_, owner, heir, anyone]) { ...@@ -77,7 +76,7 @@ contract('Heritable', function ([_, owner, heir, anyone]) {
await expectThrow(heritable.claimHeirOwnership({ from: heir })); await expectThrow(heritable.claimHeirOwnership({ from: heir }));
await heritable.proclaimDeath({ from: heir }); await heritable.proclaimDeath({ from: heir });
await increaseTime(4141); await increaseTime(heartbeatTimeout);
await heritable.heartbeat({ from: owner }); await heritable.heartbeat({ from: owner });
await expectThrow(heritable.claimHeirOwnership({ from: heir })); await expectThrow(heritable.claimHeirOwnership({ from: heir }));
}); });
...@@ -86,36 +85,36 @@ contract('Heritable', function ([_, owner, heir, anyone]) { ...@@ -86,36 +85,36 @@ contract('Heritable', function ([_, owner, heir, anyone]) {
const setHeirLogs = (await heritable.setHeir(heir, { from: owner })).logs; const setHeirLogs = (await heritable.setHeir(heir, { from: owner })).logs;
const setHeirEvent = setHeirLogs.find(e => e.event === 'HeirChanged'); const setHeirEvent = setHeirLogs.find(e => e.event === 'HeirChanged');
assert.isTrue(setHeirEvent.args.owner === owner); setHeirEvent.args.owner.should.eq(owner);
assert.isTrue(setHeirEvent.args.newHeir === heir); setHeirEvent.args.newHeir.should.eq(heir);
const heartbeatLogs = (await heritable.heartbeat({ from: owner })).logs; const heartbeatLogs = (await heritable.heartbeat({ from: owner })).logs;
const heartbeatEvent = heartbeatLogs.find(e => e.event === 'OwnerHeartbeated'); const heartbeatEvent = heartbeatLogs.find(e => e.event === 'OwnerHeartbeated');
assert.isTrue(heartbeatEvent.args.owner === owner); heartbeatEvent.args.owner.should.eq(owner);
const proclaimDeathLogs = (await heritable.proclaimDeath({ from: heir })).logs; const proclaimDeathLogs = (await heritable.proclaimDeath({ from: heir })).logs;
const ownerDeadEvent = proclaimDeathLogs.find(e => e.event === 'OwnerProclaimedDead'); const ownerDeadEvent = proclaimDeathLogs.find(e => e.event === 'OwnerProclaimedDead');
assert.isTrue(ownerDeadEvent.args.owner === owner); ownerDeadEvent.args.owner.should.eq(owner);
assert.isTrue(ownerDeadEvent.args.heir === heir); ownerDeadEvent.args.heir.should.eq(heir);
await increaseTime(4141); await increaseTime(heartbeatTimeout);
const claimHeirOwnershipLogs = (await heritable.claimHeirOwnership({ from: heir })).logs; const claimHeirOwnershipLogs = (await heritable.claimHeirOwnership({ from: heir })).logs;
const ownershipTransferredEvent = claimHeirOwnershipLogs.find(e => e.event === 'OwnershipTransferred'); const ownershipTransferredEvent = claimHeirOwnershipLogs.find(e => e.event === 'OwnershipTransferred');
const heirOwnershipClaimedEvent = claimHeirOwnershipLogs.find(e => e.event === 'HeirOwnershipClaimed'); const heirOwnershipClaimedEvent = claimHeirOwnershipLogs.find(e => e.event === 'HeirOwnershipClaimed');
assert.isTrue(ownershipTransferredEvent.args.previousOwner === owner); ownershipTransferredEvent.args.previousOwner.should.eq(owner);
assert.isTrue(ownershipTransferredEvent.args.newOwner === heir); ownershipTransferredEvent.args.newOwner.should.eq(heir);
assert.isTrue(heirOwnershipClaimedEvent.args.previousOwner === owner); heirOwnershipClaimedEvent.args.previousOwner.should.eq(owner);
assert.isTrue(heirOwnershipClaimedEvent.args.newOwner === heir); heirOwnershipClaimedEvent.args.newOwner.should.eq(heir);
}); });
it('timeOfDeath can be queried', async function () { it('timeOfDeath can be queried', async function () {
assert.equal(await heritable.timeOfDeath(), 0); (await heritable.timeOfDeath()).should.be.bignumber.equal(0);
}); });
it('heartbeatTimeout can be queried', async function () { it('heartbeatTimeout can be queried', async function () {
assert.equal(await heritable.heartbeatTimeout(), 4141); (await heritable.heartbeatTimeout()).should.be.bignumber.equal(heartbeatTimeout);
}); });
}); });
...@@ -3,6 +3,12 @@ const { ethGetBalance } = require('./helpers/web3'); ...@@ -3,6 +3,12 @@ const { ethGetBalance } = require('./helpers/web3');
const LimitBalanceMock = artifacts.require('LimitBalanceMock'); const LimitBalanceMock = artifacts.require('LimitBalanceMock');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('LimitBalance', function () { contract('LimitBalance', function () {
let limitBalance; let limitBalance;
...@@ -14,7 +20,7 @@ contract('LimitBalance', function () { ...@@ -14,7 +20,7 @@ contract('LimitBalance', function () {
it('should expose limit', async function () { it('should expose limit', async function () {
const limit = await limitBalance.limit(); const limit = await limitBalance.limit();
assert.equal(limit, LIMIT); limit.should.be.bignumber.equal(LIMIT);
}); });
it('should allow sending below limit', async function () { it('should allow sending below limit', async function () {
...@@ -22,7 +28,7 @@ contract('LimitBalance', function () { ...@@ -22,7 +28,7 @@ contract('LimitBalance', function () {
await limitBalance.limitedDeposit({ value: amount }); await limitBalance.limitedDeposit({ value: amount });
const balance = await ethGetBalance(limitBalance.address); const balance = await ethGetBalance(limitBalance.address);
assert.equal(balance, amount); balance.should.be.bignumber.equal(amount);
}); });
it('shouldnt allow sending above limit', async function () { it('shouldnt allow sending above limit', async function () {
...@@ -35,11 +41,11 @@ contract('LimitBalance', function () { ...@@ -35,11 +41,11 @@ contract('LimitBalance', function () {
await limitBalance.limitedDeposit({ value: amount }); await limitBalance.limitedDeposit({ value: amount });
const balance = await ethGetBalance(limitBalance.address); const balance = await ethGetBalance(limitBalance.address);
assert.equal(balance, amount); balance.should.be.bignumber.equal(amount);
await limitBalance.limitedDeposit({ value: amount }); await limitBalance.limitedDeposit({ value: amount });
const updatedBalance = await ethGetBalance(limitBalance.address); const updatedBalance = await ethGetBalance(limitBalance.address);
assert.equal(updatedBalance, amount * 2); updatedBalance.should.be.bignumber.equal(amount * 2);
}); });
it('shouldnt allow multiple sends above limit', async function () { it('shouldnt allow multiple sends above limit', async function () {
...@@ -47,7 +53,7 @@ contract('LimitBalance', function () { ...@@ -47,7 +53,7 @@ contract('LimitBalance', function () {
await limitBalance.limitedDeposit({ value: amount }); await limitBalance.limitedDeposit({ value: amount });
const balance = await ethGetBalance(limitBalance.address); const balance = await ethGetBalance(limitBalance.address);
assert.equal(balance, amount); balance.should.be.bignumber.equal(amount);
await assertRevert(limitBalance.limitedDeposit({ value: amount + 1 })); await assertRevert(limitBalance.limitedDeposit({ value: amount + 1 }));
}); });
}); });
...@@ -2,13 +2,19 @@ const { expectThrow } = require('./helpers/expectThrow'); ...@@ -2,13 +2,19 @@ const { expectThrow } = require('./helpers/expectThrow');
const ReentrancyMock = artifacts.require('ReentrancyMock'); const ReentrancyMock = artifacts.require('ReentrancyMock');
const ReentrancyAttack = artifacts.require('ReentrancyAttack'); const ReentrancyAttack = artifacts.require('ReentrancyAttack');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('ReentrancyGuard', function () { contract('ReentrancyGuard', function () {
let reentrancyMock; let reentrancyMock;
beforeEach(async function () { beforeEach(async function () {
reentrancyMock = await ReentrancyMock.new(); reentrancyMock = await ReentrancyMock.new();
const initialCounter = await reentrancyMock.counter(); const initialCounter = await reentrancyMock.counter();
assert.equal(initialCounter, 0); initialCounter.should.be.bignumber.equal(0);
}); });
it('should not allow remote callback', async function () { it('should not allow remote callback', async function () {
......
...@@ -3,6 +3,12 @@ const { ethGetBalance, ethSendTransaction } = require('./helpers/web3'); ...@@ -3,6 +3,12 @@ const { ethGetBalance, ethSendTransaction } = require('./helpers/web3');
const SimpleSavingsWallet = artifacts.require('SimpleSavingsWallet'); const SimpleSavingsWallet = artifacts.require('SimpleSavingsWallet');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('SimpleSavingsWallet', function ([_, owner, anyone]) { contract('SimpleSavingsWallet', function ([_, owner, anyone]) {
let savingsWallet; let savingsWallet;
...@@ -15,7 +21,7 @@ contract('SimpleSavingsWallet', function ([_, owner, anyone]) { ...@@ -15,7 +21,7 @@ contract('SimpleSavingsWallet', function ([_, owner, anyone]) {
it('should receive funds', async function () { it('should receive funds', async function () {
await ethSendTransaction({ from: owner, to: savingsWallet.address, value: paymentAmount }); await ethSendTransaction({ from: owner, to: savingsWallet.address, value: paymentAmount });
const balance = await ethGetBalance(savingsWallet.address); const balance = await ethGetBalance(savingsWallet.address);
assert.isTrue((new web3.BigNumber(paymentAmount)).equals(balance)); balance.should.be.bignumber.equal(paymentAmount);
}); });
it('owner can send funds', async function () { it('owner can send funds', async function () {
...@@ -29,6 +35,6 @@ contract('SimpleSavingsWallet', function ([_, owner, anyone]) { ...@@ -29,6 +35,6 @@ contract('SimpleSavingsWallet', function ([_, owner, anyone]) {
const balance = await ethGetBalance(anyone); const balance = await ethGetBalance(anyone);
await savingsWallet.sendTo(anyone, paymentAmount, { from: owner }); await savingsWallet.sendTo(anyone, paymentAmount, { from: owner });
const updatedBalance = await ethGetBalance(anyone); const updatedBalance = await ethGetBalance(anyone);
assert.isTrue(balance.plus(paymentAmount).equals(updatedBalance)); balance.plus(paymentAmount).should.be.bignumber.equal(updatedBalance);
}); });
}); });
...@@ -3,7 +3,10 @@ const { getBouncerSigner } = require('../helpers/sign'); ...@@ -3,7 +3,10 @@ const { getBouncerSigner } = require('../helpers/sign');
const Bouncer = artifacts.require('SignatureBouncerMock'); const Bouncer = artifacts.require('SignatureBouncerMock');
const BigNumber = web3.BigNumber;
require('chai') require('chai')
.use(require('chai-bignumber')(BigNumber))
.should(); .should();
const UINT_VALUE = 23; const UINT_VALUE = 23;
......
...@@ -39,8 +39,8 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW ...@@ -39,8 +39,8 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
const { logs } = await this.crowdsale.sendTransaction({ value: value, from: investor }); const { logs } = await this.crowdsale.sendTransaction({ value: value, from: investor });
const event = logs.find(e => e.event === 'TokenPurchase'); const event = logs.find(e => e.event === 'TokenPurchase');
should.exist(event); should.exist(event);
event.args.purchaser.should.equal(investor); event.args.purchaser.should.eq(investor);
event.args.beneficiary.should.equal(investor); event.args.beneficiary.should.eq(investor);
event.args.value.should.be.bignumber.equal(value); event.args.value.should.be.bignumber.equal(value);
event.args.amount.should.be.bignumber.equal(expectedTokenAmount); event.args.amount.should.be.bignumber.equal(expectedTokenAmount);
}); });
......
...@@ -58,19 +58,19 @@ contract('CappedCrowdsale', function ([_, wallet]) { ...@@ -58,19 +58,19 @@ contract('CappedCrowdsale', function ([_, wallet]) {
it('should not reach cap if sent under cap', async function () { it('should not reach cap if sent under cap', async function () {
await this.crowdsale.send(lessThanCap); await this.crowdsale.send(lessThanCap);
const capReached = await this.crowdsale.capReached(); const capReached = await this.crowdsale.capReached();
capReached.should.equal(false); capReached.should.eq(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));
const capReached = await this.crowdsale.capReached(); const capReached = await this.crowdsale.capReached();
capReached.should.equal(false); capReached.should.eq(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);
const capReached = await this.crowdsale.capReached(); const capReached = await this.crowdsale.capReached();
capReached.should.equal(true); capReached.should.eq(true);
}); });
}); });
}); });
...@@ -34,8 +34,8 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { ...@@ -34,8 +34,8 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
const { logs } = await this.crowdsale.sendTransaction({ value: value, from: investor }); const { logs } = await this.crowdsale.sendTransaction({ value: value, from: investor });
const event = logs.find(e => e.event === 'TokenPurchase'); const event = logs.find(e => e.event === 'TokenPurchase');
should.exist(event); should.exist(event);
event.args.purchaser.should.equal(investor); event.args.purchaser.should.eq(investor);
event.args.beneficiary.should.equal(investor); event.args.beneficiary.should.eq(investor);
event.args.value.should.be.bignumber.equal(value); event.args.value.should.be.bignumber.equal(value);
event.args.amount.should.be.bignumber.equal(expectedTokenAmount); event.args.amount.should.be.bignumber.equal(expectedTokenAmount);
}); });
...@@ -59,8 +59,8 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { ...@@ -59,8 +59,8 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
const { logs } = await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }); const { logs } = await this.crowdsale.buyTokens(investor, { value: value, from: purchaser });
const event = logs.find(e => e.event === 'TokenPurchase'); const event = logs.find(e => e.event === 'TokenPurchase');
should.exist(event); should.exist(event);
event.args.purchaser.should.equal(purchaser); event.args.purchaser.should.eq(purchaser);
event.args.beneficiary.should.equal(investor); event.args.beneficiary.should.eq(investor);
event.args.value.should.be.bignumber.equal(value); event.args.value.should.be.bignumber.equal(value);
event.args.amount.should.be.bignumber.equal(expectedTokenAmount); event.args.amount.should.be.bignumber.equal(expectedTokenAmount);
}); });
......
...@@ -22,8 +22,8 @@ function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate ...@@ -22,8 +22,8 @@ function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate
const { logs } = await this.crowdsale.sendTransaction({ value: value, from: investor }); const { logs } = await this.crowdsale.sendTransaction({ value: value, from: investor });
const event = logs.find(e => e.event === 'TokenPurchase'); const event = logs.find(e => e.event === 'TokenPurchase');
should.exist(event); should.exist(event);
event.args.purchaser.should.equal(investor); event.args.purchaser.should.eq(investor);
event.args.beneficiary.should.equal(investor); event.args.beneficiary.should.eq(investor);
event.args.value.should.be.bignumber.equal(value); event.args.value.should.be.bignumber.equal(value);
event.args.amount.should.be.bignumber.equal(expectedTokenAmount); event.args.amount.should.be.bignumber.equal(expectedTokenAmount);
}); });
......
...@@ -20,7 +20,7 @@ contract('MintedCrowdsale', function ([_, investor, wallet, purchaser]) { ...@@ -20,7 +20,7 @@ contract('MintedCrowdsale', function ([_, investor, wallet, purchaser]) {
it('should be token owner', async function () { it('should be token owner', async function () {
const owner = await this.token.owner(); const owner = await this.token.owner();
owner.should.equal(this.crowdsale.address); owner.should.eq(this.crowdsale.address);
}); });
shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value); shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value);
...@@ -37,7 +37,7 @@ contract('MintedCrowdsale', function ([_, investor, wallet, purchaser]) { ...@@ -37,7 +37,7 @@ contract('MintedCrowdsale', function ([_, investor, wallet, purchaser]) {
it('should have minter role on token', async function () { it('should have minter role on token', async function () {
const isMinter = await this.token.hasRole(this.crowdsale.address, ROLE_MINTER); const isMinter = await this.token.hasRole(this.crowdsale.address, ROLE_MINTER);
isMinter.should.equal(true); isMinter.should.eq(true);
}); });
shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value); shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value);
......
...@@ -35,10 +35,10 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { ...@@ -35,10 +35,10 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) {
it('should be ended only after end', async function () { it('should be ended only after end', async function () {
let ended = await this.crowdsale.hasClosed(); let ended = await this.crowdsale.hasClosed();
ended.should.equal(false); ended.should.eq(false);
await increaseTimeTo(this.afterClosingTime); await increaseTimeTo(this.afterClosingTime);
ended = await this.crowdsale.hasClosed(); ended = await this.crowdsale.hasClosed();
ended.should.equal(true); ended.should.eq(true);
}); });
describe('accepting payments', function () { describe('accepting payments', function () {
......
...@@ -44,9 +44,9 @@ contract('WhitelistedCrowdsale', function ([_, wallet, authorized, unauthorized, ...@@ -44,9 +44,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 () {
const isAuthorized = await this.crowdsale.whitelist(authorized); const isAuthorized = await this.crowdsale.whitelist(authorized);
isAuthorized.should.equal(true); isAuthorized.should.eq(true);
const isntAuthorized = await this.crowdsale.whitelist(unauthorized); const isntAuthorized = await this.crowdsale.whitelist(unauthorized);
isntAuthorized.should.equal(false); isntAuthorized.should.eq(false);
}); });
}); });
}); });
...@@ -83,11 +83,11 @@ contract('WhitelistedCrowdsale', function ([_, wallet, authorized, unauthorized, ...@@ -83,11 +83,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 () {
const isAuthorized = await this.crowdsale.whitelist(authorized); const isAuthorized = await this.crowdsale.whitelist(authorized);
isAuthorized.should.equal(true); isAuthorized.should.eq(true);
const isAnotherAuthorized = await this.crowdsale.whitelist(anotherAuthorized); const isAnotherAuthorized = await this.crowdsale.whitelist(anotherAuthorized);
isAnotherAuthorized.should.equal(true); isAnotherAuthorized.should.eq(true);
const isntAuthorized = await this.crowdsale.whitelist(unauthorized); const isntAuthorized = await this.crowdsale.whitelist(unauthorized);
isntAuthorized.should.equal(false); isntAuthorized.should.eq(false);
}); });
}); });
}); });
......
const { decodeLogs } = require('../helpers/decodeLogs'); const { decodeLogs } = require('../helpers/decodeLogs');
const SimpleToken = artifacts.require('SimpleToken'); const SimpleToken = artifacts.require('SimpleToken');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('SimpleToken', function ([_, creator]) { contract('SimpleToken', function ([_, creator]) {
let token; let token;
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
beforeEach(async function () { beforeEach(async function () {
token = await SimpleToken.new({ from: creator }); token = await SimpleToken.new({ from: creator });
}); });
it('has a name', async function () { it('has a name', async function () {
const name = await token.name(); const name = await token.name();
assert.equal(name, 'SimpleToken'); name.should.eq('SimpleToken');
}); });
it('has a symbol', async function () { it('has a symbol', async function () {
const symbol = await token.symbol(); const symbol = await token.symbol();
assert.equal(symbol, 'SIM'); symbol.should.eq('SIM');
}); });
it('has 18 decimals', async function () { it('has 18 decimals', async function () {
const decimals = await token.decimals(); const decimals = await token.decimals();
assert(decimals.eq(18)); decimals.should.be.bignumber.equal(18);
}); });
it('assigns the initial total supply to the creator', async function () { it('assigns the initial total supply to the creator', async function () {
const totalSupply = await token.totalSupply(); const totalSupply = await token.totalSupply();
const creatorBalance = await token.balanceOf(creator); const creatorBalance = await token.balanceOf(creator);
assert(creatorBalance.eq(totalSupply)); creatorBalance.should.be.bignumber.equal(totalSupply);
const receipt = await web3.eth.getTransactionReceipt(token.transactionHash); const receipt = await web3.eth.getTransactionReceipt(token.transactionHash);
const logs = decodeLogs(receipt.logs, SimpleToken, token.address); const logs = decodeLogs(receipt.logs, SimpleToken, token.address);
assert.equal(logs.length, 1); logs.length.should.eq(1);
assert.equal(logs[0].event, 'Transfer'); logs[0].event.should.equal('Transfer');
assert.equal(logs[0].args.from.valueOf(), 0x0); logs[0].args.from.valueOf().should.equal(ZERO_ADDRESS);
assert.equal(logs[0].args.to.valueOf(), creator); logs[0].args.to.valueOf().should.equal(creator);
assert(logs[0].args.value.eq(totalSupply)); logs[0].args.value.should.be.bignumber.equal(totalSupply);
}); });
}); });
const should = require('chai')
.should();
async function assertJump (promise) { async function assertJump (promise) {
try { try {
await promise; await promise;
assert.fail('Expected invalid opcode not received'); should.fail('Expected invalid opcode not received');
} catch (error) { } catch (error) {
const invalidOpcodeReceived = error.message.search('invalid opcode') >= 0; error.message.should.include('invalid opcode', `Expected "invalid opcode", got ${error} instead`);
assert(invalidOpcodeReceived, `Expected "invalid opcode", got ${error} instead`);
} }
} }
......
const should = require('chai')
.should();
async function assertRevert (promise) { async function assertRevert (promise) {
try { try {
await promise; await promise;
} catch (error) { } catch (error) {
const revertFound = error.message.search('revert') >= 0; error.message.should.include('revert', `Expected "revert", got ${error} instead`);
assert(revertFound, `Expected "revert", got ${error} instead`);
return; return;
} }
assert.fail('Expected revert not received'); should.fail('Expected revert not received');
} }
module.exports = { module.exports = {
......
const should = require('chai')
.should();
async function expectThrow (promise, message) { async function expectThrow (promise, message) {
try { try {
await promise; await promise;
} catch (error) { } catch (error) {
// Message is an optional parameter here // Message is an optional parameter here
if (message) { if (message) {
assert( error.message.should.include(message, 'Expected \'' + message + '\', got \'' + error + '\' instead');
error.message.search(message) >= 0,
'Expected \'' + message + '\', got \'' + error + '\' instead',
);
return; return;
} else { } else {
// TODO: Check jump destination to destinguish between a throw // TODO: Check jump destination to destinguish between a throw
// and an actual invalid jump. // and an actual invalid jump.
const invalidOpcode = error.message.search('invalid opcode') >= 0;
// TODO: When we contract A calls contract B, and B throws, instead // TODO: When we contract A calls contract B, and B throws, instead
// of an 'invalid jump', we get an 'out of gas' error. How do // of an 'invalid jump', we get an 'out of gas' error. How do
// we distinguish this from an actual out of gas event? (The // we distinguish this from an actual out of gas event? (The
// ganache log actually show an 'invalid jump' event.) // ganache log actually show an 'invalid jump' event.)
const outOfGas = error.message.search('out of gas') >= 0; error.message.should.match(/[invalid opcode|out of gas|revert]/, 'Expected throw, got \'' + error + '\' instead');
const revert = error.message.search('revert') >= 0;
assert(
invalidOpcode || outOfGas || revert,
'Expected throw, got \'' + error + '\' instead',
);
return; return;
} }
} }
assert.fail('Expected throw not received'); should.fail('Expected throw not received');
} }
module.exports = { module.exports = {
......
...@@ -52,7 +52,7 @@ contract('ECRecovery', function ([_, anyone]) { ...@@ -52,7 +52,7 @@ contract('ECRecovery', function ([_, anyone]) {
// Recover the signer address from the generated message and wrong signature. // Recover the signer address from the generated message and wrong signature.
const addrRecovered = await ecrecovery.recover(hashMessage('Nope'), signature); const addrRecovered = await ecrecovery.recover(hashMessage('Nope'), signature);
assert.notEqual(anyone, addrRecovered); addrRecovered.should.not.eq(anyone);
}); });
it('recover should revert when a small hash is sent', async function () { it('recover should revert when a small hash is sent', async function () {
......
const MathMock = artifacts.require('MathMock'); const MathMock = artifacts.require('MathMock');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('Math', function () { contract('Math', function () {
const min = 1234; const min = 1234;
const max = 5678; const max = 5678;
...@@ -11,24 +17,24 @@ contract('Math', function () { ...@@ -11,24 +17,24 @@ contract('Math', function () {
describe('max', function () { describe('max', function () {
it('is correctly detected in first argument position', async function () { it('is correctly detected in first argument position', async function () {
const result = await this.math.max(max, min); const result = await this.math.max(max, min);
assert.equal(result, max); result.should.be.bignumber.equal(max);
}); });
it('is correctly detected in second argument position', async function () { it('is correctly detected in second argument position', async function () {
const result = await this.math.max(min, max); const result = await this.math.max(min, max);
assert.equal(result, max); result.should.be.bignumber.equal(max);
}); });
}); });
describe('min', function () { describe('min', function () {
it('is correctly detected in first argument position', async function () { it('is correctly detected in first argument position', async function () {
const result = await this.math.min(min, max); const result = await this.math.min(min, max);
assert.equal(result, min); result.should.be.bignumber.equal(min);
}); });
it('is correctly detected in second argument position', async function () { it('is correctly detected in second argument position', async function () {
const result = await this.math.min(max, min); const result = await this.math.min(max, min);
assert.equal(result, min); result.should.be.bignumber.equal(min);
}); });
}); });
}); });
...@@ -3,6 +3,9 @@ const { sha3, bufferToHex } = require('ethereumjs-util'); ...@@ -3,6 +3,9 @@ const { sha3, bufferToHex } = require('ethereumjs-util');
const MerkleProofWrapper = artifacts.require('MerkleProofWrapper'); const MerkleProofWrapper = artifacts.require('MerkleProofWrapper');
require('chai')
.should();
contract('MerkleProof', function () { contract('MerkleProof', function () {
let merkleProof; let merkleProof;
...@@ -22,7 +25,7 @@ contract('MerkleProof', function () { ...@@ -22,7 +25,7 @@ contract('MerkleProof', function () {
const leaf = bufferToHex(sha3(elements[0])); const leaf = bufferToHex(sha3(elements[0]));
const result = await merkleProof.verifyProof(proof, root, leaf); const result = await merkleProof.verifyProof(proof, root, leaf);
assert.isOk(result, 'verifyProof did not return true for a valid proof'); result.should.be.true;
}); });
it('should return false for an invalid Merkle proof', async function () { it('should return false for an invalid Merkle proof', async function () {
...@@ -39,7 +42,7 @@ contract('MerkleProof', function () { ...@@ -39,7 +42,7 @@ contract('MerkleProof', function () {
const badProof = badMerkleTree.getHexProof(badElements[0]); const badProof = badMerkleTree.getHexProof(badElements[0]);
const result = await merkleProof.verifyProof(badProof, correctRoot, correctLeaf); const result = await merkleProof.verifyProof(badProof, correctRoot, correctLeaf);
assert.isNotOk(result, 'verifyProof did not return false for an invalid proof'); result.should.be.false;
}); });
it('should return false for a Merkle proof of invalid length', async function () { it('should return false for a Merkle proof of invalid length', async function () {
...@@ -54,7 +57,7 @@ contract('MerkleProof', function () { ...@@ -54,7 +57,7 @@ contract('MerkleProof', function () {
const leaf = bufferToHex(sha3(elements[0])); const leaf = bufferToHex(sha3(elements[0]));
const result = await merkleProof.verifyProof(badProof, root, leaf); const result = await merkleProof.verifyProof(badProof, root, leaf);
assert.isNotOk(result, 'verifyProof did not return false for proof of invalid length'); result.should.be.false;
}); });
}); });
}); });
const DestructibleMock = artifacts.require('DestructibleMock'); const DestructibleMock = artifacts.require('DestructibleMock');
const { ethGetBalance } = require('../helpers/web3'); const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('Destructible', function ([_, owner, recipient]) { contract('Destructible', function ([_, owner, recipient]) {
beforeEach(async function () { beforeEach(async function () {
this.destructible = await DestructibleMock.new({ from: owner }); this.destructible = await DestructibleMock.new({ from: owner });
...@@ -15,13 +21,13 @@ contract('Destructible', function ([_, owner, recipient]) { ...@@ -15,13 +21,13 @@ contract('Destructible', function ([_, owner, recipient]) {
const initBalance = await ethGetBalance(owner); const initBalance = await ethGetBalance(owner);
await this.destructible.destroy({ from: owner }); await this.destructible.destroy({ from: owner });
const newBalance = await ethGetBalance(owner); const newBalance = await ethGetBalance(owner);
assert.isTrue(newBalance > initBalance); newBalance.should.be.bignumber.gt(initBalance);
}); });
it('should send balance to recepient after destruction', async function () { it('should send balance to recepient after destruction', async function () {
const initBalance = await ethGetBalance(recipient); const initBalance = await ethGetBalance(recipient);
await this.destructible.destroyAndSend(recipient, { from: owner }); await this.destructible.destroyAndSend(recipient, { from: owner });
const newBalance = await ethGetBalance(recipient); const newBalance = await ethGetBalance(recipient);
assert.isTrue(newBalance.greaterThan(initBalance)); newBalance.should.be.bignumber.gt(initBalance);
}); });
}); });
const { assertRevert } = require('../helpers/assertRevert'); const { assertRevert } = require('../helpers/assertRevert');
const PausableMock = artifacts.require('PausableMock'); const PausableMock = artifacts.require('PausableMock');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('Pausable', function () { contract('Pausable', function () {
beforeEach(async function () { beforeEach(async function () {
this.Pausable = await PausableMock.new(); this.Pausable = await PausableMock.new();
...@@ -8,27 +14,28 @@ contract('Pausable', function () { ...@@ -8,27 +14,28 @@ contract('Pausable', function () {
it('can perform normal process in non-pause', async function () { it('can perform normal process in non-pause', async function () {
const count0 = await this.Pausable.count(); const count0 = await this.Pausable.count();
assert.equal(count0, 0); count0.should.be.bignumber.equal(0);
await this.Pausable.normalProcess(); await this.Pausable.normalProcess();
const count1 = await this.Pausable.count(); const count1 = await this.Pausable.count();
assert.equal(count1, 1); count1.should.be.bignumber.equal(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();
const count0 = await this.Pausable.count(); const count0 = await this.Pausable.count();
assert.equal(count0, 0); count0.should.be.bignumber.equal(0);
await assertRevert(this.Pausable.normalProcess()); await assertRevert(this.Pausable.normalProcess());
const count1 = await this.Pausable.count(); const count1 = await this.Pausable.count();
assert.equal(count1, 0); count1.should.be.bignumber.equal(0);
}); });
it('can not take drastic measure in non-pause', async function () { it('can not take drastic measure in non-pause', async function () {
await assertRevert(this.Pausable.drasticMeasure()); await assertRevert(this.Pausable.drasticMeasure());
const drasticMeasureTaken = await this.Pausable.drasticMeasureTaken(); const drasticMeasureTaken = await this.Pausable.drasticMeasureTaken();
assert.isFalse(drasticMeasureTaken);
drasticMeasureTaken.should.be.false;
}); });
it('can take a drastic measure in a pause', async function () { it('can take a drastic measure in a pause', async function () {
...@@ -36,7 +43,7 @@ contract('Pausable', function () { ...@@ -36,7 +43,7 @@ contract('Pausable', function () {
await this.Pausable.drasticMeasure(); await this.Pausable.drasticMeasure();
const drasticMeasureTaken = await this.Pausable.drasticMeasureTaken(); const drasticMeasureTaken = await this.Pausable.drasticMeasureTaken();
assert.isTrue(drasticMeasureTaken); drasticMeasureTaken.should.be.true;
}); });
it('should resume allowing normal process after pause is over', async function () { it('should resume allowing normal process after pause is over', async function () {
...@@ -45,7 +52,7 @@ contract('Pausable', function () { ...@@ -45,7 +52,7 @@ contract('Pausable', function () {
await this.Pausable.normalProcess(); await this.Pausable.normalProcess();
const count0 = await this.Pausable.count(); const count0 = await this.Pausable.count();
assert.equal(count0, 1); count0.should.be.bignumber.equal(1);
}); });
it('should prevent drastic measure after pause is over', async function () { it('should prevent drastic measure after pause is over', async function () {
...@@ -55,6 +62,6 @@ contract('Pausable', function () { ...@@ -55,6 +62,6 @@ contract('Pausable', function () {
await assertRevert(this.Pausable.drasticMeasure()); await assertRevert(this.Pausable.drasticMeasure());
const drasticMeasureTaken = await this.Pausable.drasticMeasureTaken(); const drasticMeasureTaken = await this.Pausable.drasticMeasureTaken();
assert.isFalse(drasticMeasureTaken); drasticMeasureTaken.should.be.false;
}); });
}); });
...@@ -3,6 +3,12 @@ const { ethGetBalance } = require('../helpers/web3'); ...@@ -3,6 +3,12 @@ const { ethGetBalance } = require('../helpers/web3');
const TokenDestructible = artifacts.require('TokenDestructible'); const TokenDestructible = artifacts.require('TokenDestructible');
const StandardTokenMock = artifacts.require('StandardTokenMock'); const StandardTokenMock = artifacts.require('StandardTokenMock');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('TokenDestructible', function ([_, owner]) { contract('TokenDestructible', function ([_, owner]) {
let tokenDestructible; let tokenDestructible;
...@@ -18,20 +24,20 @@ contract('TokenDestructible', function ([_, owner]) { ...@@ -18,20 +24,20 @@ contract('TokenDestructible', function ([_, owner]) {
await tokenDestructible.destroy([], { from: owner }); await tokenDestructible.destroy([], { from: owner });
const newBalance = await ethGetBalance(owner); const newBalance = await ethGetBalance(owner);
assert.isTrue(newBalance > initBalance); newBalance.should.be.bignumber.gt(initBalance);
}); });
it('should send tokens to owner after destruction', async function () { it('should send tokens to owner after destruction', async function () {
const token = await StandardTokenMock.new(tokenDestructible.address, 100); const token = await StandardTokenMock.new(tokenDestructible.address, 100);
const initContractBalance = await token.balanceOf(tokenDestructible.address); const initContractBalance = await token.balanceOf(tokenDestructible.address);
const initOwnerBalance = await token.balanceOf(owner); const initOwnerBalance = await token.balanceOf(owner);
assert.equal(initContractBalance, 100); initContractBalance.should.be.bignumber.equal(100);
assert.equal(initOwnerBalance, 0); initOwnerBalance.should.be.bignumber.equal(0);
await tokenDestructible.destroy([token.address], { from: owner }); await tokenDestructible.destroy([token.address], { from: owner });
const newContractBalance = await token.balanceOf(tokenDestructible.address); const newContractBalance = await token.balanceOf(tokenDestructible.address);
const newOwnerBalance = await token.balanceOf(owner); const newOwnerBalance = await token.balanceOf(owner);
assert.equal(newContractBalance, 0); newContractBalance.should.be.bignumber.equal(0);
assert.equal(newOwnerBalance, 100); newOwnerBalance.should.be.bignumber.equal(100);
}); });
}); });
...@@ -3,6 +3,12 @@ const { expectThrow } = require('../helpers/expectThrow'); ...@@ -3,6 +3,12 @@ const { expectThrow } = require('../helpers/expectThrow');
const CanReclaimToken = artifacts.require('CanReclaimToken'); const CanReclaimToken = artifacts.require('CanReclaimToken');
const StandardTokenMock = artifacts.require('StandardTokenMock'); const StandardTokenMock = artifacts.require('StandardTokenMock');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('CanReclaimToken', function ([_, owner, anyone]) { contract('CanReclaimToken', function ([_, owner, anyone]) {
let token = null; let token = null;
let canReclaimToken = null; let canReclaimToken = null;
...@@ -15,7 +21,7 @@ contract('CanReclaimToken', function ([_, owner, anyone]) { ...@@ -15,7 +21,7 @@ contract('CanReclaimToken', function ([_, owner, anyone]) {
// Force token into contract // Force token into contract
await token.transfer(canReclaimToken.address, 10, { from: owner }); await token.transfer(canReclaimToken.address, 10, { from: owner });
const startBalance = await token.balanceOf(canReclaimToken.address); const startBalance = await token.balanceOf(canReclaimToken.address);
assert.equal(startBalance, 10); startBalance.should.be.bignumber.equal(10);
}); });
it('should allow owner to reclaim tokens', async function () { it('should allow owner to reclaim tokens', async function () {
...@@ -23,8 +29,8 @@ contract('CanReclaimToken', function ([_, owner, anyone]) { ...@@ -23,8 +29,8 @@ contract('CanReclaimToken', function ([_, owner, anyone]) {
await canReclaimToken.reclaimToken(token.address, { from: owner }); await canReclaimToken.reclaimToken(token.address, { from: owner });
const ownerFinalBalance = await token.balanceOf(owner); const ownerFinalBalance = await token.balanceOf(owner);
const finalBalance = await token.balanceOf(canReclaimToken.address); const finalBalance = await token.balanceOf(canReclaimToken.address);
assert.equal(finalBalance, 0); finalBalance.should.be.bignumber.equal(0);
assert.equal(ownerFinalBalance - ownerStartBalance, 10); ownerFinalBalance.sub(ownerStartBalance).should.be.bignumber.equal(10);
}); });
it('should allow only owner to reclaim tokens', async function () { it('should allow only owner to reclaim tokens', async function () {
......
...@@ -2,6 +2,12 @@ const { assertRevert } = require('../helpers/assertRevert'); ...@@ -2,6 +2,12 @@ const { assertRevert } = require('../helpers/assertRevert');
const Claimable = artifacts.require('Claimable'); const Claimable = artifacts.require('Claimable');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('Claimable', function ([_, owner, newOwner, anyone]) { contract('Claimable', function ([_, owner, newOwner, anyone]) {
let claimable; let claimable;
...@@ -9,11 +15,16 @@ contract('Claimable', function ([_, owner, newOwner, anyone]) { ...@@ -9,11 +15,16 @@ contract('Claimable', function ([_, owner, newOwner, anyone]) {
claimable = await Claimable.new({ from: owner }); claimable = await Claimable.new({ from: owner });
}); });
it('should have an owner', async function () {
const owner = await claimable.owner();
owner.should.not.eq(0);
});
it('changes pendingOwner after transfer', async function () { it('changes pendingOwner after transfer', async function () {
await claimable.transferOwnership(newOwner, { from: owner }); await claimable.transferOwnership(newOwner, { from: owner });
const pendingOwner = await claimable.pendingOwner(); const pendingOwner = await claimable.pendingOwner();
assert.isTrue(pendingOwner === newOwner); pendingOwner.should.eq(newOwner);
}); });
it('should prevent to claimOwnership from anyone', async function () { it('should prevent to claimOwnership from anyone', async function () {
...@@ -31,7 +42,8 @@ contract('Claimable', function ([_, owner, newOwner, anyone]) { ...@@ -31,7 +42,8 @@ contract('Claimable', function ([_, owner, newOwner, anyone]) {
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 });
assert.isTrue((await claimable.owner()) === newOwner);
(await claimable.owner()).should.eq(newOwner);
}); });
}); });
}); });
...@@ -9,7 +9,7 @@ contract('Contactable', function () { ...@@ -9,7 +9,7 @@ contract('Contactable', function () {
it('should have an empty contact info', async function () { it('should have an empty contact info', async function () {
const info = await contactable.contactInformation(); const info = await contactable.contactInformation();
assert.isTrue(info === ''); info.should.eq('');
}); });
describe('after setting the contact information', function () { describe('after setting the contact information', function () {
...@@ -21,7 +21,7 @@ contract('Contactable', function () { ...@@ -21,7 +21,7 @@ contract('Contactable', function () {
it('should return the setted contact information', async function () { it('should return the setted contact information', async function () {
const info = await contactable.contactInformation(); const info = await contactable.contactInformation();
assert.isTrue(info === contactInfo); info.should.eq(contactInfo);
}); });
}); });
}); });
const { assertRevert } = require('../helpers/assertRevert'); const { assertRevert } = require('../helpers/assertRevert');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
const DelayedClaimable = artifacts.require('DelayedClaimable'); const DelayedClaimable = artifacts.require('DelayedClaimable');
contract('DelayedClaimable', function ([_, owner, newOwner]) { contract('DelayedClaimable', function ([_, owner, newOwner]) {
...@@ -10,34 +16,42 @@ contract('DelayedClaimable', function ([_, owner, newOwner]) { ...@@ -10,34 +16,42 @@ contract('DelayedClaimable', function ([_, owner, newOwner]) {
it('can set claim blocks', async function () { it('can set claim blocks', async function () {
await this.delayedClaimable.transferOwnership(newOwner, { from: owner }); await this.delayedClaimable.transferOwnership(newOwner, { from: owner });
await this.delayedClaimable.setLimits(0, 1000, { from: owner }); await this.delayedClaimable.setLimits(0, 1000, { from: owner });
const end = await this.delayedClaimable.end(); const end = await this.delayedClaimable.end();
assert.equal(end, 1000); end.should.be.bignumber.equal(1000);
const start = await this.delayedClaimable.start(); const start = await this.delayedClaimable.start();
assert.equal(start, 0); start.should.be.bignumber.equal(0);
}); });
it('changes pendingOwner after transfer successful', async function () { it('changes pendingOwner after transfer successful', async function () {
await this.delayedClaimable.transferOwnership(newOwner, { from: owner }); await this.delayedClaimable.transferOwnership(newOwner, { from: owner });
await this.delayedClaimable.setLimits(0, 1000, { from: owner }); await this.delayedClaimable.setLimits(0, 1000, { from: owner });
const end = await this.delayedClaimable.end(); const end = await this.delayedClaimable.end();
assert.equal(end, 1000); end.should.be.bignumber.equal(1000);
const start = await this.delayedClaimable.start(); const start = await this.delayedClaimable.start();
assert.equal(start, 0); start.should.be.bignumber.equal(0);
assert.equal((await this.delayedClaimable.pendingOwner()), newOwner);
(await this.delayedClaimable.pendingOwner()).should.eq(newOwner);
await this.delayedClaimable.claimOwnership({ from: newOwner }); await this.delayedClaimable.claimOwnership({ from: newOwner });
assert.equal((await this.delayedClaimable.owner()), newOwner); (await this.delayedClaimable.owner()).should.eq(newOwner);
}); });
it('changes pendingOwner after transfer fails', async function () { it('changes pendingOwner after transfer fails', async function () {
await this.delayedClaimable.transferOwnership(newOwner, { from: owner }); await this.delayedClaimable.transferOwnership(newOwner, { from: owner });
await this.delayedClaimable.setLimits(100, 110, { from: owner }); await this.delayedClaimable.setLimits(100, 110, { from: owner });
const end = await this.delayedClaimable.end(); const end = await this.delayedClaimable.end();
assert.equal(end, 110); end.should.be.bignumber.equal(110);
const start = await this.delayedClaimable.start(); const start = await this.delayedClaimable.start();
assert.equal(start, 100); start.should.be.bignumber.equal(100);
assert.equal((await this.delayedClaimable.pendingOwner()), newOwner);
(await this.delayedClaimable.pendingOwner()).should.eq(newOwner);
await assertRevert(this.delayedClaimable.claimOwnership({ from: newOwner })); await assertRevert(this.delayedClaimable.claimOwnership({ from: newOwner }));
assert.isTrue((await this.delayedClaimable.owner()) !== newOwner); (await this.delayedClaimable.owner()).should.not.eq(newOwner);
}); });
it('set end and start invalid values fail', async function () { it('set end and start invalid values fail', async function () {
......
...@@ -18,7 +18,7 @@ contract('HasNoContracts', function ([_, owner, anyone]) { ...@@ -18,7 +18,7 @@ contract('HasNoContracts', function ([_, owner, anyone]) {
it('should allow owner to reclaim contracts', async function () { it('should allow owner to reclaim contracts', async function () {
await hasNoContracts.reclaimContract(ownable.address, { from: owner }); await hasNoContracts.reclaimContract(ownable.address, { from: owner });
assert.equal((await ownable.owner()), owner); (await ownable.owner()).should.eq(owner);
}); });
it('should allow only owner to reclaim contracts', async function () { it('should allow only owner to reclaim contracts', async function () {
......
...@@ -33,20 +33,20 @@ contract('HasNoEther', function ([_, owner, anyone]) { ...@@ -33,20 +33,20 @@ contract('HasNoEther', function ([_, owner, anyone]) {
it('should allow owner to reclaim ether', async function () { it('should allow owner to reclaim ether', async function () {
const startBalance = await ethGetBalance(this.hasNoEther.address); const startBalance = await ethGetBalance(this.hasNoEther.address);
assert.equal(startBalance, 0); startBalance.should.be.bignumber.equal(0);
// Force ether into it // Force ether into it
const forceEther = await ForceEther.new({ value: amount }); const forceEther = await ForceEther.new({ value: amount });
await forceEther.destroyAndSend(this.hasNoEther.address); await forceEther.destroyAndSend(this.hasNoEther.address);
const forcedBalance = await ethGetBalance(this.hasNoEther.address); const forcedBalance = await ethGetBalance(this.hasNoEther.address);
assert.equal(forcedBalance, amount); forcedBalance.should.be.bignumber.equal(amount);
// Reclaim // Reclaim
const ownerStartBalance = await ethGetBalance(owner); const ownerStartBalance = await ethGetBalance(owner);
await this.hasNoEther.reclaimEther({ from: owner }); await this.hasNoEther.reclaimEther({ from: owner });
const ownerFinalBalance = await ethGetBalance(owner); const ownerFinalBalance = await ethGetBalance(owner);
const finalBalance = await ethGetBalance(this.hasNoEther.address); const finalBalance = await ethGetBalance(this.hasNoEther.address);
assert.equal(finalBalance, 0); finalBalance.should.be.bignumber.equal(0);
ownerFinalBalance.should.be.bignumber.gt(ownerStartBalance); ownerFinalBalance.should.be.bignumber.gt(ownerStartBalance);
}); });
...@@ -56,7 +56,7 @@ contract('HasNoEther', function ([_, owner, anyone]) { ...@@ -56,7 +56,7 @@ contract('HasNoEther', function ([_, owner, anyone]) {
const forceEther = await ForceEther.new({ value: amount }); const forceEther = await ForceEther.new({ value: amount });
await forceEther.destroyAndSend(this.hasNoEther.address); await forceEther.destroyAndSend(this.hasNoEther.address);
const forcedBalance = await ethGetBalance(this.hasNoEther.address); const forcedBalance = await ethGetBalance(this.hasNoEther.address);
assert.equal(forcedBalance, amount); forcedBalance.should.be.bignumber.equal(amount);
// Reclaim // Reclaim
await expectThrow(this.hasNoEther.reclaimEther({ from: anyone })); await expectThrow(this.hasNoEther.reclaimEther({ from: anyone }));
......
...@@ -3,6 +3,12 @@ const { expectThrow } = require('../helpers/expectThrow'); ...@@ -3,6 +3,12 @@ const { expectThrow } = require('../helpers/expectThrow');
const HasNoTokens = artifacts.require('HasNoTokens'); const HasNoTokens = artifacts.require('HasNoTokens');
const ERC223TokenMock = artifacts.require('ERC223TokenMock'); const ERC223TokenMock = artifacts.require('ERC223TokenMock');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('HasNoTokens', function ([_, owner, initialAccount, anyone]) { contract('HasNoTokens', function ([_, owner, initialAccount, anyone]) {
let hasNoTokens = null; let hasNoTokens = null;
let token = null; let token = null;
...@@ -14,8 +20,9 @@ contract('HasNoTokens', function ([_, owner, initialAccount, anyone]) { ...@@ -14,8 +20,9 @@ contract('HasNoTokens', function ([_, owner, initialAccount, anyone]) {
// Force token into contract // Force token into contract
await token.transfer(hasNoTokens.address, 10, { from: initialAccount }); await token.transfer(hasNoTokens.address, 10, { from: initialAccount });
const startBalance = await token.balanceOf(hasNoTokens.address); const startBalance = await token.balanceOf(hasNoTokens.address);
assert.equal(startBalance, 10); startBalance.should.be.bignumber.equal(10);
}); });
it('should not accept ERC223 tokens', async function () { it('should not accept ERC223 tokens', async function () {
...@@ -25,10 +32,12 @@ contract('HasNoTokens', function ([_, owner, initialAccount, anyone]) { ...@@ -25,10 +32,12 @@ contract('HasNoTokens', function ([_, owner, initialAccount, anyone]) {
it('should allow owner to reclaim tokens', async function () { it('should allow owner to reclaim tokens', async function () {
const ownerStartBalance = await token.balanceOf(owner); const ownerStartBalance = await token.balanceOf(owner);
await hasNoTokens.reclaimToken(token.address, { from: owner }); await hasNoTokens.reclaimToken(token.address, { from: owner });
const ownerFinalBalance = await token.balanceOf(owner); const ownerFinalBalance = await token.balanceOf(owner);
const finalBalance = await token.balanceOf(hasNoTokens.address); const finalBalance = await token.balanceOf(hasNoTokens.address);
assert.equal(finalBalance, 0);
assert.equal(ownerFinalBalance - ownerStartBalance, 10); finalBalance.should.be.bignumber.equal(0);
ownerFinalBalance.sub(ownerStartBalance).should.be.bignumber.equal(10);
}); });
it('should allow only owner to reclaim tokens', async function () { it('should allow only owner to reclaim tokens', async function () {
......
...@@ -15,16 +15,10 @@ contract('PullPayment', function ([_, payer, payee1, payee2]) { ...@@ -15,16 +15,10 @@ contract('PullPayment', function ([_, payer, payee1, payee2]) {
this.contract = await PullPaymentMock.new({ value: amount }); this.contract = await PullPaymentMock.new({ value: amount });
}); });
it('can\'t call asyncSend externally', async function () {
assert.isUndefined(this.contract.asyncSend);
});
it('can record an async payment correctly', async function () { it('can record an async payment correctly', async function () {
const AMOUNT = 100; await this.contract.callTransfer(payee1, 100, { from: payer });
await this.contract.callTransfer(payee1, AMOUNT, { from: payer });
const paymentsToPayee1 = await this.contract.payments(payee1); const paymentsToPayee1 = await this.contract.payments(payee1);
paymentsToPayee1.should.be.bignumber.equal(AMOUNT); paymentsToPayee1.should.be.bignumber.equal(100);
}); });
it('can add multiple balances on one account', async function () { it('can add multiple balances on one account', async function () {
......
...@@ -7,22 +7,22 @@ require('chai') ...@@ -7,22 +7,22 @@ require('chai')
.should(); .should();
const { expectThrow } = require('../helpers/expectThrow'); const { expectThrow } = require('../helpers/expectThrow');
const EVMThrow = require('../helpers/EVMThrow.js'); const { EVMRevert } = require('../helpers/EVMRevert.js');
const SplitPayment = artifacts.require('SplitPayment'); const SplitPayment = artifacts.require('SplitPayment');
contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, payer1]) { contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, payer1]) {
const amount = web3.toWei(1.0, 'ether'); const amount = web3.toWei(1.0, 'ether');
it('cannot be created with no payees', async function () { it('cannot be created with no payees', async function () {
await expectThrow(SplitPayment.new([], []), EVMThrow); await expectThrow(SplitPayment.new([], []), EVMRevert);
}); });
it('requires shares for each payee', async function () { it('requires shares for each payee', async function () {
await expectThrow(SplitPayment.new([payee1, payee2, payee3], [20, 30]), EVMThrow); await expectThrow(SplitPayment.new([payee1, payee2, payee3], [20, 30]), EVMRevert);
}); });
it('requires a payee for each share', async function () { it('requires a payee for each share', async function () {
await expectThrow(SplitPayment.new([payee1, payee2], [20, 30, 40]), EVMThrow); await expectThrow(SplitPayment.new([payee1, payee2], [20, 30, 40]), EVMRevert);
}); });
context('once deployed', function () { context('once deployed', function () {
...@@ -42,7 +42,7 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, ...@@ -42,7 +42,7 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
it('should store shares if address is payee', async function () { it('should store shares if address is payee', async function () {
const shares = await this.contract.shares.call(payee1); const shares = await this.contract.shares.call(payee1);
shares.should.be.bignumber.not.equal(0); shares.should.be.bignumber.not.eq(0);
}); });
it('should not store shares if address is not payee', async function () { it('should not store shares if address is not payee', async function () {
...@@ -51,12 +51,12 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, ...@@ -51,12 +51,12 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
}); });
it('should throw if no funds to claim', async function () { it('should throw if no funds to claim', async function () {
await expectThrow(this.contract.claim({ from: payee1 }), EVMThrow); await expectThrow(this.contract.claim({ from: payee1 }), EVMRevert);
}); });
it('should throw if non-payee want to claim', async function () { it('should throw if non-payee want to claim', async function () {
await ethSendTransaction({ from: payer1, to: this.contract.address, value: amount }); await ethSendTransaction({ from: payer1, to: this.contract.address, value: amount });
await expectThrow(this.contract.claim({ from: nonpayee1 }), EVMThrow); await expectThrow(this.contract.claim({ from: nonpayee1 }), EVMRevert);
}); });
it('should distribute funds to payees', async function () { it('should distribute funds to payees', async function () {
...@@ -69,18 +69,18 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, ...@@ -69,18 +69,18 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
// distribute to payees // distribute to payees
const initAmount1 = await ethGetBalance(payee1); const initAmount1 = await ethGetBalance(payee1);
await this.contract.claim({ from: payee1 }); await this.contract.claim({ from: payee1 });
const profit1 = await ethGetBalance(payee1) - initAmount1; const profit1 = (await ethGetBalance(payee1)).sub(initAmount1);
assert(Math.abs(profit1 - web3.toWei(0.20, 'ether')) < 1e16); profit1.sub(web3.toWei(0.20, 'ether')).abs().should.be.bignumber.lt(1e16);
const initAmount2 = await ethGetBalance(payee2); const initAmount2 = await ethGetBalance(payee2);
await this.contract.claim({ from: payee2 }); await this.contract.claim({ from: payee2 });
const profit2 = await ethGetBalance(payee2) - initAmount2; const profit2 = (await ethGetBalance(payee2)).sub(initAmount2);
assert(Math.abs(profit2 - web3.toWei(0.10, 'ether')) < 1e16); profit2.sub(web3.toWei(0.10, 'ether')).abs().should.be.bignumber.lt(1e16);
const initAmount3 = await ethGetBalance(payee3); const initAmount3 = await ethGetBalance(payee3);
await this.contract.claim({ from: payee3 }); await this.contract.claim({ from: payee3 });
const profit3 = await ethGetBalance(payee3) - initAmount3; const profit3 = (await ethGetBalance(payee3)).sub(initAmount3);
assert(Math.abs(profit3 - web3.toWei(0.70, 'ether')) < 1e16); profit3.sub(web3.toWei(0.70, 'ether')).abs().should.be.bignumber.lt(1e16);
// end balance should be zero // end balance should be zero
const endBalance = await ethGetBalance(this.contract.address); const endBalance = await ethGetBalance(this.contract.address);
......
const { expectThrow } = require('../../helpers/expectThrow'); const { expectThrow } = require('../../helpers/expectThrow');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
function shouldBehaveLikeCappedToken (minter, [anyone], cap) { function shouldBehaveLikeCappedToken (minter, [anyone], cap) {
describe('capped token', function () { describe('capped token', function () {
const from = minter; const from = minter;
it('should start with the correct cap', async function () { it('should start with the correct cap', async function () {
const _cap = await this.token.cap(); (await this.token.cap()).should.be.bignumber.equal(cap);
assert(cap.eq(_cap));
}); });
it('should mint when amount is less than cap', async function () { it('should mint when amount is less than cap', async function () {
const result = await this.token.mint(anyone, cap.sub(1), { from }); const result = await this.token.mint(anyone, cap.sub(1), { from });
assert.equal(result.logs[0].event, 'Mint'); result.logs[0].event.should.equal('Mint');
}); });
it('should fail to mint if the ammount exceeds the cap', async function () { it('should fail to mint if the ammount exceeds the cap', async function () {
......
...@@ -11,7 +11,7 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) { ...@@ -11,7 +11,7 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) {
describe('after token creation', function () { describe('after token creation', function () {
it('sender should be token owner', async function () { it('sender should be token owner', async function () {
const tokenOwner = await this.token.owner({ from: owner }); const tokenOwner = await this.token.owner({ from: owner });
tokenOwner.should.equal(owner); tokenOwner.should.eq(owner);
}); });
}); });
...@@ -19,7 +19,7 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) { ...@@ -19,7 +19,7 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) {
describe('when the token minting is not finished', function () { describe('when the token minting is not finished', function () {
it('returns false', async function () { it('returns false', async function () {
const mintingFinished = await this.token.mintingFinished(); const mintingFinished = await this.token.mintingFinished();
assert.equal(mintingFinished, false); mintingFinished.should.be.false;
}); });
}); });
...@@ -30,7 +30,7 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) { ...@@ -30,7 +30,7 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) {
it('returns true', async function () { it('returns true', async function () {
const mintingFinished = await this.token.mintingFinished(); const mintingFinished = await this.token.mintingFinished();
assert.equal(mintingFinished, true); mintingFinished.should.be.true;
}); });
}); });
}); });
...@@ -44,14 +44,14 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) { ...@@ -44,14 +44,14 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) {
await this.token.finishMinting({ from }); await this.token.finishMinting({ from });
const mintingFinished = await this.token.mintingFinished(); const mintingFinished = await this.token.mintingFinished();
assert.equal(mintingFinished, true); mintingFinished.should.be.true;
}); });
it('emits a mint finished event', async function () { it('emits a mint finished event', async function () {
const { logs } = await this.token.finishMinting({ from }); const { logs } = await this.token.finishMinting({ from });
assert.equal(logs.length, 1); logs.length.should.be.equal(1);
assert.equal(logs[0].event, 'MintFinished'); logs[0].event.should.eq('MintFinished');
}); });
}); });
...@@ -98,17 +98,17 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) { ...@@ -98,17 +98,17 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) {
await this.token.mint(owner, amount, { from }); await this.token.mint(owner, amount, { from });
const balance = await this.token.balanceOf(owner); const balance = await this.token.balanceOf(owner);
assert.equal(balance, amount); balance.should.be.bignumber.equal(amount);
}); });
it('emits a mint and a transfer event', async function () { it('emits a mint and a transfer event', async function () {
const { logs } = await this.token.mint(owner, amount, { from }); const { logs } = await this.token.mint(owner, amount, { from });
assert.equal(logs.length, 2); logs.length.should.eq(2);
assert.equal(logs[0].event, 'Mint'); logs[0].event.should.eq('Mint');
assert.equal(logs[0].args.to, owner); logs[0].args.to.should.eq(owner);
assert.equal(logs[0].args.amount, amount); logs[0].args.amount.should.be.bignumber.equal(amount);
assert.equal(logs[1].event, 'Transfer'); logs[1].event.should.eq('Transfer');
}); });
}); });
......
...@@ -15,14 +15,14 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -15,14 +15,14 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
await this.token.pause({ from }); await this.token.pause({ from });
const paused = await this.token.paused(); const paused = await this.token.paused();
assert.equal(paused, true); paused.should.be.true;
}); });
it('emits a Pause event', async function () { it('emits a Pause event', async function () {
const { logs } = await this.token.pause({ from }); const { logs } = await this.token.pause({ from });
assert.equal(logs.length, 1); logs.length.should.eq(1);
assert.equal(logs[0].event, 'Pause'); logs[0].event.should.eq('Pause');
}); });
}); });
...@@ -59,14 +59,14 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -59,14 +59,14 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
await this.token.unpause({ from }); await this.token.unpause({ from });
const paused = await this.token.paused(); const paused = await this.token.paused();
assert.equal(paused, false); paused.should.be.false;
}); });
it('emits an Unpause event', async function () { it('emits an Unpause event', async function () {
const { logs } = await this.token.unpause({ from }); const { logs } = await this.token.unpause({ from });
assert.equal(logs.length, 1); logs.length.should.eq(1);
assert.equal(logs[0].event, 'Unpause'); logs[0].event.should.eq('Unpause');
}); });
}); });
...@@ -93,14 +93,14 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -93,14 +93,14 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
it('is not paused by default', async function () { it('is not paused by default', async function () {
const paused = await this.token.paused({ from }); const paused = await this.token.paused({ from });
assert.equal(paused, false); paused.should.be.false;
}); });
it('is paused after being paused', async function () { it('is paused after being paused', async function () {
await this.token.pause({ from }); await this.token.pause({ from });
const paused = await this.token.paused({ from }); const paused = await this.token.paused({ from });
assert.equal(paused, true); paused.should.be.true;
}); });
it('is not paused after being paused and then unpaused', async function () { it('is not paused after being paused and then unpaused', async function () {
...@@ -108,7 +108,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -108,7 +108,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
await this.token.unpause({ from }); await this.token.unpause({ from });
const paused = await this.token.paused(); const paused = await this.token.paused();
assert.equal(paused, false); paused.should.be.false;
}); });
}); });
...@@ -117,10 +117,10 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -117,10 +117,10 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
await this.token.transfer(recipient, 100, { from: owner }); await this.token.transfer(recipient, 100, { from: owner });
const senderBalance = await this.token.balanceOf(owner); const senderBalance = await this.token.balanceOf(owner);
assert.equal(senderBalance, 0); senderBalance.should.be.bignumber.equal(0);
const recipientBalance = await this.token.balanceOf(recipient); const recipientBalance = await this.token.balanceOf(recipient);
assert.equal(recipientBalance, 100); recipientBalance.should.be.bignumber.equal(100);
}); });
it('allows to transfer when paused and then unpaused', async function () { it('allows to transfer when paused and then unpaused', async function () {
...@@ -130,10 +130,10 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -130,10 +130,10 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
await this.token.transfer(recipient, 100, { from: owner }); await this.token.transfer(recipient, 100, { from: owner });
const senderBalance = await this.token.balanceOf(owner); const senderBalance = await this.token.balanceOf(owner);
assert.equal(senderBalance, 0); senderBalance.should.be.bignumber.equal(0);
const recipientBalance = await this.token.balanceOf(recipient); const recipientBalance = await this.token.balanceOf(recipient);
assert.equal(recipientBalance, 100); recipientBalance.should.be.bignumber.equal(100);
}); });
it('reverts when trying to transfer when paused', async function () { it('reverts when trying to transfer when paused', async function () {
...@@ -148,7 +148,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -148,7 +148,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
await this.token.approve(anotherAccount, 40, { from: owner }); await this.token.approve(anotherAccount, 40, { from: owner });
const allowance = await this.token.allowance(owner, anotherAccount); const allowance = await this.token.allowance(owner, anotherAccount);
assert.equal(allowance, 40); allowance.should.be.bignumber.equal(40);
}); });
it('allows to transfer when paused and then unpaused', async function () { it('allows to transfer when paused and then unpaused', async function () {
...@@ -158,7 +158,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -158,7 +158,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
await this.token.approve(anotherAccount, 40, { from: owner }); await this.token.approve(anotherAccount, 40, { from: owner });
const allowance = await this.token.allowance(owner, anotherAccount); const allowance = await this.token.allowance(owner, anotherAccount);
assert.equal(allowance, 40); allowance.should.be.bignumber.equal(40);
}); });
it('reverts when trying to transfer when paused', async function () { it('reverts when trying to transfer when paused', async function () {
...@@ -177,10 +177,10 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -177,10 +177,10 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
await this.token.transferFrom(owner, recipient, 40, { from: anotherAccount }); await this.token.transferFrom(owner, recipient, 40, { from: anotherAccount });
const senderBalance = await this.token.balanceOf(owner); const senderBalance = await this.token.balanceOf(owner);
assert.equal(senderBalance, 60); senderBalance.should.be.bignumber.equal(60);
const recipientBalance = await this.token.balanceOf(recipient); const recipientBalance = await this.token.balanceOf(recipient);
assert.equal(recipientBalance, 40); recipientBalance.should.be.bignumber.equal(40);
}); });
it('allows to transfer when paused and then unpaused', async function () { it('allows to transfer when paused and then unpaused', async function () {
...@@ -190,10 +190,10 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -190,10 +190,10 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
await this.token.transferFrom(owner, recipient, 40, { from: anotherAccount }); await this.token.transferFrom(owner, recipient, 40, { from: anotherAccount });
const senderBalance = await this.token.balanceOf(owner); const senderBalance = await this.token.balanceOf(owner);
assert.equal(senderBalance, 60); senderBalance.should.be.bignumber.equal(60);
const recipientBalance = await this.token.balanceOf(recipient); const recipientBalance = await this.token.balanceOf(recipient);
assert.equal(recipientBalance, 40); recipientBalance.should.be.bignumber.equal(40);
}); });
it('reverts when trying to transfer from when paused', async function () { it('reverts when trying to transfer from when paused', async function () {
...@@ -212,7 +212,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -212,7 +212,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
await this.token.decreaseApproval(anotherAccount, 40, { from: owner }); await this.token.decreaseApproval(anotherAccount, 40, { from: owner });
const allowance = await this.token.allowance(owner, anotherAccount); const allowance = await this.token.allowance(owner, anotherAccount);
assert.equal(allowance, 60); allowance.should.be.bignumber.equal(60);
}); });
it('allows to decrease approval when paused and then unpaused', async function () { it('allows to decrease approval when paused and then unpaused', async function () {
...@@ -222,7 +222,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -222,7 +222,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
await this.token.decreaseApproval(anotherAccount, 40, { from: owner }); await this.token.decreaseApproval(anotherAccount, 40, { from: owner });
const allowance = await this.token.allowance(owner, anotherAccount); const allowance = await this.token.allowance(owner, anotherAccount);
assert.equal(allowance, 60); allowance.should.be.bignumber.equal(60);
}); });
it('reverts when trying to transfer when paused', async function () { it('reverts when trying to transfer when paused', async function () {
...@@ -241,7 +241,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -241,7 +241,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
await this.token.increaseApproval(anotherAccount, 40, { from: owner }); await this.token.increaseApproval(anotherAccount, 40, { from: owner });
const allowance = await this.token.allowance(owner, anotherAccount); const allowance = await this.token.allowance(owner, anotherAccount);
assert.equal(allowance, 140); allowance.should.be.bignumber.equal(140);
}); });
it('allows to increase approval when paused and then unpaused', async function () { it('allows to increase approval when paused and then unpaused', async function () {
...@@ -251,7 +251,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -251,7 +251,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
await this.token.increaseApproval(anotherAccount, 40, { from: owner }); await this.token.increaseApproval(anotherAccount, 40, { from: owner });
const allowance = await this.token.allowance(owner, anotherAccount); const allowance = await this.token.allowance(owner, anotherAccount);
assert.equal(allowance, 140); allowance.should.be.bignumber.equal(140);
}); });
it('reverts when trying to increase approval when paused', async function () { it('reverts when trying to increase approval when paused', async function () {
......
...@@ -7,11 +7,11 @@ function shouldBehaveLikeRBACMintableToken (owner, [anyone]) { ...@@ -7,11 +7,11 @@ function shouldBehaveLikeRBACMintableToken (owner, [anyone]) {
it('owner can add and remove a minter role', async function () { it('owner can add and remove a minter role', async function () {
await this.token.addMinter(anyone, { from: owner }); await this.token.addMinter(anyone, { from: owner });
let hasRole = await this.token.hasRole(anyone, ROLE_MINTER); let hasRole = await this.token.hasRole(anyone, ROLE_MINTER);
assert.equal(hasRole, true); hasRole.should.be.true;
await this.token.removeMinter(anyone, { from: owner }); await this.token.removeMinter(anyone, { from: owner });
hasRole = await this.token.hasRole(anyone, ROLE_MINTER); hasRole = await this.token.hasRole(anyone, ROLE_MINTER);
assert.equal(hasRole, false); hasRole.should.be.false;
}); });
it('anyone can\'t add or remove a minter role', async function () { it('anyone can\'t add or remove a minter role', async function () {
......
...@@ -48,7 +48,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { ...@@ -48,7 +48,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
const releaseTime = block.timestamp; const releaseTime = block.timestamp;
const balance = await this.token.balanceOf(beneficiary); const balance = await this.token.balanceOf(beneficiary);
balance.should.bignumber.equal(amount.mul(releaseTime - this.start).div(this.duration).floor()); balance.should.bignumber.eq(amount.mul(releaseTime - this.start).div(this.duration).floor());
}); });
it('should linearly release tokens during vesting period', async function () { it('should linearly release tokens during vesting period', async function () {
...@@ -63,7 +63,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { ...@@ -63,7 +63,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
const balance = await this.token.balanceOf(beneficiary); const balance = await this.token.balanceOf(beneficiary);
const expectedVesting = amount.mul(now - this.start).div(this.duration).floor(); const expectedVesting = amount.mul(now - this.start).div(this.duration).floor();
balance.should.bignumber.equal(expectedVesting); balance.should.bignumber.eq(expectedVesting);
} }
}); });
...@@ -71,7 +71,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { ...@@ -71,7 +71,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
await increaseTimeTo(this.start + this.duration); await increaseTimeTo(this.start + this.duration);
await this.vesting.release(this.token.address); await this.vesting.release(this.token.address);
const balance = await this.token.balanceOf(beneficiary); const balance = await this.token.balanceOf(beneficiary);
balance.should.bignumber.equal(amount); balance.should.bignumber.eq(amount);
}); });
it('should be revoked by owner if revocable is set', async function () { it('should be revoked by owner if revocable is set', async function () {
...@@ -94,7 +94,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { ...@@ -94,7 +94,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
await this.vesting.revoke(this.token.address, { from: owner }); await this.vesting.revoke(this.token.address, { from: owner });
const ownerBalance = await this.token.balanceOf(owner); const ownerBalance = await this.token.balanceOf(owner);
ownerBalance.should.bignumber.equal(amount.sub(vested)); ownerBalance.should.bignumber.eq(amount.sub(vested));
}); });
it('should keep the vested tokens when revoked by owner', async function () { it('should keep the vested tokens when revoked by owner', async function () {
...@@ -106,7 +106,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { ...@@ -106,7 +106,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
const vestedPost = await this.vesting.vestedAmount(this.token.address); const vestedPost = await this.vesting.vestedAmount(this.token.address);
vestedPre.should.bignumber.equal(vestedPost); vestedPre.should.bignumber.eq(vestedPost);
}); });
it('should fail to be revoked a second time', async function () { it('should fail to be revoked a second time', async function () {
......
...@@ -116,7 +116,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -116,7 +116,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
if (approved) { if (approved) {
it('emit only a transfer event', async function () { it('emit only a transfer event', async function () {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.eq('Transfer'); logs[0].event.should.be.equal('Transfer');
logs[0].args._from.should.be.equal(owner); logs[0].args._from.should.be.equal(owner);
logs[0].args._to.should.be.equal(this.to); logs[0].args._to.should.be.equal(this.to);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId); logs[0].args._tokenId.should.be.bignumber.equal(tokenId);
...@@ -124,7 +124,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -124,7 +124,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
} else { } else {
it('emits only a transfer event', async function () { it('emits only a transfer event', async function () {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.eq('Transfer'); logs[0].event.should.be.equal('Transfer');
logs[0].args._from.should.be.equal(owner); logs[0].args._from.should.be.equal(owner);
logs[0].args._to.should.be.equal(this.to); logs[0].args._to.should.be.equal(this.to);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId); logs[0].args._tokenId.should.be.bignumber.equal(tokenId);
...@@ -146,7 +146,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -146,7 +146,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
newOwnerToken.toNumber().should.be.equal(tokenId); newOwnerToken.toNumber().should.be.equal(tokenId);
const previousOwnerToken = await this.token.tokenOfOwnerByIndex(owner, 0); const previousOwnerToken = await this.token.tokenOfOwnerByIndex(owner, 0);
previousOwnerToken.toNumber().should.not.be.equal(tokenId); previousOwnerToken.toNumber().should.not.be.eq(tokenId);
}); });
}; };
...@@ -197,7 +197,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -197,7 +197,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
it('emits only a transfer event', async function () { it('emits only a transfer event', async function () {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.eq('Transfer'); logs[0].event.should.be.equal('Transfer');
logs[0].args._from.should.be.equal(owner); logs[0].args._from.should.be.equal(owner);
logs[0].args._to.should.be.equal(owner); logs[0].args._to.should.be.equal(owner);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId); logs[0].args._tokenId.should.be.bignumber.equal(tokenId);
...@@ -278,7 +278,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -278,7 +278,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
const result = await transferFun.call(this, owner, this.to, tokenId, { from: owner }); const result = await transferFun.call(this, owner, this.to, tokenId, { from: owner });
result.receipt.logs.length.should.be.equal(2); result.receipt.logs.length.should.be.equal(2);
const [log] = decodeLogs([result.receipt.logs[1]], ERC721Receiver, this.receiver.address); const [log] = decodeLogs([result.receipt.logs[1]], ERC721Receiver, this.receiver.address);
log.event.should.be.eq('Received'); log.event.should.be.equal('Received');
log.args._operator.should.be.equal(owner); log.args._operator.should.be.equal(owner);
log.args._from.should.be.equal(owner); log.args._from.should.be.equal(owner);
log.args._tokenId.toNumber().should.be.equal(tokenId); log.args._tokenId.toNumber().should.be.equal(tokenId);
...@@ -289,7 +289,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -289,7 +289,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
const result = await transferFun.call(this, owner, this.to, tokenId, { from: approved }); const result = await transferFun.call(this, owner, this.to, tokenId, { from: approved });
result.receipt.logs.length.should.be.equal(2); result.receipt.logs.length.should.be.equal(2);
const [log] = decodeLogs([result.receipt.logs[1]], ERC721Receiver, this.receiver.address); const [log] = decodeLogs([result.receipt.logs[1]], ERC721Receiver, this.receiver.address);
log.event.should.be.eq('Received'); log.event.should.be.equal('Received');
log.args._operator.should.be.equal(approved); log.args._operator.should.be.equal(approved);
log.args._from.should.be.equal(owner); log.args._from.should.be.equal(owner);
log.args._tokenId.toNumber().should.be.equal(tokenId); log.args._tokenId.toNumber().should.be.equal(tokenId);
...@@ -367,7 +367,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -367,7 +367,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
const itEmitsApprovalEvent = function (address) { const itEmitsApprovalEvent = function (address) {
it('emits an approval event', async function () { it('emits an approval event', async function () {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.eq('Approval'); logs[0].event.should.be.equal('Approval');
logs[0].args._owner.should.be.equal(sender); logs[0].args._owner.should.be.equal(sender);
logs[0].args._approved.should.be.equal(address); logs[0].args._approved.should.be.equal(address);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId); logs[0].args._tokenId.should.be.bignumber.equal(tokenId);
...@@ -481,7 +481,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -481,7 +481,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
const { logs } = await this.token.setApprovalForAll(operator, true, { from: sender }); const { logs } = await this.token.setApprovalForAll(operator, true, { from: sender });
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.eq('ApprovalForAll'); logs[0].event.should.be.equal('ApprovalForAll');
logs[0].args._owner.should.be.equal(sender); logs[0].args._owner.should.be.equal(sender);
logs[0].args._operator.should.be.equal(operator); logs[0].args._operator.should.be.equal(operator);
logs[0].args._approved.should.be.true; logs[0].args._approved.should.be.true;
...@@ -504,7 +504,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -504,7 +504,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
const { logs } = await this.token.setApprovalForAll(operator, true, { from: sender }); const { logs } = await this.token.setApprovalForAll(operator, true, { from: sender });
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.eq('ApprovalForAll'); logs[0].event.should.be.equal('ApprovalForAll');
logs[0].args._owner.should.be.equal(sender); logs[0].args._owner.should.be.equal(sender);
logs[0].args._operator.should.be.equal(operator); logs[0].args._operator.should.be.equal(operator);
logs[0].args._approved.should.be.true; logs[0].args._approved.should.be.true;
...@@ -534,7 +534,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -534,7 +534,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
const { logs } = await this.token.setApprovalForAll(operator, true, { from: sender }); const { logs } = await this.token.setApprovalForAll(operator, true, { from: sender });
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.eq('ApprovalForAll'); logs[0].event.should.be.equal('ApprovalForAll');
logs[0].args._owner.should.be.equal(sender); logs[0].args._owner.should.be.equal(sender);
logs[0].args._operator.should.be.equal(operator); logs[0].args._operator.should.be.equal(operator);
logs[0].args._approved.should.be.true; logs[0].args._approved.should.be.true;
......
...@@ -41,7 +41,7 @@ function shouldBehaveLikeMintAndBurnERC721Token (accounts) { ...@@ -41,7 +41,7 @@ function shouldBehaveLikeMintAndBurnERC721Token (accounts) {
it('emits a transfer event', async function () { it('emits a transfer event', async function () {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.eq('Transfer'); logs[0].event.should.be.equal('Transfer');
logs[0].args._from.should.be.equal(ZERO_ADDRESS); logs[0].args._from.should.be.equal(ZERO_ADDRESS);
logs[0].args._to.should.be.equal(to); logs[0].args._to.should.be.equal(to);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId); logs[0].args._tokenId.should.be.bignumber.equal(tokenId);
...@@ -80,7 +80,7 @@ function shouldBehaveLikeMintAndBurnERC721Token (accounts) { ...@@ -80,7 +80,7 @@ function shouldBehaveLikeMintAndBurnERC721Token (accounts) {
it('emits a burn event', async function () { it('emits a burn event', async function () {
logs.length.should.be.equal(1); logs.length.should.be.equal(1);
logs[0].event.should.be.eq('Transfer'); logs[0].event.should.be.equal('Transfer');
logs[0].args._from.should.be.equal(sender); logs[0].args._from.should.be.equal(sender);
logs[0].args._to.should.be.equal(ZERO_ADDRESS); logs[0].args._to.should.be.equal(ZERO_ADDRESS);
logs[0].args._tokenId.should.be.bignumber.equal(tokenId); logs[0].args._tokenId.should.be.bignumber.equal(tokenId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment