Unverified Commit 20cf8854 by Nicolás Venturo Committed by GitHub

No longer assigning awaits to temporary variables. (#1216)

parent df9426f9
...@@ -47,8 +47,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW ...@@ -47,8 +47,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
it('should assign tokens to sender', async function () { it('should assign tokens to sender', async function () {
await this.crowdsale.sendTransaction({ value: value, from: investor }); await this.crowdsale.sendTransaction({ value: value, from: investor });
const balance = await this.token.balanceOf(investor); (await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount);
balance.should.be.bignumber.equal(expectedTokenAmount);
}); });
it('should forward funds to wallet', async function () { it('should forward funds to wallet', async function () {
...@@ -63,8 +62,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW ...@@ -63,8 +62,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
it('should report correct allowace left', async function () { it('should report correct allowace left', async function () {
const remainingAllowance = tokenAllowance - expectedTokenAmount; const remainingAllowance = tokenAllowance - expectedTokenAmount;
await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }); await this.crowdsale.buyTokens(investor, { value: value, from: purchaser });
const tokensRemaining = await this.crowdsale.remainingTokens(); (await this.crowdsale.remainingTokens()).should.be.bignumber.equal(remainingAllowance);
tokensRemaining.should.be.bignumber.equal(remainingAllowance);
}); });
}); });
......
...@@ -57,20 +57,17 @@ contract('CappedCrowdsale', function ([_, wallet]) { ...@@ -57,20 +57,17 @@ contract('CappedCrowdsale', function ([_, wallet]) {
describe('ending', function () { describe('ending', function () {
it('should not reach cap if sent under cap', async function () { it('should not reach cap if sent under cap', async function () {
await this.crowdsale.send(lessThanCap); await this.crowdsale.send(lessThanCap);
const capReached = await this.crowdsale.capReached(); (await this.crowdsale.capReached()).should.be.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(); (await this.crowdsale.capReached()).should.be.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(); (await this.crowdsale.capReached()).should.be.true;
capReached.should.eq(true);
}); });
}); });
}); });
...@@ -92,8 +92,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { ...@@ -92,8 +92,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
it('should assign tokens to sender', async function () { it('should assign tokens to sender', async function () {
await this.crowdsale.sendTransaction({ value: value, from: investor }); await this.crowdsale.sendTransaction({ value: value, from: investor });
const balance = await this.token.balanceOf(investor); (await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount);
balance.should.be.bignumber.equal(expectedTokenAmount);
}); });
it('should forward funds to wallet', async function () { it('should forward funds to wallet', async function () {
...@@ -117,8 +116,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { ...@@ -117,8 +116,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
it('should assign tokens to beneficiary', async function () { it('should assign tokens to beneficiary', async function () {
await this.crowdsale.buyTokens(investor, { value, from: purchaser }); await this.crowdsale.buyTokens(investor, { value, from: purchaser });
const balance = await this.token.balanceOf(investor); (await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount);
balance.should.be.bignumber.equal(expectedTokenAmount);
}); });
it('should forward funds to wallet', async function () { it('should forward funds to wallet', async function () {
......
...@@ -17,7 +17,6 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) ...@@ -17,7 +17,6 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
const tokenSupply = new BigNumber('1e22'); const tokenSupply = new BigNumber('1e22');
describe('rate during crowdsale should change at a fixed step every block', async function () { describe('rate during crowdsale should change at a fixed step every block', async function () {
let balance;
const initialRate = new BigNumber(9166); const initialRate = new BigNumber(9166);
const finalRate = new BigNumber(5500); const finalRate = new BigNumber(5500);
const rateAtTime150 = new BigNumber(9166); const rateAtTime150 = new BigNumber(9166);
...@@ -42,50 +41,43 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) ...@@ -42,50 +41,43 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
it('at start', async function () { it('at start', async function () {
await increaseTimeTo(this.startTime); await increaseTimeTo(this.startTime);
await this.crowdsale.buyTokens(investor, { value, from: purchaser }); await this.crowdsale.buyTokens(investor, { value, from: purchaser });
balance = await this.token.balanceOf(investor); (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(initialRate));
balance.should.be.bignumber.equal(value.mul(initialRate));
}); });
it('at time 150', async function () { it('at time 150', async function () {
await increaseTimeTo(this.startTime + 150); await increaseTimeTo(this.startTime + 150);
await this.crowdsale.buyTokens(investor, { value, from: purchaser }); await this.crowdsale.buyTokens(investor, { value, from: purchaser });
balance = await this.token.balanceOf(investor); (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime150));
balance.should.be.bignumber.equal(value.mul(rateAtTime150));
}); });
it('at time 300', async function () { it('at time 300', async function () {
await increaseTimeTo(this.startTime + 300); await increaseTimeTo(this.startTime + 300);
await this.crowdsale.buyTokens(investor, { value, from: purchaser }); await this.crowdsale.buyTokens(investor, { value, from: purchaser });
balance = await this.token.balanceOf(investor); (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime300));
balance.should.be.bignumber.equal(value.mul(rateAtTime300));
}); });
it('at time 1500', async function () { it('at time 1500', async function () {
await increaseTimeTo(this.startTime + 1500); await increaseTimeTo(this.startTime + 1500);
await this.crowdsale.buyTokens(investor, { value, from: purchaser }); await this.crowdsale.buyTokens(investor, { value, from: purchaser });
balance = await this.token.balanceOf(investor); (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime1500));
balance.should.be.bignumber.equal(value.mul(rateAtTime1500));
}); });
it('at time 30', async function () { it('at time 30', async function () {
await increaseTimeTo(this.startTime + 30); await increaseTimeTo(this.startTime + 30);
await this.crowdsale.buyTokens(investor, { value, from: purchaser }); await this.crowdsale.buyTokens(investor, { value, from: purchaser });
balance = await this.token.balanceOf(investor); (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime30));
balance.should.be.bignumber.equal(value.mul(rateAtTime30));
}); });
it('at time 150000', async function () { it('at time 150000', async function () {
await increaseTimeTo(this.startTime + 150000); await increaseTimeTo(this.startTime + 150000);
await this.crowdsale.buyTokens(investor, { value, from: purchaser }); await this.crowdsale.buyTokens(investor, { value, from: purchaser });
balance = await this.token.balanceOf(investor); (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime150000));
balance.should.be.bignumber.equal(value.mul(rateAtTime150000));
}); });
it('at time 450000', async function () { it('at time 450000', async function () {
await increaseTimeTo(this.startTime + 450000); await increaseTimeTo(this.startTime + 450000);
await this.crowdsale.buyTokens(investor, { value, from: purchaser }); await this.crowdsale.buyTokens(investor, { value, from: purchaser });
balance = await this.token.balanceOf(investor); (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime450000));
balance.should.be.bignumber.equal(value.mul(rateAtTime450000));
}); });
}); });
}); });
...@@ -56,14 +56,12 @@ contract('IndividuallyCappedCrowdsale', function ([_, wallet, alice, bob, charli ...@@ -56,14 +56,12 @@ contract('IndividuallyCappedCrowdsale', function ([_, wallet, alice, bob, charli
describe('reporting state', function () { describe('reporting state', function () {
it('should report correct cap', async function () { it('should report correct cap', async function () {
const retrievedCap = await this.crowdsale.getUserCap(alice); (await this.crowdsale.getUserCap(alice)).should.be.bignumber.equal(capAlice);
retrievedCap.should.be.bignumber.equal(capAlice);
}); });
it('should report actual contribution', async function () { it('should report actual contribution', async function () {
await this.crowdsale.buyTokens(alice, { value: lessThanCapAlice }); await this.crowdsale.buyTokens(alice, { value: lessThanCapAlice });
const retrievedContribution = await this.crowdsale.getUserContribution(alice); (await this.crowdsale.getUserContribution(alice)).should.be.bignumber.equal(lessThanCapAlice);
retrievedContribution.should.be.bignumber.equal(lessThanCapAlice);
}); });
}); });
}); });
...@@ -97,10 +95,8 @@ contract('IndividuallyCappedCrowdsale', function ([_, wallet, alice, bob, charli ...@@ -97,10 +95,8 @@ contract('IndividuallyCappedCrowdsale', function ([_, wallet, alice, bob, charli
describe('reporting state', function () { describe('reporting state', function () {
it('should report correct cap', async function () { it('should report correct cap', async function () {
const retrievedCapBob = await this.crowdsale.getUserCap(bob); (await this.crowdsale.getUserCap(bob)).should.be.bignumber.equal(capBob);
retrievedCapBob.should.be.bignumber.equal(capBob); (await this.crowdsale.getUserCap(charlie)).should.be.bignumber.equal(capBob);
const retrievedCapCharlie = await this.crowdsale.getUserCap(charlie);
retrievedCapCharlie.should.be.bignumber.equal(capBob);
}); });
}); });
}); });
......
...@@ -30,8 +30,7 @@ function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate ...@@ -30,8 +30,7 @@ function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate
it('should assign tokens to sender', async function () { it('should assign tokens to sender', async function () {
await this.crowdsale.sendTransaction({ value: value, from: investor }); await this.crowdsale.sendTransaction({ value: value, from: investor });
const balance = await this.token.balanceOf(investor); (await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount);
balance.should.be.bignumber.equal(expectedTokenAmount);
}); });
it('should forward funds to wallet', async function () { it('should forward funds to wallet', async function () {
......
...@@ -19,8 +19,7 @@ contract('MintedCrowdsale', function ([_, investor, wallet, purchaser]) { ...@@ -19,8 +19,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(); (await this.token.owner()).should.eq(this.crowdsale.address);
owner.should.eq(this.crowdsale.address);
}); });
shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value); shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value);
...@@ -36,8 +35,7 @@ contract('MintedCrowdsale', function ([_, investor, wallet, purchaser]) { ...@@ -36,8 +35,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); (await this.token.hasRole(this.crowdsale.address, ROLE_MINTER)).should.be.true;
isMinter.should.eq(true);
}); });
shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value); shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value);
......
...@@ -39,8 +39,7 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { ...@@ -39,8 +39,7 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
it('should not immediately assign tokens to beneficiary', async function () { it('should not immediately assign tokens to beneficiary', async function () {
await increaseTimeTo(this.openingTime); await increaseTimeTo(this.openingTime);
await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }); await this.crowdsale.buyTokens(investor, { value: value, from: purchaser });
const balance = await this.token.balanceOf(investor); (await this.token.balanceOf(investor)).should.be.bignumber.equal(0);
balance.should.be.bignumber.equal(0);
}); });
it('should not allow beneficiaries to withdraw tokens before crowdsale ends', async function () { it('should not allow beneficiaries to withdraw tokens before crowdsale ends', async function () {
...@@ -61,7 +60,6 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { ...@@ -61,7 +60,6 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }); await this.crowdsale.buyTokens(investor, { value: value, from: purchaser });
await increaseTimeTo(this.afterClosingTime); await increaseTimeTo(this.afterClosingTime);
await this.crowdsale.withdrawTokens({ from: investor }); await this.crowdsale.withdrawTokens({ from: investor });
const balance = await this.token.balanceOf(investor); (await this.token.balanceOf(investor)).should.be.bignumber.equal(value);
balance.should.be.bignumber.equal(value);
}); });
}); });
...@@ -34,11 +34,9 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { ...@@ -34,11 +34,9 @@ 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(); (await this.crowdsale.hasClosed()).should.be.false;
ended.should.eq(false);
await increaseTimeTo(this.afterClosingTime); await increaseTimeTo(this.afterClosingTime);
ended = await this.crowdsale.hasClosed(); (await this.crowdsale.hasClosed()).should.be.true;
ended.should.eq(true);
}); });
describe('accepting payments', function () { describe('accepting payments', function () {
......
...@@ -43,10 +43,8 @@ contract('WhitelistedCrowdsale', function ([_, wallet, authorized, unauthorized, ...@@ -43,10 +43,8 @@ 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); (await this.crowdsale.whitelist(authorized)).should.be.true;
isAuthorized.should.eq(true); (await this.crowdsale.whitelist(unauthorized)).should.be.false;
const isntAuthorized = await this.crowdsale.whitelist(unauthorized);
isntAuthorized.should.eq(false);
}); });
}); });
}); });
...@@ -82,12 +80,9 @@ contract('WhitelistedCrowdsale', function ([_, wallet, authorized, unauthorized, ...@@ -82,12 +80,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); (await this.crowdsale.whitelist(authorized)).should.be.true;
isAuthorized.should.eq(true); (await this.crowdsale.whitelist(anotherAuthorized)).should.be.true;
const isAnotherAuthorized = await this.crowdsale.whitelist(anotherAuthorized); (await this.crowdsale.whitelist(unauthorized)).should.be.false;
isAnotherAuthorized.should.eq(true);
const isntAuthorized = await this.crowdsale.whitelist(unauthorized);
isntAuthorized.should.eq(false);
}); });
}); });
}); });
......
...@@ -43,19 +43,12 @@ contract('SampleCrowdsale', function ([_, owner, wallet, investor]) { ...@@ -43,19 +43,12 @@ contract('SampleCrowdsale', function ([_, owner, wallet, investor]) {
this.crowdsale.should.exist; this.crowdsale.should.exist;
this.token.should.exist; this.token.should.exist;
const openingTime = await this.crowdsale.openingTime(); (await this.crowdsale.openingTime()).should.be.bignumber.equal(this.openingTime);
const closingTime = await this.crowdsale.closingTime(); (await this.crowdsale.closingTime()).should.be.bignumber.equal(this.closingTime);
const rate = await this.crowdsale.rate(); (await this.crowdsale.rate()).should.be.bignumber.equal(RATE);
const walletAddress = await this.crowdsale.wallet(); (await this.crowdsale.wallet()).should.be.equal(wallet);
const goal = await this.crowdsale.goal(); (await this.crowdsale.goal()).should.be.bignumber.equal(GOAL);
const cap = await this.crowdsale.cap(); (await this.crowdsale.cap()).should.be.bignumber.equal(CAP);
openingTime.should.be.bignumber.equal(this.openingTime);
closingTime.should.be.bignumber.equal(this.closingTime);
rate.should.be.bignumber.equal(RATE);
walletAddress.should.be.equal(wallet);
goal.should.be.bignumber.equal(GOAL);
cap.should.be.bignumber.equal(CAP);
}); });
it('should not accept payments before start', async function () { it('should not accept payments before start', async function () {
......
...@@ -17,18 +17,15 @@ contract('SimpleToken', function ([_, creator]) { ...@@ -17,18 +17,15 @@ contract('SimpleToken', function ([_, creator]) {
}); });
it('has a name', async function () { it('has a name', async function () {
const name = await token.name(); (await token.name()).should.eq('SimpleToken');
name.should.eq('SimpleToken');
}); });
it('has a symbol', async function () { it('has a symbol', async function () {
const symbol = await token.symbol(); (await token.symbol()).should.eq('SIM');
symbol.should.eq('SIM');
}); });
it('has 18 decimals', async function () { it('has 18 decimals', async function () {
const decimals = await token.decimals(); (await token.decimals()).should.be.bignumber.equal(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 () {
......
...@@ -40,13 +40,11 @@ function shouldSupportInterfaces (interfaces = []) { ...@@ -40,13 +40,11 @@ function shouldSupportInterfaces (interfaces = []) {
const interfaceId = INTERFACE_IDS[k]; const interfaceId = INTERFACE_IDS[k];
describe(k, function () { describe(k, function () {
it('should use less than 30k gas', async function () { it('should use less than 30k gas', async function () {
const gasEstimate = await this.thing.supportsInterface.estimateGas(interfaceId); (await this.thing.supportsInterface.estimateGas(interfaceId)).should.be.lte(30000);
gasEstimate.should.be.lte(30000);
}); });
it('is supported', async function () { it('is supported', async function () {
const isSupported = await this.thing.supportsInterface(interfaceId); (await this.thing.supportsInterface(interfaceId)).should.be.true;
isSupported.should.eq(true);
}); });
}); });
} }
......
...@@ -20,8 +20,7 @@ contract('ECRecovery', function ([_, anyone]) { ...@@ -20,8 +20,7 @@ contract('ECRecovery', function ([_, anyone]) {
const message = web3.sha3(TEST_MESSAGE); const message = web3.sha3(TEST_MESSAGE);
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
const signature = '0x5d99b6f7f6d1f73d1a26497f2b1c89b24c0993913f86e9a2d02cd69887d9c94f3c880358579d811b21dd1b7fd9bb01c1d81d10e69f0384e675c32b39643be89200'; const signature = '0x5d99b6f7f6d1f73d1a26497f2b1c89b24c0993913f86e9a2d02cd69887d9c94f3c880358579d811b21dd1b7fd9bb01c1d81d10e69f0384e675c32b39643be89200';
const addrRecovered = await ecrecovery.recover(message, signature); (await ecrecovery.recover(message, signature)).should.eq(signer);
addrRecovered.should.eq(signer);
}); });
it('recover v1', async function () { it('recover v1', async function () {
...@@ -30,8 +29,7 @@ contract('ECRecovery', function ([_, anyone]) { ...@@ -30,8 +29,7 @@ contract('ECRecovery', function ([_, anyone]) {
const message = web3.sha3(TEST_MESSAGE); const message = web3.sha3(TEST_MESSAGE);
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
const signature = '0x331fe75a821c982f9127538858900d87d3ec1f9f737338ad67cad133fa48feff48e6fa0c18abc62e42820f05943e47af3e9fbe306ce74d64094bdf1691ee53e001'; const signature = '0x331fe75a821c982f9127538858900d87d3ec1f9f737338ad67cad133fa48feff48e6fa0c18abc62e42820f05943e47af3e9fbe306ce74d64094bdf1691ee53e001';
const addrRecovered = await ecrecovery.recover(message, signature); (await ecrecovery.recover(message, signature)).should.eq(signer);
addrRecovered.should.eq(signer);
}); });
it('recover using web3.eth.sign()', async function () { it('recover using web3.eth.sign()', async function () {
...@@ -39,11 +37,10 @@ contract('ECRecovery', function ([_, anyone]) { ...@@ -39,11 +37,10 @@ contract('ECRecovery', function ([_, anyone]) {
const signature = signMessage(anyone, web3.sha3(TEST_MESSAGE)); const signature = signMessage(anyone, web3.sha3(TEST_MESSAGE));
// Recover the signer address from the generated message and signature. // Recover the signer address from the generated message and signature.
const addrRecovered = await ecrecovery.recover( (await ecrecovery.recover(
hashMessage(TEST_MESSAGE), hashMessage(TEST_MESSAGE),
signature signature
); )).should.eq(anyone);
addrRecovered.should.eq(anyone);
}); });
it('recover using web3.eth.sign() should return wrong signer', async function () { it('recover using web3.eth.sign() should return wrong signer', async function () {
...@@ -51,8 +48,7 @@ contract('ECRecovery', function ([_, anyone]) { ...@@ -51,8 +48,7 @@ contract('ECRecovery', function ([_, anyone]) {
const signature = signMessage(anyone, web3.sha3(TEST_MESSAGE)); const signature = signMessage(anyone, web3.sha3(TEST_MESSAGE));
// 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); (await ecrecovery.recover(hashMessage('Nope'), signature)).should.not.eq(anyone);
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 () {
...@@ -70,8 +66,7 @@ contract('ECRecovery', function ([_, anyone]) { ...@@ -70,8 +66,7 @@ contract('ECRecovery', function ([_, anyone]) {
context('toEthSignedMessage', () => { context('toEthSignedMessage', () => {
it('should prefix hashes correctly', async function () { it('should prefix hashes correctly', async function () {
const hashedMessage = web3.sha3(TEST_MESSAGE); const hashedMessage = web3.sha3(TEST_MESSAGE);
const ethMessage = await ecrecovery.toEthSignedMessageHash(hashedMessage); (await ecrecovery.toEthSignedMessageHash(hashedMessage)).should.eq(hashMessage(TEST_MESSAGE));
ethMessage.should.eq(hashMessage(TEST_MESSAGE));
}); });
}); });
}); });
...@@ -16,25 +16,21 @@ contract('Math', function () { ...@@ -16,25 +16,21 @@ 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); (await this.math.max(max, min)).should.be.bignumber.equal(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); (await this.math.max(min, max)).should.be.bignumber.equal(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); (await this.math.min(min, max)).should.be.bignumber.equal(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); (await this.math.min(max, min)).should.be.bignumber.equal(min);
result.should.be.bignumber.equal(min);
}); });
}); });
......
...@@ -24,8 +24,7 @@ contract('MerkleProof', function () { ...@@ -24,8 +24,7 @@ contract('MerkleProof', function () {
const leaf = bufferToHex(sha3(elements[0])); const leaf = bufferToHex(sha3(elements[0]));
const result = await merkleProof.verifyProof(proof, root, leaf); (await merkleProof.verifyProof(proof, root, leaf)).should.be.true;
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 () {
...@@ -41,8 +40,7 @@ contract('MerkleProof', function () { ...@@ -41,8 +40,7 @@ contract('MerkleProof', function () {
const badProof = badMerkleTree.getHexProof(badElements[0]); const badProof = badMerkleTree.getHexProof(badElements[0]);
const result = await merkleProof.verifyProof(badProof, correctRoot, correctLeaf); (await merkleProof.verifyProof(badProof, correctRoot, correctLeaf)).should.be.false;
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 () {
...@@ -56,8 +54,7 @@ contract('MerkleProof', function () { ...@@ -56,8 +54,7 @@ contract('MerkleProof', function () {
const leaf = bufferToHex(sha3(elements[0])); const leaf = bufferToHex(sha3(elements[0]));
const result = await merkleProof.verifyProof(badProof, root, leaf); (await merkleProof.verifyProof(badProof, root, leaf)).should.be.false;
result.should.be.false;
}); });
}); });
}); });
...@@ -13,46 +13,36 @@ contract('Pausable', function () { ...@@ -13,46 +13,36 @@ 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(); (await this.Pausable.count()).should.be.bignumber.equal(0);
count0.should.be.bignumber.equal(0);
await this.Pausable.normalProcess(); await this.Pausable.normalProcess();
const count1 = await this.Pausable.count(); (await this.Pausable.count()).should.be.bignumber.equal(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(); (await this.Pausable.count()).should.be.bignumber.equal(0);
count0.should.be.bignumber.equal(0);
await assertRevert(this.Pausable.normalProcess()); await assertRevert(this.Pausable.normalProcess());
const count1 = await this.Pausable.count(); (await this.Pausable.count()).should.be.bignumber.equal(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(); (await this.Pausable.drasticMeasureTaken()).should.be.false;
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 () {
await this.Pausable.pause(); await this.Pausable.pause();
await this.Pausable.drasticMeasure(); await this.Pausable.drasticMeasure();
const drasticMeasureTaken = await this.Pausable.drasticMeasureTaken(); (await this.Pausable.drasticMeasureTaken()).should.be.true;
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 () {
await this.Pausable.pause(); await this.Pausable.pause();
await this.Pausable.unpause(); await this.Pausable.unpause();
await this.Pausable.normalProcess(); await this.Pausable.normalProcess();
const count0 = await this.Pausable.count(); (await this.Pausable.count()).should.be.bignumber.equal(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 () {
...@@ -61,7 +51,6 @@ contract('Pausable', function () { ...@@ -61,7 +51,6 @@ contract('Pausable', function () {
await assertRevert(this.Pausable.drasticMeasure()); await assertRevert(this.Pausable.drasticMeasure());
const drasticMeasureTaken = await this.Pausable.drasticMeasureTaken(); (await this.Pausable.drasticMeasureTaken()).should.be.false;
drasticMeasureTaken.should.be.false;
}); });
}); });
...@@ -29,15 +29,11 @@ contract('TokenDestructible', function ([_, owner]) { ...@@ -29,15 +29,11 @@ contract('TokenDestructible', function ([_, owner]) {
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); (await token.balanceOf(tokenDestructible.address)).should.be.bignumber.equal(100);
const initOwnerBalance = await token.balanceOf(owner); (await token.balanceOf(owner)).should.be.bignumber.equal(0);
initContractBalance.should.be.bignumber.equal(100);
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); (await token.balanceOf(tokenDestructible.address)).should.be.bignumber.equal(0);
const newOwnerBalance = await token.balanceOf(owner); (await token.balanceOf(owner)).should.be.bignumber.equal(100);
newContractBalance.should.be.bignumber.equal(0);
newOwnerBalance.should.be.bignumber.equal(100);
}); });
}); });
...@@ -19,8 +19,7 @@ contract('SafeMath', () => { ...@@ -19,8 +19,7 @@ contract('SafeMath', () => {
const a = new BigNumber(5678); const a = new BigNumber(5678);
const b = new BigNumber(1234); const b = new BigNumber(1234);
const result = await this.safeMath.add(a, b); (await this.safeMath.add(a, b)).should.be.bignumber.equal(a.plus(b));
result.should.be.bignumber.equal(a.plus(b));
}); });
it('throws a revert error on addition overflow', async function () { it('throws a revert error on addition overflow', async function () {
...@@ -36,8 +35,7 @@ contract('SafeMath', () => { ...@@ -36,8 +35,7 @@ contract('SafeMath', () => {
const a = new BigNumber(5678); const a = new BigNumber(5678);
const b = new BigNumber(1234); const b = new BigNumber(1234);
const result = await this.safeMath.sub(a, b); (await this.safeMath.sub(a, b)).should.be.bignumber.equal(a.minus(b));
result.should.be.bignumber.equal(a.minus(b));
}); });
it('throws a revert error if subtraction result would be negative', async function () { it('throws a revert error if subtraction result would be negative', async function () {
...@@ -53,16 +51,14 @@ contract('SafeMath', () => { ...@@ -53,16 +51,14 @@ contract('SafeMath', () => {
const a = new BigNumber(1234); const a = new BigNumber(1234);
const b = new BigNumber(5678); const b = new BigNumber(5678);
const result = await this.safeMath.mul(a, b); (await this.safeMath.mul(a, b)).should.be.bignumber.equal(a.times(b));
result.should.be.bignumber.equal(a.times(b));
}); });
it('handles a zero product correctly', async function () { it('handles a zero product correctly', async function () {
const a = new BigNumber(0); const a = new BigNumber(0);
const b = new BigNumber(5678); const b = new BigNumber(5678);
const result = await this.safeMath.mul(a, b); (await this.safeMath.mul(a, b)).should.be.bignumber.equal(a.times(b));
result.should.be.bignumber.equal(a.times(b));
}); });
it('throws a revert error on multiplication overflow', async function () { it('throws a revert error on multiplication overflow', async function () {
...@@ -78,8 +74,7 @@ contract('SafeMath', () => { ...@@ -78,8 +74,7 @@ contract('SafeMath', () => {
const a = new BigNumber(5678); const a = new BigNumber(5678);
const b = new BigNumber(5678); const b = new BigNumber(5678);
const result = await this.safeMath.div(a, b); (await this.safeMath.div(a, b)).should.be.bignumber.equal(a.div(b));
result.should.be.bignumber.equal(a.div(b));
}); });
it('throws a revert error on zero division', async function () { it('throws a revert error on zero division', async function () {
......
...@@ -20,17 +20,16 @@ contract('CanReclaimToken', function ([_, owner, anyone]) { ...@@ -20,17 +20,16 @@ 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); (await token.balanceOf(canReclaimToken.address)).should.be.bignumber.equal(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 () {
const ownerStartBalance = await token.balanceOf(owner); const ownerStartBalance = await token.balanceOf(owner);
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);
finalBalance.should.be.bignumber.equal(0);
ownerFinalBalance.sub(ownerStartBalance).should.be.bignumber.equal(10); ownerFinalBalance.sub(ownerStartBalance).should.be.bignumber.equal(10);
(await token.balanceOf(canReclaimToken.address)).should.be.bignumber.equal(0);
}); });
it('should allow only owner to reclaim tokens', async function () { it('should allow only owner to reclaim tokens', async function () {
......
...@@ -16,15 +16,12 @@ contract('Claimable', function ([_, owner, newOwner, anyone]) { ...@@ -16,15 +16,12 @@ contract('Claimable', function ([_, owner, newOwner, anyone]) {
}); });
it('should have an owner', async function () { it('should have an owner', async function () {
const owner = await claimable.owner(); (await claimable.owner()).should.not.eq(0);
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(); (await claimable.pendingOwner()).should.eq(newOwner);
pendingOwner.should.eq(newOwner);
}); });
it('should prevent to claimOwnership from anyone', async function () { it('should prevent to claimOwnership from anyone', async function () {
......
...@@ -8,8 +8,7 @@ contract('Contactable', function () { ...@@ -8,8 +8,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(); (await contactable.contactInformation()).should.eq('');
info.should.eq('');
}); });
describe('after setting the contact information', function () { describe('after setting the contact information', function () {
...@@ -20,8 +19,7 @@ contract('Contactable', function () { ...@@ -20,8 +19,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(); (await contactable.contactInformation()).should.eq(contactInfo);
info.should.eq(contactInfo);
}); });
}); });
}); });
...@@ -17,22 +17,18 @@ contract('DelayedClaimable', function ([_, owner, newOwner]) { ...@@ -17,22 +17,18 @@ contract('DelayedClaimable', function ([_, owner, newOwner]) {
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(); (await this.delayedClaimable.end()).should.be.bignumber.equal(1000);
end.should.be.bignumber.equal(1000);
const start = await this.delayedClaimable.start(); (await this.delayedClaimable.start()).should.be.bignumber.equal(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(); (await this.delayedClaimable.end()).should.be.bignumber.equal(1000);
end.should.be.bignumber.equal(1000);
const start = await this.delayedClaimable.start(); (await this.delayedClaimable.start()).should.be.bignumber.equal(0);
start.should.be.bignumber.equal(0);
(await this.delayedClaimable.pendingOwner()).should.eq(newOwner); (await this.delayedClaimable.pendingOwner()).should.eq(newOwner);
await this.delayedClaimable.claimOwnership({ from: newOwner }); await this.delayedClaimable.claimOwnership({ from: newOwner });
...@@ -43,11 +39,9 @@ contract('DelayedClaimable', function ([_, owner, newOwner]) { ...@@ -43,11 +39,9 @@ contract('DelayedClaimable', function ([_, owner, newOwner]) {
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(); (await this.delayedClaimable.end()).should.be.bignumber.equal(110);
end.should.be.bignumber.equal(110);
const start = await this.delayedClaimable.start(); (await this.delayedClaimable.start()).should.be.bignumber.equal(100);
start.should.be.bignumber.equal(100);
(await this.delayedClaimable.pendingOwner()).should.eq(newOwner); (await this.delayedClaimable.pendingOwner()).should.eq(newOwner);
await assertRevert(this.delayedClaimable.claimOwnership({ from: newOwner })); await assertRevert(this.delayedClaimable.claimOwnership({ from: newOwner }));
......
...@@ -38,25 +38,22 @@ contract('HasNoEther', function ([_, owner, anyone]) { ...@@ -38,25 +38,22 @@ contract('HasNoEther', function ([_, owner, anyone]) {
// 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); (await ethGetBalance(this.hasNoEther.address)).should.be.bignumber.equal(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);
finalBalance.should.be.bignumber.equal(0);
ownerFinalBalance.should.be.bignumber.gt(ownerStartBalance); ownerFinalBalance.should.be.bignumber.gt(ownerStartBalance);
(await ethGetBalance(this.hasNoEther.address)).should.be.bignumber.equal(0);
}); });
it('should allow only owner to reclaim ether', async function () { it('should allow only owner to reclaim ether', async function () {
// 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); (await ethGetBalance(this.hasNoEther.address)).should.be.bignumber.equal(amount);
forcedBalance.should.be.bignumber.equal(amount);
// Reclaim // Reclaim
await expectThrow(this.hasNoEther.reclaimEther({ from: anyone })); await expectThrow(this.hasNoEther.reclaimEther({ from: anyone }));
......
...@@ -21,8 +21,7 @@ contract('HasNoTokens', function ([_, owner, initialAccount, anyone]) { ...@@ -21,8 +21,7 @@ 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); (await token.balanceOf(hasNoTokens.address)).should.be.bignumber.equal(10);
startBalance.should.be.bignumber.equal(10);
}); });
it('should not accept ERC223 tokens', async function () { it('should not accept ERC223 tokens', async function () {
...@@ -34,10 +33,9 @@ contract('HasNoTokens', function ([_, owner, initialAccount, anyone]) { ...@@ -34,10 +33,9 @@ contract('HasNoTokens', function ([_, owner, initialAccount, anyone]) {
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);
finalBalance.should.be.bignumber.equal(0);
ownerFinalBalance.sub(ownerStartBalance).should.be.bignumber.equal(10); ownerFinalBalance.sub(ownerStartBalance).should.be.bignumber.equal(10);
(await token.balanceOf(hasNoTokens.address)).should.be.bignumber.equal(0);
}); });
it('should allow only owner to reclaim tokens', async function () { it('should allow only owner to reclaim tokens', async function () {
......
...@@ -15,18 +15,15 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone]) ...@@ -15,18 +15,15 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone])
context('in normal conditions', () => { context('in normal conditions', () => {
it('should set the owner as the default superuser', async function () { it('should set the owner as the default superuser', async function () {
const ownerIsSuperuser = await this.superuser.isSuperuser(firstOwner); (await this.superuser.isSuperuser(firstOwner)).should.be.be.true;
ownerIsSuperuser.should.be.equal(true);
}); });
it('should change superuser after transferring', async function () { it('should change superuser after transferring', async function () {
await this.superuser.transferSuperuser(newSuperuser, { from: firstOwner }); await this.superuser.transferSuperuser(newSuperuser, { from: firstOwner });
const ownerIsSuperuser = await this.superuser.isSuperuser(firstOwner); (await this.superuser.isSuperuser(firstOwner)).should.be.be.false;
ownerIsSuperuser.should.be.equal(false);
const newSuperuserIsSuperuser = await this.superuser.isSuperuser(newSuperuser); (await this.superuser.isSuperuser(newSuperuser)).should.be.be.true;
newSuperuserIsSuperuser.should.be.equal(true);
}); });
it('should prevent changing to a null superuser', async function () { it('should prevent changing to a null superuser', async function () {
...@@ -43,8 +40,7 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone]) ...@@ -43,8 +40,7 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone])
'OwnershipTransferred' 'OwnershipTransferred'
); );
const currentOwner = await this.superuser.owner(); (await this.superuser.owner()).should.equal(newOwner);
currentOwner.should.be.equal(newOwner);
}); });
it('should change owner after the owner transfers the ownership', async function () { it('should change owner after the owner transfers the ownership', async function () {
...@@ -53,8 +49,7 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone]) ...@@ -53,8 +49,7 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone])
'OwnershipTransferred' 'OwnershipTransferred'
); );
const currentOwner = await this.superuser.owner(); (await this.superuser.owner()).should.equal(newOwner);
currentOwner.should.be.equal(newOwner);
}); });
}); });
......
...@@ -21,8 +21,7 @@ contract('Whitelist', function ([_, owner, whitelistedAddress1, whitelistedAddre ...@@ -21,8 +21,7 @@ contract('Whitelist', function ([_, owner, whitelistedAddress1, whitelistedAddre
'RoleAdded', 'RoleAdded',
{ role: this.role }, { role: this.role },
); );
const isWhitelisted = await this.mock.whitelist(whitelistedAddress1); (await this.mock.whitelist(whitelistedAddress1)).should.be.be.true;
isWhitelisted.should.be.equal(true);
}); });
it('should add addresses to the whitelist', async function () { it('should add addresses to the whitelist', async function () {
...@@ -32,8 +31,7 @@ contract('Whitelist', function ([_, owner, whitelistedAddress1, whitelistedAddre ...@@ -32,8 +31,7 @@ contract('Whitelist', function ([_, owner, whitelistedAddress1, whitelistedAddre
{ role: this.role }, { role: this.role },
); );
for (const addr of whitelistedAddresses) { for (const addr of whitelistedAddresses) {
const isWhitelisted = await this.mock.whitelist(addr); (await this.mock.whitelist(addr)).should.be.be.true;
isWhitelisted.should.be.equal(true);
} }
}); });
...@@ -43,8 +41,7 @@ contract('Whitelist', function ([_, owner, whitelistedAddress1, whitelistedAddre ...@@ -43,8 +41,7 @@ contract('Whitelist', function ([_, owner, whitelistedAddress1, whitelistedAddre
'RoleRemoved', 'RoleRemoved',
{ role: this.role }, { role: this.role },
); );
const isWhitelisted = await this.mock.whitelist(whitelistedAddress1); (await this.mock.whitelist(whitelistedAddress1)).should.be.be.false;
isWhitelisted.should.be.equal(false);
}); });
it('should remove addresses from the the whitelist', async function () { it('should remove addresses from the the whitelist', async function () {
...@@ -54,8 +51,7 @@ contract('Whitelist', function ([_, owner, whitelistedAddress1, whitelistedAddre ...@@ -54,8 +51,7 @@ contract('Whitelist', function ([_, owner, whitelistedAddress1, whitelistedAddre
{ role: this.role }, { role: this.role },
); );
for (const addr of whitelistedAddresses) { for (const addr of whitelistedAddresses) {
const isWhitelisted = await this.mock.whitelist(addr); (await this.mock.whitelist(addr)).should.be.be.false;
isWhitelisted.should.be.equal(false);
} }
}); });
......
...@@ -17,11 +17,9 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) { ...@@ -17,11 +17,9 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
it('can accept a single deposit', async function () { it('can accept a single deposit', async function () {
await this.escrow.deposit(payee1, { from: owner, value: amount }); await this.escrow.deposit(payee1, { from: owner, value: amount });
const balance = await ethGetBalance(this.escrow.address); (await ethGetBalance(this.escrow.address)).should.be.bignumber.equal(amount);
const deposit = await this.escrow.depositsOf(payee1);
balance.should.be.bignumber.equal(amount); (await this.escrow.depositsOf(payee1)).should.be.bignumber.equal(amount);
deposit.should.be.bignumber.equal(amount);
}); });
it('can accept an empty deposit', async function () { it('can accept an empty deposit', async function () {
...@@ -43,24 +41,20 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) { ...@@ -43,24 +41,20 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
await this.escrow.deposit(payee1, { from: owner, value: amount }); await this.escrow.deposit(payee1, { from: owner, value: amount });
await this.escrow.deposit(payee1, { from: owner, value: amount * 2 }); await this.escrow.deposit(payee1, { from: owner, value: amount * 2 });
const balance = await ethGetBalance(this.escrow.address); (await ethGetBalance(this.escrow.address)).should.be.bignumber.equal(amount * 3);
const deposit = await this.escrow.depositsOf(payee1);
balance.should.be.bignumber.equal(amount * 3); (await this.escrow.depositsOf(payee1)).should.be.bignumber.equal(amount * 3);
deposit.should.be.bignumber.equal(amount * 3);
}); });
it('can track deposits to multiple accounts', async function () { it('can track deposits to multiple accounts', async function () {
await this.escrow.deposit(payee1, { from: owner, value: amount }); await this.escrow.deposit(payee1, { from: owner, value: amount });
await this.escrow.deposit(payee2, { from: owner, value: amount * 2 }); await this.escrow.deposit(payee2, { from: owner, value: amount * 2 });
const balance = await ethGetBalance(this.escrow.address); (await ethGetBalance(this.escrow.address)).should.be.bignumber.equal(amount * 3);
const depositPayee1 = await this.escrow.depositsOf(payee1);
const depositPayee2 = await this.escrow.depositsOf(payee2);
balance.should.be.bignumber.equal(amount * 3); (await this.escrow.depositsOf(payee1)).should.be.bignumber.equal(amount);
depositPayee1.should.be.bignumber.equal(amount);
depositPayee2.should.be.bignumber.equal(amount * 2); (await this.escrow.depositsOf(payee2)).should.be.bignumber.equal(amount * 2);
}); });
}); });
...@@ -71,12 +65,11 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) { ...@@ -71,12 +65,11 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
await this.escrow.deposit(payee1, { from: owner, value: amount }); await this.escrow.deposit(payee1, { from: owner, value: amount });
await this.escrow.withdraw(payee1, { from: owner }); await this.escrow.withdraw(payee1, { from: owner });
const escrowBalance = await ethGetBalance(this.escrow.address); (await ethGetBalance(this.escrow.address)).should.be.bignumber.equal(0);
const finalDeposit = await this.escrow.depositsOf(payee1);
const payeeFinalBalance = await ethGetBalance(payee1);
escrowBalance.should.be.bignumber.equal(0); (await this.escrow.depositsOf(payee1)).should.be.bignumber.equal(0);
finalDeposit.should.be.bignumber.equal(0);
const payeeFinalBalance = await ethGetBalance(payee1);
payeeFinalBalance.sub(payeeInitialBalance).should.be.bignumber.equal(amount); payeeFinalBalance.sub(payeeInitialBalance).should.be.bignumber.equal(amount);
}); });
......
...@@ -17,26 +17,22 @@ contract('PullPayment', function ([_, payer, payee1, payee2]) { ...@@ -17,26 +17,22 @@ contract('PullPayment', function ([_, payer, payee1, payee2]) {
it('can record an async payment correctly', async function () { it('can record an async payment correctly', async function () {
await this.contract.callTransfer(payee1, 100, { from: payer }); await this.contract.callTransfer(payee1, 100, { from: payer });
const paymentsToPayee1 = await this.contract.payments(payee1); (await this.contract.payments(payee1)).should.be.bignumber.equal(100);
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 () {
await this.contract.callTransfer(payee1, 200, { from: payer }); await this.contract.callTransfer(payee1, 200, { from: payer });
await this.contract.callTransfer(payee1, 300, { from: payer }); await this.contract.callTransfer(payee1, 300, { from: payer });
const paymentsToPayee1 = await this.contract.payments(payee1); (await this.contract.payments(payee1)).should.be.bignumber.equal(500);
paymentsToPayee1.should.be.bignumber.equal(500);
}); });
it('can add balances on multiple accounts', async function () { it('can add balances on multiple accounts', async function () {
await this.contract.callTransfer(payee1, 200, { from: payer }); await this.contract.callTransfer(payee1, 200, { from: payer });
await this.contract.callTransfer(payee2, 300, { from: payer }); await this.contract.callTransfer(payee2, 300, { from: payer });
const paymentsToPayee1 = await this.contract.payments(payee1); (await this.contract.payments(payee1)).should.be.bignumber.equal(200);
paymentsToPayee1.should.be.bignumber.equal(200);
const paymentsToPayee2 = await this.contract.payments(payee2); (await this.contract.payments(payee2)).should.be.bignumber.equal(300);
paymentsToPayee2.should.be.bignumber.equal(300);
}); });
it('can withdraw payment', async function () { it('can withdraw payment', async function () {
...@@ -44,12 +40,10 @@ contract('PullPayment', function ([_, payer, payee1, payee2]) { ...@@ -44,12 +40,10 @@ contract('PullPayment', function ([_, payer, payee1, payee2]) {
await this.contract.callTransfer(payee1, amount, { from: payer }); await this.contract.callTransfer(payee1, amount, { from: payer });
const payment1 = await this.contract.payments(payee1); (await this.contract.payments(payee1)).should.be.bignumber.equal(amount);
payment1.should.be.bignumber.equal(amount);
await this.contract.withdrawPayments({ from: payee1 }); await this.contract.withdrawPayments({ from: payee1 });
const payment2 = await this.contract.payments(payee1); (await this.contract.payments(payee1)).should.be.bignumber.equal(0);
payment2.should.be.bignumber.equal(0);
const balance = await ethGetBalance(payee1); const balance = await ethGetBalance(payee1);
Math.abs(balance - initialBalance - amount).should.be.lt(1e16); Math.abs(balance - initialBalance - amount).should.be.lt(1e16);
......
...@@ -31,8 +31,7 @@ contract('RefundEscrow', function ([_, owner, beneficiary, refundee1, refundee2] ...@@ -31,8 +31,7 @@ contract('RefundEscrow', function ([_, owner, beneficiary, refundee1, refundee2]
it('accepts deposits', async function () { it('accepts deposits', async function () {
await this.escrow.deposit(refundee1, { from: owner, value: amount }); await this.escrow.deposit(refundee1, { from: owner, value: amount });
const deposit = await this.escrow.depositsOf(refundee1); (await this.escrow.depositsOf(refundee1)).should.be.bignumber.equal(amount);
deposit.should.be.bignumber.equal(amount);
}); });
it('does not refund refundees', async function () { it('does not refund refundees', async function () {
......
...@@ -49,18 +49,15 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, ...@@ -49,18 +49,15 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
it('should accept payments', async function () { it('should accept payments', async function () {
await ethSendTransaction({ from: owner, to: this.contract.address, value: amount }); await ethSendTransaction({ from: owner, to: this.contract.address, value: amount });
const balance = await ethGetBalance(this.contract.address); (await ethGetBalance(this.contract.address)).should.be.bignumber.equal(amount);
balance.should.be.bignumber.equal(amount);
}); });
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); (await this.contract.shares.call(payee1)).should.be.bignumber.not.eq(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 () {
const shares = await this.contract.shares.call(nonpayee1); (await this.contract.shares.call(nonpayee1)).should.be.bignumber.equal(0);
shares.should.be.bignumber.equal(0);
}); });
it('should throw if no funds to claim', async function () { it('should throw if no funds to claim', async function () {
...@@ -96,12 +93,10 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, ...@@ -96,12 +93,10 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
profit3.sub(web3.toWei(0.70, 'ether')).abs().should.be.bignumber.lt(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); (await ethGetBalance(this.contract.address)).should.be.bignumber.equal(0);
endBalance.should.be.bignumber.equal(0);
// check correct funds released accounting // check correct funds released accounting
const totalReleased = await this.contract.totalReleased.call(); (await this.contract.totalReleased.call()).should.be.bignumber.equal(initBalance);
totalReleased.should.be.bignumber.equal(initBalance);
}); });
}); });
}); });
...@@ -11,7 +11,6 @@ describe('ERC20WithMetadata', function () { ...@@ -11,7 +11,6 @@ describe('ERC20WithMetadata', function () {
}); });
it('responds with the metadata', async function () { it('responds with the metadata', async function () {
const got = await this.token.tokenURI(); (await this.token.tokenURI()).should.eq(metadataURI);
got.should.eq(metadataURI);
}); });
}); });
...@@ -18,8 +18,7 @@ function shouldBehaveLikeBurnableToken (owner, initialBalance, [burner]) { ...@@ -18,8 +18,7 @@ function shouldBehaveLikeBurnableToken (owner, initialBalance, [burner]) {
}); });
it('burns the requested amount', async function () { it('burns the requested amount', async function () {
const balance = await this.token.balanceOf(owner); (await this.token.balanceOf(owner)).should.be.bignumber.equal(initialBalance - amount);
balance.should.be.bignumber.equal(initialBalance - amount);
}); });
it('emits a burn event', async function () { it('emits a burn event', async function () {
...@@ -56,13 +55,11 @@ function shouldBehaveLikeBurnableToken (owner, initialBalance, [burner]) { ...@@ -56,13 +55,11 @@ function shouldBehaveLikeBurnableToken (owner, initialBalance, [burner]) {
}); });
it('burns the requested amount', async function () { it('burns the requested amount', async function () {
const balance = await this.token.balanceOf(owner); (await this.token.balanceOf(owner)).should.be.bignumber.equal(initialBalance - amount);
balance.should.be.bignumber.equal(initialBalance - amount);
}); });
it('decrements allowance', async function () { it('decrements allowance', async function () {
const allowance = await this.token.allowance(owner, burner); (await this.token.allowance(owner, burner)).should.be.bignumber.equal(200);
allowance.should.be.bignumber.equal(200);
}); });
it('emits a burn event', async function () { it('emits a burn event', async function () {
......
...@@ -18,17 +18,14 @@ contract('DetailedERC20', function () { ...@@ -18,17 +18,14 @@ contract('DetailedERC20', function () {
}); });
it('has a name', async function () { it('has a name', async function () {
const name = await detailedERC20.name(); (await detailedERC20.name()).should.be.equal(_name);
name.should.be.equal(_name);
}); });
it('has a symbol', async function () { it('has a symbol', async function () {
const symbol = await detailedERC20.symbol(); (await detailedERC20.symbol()).should.be.equal(_symbol);
symbol.should.be.equal(_symbol);
}); });
it('has an amount of decimals', async function () { it('has an amount of decimals', async function () {
const decimals = await detailedERC20.decimals(); (await detailedERC20.decimals()).should.be.bignumber.equal(_decimals);
decimals.should.be.bignumber.equal(_decimals);
}); });
}); });
...@@ -13,16 +13,14 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) { ...@@ -13,16 +13,14 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) {
describe('as a basic mintable token', function () { describe('as a basic mintable token', function () {
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 }); (await this.token.owner({ from: owner })).should.equal(owner);
tokenOwner.should.eq(owner);
}); });
}); });
describe('minting finished', function () { describe('minting finished', function () {
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(); (await this.token.mintingFinished()).should.be.false;
mintingFinished.should.be.false;
}); });
}); });
...@@ -32,8 +30,7 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) { ...@@ -32,8 +30,7 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) {
}); });
it('returns true', async function () { it('returns true', async function () {
const mintingFinished = await this.token.mintingFinished(); (await this.token.mintingFinished()).should.be.true;
mintingFinished.should.be.true;
}); });
}); });
}); });
...@@ -46,8 +43,7 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) { ...@@ -46,8 +43,7 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) {
it('finishes token minting', async function () { it('finishes token minting', async function () {
await this.token.finishMinting({ from }); await this.token.finishMinting({ from });
const mintingFinished = await this.token.mintingFinished(); (await this.token.mintingFinished()).should.be.true;
mintingFinished.should.be.true;
}); });
it('emits a mint finished event', async function () { it('emits a mint finished event', async function () {
...@@ -100,8 +96,7 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) { ...@@ -100,8 +96,7 @@ function shouldBehaveLikeMintableToken (owner, minter, [anyone]) {
it('mints the requested amount', async function () { it('mints the requested amount', async function () {
await this.token.mint(owner, amount, { from }); await this.token.mint(owner, amount, { from });
const balance = await this.token.balanceOf(owner); (await this.token.balanceOf(owner)).should.be.bignumber.equal(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 () {
......
...@@ -13,9 +13,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -13,9 +13,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
describe('when the token is unpaused', function () { describe('when the token is unpaused', function () {
it('pauses the token', async function () { it('pauses the token', async function () {
await this.token.pause({ from }); await this.token.pause({ from });
(await this.token.paused()).should.be.true;
const paused = await this.token.paused();
paused.should.be.true;
}); });
it('emits a Pause event', async function () { it('emits a Pause event', async function () {
...@@ -57,9 +55,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -57,9 +55,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
it('unpauses the token', async function () { it('unpauses the token', async function () {
await this.token.unpause({ from }); await this.token.unpause({ from });
(await this.token.paused()).should.be.false;
const paused = await this.token.paused();
paused.should.be.false;
}); });
it('emits an Unpause event', async function () { it('emits an Unpause event', async function () {
...@@ -91,24 +87,18 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -91,24 +87,18 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
describe('paused', function () { describe('paused', function () {
it('is not paused by default', async function () { it('is not paused by default', async function () {
const paused = await this.token.paused({ from }); (await this.token.paused({ from })).should.be.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 }); (await this.token.paused({ from })).should.be.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 () {
await this.token.pause({ from }); await this.token.pause({ from });
await this.token.unpause({ from }); await this.token.unpause({ from });
const paused = await this.token.paused(); (await this.token.paused()).should.be.false;
paused.should.be.false;
}); });
}); });
...@@ -116,11 +106,8 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -116,11 +106,8 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
it('allows to transfer when unpaused', async function () { it('allows to transfer when unpaused', async function () {
await this.token.transfer(recipient, 100, { from: owner }); await this.token.transfer(recipient, 100, { from: owner });
const senderBalance = await this.token.balanceOf(owner); (await this.token.balanceOf(owner)).should.be.bignumber.equal(0);
senderBalance.should.be.bignumber.equal(0); (await this.token.balanceOf(recipient)).should.be.bignumber.equal(100);
const recipientBalance = await this.token.balanceOf(recipient);
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 () {
...@@ -129,11 +116,8 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -129,11 +116,8 @@ 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); (await this.token.balanceOf(owner)).should.be.bignumber.equal(0);
senderBalance.should.be.bignumber.equal(0); (await this.token.balanceOf(recipient)).should.be.bignumber.equal(100);
const recipientBalance = await this.token.balanceOf(recipient);
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 () {
...@@ -147,8 +131,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -147,8 +131,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
it('allows to approve when unpaused', async function () { it('allows to approve when unpaused', async function () {
await this.token.approve(anotherAccount, 40, { from: owner }); await this.token.approve(anotherAccount, 40, { from: owner });
const allowance = await this.token.allowance(owner, anotherAccount); (await this.token.allowance(owner, anotherAccount)).should.be.bignumber.equal(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 () {
...@@ -157,8 +140,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -157,8 +140,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); (await this.token.allowance(owner, anotherAccount)).should.be.bignumber.equal(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 () {
...@@ -176,11 +158,8 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -176,11 +158,8 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
it('allows to transfer from when unpaused', async function () { it('allows to transfer from when unpaused', async function () {
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); (await this.token.balanceOf(owner)).should.be.bignumber.equal(60);
senderBalance.should.be.bignumber.equal(60); (await this.token.balanceOf(recipient)).should.be.bignumber.equal(40);
const recipientBalance = await this.token.balanceOf(recipient);
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 () {
...@@ -189,11 +168,8 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -189,11 +168,8 @@ 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); (await this.token.balanceOf(owner)).should.be.bignumber.equal(60);
senderBalance.should.be.bignumber.equal(60); (await this.token.balanceOf(recipient)).should.be.bignumber.equal(40);
const recipientBalance = await this.token.balanceOf(recipient);
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 () {
...@@ -211,8 +187,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -211,8 +187,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
it('allows to decrease approval when unpaused', async function () { it('allows to decrease approval when unpaused', async function () {
await this.token.decreaseApproval(anotherAccount, 40, { from: owner }); await this.token.decreaseApproval(anotherAccount, 40, { from: owner });
const allowance = await this.token.allowance(owner, anotherAccount); (await this.token.allowance(owner, anotherAccount)).should.be.bignumber.equal(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 () {
...@@ -221,8 +196,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -221,8 +196,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); (await this.token.allowance(owner, anotherAccount)).should.be.bignumber.equal(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 () {
...@@ -240,8 +214,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -240,8 +214,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
it('allows to increase approval when unpaused', async function () { it('allows to increase approval when unpaused', async function () {
await this.token.increaseApproval(anotherAccount, 40, { from: owner }); await this.token.increaseApproval(anotherAccount, 40, { from: owner });
const allowance = await this.token.allowance(owner, anotherAccount); (await this.token.allowance(owner, anotherAccount)).should.be.bignumber.equal(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 () {
...@@ -250,8 +223,7 @@ contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { ...@@ -250,8 +223,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); (await this.token.allowance(owner, anotherAccount)).should.be.bignumber.equal(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 () {
......
...@@ -6,12 +6,10 @@ function shouldBehaveLikeRBACMintableToken (owner, [anyone]) { ...@@ -6,12 +6,10 @@ function shouldBehaveLikeRBACMintableToken (owner, [anyone]) {
describe('handle roles', function () { describe('handle roles', function () {
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); (await this.token.hasRole(anyone, ROLE_MINTER)).should.be.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); (await this.token.hasRole(anyone, ROLE_MINTER)).should.be.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 () {
......
...@@ -45,23 +45,20 @@ contract('TokenTimelock', function ([_, owner, beneficiary]) { ...@@ -45,23 +45,20 @@ contract('TokenTimelock', function ([_, owner, beneficiary]) {
it('can be released just after limit', async function () { it('can be released just after limit', async function () {
await increaseTimeTo(this.releaseTime + duration.seconds(1)); await increaseTimeTo(this.releaseTime + duration.seconds(1));
await this.timelock.release(); await this.timelock.release();
const balance = await this.token.balanceOf(beneficiary); (await this.token.balanceOf(beneficiary)).should.be.bignumber.equal(amount);
balance.should.be.bignumber.equal(amount);
}); });
it('can be released after time limit', async function () { it('can be released after time limit', async function () {
await increaseTimeTo(this.releaseTime + duration.years(1)); await increaseTimeTo(this.releaseTime + duration.years(1));
await this.timelock.release(); await this.timelock.release();
const balance = await this.token.balanceOf(beneficiary); (await this.token.balanceOf(beneficiary)).should.be.bignumber.equal(amount);
balance.should.be.bignumber.equal(amount);
}); });
it('cannot be released twice', async function () { it('cannot be released twice', async function () {
await increaseTimeTo(this.releaseTime + duration.years(1)); await increaseTimeTo(this.releaseTime + duration.years(1));
await this.timelock.release(); await this.timelock.release();
await expectThrow(this.timelock.release()); await expectThrow(this.timelock.release());
const balance = await this.token.balanceOf(beneficiary); (await this.token.balanceOf(beneficiary)).should.be.bignumber.equal(amount);
balance.should.be.bignumber.equal(amount);
}); });
}); });
}); });
......
...@@ -67,8 +67,9 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { ...@@ -67,8 +67,9 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
const block = await ethGetBlock(receipt.blockNumber); const block = await ethGetBlock(receipt.blockNumber);
const releaseTime = block.timestamp; const releaseTime = block.timestamp;
const balance = await this.token.balanceOf(beneficiary); (await this.token.balanceOf(beneficiary)).should.bignumber.eq(
balance.should.bignumber.eq(amount.mul(releaseTime - this.start).div(this.duration).floor()); 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 () {
...@@ -80,18 +81,15 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { ...@@ -80,18 +81,15 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
await increaseTimeTo(now); await increaseTimeTo(now);
await this.vesting.release(this.token.address); await this.vesting.release(this.token.address);
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();
(await this.token.balanceOf(beneficiary)).should.bignumber.eq(expectedVesting);
balance.should.bignumber.eq(expectedVesting);
} }
}); });
it('should have released all after end', async function () { it('should have released all after end', async function () {
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); (await this.token.balanceOf(beneficiary)).should.bignumber.eq(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 () {
...@@ -116,8 +114,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { ...@@ -116,8 +114,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); (await this.token.balanceOf(owner)).should.bignumber.eq(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 () {
......
...@@ -28,15 +28,13 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -28,15 +28,13 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
describe('balanceOf', function () { describe('balanceOf', function () {
context('when the given address owns some tokens', function () { context('when the given address owns some tokens', function () {
it('returns the amount of tokens owned by the given address', async function () { it('returns the amount of tokens owned by the given address', async function () {
const balance = await this.token.balanceOf(creator); (await this.token.balanceOf(creator)).should.be.bignumber.equal(2);
balance.should.be.bignumber.equal(2);
}); });
}); });
context('when the given address does not own any tokens', function () { context('when the given address does not own any tokens', function () {
it('returns 0', async function () { it('returns 0', async function () {
const balance = await this.token.balanceOf(accounts[1]); (await this.token.balanceOf(accounts[1])).should.be.bignumber.equal(0);
balance.should.be.bignumber.equal(0);
}); });
}); });
...@@ -52,8 +50,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -52,8 +50,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
const tokenId = firstTokenId; const tokenId = firstTokenId;
it('returns the owner of the given token ID', async function () { it('returns the owner of the given token ID', async function () {
const owner = await this.token.ownerOf(tokenId); (await this.token.ownerOf(tokenId)).should.be.equal(creator);
owner.should.be.equal(creator);
}); });
}); });
...@@ -84,13 +81,11 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -84,13 +81,11 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
const transferWasSuccessful = function ({ owner, tokenId, approved }) { const transferWasSuccessful = function ({ owner, tokenId, approved }) {
it('transfers the ownership of the given token ID to the given address', async function () { it('transfers the ownership of the given token ID to the given address', async function () {
const newOwner = await this.token.ownerOf(tokenId); (await this.token.ownerOf(tokenId)).should.be.equal(this.to);
newOwner.should.be.equal(this.to);
}); });
it('clears the approval for the token ID', async function () { it('clears the approval for the token ID', async function () {
const approvedAccount = await this.token.getApproved(tokenId); (await this.token.getApproved(tokenId)).should.be.equal(ZERO_ADDRESS);
approvedAccount.should.be.equal(ZERO_ADDRESS);
}); });
if (approved) { if (approved) {
...@@ -112,21 +107,17 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -112,21 +107,17 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
} }
it('adjusts owners balances', async function () { it('adjusts owners balances', async function () {
const newOwnerBalance = await this.token.balanceOf(this.to); (await this.token.balanceOf(this.to)).should.be.bignumber.equal(1);
newOwnerBalance.should.be.bignumber.equal(1);
const previousOwnerBalance = await this.token.balanceOf(owner); (await this.token.balanceOf(owner)).should.be.bignumber.equal(1);
previousOwnerBalance.should.be.bignumber.equal(1);
}); });
it('adjusts owners tokens by index', async function () { it('adjusts owners tokens by index', async function () {
if (!this.token.tokenOfOwnerByIndex) return; if (!this.token.tokenOfOwnerByIndex) return;
const newOwnerToken = await this.token.tokenOfOwnerByIndex(this.to, 0); (await this.token.tokenOfOwnerByIndex(this.to, 0)).toNumber().should.be.equal(tokenId);
newOwnerToken.toNumber().should.be.equal(tokenId);
const previousOwnerToken = await this.token.tokenOfOwnerByIndex(owner, 0); (await this.token.tokenOfOwnerByIndex(owner, 0)).toNumber().should.not.be.eq(tokenId);
previousOwnerToken.toNumber().should.not.be.eq(tokenId);
}); });
}; };
...@@ -166,13 +157,11 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -166,13 +157,11 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
}); });
it('keeps ownership of the token', async function () { it('keeps ownership of the token', async function () {
const newOwner = await this.token.ownerOf(tokenId); (await this.token.ownerOf(tokenId)).should.be.equal(owner);
newOwner.should.be.equal(owner);
}); });
it('clears the approval for the token ID', async function () { it('clears the approval for the token ID', async function () {
const approvedAccount = await this.token.getApproved(tokenId); (await this.token.getApproved(tokenId)).should.be.equal(ZERO_ADDRESS);
approvedAccount.should.be.equal(ZERO_ADDRESS);
}); });
it('emits only a transfer event', async function () { it('emits only a transfer event', async function () {
...@@ -184,8 +173,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -184,8 +173,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
}); });
it('keeps the owner balance', async function () { it('keeps the owner balance', async function () {
const ownerBalance = await this.token.balanceOf(owner); (await this.token.balanceOf(owner)).should.be.bignumber.equal(2);
ownerBalance.should.be.bignumber.equal(2);
}); });
it('keeps same tokens by index', async function () { it('keeps same tokens by index', async function () {
...@@ -332,15 +320,13 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -332,15 +320,13 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
const itClearsApproval = function () { const itClearsApproval = function () {
it('clears approval for the token', async function () { it('clears approval for the token', async function () {
const approvedAccount = await this.token.getApproved(tokenId); (await this.token.getApproved(tokenId)).should.be.equal(ZERO_ADDRESS);
approvedAccount.should.be.equal(ZERO_ADDRESS);
}); });
}; };
const itApproves = function (address) { const itApproves = function (address) {
it('sets the approval for the target address', async function () { it('sets the approval for the target address', async function () {
const approvedAccount = await this.token.getApproved(tokenId); (await this.token.getApproved(tokenId)).should.be.equal(address);
approvedAccount.should.be.equal(address);
}); });
}; };
...@@ -453,8 +439,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -453,8 +439,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
it('approves the operator', async function () { it('approves the operator', async function () {
await this.token.setApprovalForAll(operator, true, { from: sender }); await this.token.setApprovalForAll(operator, true, { from: sender });
const isApproved = await this.token.isApprovedForAll(sender, operator); (await this.token.isApprovedForAll(sender, operator)).should.be.true;
isApproved.should.be.true;
}); });
it('emits an approval event', async function () { it('emits an approval event', async function () {
...@@ -476,8 +461,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -476,8 +461,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
it('approves the operator', async function () { it('approves the operator', async function () {
await this.token.setApprovalForAll(operator, true, { from: sender }); await this.token.setApprovalForAll(operator, true, { from: sender });
const isApproved = await this.token.isApprovedForAll(sender, operator); (await this.token.isApprovedForAll(sender, operator)).should.be.true;
isApproved.should.be.true;
}); });
it('emits an approval event', async function () { it('emits an approval event', async function () {
...@@ -493,8 +477,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -493,8 +477,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
it('can unset the operator approval', async function () { it('can unset the operator approval', async function () {
await this.token.setApprovalForAll(operator, false, { from: sender }); await this.token.setApprovalForAll(operator, false, { from: sender });
const isApproved = await this.token.isApprovedForAll(sender, operator); (await this.token.isApprovedForAll(sender, operator)).should.be.false;
isApproved.should.be.false;
}); });
}); });
...@@ -506,8 +489,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -506,8 +489,7 @@ function shouldBehaveLikeERC721BasicToken (accounts) {
it('keeps the approval to the given address', async function () { it('keeps the approval to the given address', async function () {
await this.token.setApprovalForAll(operator, true, { from: sender }); await this.token.setApprovalForAll(operator, true, { from: sender });
const isApproved = await this.token.isApprovedForAll(sender, operator); (await this.token.isApprovedForAll(sender, operator)).should.be.true;
isApproved.should.be.true;
}); });
it('emits an approval event', async function () { it('emits an approval event', async function () {
......
...@@ -30,13 +30,11 @@ function shouldBehaveLikeMintAndBurnERC721Token (accounts) { ...@@ -30,13 +30,11 @@ function shouldBehaveLikeMintAndBurnERC721Token (accounts) {
}); });
it('assigns the token to the new owner', async function () { it('assigns the token to the new owner', async function () {
const owner = await this.token.ownerOf(tokenId); (await this.token.ownerOf(tokenId)).should.be.equal(to);
owner.should.be.equal(to);
}); });
it('increases the balance of its owner', async function () { it('increases the balance of its owner', async function () {
const balance = await this.token.balanceOf(to); (await this.token.balanceOf(to)).should.be.bignumber.equal(1);
balance.should.be.bignumber.equal(1);
}); });
it('emits a transfer event', async function () { it('emits a transfer event', async function () {
...@@ -74,8 +72,7 @@ function shouldBehaveLikeMintAndBurnERC721Token (accounts) { ...@@ -74,8 +72,7 @@ function shouldBehaveLikeMintAndBurnERC721Token (accounts) {
it('burns the given token ID and adjusts the balance of the owner', async function () { it('burns the given token ID and adjusts the balance of the owner', async function () {
await assertRevert(this.token.ownerOf(tokenId)); await assertRevert(this.token.ownerOf(tokenId));
const balance = await this.token.balanceOf(sender); (await this.token.balanceOf(sender)).should.be.bignumber.equal(1);
balance.should.be.bignumber.equal(1);
}); });
it('emits a burn event', async function () { it('emits a burn event', async function () {
...@@ -95,8 +92,7 @@ function shouldBehaveLikeMintAndBurnERC721Token (accounts) { ...@@ -95,8 +92,7 @@ function shouldBehaveLikeMintAndBurnERC721Token (accounts) {
}); });
it('clears the approval', async function () { it('clears the approval', async function () {
const approvedAccount = await this.token.getApproved(tokenId); (await this.token.getApproved(tokenId)).should.be.equal(ZERO_ADDRESS);
approvedAccount.should.be.equal(ZERO_ADDRESS);
}); });
}); });
......
...@@ -42,13 +42,11 @@ contract('ERC721Token', function (accounts) { ...@@ -42,13 +42,11 @@ contract('ERC721Token', function (accounts) {
}); });
it('adjusts owner tokens by index', async function () { it('adjusts owner tokens by index', async function () {
const token = await this.token.tokenOfOwnerByIndex(to, 0); (await this.token.tokenOfOwnerByIndex(to, 0)).toNumber().should.be.equal(tokenId);
token.toNumber().should.be.equal(tokenId);
}); });
it('adjusts all tokens list', async function () { it('adjusts all tokens list', async function () {
const newToken = await this.token.tokenByIndex(2); (await this.token.tokenByIndex(2)).toNumber().should.be.equal(tokenId);
newToken.toNumber().should.be.equal(tokenId);
}); });
}); });
...@@ -61,19 +59,16 @@ contract('ERC721Token', function (accounts) { ...@@ -61,19 +59,16 @@ contract('ERC721Token', function (accounts) {
}); });
it('removes that token from the token list of the owner', async function () { it('removes that token from the token list of the owner', async function () {
const token = await this.token.tokenOfOwnerByIndex(sender, 0); (await this.token.tokenOfOwnerByIndex(sender, 0)).toNumber().should.be.equal(secondTokenId);
token.toNumber().should.be.equal(secondTokenId);
}); });
it('adjusts all tokens list', async function () { it('adjusts all tokens list', async function () {
const token = await this.token.tokenByIndex(0); (await this.token.tokenByIndex(0)).toNumber().should.be.equal(secondTokenId);
token.toNumber().should.be.equal(secondTokenId);
}); });
it('burns all tokens', async function () { it('burns all tokens', async function () {
await this.token.burn(secondTokenId, { from: sender }); await this.token.burn(secondTokenId, { from: sender });
const total = await this.token.totalSupply(); (await this.token.totalSupply()).toNumber().should.be.equal(0);
total.toNumber().should.be.equal(0);
await assertRevert(this.token.tokenByIndex(0)); await assertRevert(this.token.tokenByIndex(0));
}); });
}); });
...@@ -95,18 +90,15 @@ contract('ERC721Token', function (accounts) { ...@@ -95,18 +90,15 @@ contract('ERC721Token', function (accounts) {
}); });
it('adjusts token list', async function () { it('adjusts token list', async function () {
const token = await this.token.tokenOfOwnerByIndex(creator, 0); (await this.token.tokenOfOwnerByIndex(creator, 0)).toNumber().should.be.equal(secondTokenId);
token.toNumber().should.be.equal(secondTokenId);
}); });
it('adjusts owner count', async function () { it('adjusts owner count', async function () {
const count = await this.token.balanceOf(creator); (await this.token.balanceOf(creator)).toNumber().should.be.equal(1);
count.toNumber().should.be.equal(1);
}); });
it('does not adjust supply', async function () { it('does not adjust supply', async function () {
const total = await this.token.totalSupply(); (await this.token.totalSupply()).toNumber().should.be.equal(2);
total.toNumber().should.be.equal(2);
}); });
}); });
}); });
...@@ -115,19 +107,16 @@ contract('ERC721Token', function (accounts) { ...@@ -115,19 +107,16 @@ contract('ERC721Token', function (accounts) {
const sampleUri = 'mock://mytoken'; const sampleUri = 'mock://mytoken';
it('has a name', async function () { it('has a name', async function () {
const tokenName = await this.token.name(); (await this.token.name()).should.be.equal(name);
tokenName.should.be.equal(name);
}); });
it('has a symbol', async function () { it('has a symbol', async function () {
const tokenSymbol = await this.token.symbol(); (await this.token.symbol()).should.be.equal(symbol);
tokenSymbol.should.be.equal(symbol);
}); });
it('sets and returns metadata for a token id', async function () { it('sets and returns metadata for a token id', async function () {
await this.token.setTokenURI(firstTokenId, sampleUri); await this.token.setTokenURI(firstTokenId, sampleUri);
const uri = await this.token.tokenURI(firstTokenId); (await this.token.tokenURI(firstTokenId)).should.be.equal(sampleUri);
uri.should.be.equal(sampleUri);
}); });
it('reverts when setting metadata for non existent token id', async function () { it('reverts when setting metadata for non existent token id', async function () {
...@@ -137,13 +126,11 @@ contract('ERC721Token', function (accounts) { ...@@ -137,13 +126,11 @@ contract('ERC721Token', function (accounts) {
it('can burn token with metadata', async function () { it('can burn token with metadata', async function () {
await this.token.setTokenURI(firstTokenId, sampleUri); await this.token.setTokenURI(firstTokenId, sampleUri);
await this.token.burn(firstTokenId); await this.token.burn(firstTokenId);
const exists = await this.token.exists(firstTokenId); (await this.token.exists(firstTokenId)).should.be.false;
exists.should.be.false;
}); });
it('returns empty metadata for token', async function () { it('returns empty metadata for token', async function () {
const uri = await this.token.tokenURI(firstTokenId); (await this.token.tokenURI(firstTokenId)).should.be.equal('');
uri.should.be.equal('');
}); });
it('reverts when querying metadata for non existent token id', async function () { it('reverts when querying metadata for non existent token id', async function () {
...@@ -153,8 +140,7 @@ contract('ERC721Token', function (accounts) { ...@@ -153,8 +140,7 @@ contract('ERC721Token', function (accounts) {
describe('totalSupply', function () { describe('totalSupply', function () {
it('returns total token supply', async function () { it('returns total token supply', async function () {
const totalSupply = await this.token.totalSupply(); (await this.token.totalSupply()).should.be.bignumber.equal(2);
totalSupply.should.be.bignumber.equal(2);
}); });
}); });
...@@ -164,8 +150,7 @@ contract('ERC721Token', function (accounts) { ...@@ -164,8 +150,7 @@ contract('ERC721Token', function (accounts) {
describe('when the given index is lower than the amount of tokens owned by the given address', function () { describe('when the given index is lower than the amount of tokens owned by the given address', function () {
it('returns the token ID placed at the given index', async function () { it('returns the token ID placed at the given index', async function () {
const tokenId = await this.token.tokenOfOwnerByIndex(owner, 0); (await this.token.tokenOfOwnerByIndex(owner, 0)).should.be.bignumber.equal(firstTokenId);
tokenId.should.be.bignumber.equal(firstTokenId);
}); });
}); });
...@@ -188,15 +173,13 @@ contract('ERC721Token', function (accounts) { ...@@ -188,15 +173,13 @@ contract('ERC721Token', function (accounts) {
}); });
it('returns correct token IDs for target', async function () { it('returns correct token IDs for target', async function () {
const count = await this.token.balanceOf(another); (await this.token.balanceOf(another)).toNumber().should.be.equal(2);
count.toNumber().should.be.equal(2);
const tokensListed = await Promise.all(_.range(2).map(i => this.token.tokenOfOwnerByIndex(another, i))); const tokensListed = await Promise.all(_.range(2).map(i => this.token.tokenOfOwnerByIndex(another, i)));
tokensListed.map(t => t.toNumber()).should.have.members([firstTokenId, secondTokenId]); tokensListed.map(t => t.toNumber()).should.have.members([firstTokenId, secondTokenId]);
}); });
it('returns empty collection for original owner', async function () { it('returns empty collection for original owner', async function () {
const count = await this.token.balanceOf(owner); (await this.token.balanceOf(owner)).toNumber().should.be.equal(0);
count.toNumber().should.be.equal(0);
await assertRevert(this.token.tokenOfOwnerByIndex(owner, 0)); await assertRevert(this.token.tokenOfOwnerByIndex(owner, 0));
}); });
}); });
...@@ -222,8 +205,7 @@ contract('ERC721Token', function (accounts) { ...@@ -222,8 +205,7 @@ contract('ERC721Token', function (accounts) {
await this.token.mint(owner, newTokenId, { from: owner }); await this.token.mint(owner, newTokenId, { from: owner });
await this.token.mint(owner, anotherNewTokenId, { from: owner }); await this.token.mint(owner, anotherNewTokenId, { from: owner });
const count = await this.token.totalSupply(); (await this.token.totalSupply()).toNumber().should.be.equal(3);
count.toNumber().should.be.equal(3);
const tokensListed = await Promise.all(_.range(3).map(i => this.token.tokenByIndex(i))); const tokensListed = await Promise.all(_.range(3).map(i => this.token.tokenByIndex(i)));
const expectedTokens = _.filter( const expectedTokens = _.filter(
......
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