From dae0196ec22cbeec5207f31485042571e5ec5d87 Mon Sep 17 00:00:00 2001 From: RCYP Date: Fri, 31 May 2019 14:28:03 -0400 Subject: [PATCH 1/8] changed exxpect to expect wherever applicable --- test/access/Roles.test.js | 16 ++--- .../access/roles/PublicRole.behavior.js | 16 ++--- test/crowdsale/AllowanceCrowdsale.test.js | 12 ++-- test/crowdsale/CappedCrowdsale.test.js | 8 ++- test/crowdsale/Crowdsale.test.js | 10 ++-- .../IncreasingPriceCrowdsale.test.js | 24 ++++---- .../IndividuallyCappedCrowdsale.test.js | 8 ++- test/crowdsale/MintedCrowdsale.behavior.js | 6 +- test/crowdsale/MintedCrowdsale.test.js | 4 +- test/crowdsale/PostDeliveryCrowdsale.test.js | 10 ++-- test/crowdsale/RefundableCrowdsale.test.js | 6 +- .../RefundablePostDeliveryCrowdsale.test.js | 14 +++-- test/crowdsale/TimedCrowdsale.test.js | 20 ++++--- test/cryptography/ECDSA.test.js | 23 ++++---- test/cryptography/MerkleProof.test.js | 8 ++- test/drafts/Counters.test.js | 16 ++--- test/drafts/ERC1046/ERC20Metadata.test.js | 6 +- test/drafts/ERC20Migrator.test.js | 26 +++++---- test/drafts/ERC20Snapshot.test.js | 58 ++++++++++--------- test/drafts/SignatureBouncer.test.js | 48 +++++++-------- test/drafts/SignedSafeMath.test.js | 16 ++--- test/drafts/Strings.test.js | 8 ++- test/drafts/TokenVesting.test.js | 32 +++++----- test/examples/SampleCrowdsale.test.js | 22 +++---- test/examples/SimpleToken.test.js | 10 ++-- test/introspection/ERC165Checker.test.js | 36 ++++++------ test/introspection/ERC1820Implementer.test.js | 22 +++---- .../SupportsInterface.behavior.js | 8 ++- test/lifecycle/Pausable.test.js | 20 ++++--- test/math/Math.test.js | 16 ++--- test/math/SafeMath.test.js | 22 +++---- test/ownership/Ownable.behavior.js | 12 ++-- test/ownership/Secondary.test.js | 6 +- test/payment/PaymentSplitter.test.js | 26 +++++---- test/payment/PullPayment.test.js | 10 ++-- test/payment/escrow/Escrow.behavior.js | 22 +++---- test/payment/escrow/RefundEscrow.test.js | 12 ++-- test/token/ERC20/ERC20.behavior.js | 30 +++++----- test/token/ERC20/ERC20.test.js | 34 ++++++----- test/token/ERC20/ERC20Detailed.test.js | 8 ++- test/token/ERC20/ERC20Pausable.test.js | 40 +++++++------ test/token/ERC20/TokenTimelock.test.js | 14 +++-- .../ERC20/behaviors/ERC20Burnable.behavior.js | 8 ++- .../ERC20/behaviors/ERC20Capped.behavior.js | 6 +- .../ERC20/behaviors/ERC20Mintable.behavior.js | 4 +- test/token/ERC721/ERC721.behavior.js | 38 ++++++------ test/token/ERC721/ERC721.test.js | 10 ++-- test/token/ERC721/ERC721Full.test.js | 44 +++++++------- test/token/ERC721/ERC721Holder.test.js | 4 +- test/token/ERC721/ERC721MintBurn.behavior.js | 8 ++- .../ERC721/ERC721PausedToken.behavior.js | 12 ++-- test/token/ERC777/ERC777.behavior.js | 18 +++--- test/token/ERC777/ERC777.test.js | 58 ++++++++++--------- test/utils/Address.test.js | 32 +++------- test/utils/Arrays.test.js | 26 +++++---- test/utils/ReentrancyGuard.test.js | 4 +- 56 files changed, 566 insertions(+), 471 deletions(-) diff --git a/test/access/Roles.test.js b/test/access/Roles.test.js index 14898f85787..0b97e768a7c 100644 --- a/test/access/Roles.test.js +++ b/test/access/Roles.test.js @@ -1,6 +1,8 @@ const { expectRevert, constants } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + const RolesMock = artifacts.require('RolesMock'); contract('Roles', function ([_, authorized, otherAuthorized, other]) { @@ -14,16 +16,16 @@ contract('Roles', function ([_, authorized, otherAuthorized, other]) { context('initially', function () { it('doesn\'t pre-assign roles', async function () { - (await this.roles.has(authorized)).should.equal(false); - (await this.roles.has(otherAuthorized)).should.equal(false); - (await this.roles.has(other)).should.equal(false); + expect(await this.roles.has(authorized)).to.equal(false); + expect(await this.roles.has(otherAuthorized)).to.equal(false); + expect(await this.roles.has(other)).to.equal(false); }); describe('adding roles', function () { it('adds roles to a single account', async function () { await this.roles.add(authorized); - (await this.roles.has(authorized)).should.equal(true); - (await this.roles.has(other)).should.equal(false); + expect(await this.roles.has(authorized)).to.equal(true); + expect(await this.roles.has(other)).to.equal(false); }); it('reverts when adding roles to an already assigned account', async function () { @@ -46,8 +48,8 @@ contract('Roles', function ([_, authorized, otherAuthorized, other]) { describe('removing roles', function () { it('removes a single role', async function () { await this.roles.remove(authorized); - (await this.roles.has(authorized)).should.equal(false); - (await this.roles.has(otherAuthorized)).should.equal(true); + expect(await this.roles.has(authorized)).to.equal(false); + expect(await this.roles.has(otherAuthorized)).to.equal(true); }); it('reverts when removing unassigned roles', async function () { diff --git a/test/behaviors/access/roles/PublicRole.behavior.js b/test/behaviors/access/roles/PublicRole.behavior.js index 04844c3b2ef..35877e8d2a7 100644 --- a/test/behaviors/access/roles/PublicRole.behavior.js +++ b/test/behaviors/access/roles/PublicRole.behavior.js @@ -1,6 +1,8 @@ const { expectRevert, constants, expectEvent } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + function capitalize (str) { return str.replace(/\b\w/g, l => l.toUpperCase()); } @@ -25,9 +27,9 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen describe('should behave like public role', function () { beforeEach('check preconditions', async function () { - (await this.contract[`is${rolename}`](authorized)).should.equal(true); - (await this.contract[`is${rolename}`](otherAuthorized)).should.equal(true); - (await this.contract[`is${rolename}`](other)).should.equal(false); + expect(await this.contract[`is${rolename}`](authorized)).to.equal(true); + expect(await this.contract[`is${rolename}`](otherAuthorized)).to.equal(true); + expect(await this.contract[`is${rolename}`](other)).to.equal(false); }); if (manager === undefined) { // Managed roles are only assigned by the manager, and none are set at construction @@ -70,7 +72,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen context(`from ${manager ? 'the manager' : 'a role-haver'} account`, function () { it('adds role to a new account', async function () { await this.contract[`add${rolename}`](other, { from }); - (await this.contract[`is${rolename}`](other)).should.equal(true); + expect(await this.contract[`is${rolename}`](other)).to.equal(true); }); it(`emits a ${rolename}Added event`, async function () { @@ -99,8 +101,8 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen context(`from ${manager ? 'the manager' : 'any'} account`, function () { it('removes role from an already assigned account', async function () { await this.contract[`remove${rolename}`](authorized, { from }); - (await this.contract[`is${rolename}`](authorized)).should.equal(false); - (await this.contract[`is${rolename}`](otherAuthorized)).should.equal(true); + expect(await this.contract[`is${rolename}`](authorized)).to.equal(false); + expect(await this.contract[`is${rolename}`](otherAuthorized)).to.equal(true); }); it(`emits a ${rolename}Removed event`, async function () { @@ -125,7 +127,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen describe('renouncing roles', function () { it('renounces an assigned role', async function () { await this.contract[`renounce${rolename}`]({ from: authorized }); - (await this.contract[`is${rolename}`](authorized)).should.equal(false); + expect(await this.contract[`is${rolename}`](authorized)).to.equal(false); }); it(`emits a ${rolename}Removed event`, async function () { diff --git a/test/crowdsale/AllowanceCrowdsale.test.js b/test/crowdsale/AllowanceCrowdsale.test.js index 35cd18b8506..514c00135cf 100644 --- a/test/crowdsale/AllowanceCrowdsale.test.js +++ b/test/crowdsale/AllowanceCrowdsale.test.js @@ -1,6 +1,8 @@ const { balance, BN, constants, ether, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + const AllowanceCrowdsaleImpl = artifacts.require('AllowanceCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); @@ -18,7 +20,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW describe('accepting payments', function () { it('should have token wallet', async function () { - (await this.crowdsale.tokenWallet()).should.be.equal(tokenWallet); + expect(await this.crowdsale.tokenWallet()).to.equal(tokenWallet); }); it('should accept sends', async function () { @@ -43,13 +45,13 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW it('should assign tokens to sender', async function () { await this.crowdsale.sendTransaction({ value: value, from: investor }); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(expectedTokenAmount); }); it('should forward funds to wallet', async function () { const balanceTracker = await balance.tracker(wallet); await this.crowdsale.sendTransaction({ value, from: investor }); - (await balanceTracker.delta()).should.be.bignumber.equal(value); + expect(await balanceTracker.delta()).to.be.bignumber.equal(value); }); }); @@ -57,7 +59,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW it('should report correct allowance left', async function () { const remainingAllowance = tokenAllowance.sub(expectedTokenAmount); await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }); - (await this.crowdsale.remainingTokens()).should.be.bignumber.equal(remainingAllowance); + expect(await this.crowdsale.remainingTokens()).to.be.bignumber.equal(remainingAllowance); }); context('when the allowance is larger than the token amount', function () { @@ -67,7 +69,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW }); it('should report the amount instead of the allowance', async function () { - (await this.crowdsale.remainingTokens()).should.be.bignumber.equal(await this.token.balanceOf(tokenWallet)); + expect(await this.crowdsale.remainingTokens()).to.be.bignumber.equal(await this.token.balanceOf(tokenWallet)); }); }); }); diff --git a/test/crowdsale/CappedCrowdsale.test.js b/test/crowdsale/CappedCrowdsale.test.js index bd5ec00f26a..5078bbe09e4 100644 --- a/test/crowdsale/CappedCrowdsale.test.js +++ b/test/crowdsale/CappedCrowdsale.test.js @@ -1,5 +1,7 @@ const { BN, ether, expectRevert } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const CappedCrowdsaleImpl = artifacts.require('CappedCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); @@ -44,17 +46,17 @@ contract('CappedCrowdsale', function ([_, wallet]) { describe('ending', function () { it('should not reach cap if sent under cap', async function () { await this.crowdsale.send(lessThanCap); - (await this.crowdsale.capReached()).should.equal(false); + expect(await this.crowdsale.capReached()).to.equal(false); }); it('should not reach cap if sent just under cap', async function () { await this.crowdsale.send(cap.subn(1)); - (await this.crowdsale.capReached()).should.equal(false); + expect(await this.crowdsale.capReached()).to.equal(false); }); it('should reach cap if cap sent', async function () { await this.crowdsale.send(cap); - (await this.crowdsale.capReached()).should.equal(true); + expect(await this.crowdsale.capReached()).to.equal(true); }); }); }); diff --git a/test/crowdsale/Crowdsale.test.js b/test/crowdsale/Crowdsale.test.js index f0923d477e1..1f751ad6618 100644 --- a/test/crowdsale/Crowdsale.test.js +++ b/test/crowdsale/Crowdsale.test.js @@ -1,6 +1,8 @@ const { balance, BN, constants, ether, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + const Crowdsale = artifacts.require('CrowdsaleMock'); const SimpleToken = artifacts.require('SimpleToken'); @@ -86,13 +88,13 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { it('should assign tokens to sender', async function () { await this.crowdsale.sendTransaction({ value: value, from: investor }); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(expectedTokenAmount); }); it('should forward funds to wallet', async function () { const balanceTracker = await balance.tracker(wallet); await this.crowdsale.sendTransaction({ value, from: investor }); - (await balanceTracker.delta()).should.be.bignumber.equal(value); + expect(await balanceTracker.delta()).to.be.bignumber.equal(value); }); }); @@ -109,13 +111,13 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { it('should assign tokens to beneficiary', async function () { await this.crowdsale.buyTokens(investor, { value, from: purchaser }); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(expectedTokenAmount); }); it('should forward funds to wallet', async function () { const balanceTracker = await balance.tracker(wallet); await this.crowdsale.buyTokens(investor, { value, from: purchaser }); - (await balanceTracker.delta()).should.be.bignumber.equal(value); + expect(await balanceTracker.delta()).to.be.bignumber.equal(value); }); }); }); diff --git a/test/crowdsale/IncreasingPriceCrowdsale.test.js b/test/crowdsale/IncreasingPriceCrowdsale.test.js index 5d1fdb7bf1b..94e6b121b6f 100644 --- a/test/crowdsale/IncreasingPriceCrowdsale.test.js +++ b/test/crowdsale/IncreasingPriceCrowdsale.test.js @@ -1,5 +1,7 @@ const { BN, ether, expectRevert, time } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const IncreasingPriceCrowdsaleImpl = artifacts.require('IncreasingPriceCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); @@ -52,8 +54,8 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) }); it('should have initial and final rate', async function () { - (await this.crowdsale.initialRate()).should.be.bignumber.equal(initialRate); - (await this.crowdsale.finalRate()).should.be.bignumber.equal(finalRate); + expect(await this.crowdsale.initialRate()).to.be.bignumber.equal(initialRate); + expect(await this.crowdsale.finalRate()).to.be.bignumber.equal(finalRate); }); it('reverts when the base Crowdsale\'s rate function is called', async function () { @@ -63,54 +65,54 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) }); it('returns a rate of 0 before the crowdsale starts', async function () { - (await this.crowdsale.getCurrentRate()).should.be.bignumber.equal('0'); + expect(await this.crowdsale.getCurrentRate()).to.be.bignumber.equal('0'); }); it('returns a rate of 0 after the crowdsale ends', async function () { await time.increaseTo(this.afterClosingTime); - (await this.crowdsale.getCurrentRate()).should.be.bignumber.equal('0'); + expect(await this.crowdsale.getCurrentRate()).to.be.bignumber.equal('0'); }); it('at start', async function () { await time.increaseTo(this.startTime); await this.crowdsale.buyTokens(investor, { value, from: purchaser }); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(initialRate)); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(initialRate)); }); it('at time 150', async function () { await time.increaseTo(this.startTime.addn(150)); await this.crowdsale.buyTokens(investor, { value, from: purchaser }); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime150)); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(rateAtTime150)); }); it('at time 300', async function () { await time.increaseTo(this.startTime.addn(300)); await this.crowdsale.buyTokens(investor, { value, from: purchaser }); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime300)); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(rateAtTime300)); }); it('at time 1500', async function () { await time.increaseTo(this.startTime.addn(1500)); await this.crowdsale.buyTokens(investor, { value, from: purchaser }); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime1500)); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(rateAtTime1500)); }); it('at time 30', async function () { await time.increaseTo(this.startTime.addn(30)); await this.crowdsale.buyTokens(investor, { value, from: purchaser }); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime30)); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(rateAtTime30)); }); it('at time 150000', async function () { await time.increaseTo(this.startTime.addn(150000)); await this.crowdsale.buyTokens(investor, { value, from: purchaser }); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime150000)); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(rateAtTime150000)); }); it('at time 450000', async function () { await time.increaseTo(this.startTime.addn(450000)); await this.crowdsale.buyTokens(investor, { value, from: purchaser }); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime450000)); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(rateAtTime450000)); }); }); }); diff --git a/test/crowdsale/IndividuallyCappedCrowdsale.test.js b/test/crowdsale/IndividuallyCappedCrowdsale.test.js index f5ebb29ce1a..73dba0af2e0 100644 --- a/test/crowdsale/IndividuallyCappedCrowdsale.test.js +++ b/test/crowdsale/IndividuallyCappedCrowdsale.test.js @@ -1,5 +1,7 @@ const { BN, ether, expectRevert } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const IndividuallyCappedCrowdsaleImpl = artifacts.require('IndividuallyCappedCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); const { shouldBehaveLikePublicRole } = require('../behaviors/access/roles/PublicRole.behavior'); @@ -30,7 +32,7 @@ contract('IndividuallyCappedCrowdsale', function ( describe('individual caps', function () { it('sets a cap when the sender is a capper', async function () { await this.crowdsale.setCap(alice, capAlice, { from: capper }); - (await this.crowdsale.getCap(alice)).should.be.bignumber.equal(capAlice); + expect(await this.crowdsale.getCap(alice)).to.be.bignumber.equal(capAlice); }); it('reverts when a non-capper sets a cap', async function () { @@ -84,12 +86,12 @@ contract('IndividuallyCappedCrowdsale', function ( describe('reporting state', function () { it('should report correct cap', async function () { - (await this.crowdsale.getCap(alice)).should.be.bignumber.equal(capAlice); + expect(await this.crowdsale.getCap(alice)).to.be.bignumber.equal(capAlice); }); it('should report actual contribution', async function () { await this.crowdsale.buyTokens(alice, { value: lessThanCapAlice }); - (await this.crowdsale.getContribution(alice)).should.be.bignumber.equal(lessThanCapAlice); + expect(await this.crowdsale.getContribution(alice)).to.be.bignumber.equal(lessThanCapAlice); }); }); }); diff --git a/test/crowdsale/MintedCrowdsale.behavior.js b/test/crowdsale/MintedCrowdsale.behavior.js index 2389bebe79b..5010ce89928 100644 --- a/test/crowdsale/MintedCrowdsale.behavior.js +++ b/test/crowdsale/MintedCrowdsale.behavior.js @@ -1,5 +1,7 @@ const { balance, expectEvent } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate, value) { const expectedTokenAmount = rate.mul(value); @@ -24,13 +26,13 @@ function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate it('should assign tokens to sender', async function () { await this.crowdsale.sendTransaction({ value: value, from: investor }); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(expectedTokenAmount); }); it('should forward funds to wallet', async function () { const balanceTracker = await balance.tracker(wallet); await this.crowdsale.sendTransaction({ value, from: investor }); - (await balanceTracker.delta()).should.be.bignumber.equal(value); + expect(await balanceTracker.delta()).to.be.bignumber.equal(value); }); }); }); diff --git a/test/crowdsale/MintedCrowdsale.test.js b/test/crowdsale/MintedCrowdsale.test.js index d323fe1c97d..9322a73d47d 100644 --- a/test/crowdsale/MintedCrowdsale.test.js +++ b/test/crowdsale/MintedCrowdsale.test.js @@ -1,6 +1,8 @@ const { BN, ether, expectRevert } = require('openzeppelin-test-helpers'); const { shouldBehaveLikeMintedCrowdsale } = require('./MintedCrowdsale.behavior'); +const { expect } = require('chai'); + const MintedCrowdsaleImpl = artifacts.require('MintedCrowdsaleImpl'); const ERC20Mintable = artifacts.require('ERC20Mintable'); const ERC20 = artifacts.require('ERC20'); @@ -19,7 +21,7 @@ contract('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser] }); it('crowdsale should be minter', async function () { - (await this.token.isMinter(this.crowdsale.address)).should.equal(true); + expect(await this.token.isMinter(this.crowdsale.address)).to.equal(true); }); shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value); diff --git a/test/crowdsale/PostDeliveryCrowdsale.test.js b/test/crowdsale/PostDeliveryCrowdsale.test.js index 7858e093dbb..129cb07890a 100644 --- a/test/crowdsale/PostDeliveryCrowdsale.test.js +++ b/test/crowdsale/PostDeliveryCrowdsale.test.js @@ -1,5 +1,7 @@ const { BN, ether, expectRevert, time } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const PostDeliveryCrowdsaleImpl = artifacts.require('PostDeliveryCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); @@ -36,8 +38,8 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { }); it('does not immediately assign tokens to beneficiaries', async function () { - (await this.crowdsale.balanceOf(investor)).should.be.bignumber.equal(value); - (await this.token.balanceOf(investor)).should.be.bignumber.equal('0'); + expect(await this.crowdsale.balanceOf(investor)).to.be.bignumber.equal(value); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal('0'); }); it('does not allow beneficiaries to withdraw tokens before crowdsale ends', async function () { @@ -53,8 +55,8 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { it('allows beneficiaries to withdraw tokens', async function () { await this.crowdsale.withdrawTokens(investor); - (await this.crowdsale.balanceOf(investor)).should.be.bignumber.equal('0'); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(value); + expect(await this.crowdsale.balanceOf(investor)).to.be.bignumber.equal('0'); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value); }); it('rejects multiple withdrawals', async function () { diff --git a/test/crowdsale/RefundableCrowdsale.test.js b/test/crowdsale/RefundableCrowdsale.test.js index 1620f55a648..e8602cf445d 100644 --- a/test/crowdsale/RefundableCrowdsale.test.js +++ b/test/crowdsale/RefundableCrowdsale.test.js @@ -1,5 +1,7 @@ const { balance, BN, ether, expectRevert, time } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const RefundableCrowdsaleImpl = artifacts.require('RefundableCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); @@ -72,7 +74,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, other it('refunds', async function () { const balanceTracker = await balance.tracker(investor); await this.crowdsale.claimRefund(investor, { gasPrice: 0 }); - (await balanceTracker.delta()).should.be.bignumber.equal(lessThanGoal); + expect(await balanceTracker.delta()).to.be.bignumber.equal(lessThanGoal); }); }); }); @@ -96,7 +98,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, other it('forwards funds to wallet', async function () { const postWalletBalance = await balance.current(wallet); - postWalletBalance.sub(this.preWalletBalance).should.be.bignumber.equal(goal); + expect(postWalletBalance.sub(this.preWalletBalance)).to.be.bignumber.equal(goal); }); }); }); diff --git a/test/crowdsale/RefundablePostDeliveryCrowdsale.test.js b/test/crowdsale/RefundablePostDeliveryCrowdsale.test.js index 8644c94aed6..4bb24403480 100644 --- a/test/crowdsale/RefundablePostDeliveryCrowdsale.test.js +++ b/test/crowdsale/RefundablePostDeliveryCrowdsale.test.js @@ -1,5 +1,7 @@ const { BN, ether, expectRevert, time } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const RefundablePostDeliveryCrowdsaleImpl = artifacts.require('RefundablePostDeliveryCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); @@ -37,8 +39,8 @@ contract('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, purc }); it('does not immediately deliver tokens to beneficiaries', async function () { - (await this.crowdsale.balanceOf(investor)).should.be.bignumber.equal(value); - (await this.token.balanceOf(investor)).should.be.bignumber.equal('0'); + expect(await this.crowdsale.balanceOf(investor)).to.be.bignumber.equal(value); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal('0'); }); it('does not allow beneficiaries to withdraw tokens before crowdsale ends', async function () { @@ -69,8 +71,8 @@ contract('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, purc }); it('does not immediately deliver tokens to beneficiaries', async function () { - (await this.crowdsale.balanceOf(investor)).should.be.bignumber.equal(value); - (await this.token.balanceOf(investor)).should.be.bignumber.equal('0'); + expect(await this.crowdsale.balanceOf(investor)).to.be.bignumber.equal(value); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal('0'); }); it('does not allow beneficiaries to withdraw tokens before crowdsale ends', async function () { @@ -87,8 +89,8 @@ contract('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, purc it('allows beneficiaries to withdraw tokens', async function () { await this.crowdsale.withdrawTokens(investor); - (await this.crowdsale.balanceOf(investor)).should.be.bignumber.equal('0'); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(value); + expect(await this.crowdsale.balanceOf(investor)).to.be.bignumber.equal('0'); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value); }); it('rejects multiple withdrawals', async function () { diff --git a/test/crowdsale/TimedCrowdsale.test.js b/test/crowdsale/TimedCrowdsale.test.js index d29ca1db904..5f1b59c821f 100644 --- a/test/crowdsale/TimedCrowdsale.test.js +++ b/test/crowdsale/TimedCrowdsale.test.js @@ -1,5 +1,7 @@ const { BN, ether, expectEvent, expectRevert, time } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const TimedCrowdsaleImpl = artifacts.require('TimedCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); @@ -47,15 +49,15 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { }); it('should be ended only after end', async function () { - (await this.crowdsale.hasClosed()).should.equal(false); + expect(await this.crowdsale.hasClosed()).to.equal(false); await time.increaseTo(this.afterClosingTime); - (await this.crowdsale.isOpen()).should.equal(false); - (await this.crowdsale.hasClosed()).should.equal(true); + expect(await this.crowdsale.isOpen()).to.equal(false); + expect(await this.crowdsale.hasClosed()).to.equal(true); }); describe('accepting payments', function () { it('should reject payments before start', async function () { - (await this.crowdsale.isOpen()).should.equal(false); + expect(await this.crowdsale.isOpen()).to.equal(false); await expectRevert(this.crowdsale.send(value), 'TimedCrowdsale: not open'); await expectRevert(this.crowdsale.buyTokens(investor, { from: purchaser, value: value }), 'TimedCrowdsale: not open' @@ -64,7 +66,7 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { it('should accept payments after start', async function () { await time.increaseTo(this.openingTime); - (await this.crowdsale.isOpen()).should.equal(true); + expect(await this.crowdsale.isOpen()).to.equal(true); await this.crowdsale.send(value); await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }); }); @@ -94,7 +96,7 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { context('before crowdsale start', function () { beforeEach(async function () { - (await this.crowdsale.isOpen()).should.equal(false); + expect(await this.crowdsale.isOpen()).to.equal(false); await expectRevert(this.crowdsale.send(value), 'TimedCrowdsale: not open'); }); @@ -105,14 +107,14 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { prevClosingTime: this.closingTime, newClosingTime: newClosingTime, }); - (await this.crowdsale.closingTime()).should.be.bignumber.equal(newClosingTime); + expect(await this.crowdsale.closingTime()).to.be.bignumber.equal(newClosingTime); }); }); context('after crowdsale start', function () { beforeEach(async function () { await time.increaseTo(this.openingTime); - (await this.crowdsale.isOpen()).should.equal(true); + expect(await this.crowdsale.isOpen()).to.equal(true); await this.crowdsale.send(value); }); @@ -123,7 +125,7 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { prevClosingTime: this.closingTime, newClosingTime: newClosingTime, }); - (await this.crowdsale.closingTime()).should.be.bignumber.equal(newClosingTime); + expect(await this.crowdsale.closingTime()).to.be.bignumber.equal(newClosingTime); }); }); diff --git a/test/cryptography/ECDSA.test.js b/test/cryptography/ECDSA.test.js index 9258288b383..8ddb73700ec 100644 --- a/test/cryptography/ECDSA.test.js +++ b/test/cryptography/ECDSA.test.js @@ -2,6 +2,8 @@ const { constants, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; const { toEthSignedMessageHash, fixSignature } = require('../helpers/sign'); +const { expect } = require('chai'); + const ECDSAMock = artifacts.require('ECDSAMock'); const TEST_MESSAGE = web3.utils.sha3('OpenZeppelin'); @@ -23,7 +25,7 @@ contract('ECDSA', function ([_, other]) { it('returns 0', async function () { const version = '00'; const signature = signatureWithoutVersion + version; - (await this.ecdsa.recover(TEST_MESSAGE, signature)).should.equal(ZERO_ADDRESS); + expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(ZERO_ADDRESS); }); }); @@ -31,7 +33,7 @@ contract('ECDSA', function ([_, other]) { it('works', async function () { const version = '1b'; // 27 = 1b. const signature = signatureWithoutVersion + version; - (await this.ecdsa.recover(TEST_MESSAGE, signature)).should.equal(signer); + expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(signer); }); }); @@ -41,7 +43,7 @@ contract('ECDSA', function ([_, other]) { // The only valid values are 0, 1, 27 and 28. const version = '02'; const signature = signatureWithoutVersion + version; - (await this.ecdsa.recover(TEST_MESSAGE, signature)).should.equal(ZERO_ADDRESS); + expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(ZERO_ADDRESS); }); }); }); @@ -55,7 +57,7 @@ contract('ECDSA', function ([_, other]) { it('returns 0', async function () { const version = '01'; const signature = signatureWithoutVersion + version; - (await this.ecdsa.recover(TEST_MESSAGE, signature)).should.equal(ZERO_ADDRESS); + expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(ZERO_ADDRESS); }); }); @@ -63,7 +65,7 @@ contract('ECDSA', function ([_, other]) { it('works', async function () { const version = '1c'; // 28 = 1c. const signature = signatureWithoutVersion + version; - (await this.ecdsa.recover(TEST_MESSAGE, signature)).should.equal(signer); + expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(signer); }); }); @@ -73,7 +75,7 @@ contract('ECDSA', function ([_, other]) { // The only valid values are 0, 1, 27 and 28. const version = '02'; const signature = signatureWithoutVersion + version; - (await this.ecdsa.recover(TEST_MESSAGE, signature)).should.equal(ZERO_ADDRESS); + expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(ZERO_ADDRESS); }); }); }); @@ -84,7 +86,7 @@ contract('ECDSA', function ([_, other]) { // eslint-disable-next-line max-len const highSSignature = '0xe742ff452d41413616a5bf43fe15dd88294e983d3d36206c2712f39083d638bde0a0fc89be718fbc1033e1d30d78be1c68081562ed2e97af876f286f3453231d1b'; - (await this.ecdsa.recover(message, highSSignature)).should.equal(ZERO_ADDRESS); + expect(await this.ecdsa.recover(message, highSSignature)).to.equal(ZERO_ADDRESS); }); }); @@ -95,10 +97,10 @@ contract('ECDSA', function ([_, other]) { const signature = fixSignature(await web3.eth.sign(TEST_MESSAGE, other)); // Recover the signer address from the generated message and signature. - (await this.ecdsa.recover( + expect(await this.ecdsa.recover( toEthSignedMessageHash(TEST_MESSAGE), signature - )).should.equal(other); + )).to.equal(other); }); }); @@ -108,7 +110,7 @@ contract('ECDSA', function ([_, other]) { const signature = await web3.eth.sign(TEST_MESSAGE, other); // Recover the signer address from the generated message and wrong signature. - (await this.ecdsa.recover(WRONG_MESSAGE, signature)).should.not.equal(other); + expect(await this.ecdsa.recover(WRONG_MESSAGE, signature)).to.not.equal(other); }); }); }); @@ -129,6 +131,7 @@ contract('ECDSA', function ([_, other]) { context('toEthSignedMessage', function () { it('should prefix hashes correctly', async function () { (await this.ecdsa.toEthSignedMessageHash(TEST_MESSAGE)).should.equal(toEthSignedMessageHash(TEST_MESSAGE)); + expect(await this.ecdsa.toEthSignedMessageHash(TEST_MESSAGE)).to.equal(toEthSignedMessageHash(TEST_MESSAGE)); }); }); }); diff --git a/test/cryptography/MerkleProof.test.js b/test/cryptography/MerkleProof.test.js index b3b14d89bbe..0b14f87a554 100644 --- a/test/cryptography/MerkleProof.test.js +++ b/test/cryptography/MerkleProof.test.js @@ -3,6 +3,8 @@ require('openzeppelin-test-helpers'); const { MerkleTree } = require('../helpers/merkleTree.js'); const { keccak256, bufferToHex } = require('ethereumjs-util'); +const { expect } = require('chai'); + const MerkleProofWrapper = artifacts.require('MerkleProofWrapper'); contract('MerkleProof', function () { @@ -21,7 +23,7 @@ contract('MerkleProof', function () { const leaf = bufferToHex(keccak256(elements[0])); - (await this.merkleProof.verify(proof, root, leaf)).should.equal(true); + expect(await this.merkleProof.verify(proof, root, leaf)).to.equal(true); }); it('should return false for an invalid Merkle proof', async function () { @@ -37,7 +39,7 @@ contract('MerkleProof', function () { const badProof = badMerkleTree.getHexProof(badElements[0]); - (await this.merkleProof.verify(badProof, correctRoot, correctLeaf)).should.equal(false); + expect(await this.merkleProof.verify(badProof, correctRoot, correctLeaf)).to.equal(false); }); it('should return false for a Merkle proof of invalid length', async function () { @@ -51,7 +53,7 @@ contract('MerkleProof', function () { const leaf = bufferToHex(keccak256(elements[0])); - (await this.merkleProof.verify(badProof, root, leaf)).should.equal(false); + expect(await this.merkleProof.verify(badProof, root, leaf)).to.equal(false); }); }); }); diff --git a/test/drafts/Counters.test.js b/test/drafts/Counters.test.js index 51e2903e02c..d1e8c558a8b 100644 --- a/test/drafts/Counters.test.js +++ b/test/drafts/Counters.test.js @@ -1,5 +1,7 @@ const { expectRevert } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const CountersImpl = artifacts.require('CountersImpl'); contract('Counters', function () { @@ -8,13 +10,13 @@ contract('Counters', function () { }); it('starts at zero', async function () { - (await this.counter.current()).should.be.bignumber.equal('0'); + expect(await this.counter.current()).to.be.bignumber.equal('0'); }); describe('increment', function () { it('increments the current value by one', async function () { await this.counter.increment(); - (await this.counter.current()).should.be.bignumber.equal('1'); + expect(await this.counter.current()).to.be.bignumber.equal('1'); }); it('can be called multiple times', async function () { @@ -22,19 +24,19 @@ contract('Counters', function () { await this.counter.increment(); await this.counter.increment(); - (await this.counter.current()).should.be.bignumber.equal('3'); + expect(await this.counter.current()).to.be.bignumber.equal('3'); }); }); describe('decrement', function () { beforeEach(async function () { await this.counter.increment(); - (await this.counter.current()).should.be.bignumber.equal('1'); + expect(await this.counter.current()).to.be.bignumber.equal('1'); }); it('decrements the current value by one', async function () { await this.counter.decrement(); - (await this.counter.current()).should.be.bignumber.equal('0'); + expect(await this.counter.current()).to.be.bignumber.equal('0'); }); it('reverts if the current value is 0', async function () { @@ -46,13 +48,13 @@ contract('Counters', function () { await this.counter.increment(); await this.counter.increment(); - (await this.counter.current()).should.be.bignumber.equal('3'); + expect(await this.counter.current()).to.be.bignumber.equal('3'); await this.counter.decrement(); await this.counter.decrement(); await this.counter.decrement(); - (await this.counter.current()).should.be.bignumber.equal('0'); + expect(await this.counter.current()).to.be.bignumber.equal('0'); }); }); }); diff --git a/test/drafts/ERC1046/ERC20Metadata.test.js b/test/drafts/ERC1046/ERC20Metadata.test.js index 0f0ae49110a..5b16694c1a9 100644 --- a/test/drafts/ERC1046/ERC20Metadata.test.js +++ b/test/drafts/ERC1046/ERC20Metadata.test.js @@ -2,6 +2,8 @@ require('openzeppelin-test-helpers'); const ERC20MetadataMock = artifacts.require('ERC20MetadataMock'); +const { expect } = require('chai'); + const metadataURI = 'https://example.com'; describe('ERC20Metadata', function () { @@ -10,14 +12,14 @@ describe('ERC20Metadata', function () { }); it('responds with the metadata', async function () { - (await this.token.tokenURI()).should.equal(metadataURI); + expect(await this.token.tokenURI()).to.equal(metadataURI); }); describe('setTokenURI', function () { it('changes the original URI', async function () { const newMetadataURI = 'https://betterexample.com'; await this.token.setTokenURI(newMetadataURI); - (await this.token.tokenURI()).should.equal(newMetadataURI); + expect(await this.token.tokenURI()).to.equal(newMetadataURI); }); }); }); diff --git a/test/drafts/ERC20Migrator.test.js b/test/drafts/ERC20Migrator.test.js index 4c3cd51e3ff..33de43c6d33 100644 --- a/test/drafts/ERC20Migrator.test.js +++ b/test/drafts/ERC20Migrator.test.js @@ -1,6 +1,8 @@ const { BN, constants, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + const ERC20Mock = artifacts.require('ERC20Mock'); const ERC20Mintable = artifacts.require('ERC20Mintable'); const ERC20Migrator = artifacts.require('ERC20Migrator'); @@ -22,7 +24,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { }); it('returns legacy token', async function () { - (await this.migrator.legacyToken()).should.be.equal(this.legacyToken.address); + expect(await this.migrator.legacyToken()).to.equal(this.legacyToken.address); }); describe('beginMigration', function () { @@ -54,7 +56,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { context('before starting the migration', function () { it('returns the zero address for the new token', async function () { - (await this.migrator.newToken()).should.be.equal(ZERO_ADDRESS); + expect(await this.migrator.newToken()).to.equal(ZERO_ADDRESS); }); describe('migrateAll', function () { @@ -97,7 +99,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { }); it('returns new token', async function () { - (await this.migrator.newToken()).should.be.equal(this.newToken.address); + expect(await this.migrator.newToken()).to.equal(this.newToken.address); }); describe('migrateAll', function () { @@ -117,20 +119,20 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { it('mints the same balance of the new token', async function () { const currentBalance = await this.newToken.balanceOf(owner); - currentBalance.should.be.bignumber.equal(amount); + expect(currentBalance).to.be.bignumber.equal(amount); }); it('burns a given amount of old tokens', async function () { const currentBurnedBalance = await this.legacyToken.balanceOf(this.migrator.address); - currentBurnedBalance.should.be.bignumber.equal(amount); + expect(currentBurnedBalance).to.be.bignumber.equal(amount); const currentLegacyTokenBalance = await this.legacyToken.balanceOf(owner); - currentLegacyTokenBalance.should.be.bignumber.equal('0'); + expect(currentLegacyTokenBalance).to.be.bignumber.equal('0'); }); it('updates the total supply', async function () { const currentSupply = await this.newToken.totalSupply(); - currentSupply.should.be.bignumber.equal(amount); + expect(currentSupply).to.be.bignumber.equal(amount); }); }); @@ -144,7 +146,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { it('migrates only approved amount', async function () { const currentBalance = await this.newToken.balanceOf(owner); - currentBalance.should.be.bignumber.equal(amount); + expect(currentBalance).to.be.bignumber.equal(amount); }); }); }); @@ -165,20 +167,20 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { it('mints that amount of the new token', async function () { const currentBalance = await this.newToken.balanceOf(owner); - currentBalance.should.be.bignumber.equal(amount); + expect(currentBalance).to.be.bignumber.equal(amount); }); it('burns a given amount of old tokens', async function () { const currentBurnedBalance = await this.legacyToken.balanceOf(this.migrator.address); - currentBurnedBalance.should.be.bignumber.equal(amount); + expect(currentBurnedBalance).to.be.bignumber.equal(amount); const currentLegacyTokenBalance = await this.legacyToken.balanceOf(owner); - currentLegacyTokenBalance.should.be.bignumber.equal(totalSupply.sub(amount)); + expect(currentLegacyTokenBalance).to.be.bignumber.equal(totalSupply.sub(amount)); }); it('updates the total supply', async function () { const currentSupply = await this.newToken.totalSupply(); - currentSupply.should.be.bignumber.equal(amount); + expect(currentSupply).to.be.bignumber.equal(amount); }); }); diff --git a/test/drafts/ERC20Snapshot.test.js b/test/drafts/ERC20Snapshot.test.js index 9fc034f4750..70ea69a0e2c 100644 --- a/test/drafts/ERC20Snapshot.test.js +++ b/test/drafts/ERC20Snapshot.test.js @@ -1,6 +1,8 @@ const { BN, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const ERC20SnapshotMock = artifacts.require('ERC20SnapshotMock'); +const { expect } = require('chai'); + contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { const initialSupply = new BN(100); @@ -41,7 +43,7 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { context('with no supply changes after the snapshot', function () { it('returns the current total supply', async function () { - (await this.token.totalSupplyAt(this.initialSnapshotId)).should.be.bignumber.equal(initialSupply); + expect(await this.token.totalSupplyAt(this.initialSnapshotId)).to.be.bignumber.equal(initialSupply); }); }); @@ -52,7 +54,7 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { }); it('returns the total supply before the changes', async function () { - (await this.token.totalSupplyAt(this.initialSnapshotId)).should.be.bignumber.equal(initialSupply); + expect(await this.token.totalSupplyAt(this.initialSnapshotId)).to.be.bignumber.equal(initialSupply); }); context('with a second snapshot after supply changes', function () { @@ -64,9 +66,9 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { }); it('snapshots return the supply before and after the changes', async function () { - (await this.token.totalSupplyAt(this.initialSnapshotId)).should.be.bignumber.equal(initialSupply); + expect(await this.token.totalSupplyAt(this.initialSnapshotId)).to.be.bignumber.equal(initialSupply); - (await this.token.totalSupplyAt(this.secondSnapshotId)).should.be.bignumber.equal( + expect(await this.token.totalSupplyAt(this.secondSnapshotId)).to.be.bignumber.equal( await this.token.totalSupply() ); }); @@ -83,12 +85,12 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { }); it('all posterior snapshots return the supply after the changes', async function () { - (await this.token.totalSupplyAt(this.initialSnapshotId)).should.be.bignumber.equal(initialSupply); + expect(await this.token.totalSupplyAt(this.initialSnapshotId)).to.be.bignumber.equal(initialSupply); const currentSupply = await this.token.totalSupply(); for (const id of this.secondSnapshotIds) { - (await this.token.totalSupplyAt(id)).should.be.bignumber.equal(currentSupply); + expect(await this.token.totalSupplyAt(id)).to.be.bignumber.equal(currentSupply); } }); }); @@ -115,10 +117,10 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { context('with no balance changes after the snapshot', function () { it('returns the current balance for all accounts', async function () { - (await this.token.balanceOfAt(initialHolder, this.initialSnapshotId)) - .should.be.bignumber.equal(initialSupply); - (await this.token.balanceOfAt(recipient, this.initialSnapshotId)).should.be.bignumber.equal('0'); - (await this.token.balanceOfAt(other, this.initialSnapshotId)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOfAt(initialHolder, this.initialSnapshotId)) + .to.be.bignumber.equal(initialSupply); + expect(await this.token.balanceOfAt(recipient, this.initialSnapshotId)).to.be.bignumber.equal('0'); + expect(await this.token.balanceOfAt(other, this.initialSnapshotId)).to.be.bignumber.equal('0'); }); }); @@ -130,10 +132,10 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { }); it('returns the balances before the changes', async function () { - (await this.token.balanceOfAt(initialHolder, this.initialSnapshotId)) - .should.be.bignumber.equal(initialSupply); - (await this.token.balanceOfAt(recipient, this.initialSnapshotId)).should.be.bignumber.equal('0'); - (await this.token.balanceOfAt(other, this.initialSnapshotId)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOfAt(initialHolder, this.initialSnapshotId)) + .to.be.bignumber.equal(initialSupply); + expect(await this.token.balanceOfAt(recipient, this.initialSnapshotId)).to.be.bignumber.equal('0'); + expect(await this.token.balanceOfAt(other, this.initialSnapshotId)).to.be.bignumber.equal('0'); }); context('with a second snapshot after supply changes', function () { @@ -145,18 +147,18 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { }); it('snapshots return the balances before and after the changes', async function () { - (await this.token.balanceOfAt(initialHolder, this.initialSnapshotId)) - .should.be.bignumber.equal(initialSupply); - (await this.token.balanceOfAt(recipient, this.initialSnapshotId)).should.be.bignumber.equal('0'); - (await this.token.balanceOfAt(other, this.initialSnapshotId)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOfAt(initialHolder, this.initialSnapshotId)) + .to.be.bignumber.equal(initialSupply); + expect(await this.token.balanceOfAt(recipient, this.initialSnapshotId)).to.be.bignumber.equal('0'); + expect(await this.token.balanceOfAt(other, this.initialSnapshotId)).to.be.bignumber.equal('0'); - (await this.token.balanceOfAt(initialHolder, this.secondSnapshotId)).should.be.bignumber.equal( + expect(await this.token.balanceOfAt(initialHolder, this.secondSnapshotId)).to.be.bignumber.equal( await this.token.balanceOf(initialHolder) ); - (await this.token.balanceOfAt(recipient, this.secondSnapshotId)).should.be.bignumber.equal( + expect(await this.token.balanceOfAt(recipient, this.secondSnapshotId)).to.be.bignumber.equal( await this.token.balanceOf(recipient) ); - (await this.token.balanceOfAt(other, this.secondSnapshotId)).should.be.bignumber.equal( + expect(await this.token.balanceOfAt(other, this.secondSnapshotId)).to.be.bignumber.equal( await this.token.balanceOf(other) ); }); @@ -173,19 +175,19 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { }); it('all posterior snapshots return the supply after the changes', async function () { - (await this.token.balanceOfAt(initialHolder, this.initialSnapshotId)) - .should.be.bignumber.equal(initialSupply); - (await this.token.balanceOfAt(recipient, this.initialSnapshotId)).should.be.bignumber.equal('0'); - (await this.token.balanceOfAt(other, this.initialSnapshotId)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOfAt(initialHolder, this.initialSnapshotId)) + .to.be.bignumber.equal(initialSupply); + expect(await this.token.balanceOfAt(recipient, this.initialSnapshotId)).to.be.bignumber.equal('0'); + expect(await this.token.balanceOfAt(other, this.initialSnapshotId)).to.be.bignumber.equal('0'); for (const id of this.secondSnapshotIds) { - (await this.token.balanceOfAt(initialHolder, id)).should.be.bignumber.equal( + expect(await this.token.balanceOfAt(initialHolder, id)).to.be.bignumber.equal( await this.token.balanceOf(initialHolder) ); - (await this.token.balanceOfAt(recipient, id)).should.be.bignumber.equal( + expect(await this.token.balanceOfAt(recipient, id)).to.be.bignumber.equal( await this.token.balanceOf(recipient) ); - (await this.token.balanceOfAt(other, id)).should.be.bignumber.equal( + expect(await this.token.balanceOfAt(other, id)).to.be.bignumber.equal( await this.token.balanceOf(other) ); } diff --git a/test/drafts/SignatureBouncer.test.js b/test/drafts/SignatureBouncer.test.js index 78de3a31762..516a4ca35a7 100644 --- a/test/drafts/SignatureBouncer.test.js +++ b/test/drafts/SignatureBouncer.test.js @@ -2,6 +2,8 @@ const { expectRevert } = require('openzeppelin-test-helpers'); const { getSignFor } = require('../helpers/sign'); const { shouldBehaveLikePublicRole } = require('../behaviors/access/roles/PublicRole.behavior'); +const { expect } = require('chai'); + const SignatureBouncerMock = artifacts.require('SignatureBouncerMock'); const UINT_VALUE = 23; @@ -140,79 +142,79 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, other, authorize context('signature validation', function () { context('plain signature', function () { it('validates valid signature for valid user', async function () { - (await this.sigBouncer.checkValidSignature(authorizedUser, await this.signFor(authorizedUser))) - .should.equal(true); + expect(await this.sigBouncer.checkValidSignature(authorizedUser, await this.signFor(authorizedUser))) + .to.equal(true); }); it('does not validate invalid signature for valid user', async function () { - (await this.sigBouncer.checkValidSignature(authorizedUser, INVALID_SIGNATURE)).should.equal(false); + expect(await this.sigBouncer.checkValidSignature(authorizedUser, INVALID_SIGNATURE)).to.equal(false); }); it('does not validate valid signature for anyone', async function () { - (await this.sigBouncer.checkValidSignature(other, await this.signFor(authorizedUser))).should.equal(false); + expect(await this.sigBouncer.checkValidSignature(other, await this.signFor(authorizedUser))).to.equal(false); }); it('does not validate valid signature for method for valid user', async function () { - (await this.sigBouncer.checkValidSignature( + expect(await this.sigBouncer.checkValidSignature( authorizedUser, await this.signFor(authorizedUser, 'checkValidSignature')) - ).should.equal(false); + ).to.equal(false); }); }); context('method signature', function () { it('validates valid signature with correct method for valid user', async function () { - (await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser, + expect(await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser, await this.signFor(authorizedUser, 'checkValidSignatureAndMethod')) - ).should.equal(true); + ).to.equal(true); }); it('does not validate invalid signature with correct method for valid user', async function () { - (await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser, INVALID_SIGNATURE)).should.equal(false); + expect(await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser, INVALID_SIGNATURE)).to.equal(false); }); it('does not validate valid signature with correct method for anyone', async function () { - (await this.sigBouncer.checkValidSignatureAndMethod(other, + expect(await this.sigBouncer.checkValidSignatureAndMethod(other, await this.signFor(authorizedUser, 'checkValidSignatureAndMethod')) - ).should.equal(false); + ).to.equal(false); }); it('does not validate valid non-method signature with correct method for valid user', async function () { - (await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser, await this.signFor(authorizedUser)) - ).should.equal(false); + expect(await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser, await this.signFor(authorizedUser)) + ).to.equal(false); }); }); context('method and data signature', function () { it('validates valid signature with correct method and data for valid user', async function () { - (await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE, + expect(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE, await this.signFor(authorizedUser, 'checkValidSignatureAndData', [authorizedUser, BYTES_VALUE, UINT_VALUE])) - ).should.equal(true); + ).to.equal(true); }); it('does not validate invalid signature with correct method and data for valid user', async function () { - (await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE, INVALID_SIGNATURE) - ).should.equal(false); + expect(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE, INVALID_SIGNATURE) + ).to.equal(false); }); it('does not validate valid signature with correct method and incorrect data for valid user', async function () { - (await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE + 10, + expect(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE + 10, await this.signFor(authorizedUser, 'checkValidSignatureAndData', [authorizedUser, BYTES_VALUE, UINT_VALUE])) - ).should.equal(false); + ).to.equal(false); } ); it('does not validate valid signature with correct method and data for anyone', async function () { - (await this.sigBouncer.checkValidSignatureAndData(other, BYTES_VALUE, UINT_VALUE, + expect(await this.sigBouncer.checkValidSignatureAndData(other, BYTES_VALUE, UINT_VALUE, await this.signFor(authorizedUser, 'checkValidSignatureAndData', [authorizedUser, BYTES_VALUE, UINT_VALUE])) - ).should.equal(false); + ).that.equal(false); }); it('does not validate valid non-method-data signature with correct method and data for valid user', async function () { - (await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE, + expect(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE, await this.signFor(authorizedUser, 'checkValidSignatureAndData')) - ).should.equal(false); + ).to.equal(false); } ); }); diff --git a/test/drafts/SignedSafeMath.test.js b/test/drafts/SignedSafeMath.test.js index 6c34fe2c265..97681241176 100644 --- a/test/drafts/SignedSafeMath.test.js +++ b/test/drafts/SignedSafeMath.test.js @@ -1,6 +1,8 @@ const { BN, constants, expectRevert } = require('openzeppelin-test-helpers'); const { MAX_INT256, MIN_INT256 } = constants; +const { expect } = require('chai'); + const SignedSafeMathMock = artifacts.require('SignedSafeMathMock'); contract('SignedSafeMath', function () { @@ -9,8 +11,8 @@ contract('SignedSafeMath', function () { }); async function testCommutative (fn, lhs, rhs, expected) { - (await fn(lhs, rhs)).should.be.bignumber.equal(expected); - (await fn(rhs, lhs)).should.be.bignumber.equal(expected); + expect(await fn(lhs, rhs)).to.be.bignumber.equal(expected); + expect(await fn(rhs, lhs)).to.be.bignumber.equal(expected); } async function testFailsCommutative (fn, lhs, rhs, reason) { @@ -54,7 +56,7 @@ contract('SignedSafeMath', function () { const b = new BN('1234'); const result = await this.safeMath.sub(a, b); - result.should.be.bignumber.equal(a.sub(b)); + expect(result).to.be.bignumber.equal(a.sub(b)); }); it('subtracts correctly if it does not overflow and the result is negative', async function () { @@ -62,7 +64,7 @@ contract('SignedSafeMath', function () { const b = new BN('5678'); const result = await this.safeMath.sub(a, b); - result.should.be.bignumber.equal(a.sub(b)); + expect(result).to.be.bignumber.equal(a.sub(b)); }); it('reverts on positive subtraction overflow', async function () { @@ -116,21 +118,21 @@ contract('SignedSafeMath', function () { const b = new BN('5678'); const result = await this.safeMath.div(a, b); - result.should.be.bignumber.equal(a.div(b)); + expect(result).to.be.bignumber.equal(a.div(b)); }); it('divides zero correctly', async function () { const a = new BN('0'); const b = new BN('5678'); - (await this.safeMath.div(a, b)).should.be.bignumber.equal('0'); + expect(await this.safeMath.div(a, b)).to.be.bignumber.equal('0'); }); it('returns complete number result on non-even division', async function () { const a = new BN('7000'); const b = new BN('5678'); - (await this.safeMath.div(a, b)).should.be.bignumber.equal('1'); + expect(await this.safeMath.div(a, b)).to.be.bignumber.equal('1'); }); it('reverts on division by zero', async function () { diff --git a/test/drafts/Strings.test.js b/test/drafts/Strings.test.js index a4bf1398f3d..8908a8b29ee 100644 --- a/test/drafts/Strings.test.js +++ b/test/drafts/Strings.test.js @@ -1,5 +1,7 @@ const { constants } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const StringsMock = artifacts.require('StringsMock'); contract('Strings', function () { @@ -9,15 +11,15 @@ contract('Strings', function () { describe('from uint256', function () { it('converts 0', async function () { - (await this.strings.fromUint256(0)).should.equal('0'); + expect(await this.strings.fromUint256(0)).to.equal('0'); }); it('converts a positive number', async function () { - (await this.strings.fromUint256(4132)).should.equal('4132'); + expect(await this.strings.fromUint256(4132)).to.equal('4132'); }); it('converts MAX_UINT256', async function () { - (await this.strings.fromUint256(constants.MAX_UINT256)).should.equal(constants.MAX_UINT256.toString()); + expect(await this.strings.fromUint256(constants.MAX_UINT256)).to.equal(constants.MAX_UINT256.toString()); }); }); }); diff --git a/test/drafts/TokenVesting.test.js b/test/drafts/TokenVesting.test.js index 6858442e8d9..b4f65e2a5a3 100644 --- a/test/drafts/TokenVesting.test.js +++ b/test/drafts/TokenVesting.test.js @@ -1,6 +1,8 @@ const { BN, constants, expectEvent, expectRevert, time } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + const ERC20Mintable = artifacts.require('ERC20Mintable'); const TokenVesting = artifacts.require('TokenVesting'); @@ -18,7 +20,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { const cliffDuration = this.duration; const duration = this.cliffDuration; - cliffDuration.should.be.bignumber.that.is.at.least(duration); + expect(cliffDuration).to.be.bignumber.that.is.at.least(duration); await expectRevert( TokenVesting.new(beneficiary, this.start, cliffDuration, duration, true, { from: owner }), @@ -60,11 +62,11 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { }); it('can get state', async function () { - (await this.vesting.beneficiary()).should.be.equal(beneficiary); - (await this.vesting.cliff()).should.be.bignumber.equal(this.start.add(this.cliffDuration)); - (await this.vesting.start()).should.be.bignumber.equal(this.start); - (await this.vesting.duration()).should.be.bignumber.equal(this.duration); - (await this.vesting.revocable()).should.be.equal(true); + expect(await this.vesting.beneficiary()).to.equal(beneficiary); + expect(await this.vesting.cliff()).to.be.bignumber.equal(this.start.add(this.cliffDuration)); + expect(await this.vesting.start()).to.be.bignumber.equal(this.start); + expect(await this.vesting.duration()).to.be.bignumber.equal(this.duration); + expect(await this.vesting.revocable()).to.be.equal(true); }); it('cannot be released before cliff', async function () { @@ -89,8 +91,8 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { const releaseTime = await time.latest(); const releasedAmount = amount.mul(releaseTime.sub(this.start)).div(this.duration); - (await this.token.balanceOf(beneficiary)).should.bignumber.equal(releasedAmount); - (await this.vesting.released(this.token.address)).should.bignumber.equal(releasedAmount); + expect(await this.token.balanceOf(beneficiary)).to.be.bignumber.equal(releasedAmount); + expect(await this.vesting.released(this.token.address)).to.be.bignumber.equal(releasedAmount); }); it('should linearly release tokens during vesting period', async function () { @@ -103,22 +105,22 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { await this.vesting.release(this.token.address); const expectedVesting = amount.mul(now.sub(this.start)).div(this.duration); - (await this.token.balanceOf(beneficiary)).should.bignumber.equal(expectedVesting); - (await this.vesting.released(this.token.address)).should.bignumber.equal(expectedVesting); + expect(await this.token.balanceOf(beneficiary)).to.be.bignumber.equal(expectedVesting); + expect(await this.vesting.released(this.token.address)).to.be.bignumber.equal(expectedVesting); } }); it('should have released all after end', async function () { await time.increaseTo(this.start.add(this.duration)); await this.vesting.release(this.token.address); - (await this.token.balanceOf(beneficiary)).should.bignumber.equal(amount); - (await this.vesting.released(this.token.address)).should.bignumber.equal(amount); + expect(await this.token.balanceOf(beneficiary)).to.be.bignumber.equal(amount); + expect(await this.vesting.released(this.token.address)).to.be.bignumber.equal(amount); }); it('should be revoked by owner if revocable is set', async function () { const { logs } = await this.vesting.revoke(this.token.address, { from: owner }); expectEvent.inLogs(logs, 'TokenVestingRevoked', { token: this.token.address }); - (await this.vesting.revoked(this.token.address)).should.equal(true); + expect(await this.vesting.revoked(this.token.address)).to.equal(true); }); it('should fail to be revoked by owner if revocable not set', async function () { @@ -138,7 +140,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { await this.vesting.revoke(this.token.address, { from: owner }); - (await this.token.balanceOf(owner)).should.bignumber.equal(amount.sub(vested)); + expect(await this.token.balanceOf(owner)).to.be.bignumber.equal(amount.sub(vested)); }); it('should keep the vested tokens when revoked by owner', async function () { @@ -150,7 +152,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { const vestedPost = vestedAmount(amount, await time.latest(), this.start, this.cliffDuration, this.duration); - vestedPre.should.bignumber.equal(vestedPost); + expect(vestedPre).to.be.bignumber.equal(vestedPost); }); it('should fail to be revoked a second time', async function () { diff --git a/test/examples/SampleCrowdsale.test.js b/test/examples/SampleCrowdsale.test.js index 8bb07b71ea4..c3080644cb2 100644 --- a/test/examples/SampleCrowdsale.test.js +++ b/test/examples/SampleCrowdsale.test.js @@ -1,5 +1,7 @@ const { BN, balance, ether, expectRevert, time } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const SampleCrowdsale = artifacts.require('SampleCrowdsale'); const SampleCrowdsaleToken = artifacts.require('SampleCrowdsaleToken'); @@ -29,12 +31,12 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) { }); it('should create crowdsale with correct parameters', async function () { - (await this.crowdsale.openingTime()).should.be.bignumber.equal(this.openingTime); - (await this.crowdsale.closingTime()).should.be.bignumber.equal(this.closingTime); - (await this.crowdsale.rate()).should.be.bignumber.equal(RATE); - (await this.crowdsale.wallet()).should.be.equal(wallet); - (await this.crowdsale.goal()).should.be.bignumber.equal(GOAL); - (await this.crowdsale.cap()).should.be.bignumber.equal(CAP); + expect(await this.crowdsale.openingTime()).to.be.bignumber.equal(this.openingTime); + expect(await this.crowdsale.closingTime()).to.be.bignumber.equal(this.closingTime); + expect(await this.crowdsale.rate()).to.be.bignumber.equal(RATE); + expect(await this.crowdsale.wallet()).to.equal(wallet); + expect(await this.crowdsale.goal()).to.be.bignumber.equal(GOAL); + expect(await this.crowdsale.cap()).to.be.bignumber.equal(CAP); }); it('should not accept payments before start', async function () { @@ -51,8 +53,8 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) { await time.increaseTo(this.openingTime); await this.crowdsale.buyTokens(investor, { value: investmentAmount, from: investor }); - (await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount); - (await this.token.totalSupply()).should.be.bignumber.equal(expectedTokenAmount); + expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(expectedTokenAmount); + expect(await this.token.totalSupply()).to.be.bignumber.equal(expectedTokenAmount); }); it('should reject payments after end', async function () { @@ -76,7 +78,7 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) { const balanceTracker = await balance.tracker(wallet); await time.increaseTo(this.afterClosingTime); await this.crowdsale.finalize({ from: owner }); - (await balanceTracker.delta()).should.be.bignumber.equal(GOAL); + expect(await balanceTracker.delta()).to.be.bignumber.equal(GOAL); }); it('should allow refunds if the goal is not reached', async function () { @@ -89,7 +91,7 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) { await this.crowdsale.finalize({ from: owner }); await this.crowdsale.claimRefund(investor, { gasPrice: 0 }); - (await balanceTracker.delta()).should.be.bignumber.equal('0'); + expect(await balanceTracker.delta()).to.be.bignumber.equal('0'); }); describe('when goal > cap', function () { diff --git a/test/examples/SimpleToken.test.js b/test/examples/SimpleToken.test.js index 1ec65ee0790..e162750be9b 100644 --- a/test/examples/SimpleToken.test.js +++ b/test/examples/SimpleToken.test.js @@ -1,6 +1,8 @@ const { constants, expectEvent } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + const SimpleToken = artifacts.require('SimpleToken'); contract('SimpleToken', function ([_, creator]) { @@ -9,22 +11,22 @@ contract('SimpleToken', function ([_, creator]) { }); it('has a name', async function () { - (await this.token.name()).should.equal('SimpleToken'); + expect(await this.token.name()).to.equal('SimpleToken'); }); it('has a symbol', async function () { - (await this.token.symbol()).should.equal('SIM'); + expect(await this.token.symbol()).to.equal('SIM'); }); it('has 18 decimals', async function () { - (await this.token.decimals()).should.be.bignumber.equal('18'); + expect(await this.token.decimals()).to.be.bignumber.equal('18'); }); it('assigns the initial total supply to the creator', async function () { const totalSupply = await this.token.totalSupply(); const creatorBalance = await this.token.balanceOf(creator); - creatorBalance.should.be.bignumber.equal(totalSupply); + expect(creatorBalance).to.be.bignumber.equal(totalSupply); await expectEvent.inConstruction(this.token, 'Transfer', { from: ZERO_ADDRESS, diff --git a/test/introspection/ERC165Checker.test.js b/test/introspection/ERC165Checker.test.js index 881d19dcf93..0baf8e3b267 100644 --- a/test/introspection/ERC165Checker.test.js +++ b/test/introspection/ERC165Checker.test.js @@ -1,5 +1,7 @@ require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const ERC165CheckerMock = artifacts.require('ERC165CheckerMock'); const ERC165NotSupported = artifacts.require('ERC165NotSupported'); const ERC165InterfacesSupported = artifacts.require('ERC165InterfacesSupported'); @@ -23,17 +25,17 @@ contract('ERC165Checker', function () { it('does not support ERC165', async function () { const supported = await this.mock.supportsERC165(this.target.address); - supported.should.equal(false); + expect(supported).to.equal(false); }); it('does not support mock interface via supportsInterface', async function () { const supported = await this.mock.supportsInterface(this.target.address, DUMMY_ID); - supported.should.equal(false); + expect(supported).to.equal(false); }); it('does not support mock interface via supportsAllInterfaces', async function () { const supported = await this.mock.supportsAllInterfaces(this.target.address, [DUMMY_ID]); - supported.should.equal(false); + expect(supported).to.equal(false); }); }); @@ -44,17 +46,17 @@ contract('ERC165Checker', function () { it('supports ERC165', async function () { const supported = await this.mock.supportsERC165(this.target.address); - supported.should.equal(true); + expect(supported).to.equal(true); }); it('does not support mock interface via supportsInterface', async function () { const supported = await this.mock.supportsInterface(this.target.address, DUMMY_ID); - supported.should.equal(false); + expect(supported).to.equal(false); }); it('does not support mock interface via supportsAllInterfaces', async function () { const supported = await this.mock.supportsAllInterfaces(this.target.address, [DUMMY_ID]); - supported.should.equal(false); + expect(supported).to.equal(false); }); }); @@ -65,17 +67,17 @@ contract('ERC165Checker', function () { it('supports ERC165', async function () { const supported = await this.mock.supportsERC165(this.target.address); - supported.should.equal(true); + expect(supported).to.equal(true); }); it('supports mock interface via supportsInterface', async function () { const supported = await this.mock.supportsInterface(this.target.address, DUMMY_ID); - supported.should.equal(true); + expect(supported).to.equal(true); }); it('supports mock interface via supportsAllInterfaces', async function () { const supported = await this.mock.supportsAllInterfaces(this.target.address, [DUMMY_ID]); - supported.should.equal(true); + expect(supported).to.equal(true); }); }); @@ -87,50 +89,50 @@ contract('ERC165Checker', function () { it('supports ERC165', async function () { const supported = await this.mock.supportsERC165(this.target.address); - supported.should.equal(true); + expect(supported).to.equal(true); }); it('supports each interfaceId via supportsInterface', async function () { for (const interfaceId of this.supportedInterfaces) { const supported = await this.mock.supportsInterface(this.target.address, interfaceId); - supported.should.equal(true); + expect(supported).to.equal(true); }; }); it('supports all interfaceIds via supportsAllInterfaces', async function () { const supported = await this.mock.supportsAllInterfaces(this.target.address, this.supportedInterfaces); - supported.should.equal(true); + expect(supported).to.equal(true); }); it('supports none of the interfaces queried via supportsAllInterfaces', async function () { const interfaceIdsToTest = [DUMMY_UNSUPPORTED_ID, DUMMY_UNSUPPORTED_ID_2]; const supported = await this.mock.supportsAllInterfaces(this.target.address, interfaceIdsToTest); - supported.should.equal(false); + expect(supported).to.equal(false); }); it('supports not all of the interfaces queried via supportsAllInterfaces', async function () { const interfaceIdsToTest = [...this.supportedInterfaces, DUMMY_UNSUPPORTED_ID]; const supported = await this.mock.supportsAllInterfaces(this.target.address, interfaceIdsToTest); - supported.should.equal(false); + expect(supported).to.equal(false); }); }); context('account address does not support ERC165', function () { it('does not support ERC165', async function () { const supported = await this.mock.supportsERC165(DUMMY_ACCOUNT); - supported.should.equal(false); + expect(supported).to.equal(false); }); it('does not support mock interface via supportsInterface', async function () { const supported = await this.mock.supportsInterface(DUMMY_ACCOUNT, DUMMY_ID); - supported.should.equal(false); + expect(supported).to.equal(false); }); it('does not support mock interface via supportsAllInterfaces', async function () { const supported = await this.mock.supportsAllInterfaces(DUMMY_ACCOUNT, [DUMMY_ID]); - supported.should.equal(false); + expect(supported).to.equal(false); }); }); }); diff --git a/test/introspection/ERC1820Implementer.test.js b/test/introspection/ERC1820Implementer.test.js index 464ec6066c7..dfccb179274 100644 --- a/test/introspection/ERC1820Implementer.test.js +++ b/test/introspection/ERC1820Implementer.test.js @@ -1,6 +1,8 @@ const { expectRevert, singletons } = require('openzeppelin-test-helpers'); const { bufferToHex, keccak256 } = require('ethereumjs-util'); +const { expect } = require('chai'); + const ERC1820ImplementerMock = artifacts.require('ERC1820ImplementerMock'); contract('ERC1820Implementer', function ([_, registryFunder, implementee, other]) { @@ -16,8 +18,8 @@ contract('ERC1820Implementer', function ([_, registryFunder, implementee, other] context('with no registered interfaces', function () { it('returns false when interface implementation is queried', async function () { - (await this.implementer.canImplementInterfaceForAddress(this.interfaceA, implementee)) - .should.not.equal(ERC1820_ACCEPT_MAGIC); + expect(await this.implementer.canImplementInterfaceForAddress(this.interfaceA, implementee)) + .to.not.equal(ERC1820_ACCEPT_MAGIC); }); it('reverts when attempting to set as implementer in the registry', async function () { @@ -36,18 +38,18 @@ contract('ERC1820Implementer', function ([_, registryFunder, implementee, other] }); it('returns true when interface implementation is queried', async function () { - (await this.implementer.canImplementInterfaceForAddress(this.interfaceA, implementee)) - .should.equal(ERC1820_ACCEPT_MAGIC); + expect(await this.implementer.canImplementInterfaceForAddress(this.interfaceA, implementee)) + .to.equal(ERC1820_ACCEPT_MAGIC); }); it('returns false when interface implementation for non-supported interfaces is queried', async function () { - (await this.implementer.canImplementInterfaceForAddress(this.interfaceB, implementee)) - .should.not.equal(ERC1820_ACCEPT_MAGIC); + expect(await this.implementer.canImplementInterfaceForAddress(this.interfaceB, implementee)) + .to.not.equal(ERC1820_ACCEPT_MAGIC); }); it('returns false when interface implementation for non-supported addresses is queried', async function () { - (await this.implementer.canImplementInterfaceForAddress(this.interfaceA, other)) - .should.not.equal(ERC1820_ACCEPT_MAGIC); + expect(await this.implementer.canImplementInterfaceForAddress(this.interfaceA, other)) + .to.not.equal(ERC1820_ACCEPT_MAGIC); }); it('can be set as an implementer for supported interfaces in the registry', async function () { @@ -55,8 +57,8 @@ contract('ERC1820Implementer', function ([_, registryFunder, implementee, other] implementee, this.interfaceA, this.implementer.address, { from: implementee } ); - (await this.registry.getInterfaceImplementer(implementee, this.interfaceA)) - .should.equal(this.implementer.address); + expect(await this.registry.getInterfaceImplementer(implementee, this.interfaceA)) + .to.equal(this.implementer.address); }); }); }); diff --git a/test/introspection/SupportsInterface.behavior.js b/test/introspection/SupportsInterface.behavior.js index 0dbe002e81b..9dcc17611fb 100644 --- a/test/introspection/SupportsInterface.behavior.js +++ b/test/introspection/SupportsInterface.behavior.js @@ -1,5 +1,7 @@ const { makeInterfaceId } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const INTERFACES = { ERC165: [ 'supportsInterface(bytes4)', @@ -48,11 +50,11 @@ function shouldSupportInterfaces (interfaces = []) { describe(k, function () { describe('ERC165\'s supportsInterface(bytes4)', function () { it('should use less than 30k gas', async function () { - (await this.contractUnderTest.supportsInterface.estimateGas(interfaceId)).should.be.lte(30000); + expect(await this.contractUnderTest.supportsInterface.estimateGas(interfaceId)).to.be.lte(30000); }); it('should claim support', async function () { - (await this.contractUnderTest.supportsInterface(interfaceId)).should.equal(true); + expect(await this.contractUnderTest.supportsInterface(interfaceId)).to.equal(true); }); }); @@ -60,7 +62,7 @@ function shouldSupportInterfaces (interfaces = []) { const fnSig = FN_SIGNATURES[fnName]; describe(fnName, function () { it('should be implemented', function () { - this.contractUnderTest.abi.filter(fn => fn.signature === fnSig).length.should.equal(1); + expect(this.contractUnderTest.abi.filter(fn => fn.signature === fnSig).length).to.equal(1); }); }); } diff --git a/test/lifecycle/Pausable.test.js b/test/lifecycle/Pausable.test.js index 49e49156dee..81eb15fbfa3 100644 --- a/test/lifecycle/Pausable.test.js +++ b/test/lifecycle/Pausable.test.js @@ -1,6 +1,8 @@ const { expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const { shouldBehaveLikePublicRole } = require('../behaviors/access/roles/PublicRole.behavior'); +const { expect } = require('chai'); + const PausableMock = artifacts.require('PausableMock'); contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts]) { @@ -19,27 +21,27 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts] context('when unpaused', function () { beforeEach(async function () { - (await this.pausable.paused()).should.equal(false); + expect(await this.pausable.paused()).to.equal(false); }); it('can perform normal process in non-pause', async function () { - (await this.pausable.count()).should.be.bignumber.equal('0'); + expect(await this.pausable.count()).to.be.bignumber.equal('0'); await this.pausable.normalProcess({ from: other }); - (await this.pausable.count()).should.be.bignumber.equal('1'); + expect(await this.pausable.count()).to.be.bignumber.equal('1'); }); it('cannot take drastic measure in non-pause', async function () { await expectRevert(this.pausable.drasticMeasure({ from: other }), 'Pausable: not paused' ); - (await this.pausable.drasticMeasureTaken()).should.equal(false); + expect(await this.pausable.drasticMeasureTaken()).to.equal(false); }); describe('pausing', function () { it('is pausable by the pauser', async function () { await this.pausable.pause({ from: pauser }); - (await this.pausable.paused()).should.equal(true); + expect(await this.pausable.paused()).to.equal(true); }); it('reverts when pausing from non-pauser', async function () { @@ -63,7 +65,7 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts] it('can take a drastic measure in a pause', async function () { await this.pausable.drasticMeasure({ from: other }); - (await this.pausable.drasticMeasureTaken()).should.equal(true); + expect(await this.pausable.drasticMeasureTaken()).to.equal(true); }); it('reverts when re-pausing', async function () { @@ -73,7 +75,7 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts] describe('unpausing', function () { it('is unpausable by the pauser', async function () { await this.pausable.unpause({ from: pauser }); - (await this.pausable.paused()).should.equal(false); + expect(await this.pausable.paused()).to.equal(false); }); it('reverts when unpausing from non-pauser', async function () { @@ -92,9 +94,9 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts] }); it('should resume allowing normal process', async function () { - (await this.pausable.count()).should.be.bignumber.equal('0'); + expect(await this.pausable.count()).to.be.bignumber.equal('0'); await this.pausable.normalProcess({ from: other }); - (await this.pausable.count()).should.be.bignumber.equal('1'); + expect(await this.pausable.count()).to.be.bignumber.equal('1'); }); it('should prevent drastic measure', async function () { diff --git a/test/math/Math.test.js b/test/math/Math.test.js index d28d66ef543..829a847a995 100644 --- a/test/math/Math.test.js +++ b/test/math/Math.test.js @@ -1,5 +1,7 @@ const { BN } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const MathMock = artifacts.require('MathMock'); contract('Math', function () { @@ -12,21 +14,21 @@ contract('Math', function () { describe('max', function () { it('is correctly detected in first argument position', async function () { - (await this.math.max(max, min)).should.be.bignumber.equal(max); + expect(await this.math.max(max, min)).to.be.bignumber.equal(max); }); it('is correctly detected in second argument position', async function () { - (await this.math.max(min, max)).should.be.bignumber.equal(max); + expect(await this.math.max(min, max)).to.be.bignumber.equal(max); }); }); describe('min', function () { it('is correctly detected in first argument position', async function () { - (await this.math.min(min, max)).should.be.bignumber.equal(min); + expect(await this.math.min(min, max)).to.be.bignumber.equal(min); }); it('is correctly detected in second argument position', async function () { - (await this.math.min(max, min)).should.be.bignumber.equal(min); + expect(await this.math.min(max, min)).to.be.bignumber.equal(min); }); }); @@ -38,19 +40,19 @@ contract('Math', function () { it('is correctly calculated with two odd numbers', async function () { const a = new BN('57417'); const b = new BN('95431'); - (await this.math.average(a, b)).should.be.bignumber.equal(bnAverage(a, b)); + expect(await this.math.average(a, b)).to.be.bignumber.equal(bnAverage(a, b)); }); it('is correctly calculated with two even numbers', async function () { const a = new BN('42304'); const b = new BN('84346'); - (await this.math.average(a, b)).should.be.bignumber.equal(bnAverage(a, b)); + expect(await this.math.average(a, b)).to.be.bignumber.equal(bnAverage(a, b)); }); it('is correctly calculated with one even and one odd number', async function () { const a = new BN('57417'); const b = new BN('84346'); - (await this.math.average(a, b)).should.be.bignumber.equal(bnAverage(a, b)); + expect(await this.math.average(a, b)).to.be.bignumber.equal(bnAverage(a, b)); }); }); }); diff --git a/test/math/SafeMath.test.js b/test/math/SafeMath.test.js index 57241449e07..194b10096e0 100644 --- a/test/math/SafeMath.test.js +++ b/test/math/SafeMath.test.js @@ -1,6 +1,8 @@ const { BN, constants, expectRevert } = require('openzeppelin-test-helpers'); const { MAX_UINT256 } = constants; +const { expect } = require('chai'); + const SafeMathMock = artifacts.require('SafeMathMock'); contract('SafeMath', function () { @@ -9,8 +11,8 @@ contract('SafeMath', function () { }); async function testCommutative (fn, lhs, rhs, expected) { - (await fn(lhs, rhs)).should.be.bignumber.equal(expected); - (await fn(rhs, lhs)).should.be.bignumber.equal(expected); + expect(await fn(lhs, rhs)).to.be.bignumber.equal(expected); + expect(await fn(rhs, lhs)).to.be.bignumber.equal(expected); } async function testFailsCommutative (fn, lhs, rhs, reason) { @@ -39,7 +41,7 @@ contract('SafeMath', function () { const a = new BN('5678'); const b = new BN('1234'); - (await this.safeMath.sub(a, b)).should.be.bignumber.equal(a.sub(b)); + expect(await this.safeMath.sub(a, b)).to.be.bignumber.equal(a.sub(b)); }); it('reverts if subtraction result would be negative', async function () { @@ -78,21 +80,21 @@ contract('SafeMath', function () { const a = new BN('5678'); const b = new BN('5678'); - (await this.safeMath.div(a, b)).should.be.bignumber.equal(a.div(b)); + expect(await this.safeMath.div(a, b)).to.be.bignumber.equal(a.div(b)); }); it('divides zero correctly', async function () { const a = new BN('0'); const b = new BN('5678'); - (await this.safeMath.div(a, b)).should.be.bignumber.equal('0'); + expect(await this.safeMath.div(a, b)).to.be.bignumber.equal('0'); }); it('returns complete number result on non-even division', async function () { const a = new BN('7000'); const b = new BN('5678'); - (await this.safeMath.div(a, b)).should.be.bignumber.equal('1'); + expect(await this.safeMath.div(a, b)).to.be.bignumber.equal('1'); }); it('reverts on divison by zero', async function () { @@ -109,28 +111,28 @@ contract('SafeMath', function () { const a = new BN('284'); const b = new BN('5678'); - (await this.safeMath.mod(a, b)).should.be.bignumber.equal(a.mod(b)); + expect(await this.safeMath.mod(a, b)).to.be.bignumber.equal(a.mod(b)); }); it('when the dividend is equal to the divisor', async function () { const a = new BN('5678'); const b = new BN('5678'); - (await this.safeMath.mod(a, b)).should.be.bignumber.equal(a.mod(b)); + expect(await this.safeMath.mod(a, b)).to.be.bignumber.equal(a.mod(b)); }); it('when the dividend is larger than the divisor', async function () { const a = new BN('7000'); const b = new BN('5678'); - (await this.safeMath.mod(a, b)).should.be.bignumber.equal(a.mod(b)); + expect(await this.safeMath.mod(a, b)).to.be.bignumber.equal(a.mod(b)); }); it('when the dividend is a multiple of the divisor', async function () { const a = new BN('17034'); // 17034 == 5678 * 3 const b = new BN('5678'); - (await this.safeMath.mod(a, b)).should.be.bignumber.equal(a.mod(b)); + expect(await this.safeMath.mod(a, b)).to.be.bignumber.equal(a.mod(b)); }); }); diff --git a/test/ownership/Ownable.behavior.js b/test/ownership/Ownable.behavior.js index 8379aaea92f..f249676332f 100644 --- a/test/ownership/Ownable.behavior.js +++ b/test/ownership/Ownable.behavior.js @@ -1,19 +1,21 @@ const { constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + function shouldBehaveLikeOwnable (owner, [other]) { describe('as an ownable', function () { it('should have an owner', async function () { - (await this.ownable.owner()).should.equal(owner); + expect(await this.ownable.owner()).to.equal(owner); }); it('changes owner after transfer', async function () { - (await this.ownable.isOwner({ from: other })).should.be.equal(false); + expect(await this.ownable.isOwner({ from: other })).to.equal(false); const { logs } = await this.ownable.transferOwnership(other, { from: owner }); expectEvent.inLogs(logs, 'OwnershipTransferred'); - (await this.ownable.owner()).should.equal(other); - (await this.ownable.isOwner({ from: other })).should.be.equal(true); + expect(await this.ownable.owner()).to.equal(other); + expect(await this.ownable.isOwner({ from: other })).to.equal(true); }); it('should prevent non-owners from transferring', async function () { @@ -34,7 +36,7 @@ function shouldBehaveLikeOwnable (owner, [other]) { const { logs } = await this.ownable.renounceOwnership({ from: owner }); expectEvent.inLogs(logs, 'OwnershipTransferred'); - (await this.ownable.owner()).should.equal(ZERO_ADDRESS); + expect(await this.ownable.owner()).to.equal(ZERO_ADDRESS); }); it('should prevent non-owners from renouncement', async function () { diff --git a/test/ownership/Secondary.test.js b/test/ownership/Secondary.test.js index 51b118f833d..c115ce1c2b3 100644 --- a/test/ownership/Secondary.test.js +++ b/test/ownership/Secondary.test.js @@ -1,6 +1,8 @@ const { constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + const SecondaryMock = artifacts.require('SecondaryMock'); contract('Secondary', function ([_, primary, newPrimary, other]) { @@ -9,7 +11,7 @@ contract('Secondary', function ([_, primary, newPrimary, other]) { }); it('stores the primary\'s address', async function () { - (await this.secondary.primary()).should.equal(primary); + expect(await this.secondary.primary()).to.equal(primary); }); describe('onlyPrimary', function () { @@ -28,7 +30,7 @@ contract('Secondary', function ([_, primary, newPrimary, other]) { it('makes the recipient the new primary', async function () { const { logs } = await this.secondary.transferPrimary(newPrimary, { from: primary }); expectEvent.inLogs(logs, 'PrimaryTransferred', { recipient: newPrimary }); - (await this.secondary.primary()).should.equal(newPrimary); + expect(await this.secondary.primary()).to.equal(newPrimary); }); it('reverts when transferring to the null address', async function () { diff --git a/test/payment/PaymentSplitter.test.js b/test/payment/PaymentSplitter.test.js index 271e7b1b275..34726cff6ae 100644 --- a/test/payment/PaymentSplitter.test.js +++ b/test/payment/PaymentSplitter.test.js @@ -1,6 +1,8 @@ const { balance, constants, ether, expectEvent, send, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + const PaymentSplitter = artifacts.require('PaymentSplitter'); contract('PaymentSplitter', function ([_, owner, payee1, payee2, payee3, nonpayee1, payer1]) { @@ -49,28 +51,28 @@ contract('PaymentSplitter', function ([_, owner, payee1, payee2, payee3, nonpaye }); it('should have total shares', async function () { - (await this.contract.totalShares()).should.be.bignumber.equal('100'); + expect(await this.contract.totalShares()).to.be.bignumber.equal('100'); }); it('should have payees', async function () { await Promise.all(this.payees.map(async (payee, index) => { - (await this.contract.payee(index)).should.be.equal(payee); - (await this.contract.released(payee)).should.be.bignumber.equal('0'); + expect(await this.contract.payee(index)).to.equal(payee); + expect(await this.contract.released(payee)).to.be.bignumber.equal('0'); })); }); it('should accept payments', async function () { await send.ether(owner, this.contract.address, amount); - (await balance.current(this.contract.address)).should.be.bignumber.equal(amount); + expect(await balance.current(this.contract.address)).to.be.bignumber.equal(amount); }); it('should store shares if address is payee', async function () { - (await this.contract.shares(payee1)).should.be.bignumber.not.equal('0'); + expect(await this.contract.shares(payee1)).to.be.bignumber.not.equal('0'); }); it('should not store shares if address is not payee', async function () { - (await this.contract.shares(nonpayee1)).should.be.bignumber.equal('0'); + expect(await this.contract.shares(nonpayee1)).to.be.bignumber.equal('0'); }); it('should throw if no funds to claim', async function () { @@ -91,33 +93,33 @@ contract('PaymentSplitter', function ([_, owner, payee1, payee2, payee3, nonpaye // receive funds const initBalance = await balance.current(this.contract.address); - initBalance.should.be.bignumber.equal(amount); + expect(initBalance).to.be.bignumber.equal(amount); // distribute to payees const initAmount1 = await balance.current(payee1); const { logs: logs1 } = await this.contract.release(payee1, { gasPrice: 0 }); const profit1 = (await balance.current(payee1)).sub(initAmount1); - profit1.should.be.bignumber.equal(ether('0.20')); + expect(profit1).to.be.bignumber.equal(ether('0.20')); expectEvent.inLogs(logs1, 'PaymentReleased', { to: payee1, amount: profit1 }); const initAmount2 = await balance.current(payee2); const { logs: logs2 } = await this.contract.release(payee2, { gasPrice: 0 }); const profit2 = (await balance.current(payee2)).sub(initAmount2); - profit2.should.be.bignumber.equal(ether('0.10')); + expect(profit2).to.be.bignumber.equal(ether('0.10')); expectEvent.inLogs(logs2, 'PaymentReleased', { to: payee2, amount: profit2 }); const initAmount3 = await balance.current(payee3); const { logs: logs3 } = await this.contract.release(payee3, { gasPrice: 0 }); const profit3 = (await balance.current(payee3)).sub(initAmount3); - profit3.should.be.bignumber.equal(ether('0.70')); + expect(profit3).to.be.bignumber.equal(ether('0.70')); expectEvent.inLogs(logs3, 'PaymentReleased', { to: payee3, amount: profit3 }); // end balance should be zero - (await balance.current(this.contract.address)).should.be.bignumber.equal('0'); + expect(await balance.current(this.contract.address)).to.be.bignumber.equal('0'); // check correct funds released accounting - (await this.contract.totalReleased()).should.be.bignumber.equal(initBalance); + expect(await this.contract.totalReleased()).to.be.bignumber.equal(initBalance); }); }); }); diff --git a/test/payment/PullPayment.test.js b/test/payment/PullPayment.test.js index f030338abae..fbe36303cfa 100644 --- a/test/payment/PullPayment.test.js +++ b/test/payment/PullPayment.test.js @@ -1,5 +1,7 @@ const { balance, ether } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const PullPaymentMock = artifacts.require('PullPaymentMock'); contract('PullPayment', function ([_, payer, payee1, payee2]) { @@ -11,22 +13,22 @@ contract('PullPayment', function ([_, payer, payee1, payee2]) { it('can record an async payment correctly', async function () { await this.contract.callTransfer(payee1, 100, { from: payer }); - (await this.contract.payments(payee1)).should.be.bignumber.equal('100'); + expect(await this.contract.payments(payee1)).to.be.bignumber.equal('100'); }); it('can add multiple balances on one account', async function () { await this.contract.callTransfer(payee1, 200, { from: payer }); await this.contract.callTransfer(payee1, 300, { from: payer }); - (await this.contract.payments(payee1)).should.be.bignumber.equal('500'); + expect(await this.contract.payments(payee1)).to.be.bignumber.equal('500'); }); it('can add balances on multiple accounts', async function () { await this.contract.callTransfer(payee1, 200, { from: payer }); await this.contract.callTransfer(payee2, 300, { from: payer }); - (await this.contract.payments(payee1)).should.be.bignumber.equal('200'); + expect(await this.contract.payments(payee1)).to.be.bignumber.equal('200'); - (await this.contract.payments(payee2)).should.be.bignumber.equal('300'); + expect(await this.contract.payments(payee2)).to.be.bignumber.equal('300'); }); it('can withdraw payment', async function () { diff --git a/test/payment/escrow/Escrow.behavior.js b/test/payment/escrow/Escrow.behavior.js index 478043a76ef..df7726b86c0 100644 --- a/test/payment/escrow/Escrow.behavior.js +++ b/test/payment/escrow/Escrow.behavior.js @@ -1,5 +1,7 @@ const { balance, ether, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + function shouldBehaveLikeEscrow (primary, [payee1, payee2]) { const amount = ether('42'); @@ -8,9 +10,9 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) { it('can accept a single deposit', async function () { await this.escrow.deposit(payee1, { from: primary, value: amount }); - (await balance.current(this.escrow.address)).should.be.bignumber.equal(amount); + expect(await balance.current(this.escrow.address)).to.be.bignumber.equal(amount); - (await this.escrow.depositsOf(payee1)).should.be.bignumber.equal(amount); + expect(await this.escrow.depositsOf(payee1)).to.be.bignumber.equal(amount); }); it('can accept an empty deposit', async function () { @@ -35,20 +37,20 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) { await this.escrow.deposit(payee1, { from: primary, value: amount }); await this.escrow.deposit(payee1, { from: primary, value: amount.muln(2) }); - (await balance.current(this.escrow.address)).should.be.bignumber.equal(amount.muln(3)); + expect(await balance.current(this.escrow.address)).to.be.bignumber.equal(amount.muln(3)); - (await this.escrow.depositsOf(payee1)).should.be.bignumber.equal(amount.muln(3)); + expect(await this.escrow.depositsOf(payee1)).to.be.bignumber.equal(amount.muln(3)); }); it('can track deposits to multiple accounts', async function () { await this.escrow.deposit(payee1, { from: primary, value: amount }); await this.escrow.deposit(payee2, { from: primary, value: amount.muln(2) }); - (await balance.current(this.escrow.address)).should.be.bignumber.equal(amount.muln(3)); + expect(await balance.current(this.escrow.address)).to.be.bignumber.equal(amount.muln(3)); - (await this.escrow.depositsOf(payee1)).should.be.bignumber.equal(amount); + expect(await this.escrow.depositsOf(payee1)).to.be.bignumber.equal(amount); - (await this.escrow.depositsOf(payee2)).should.be.bignumber.equal(amount.muln(2)); + expect(await this.escrow.depositsOf(payee2)).to.be.bignumber.equal(amount.muln(2)); }); }); @@ -59,10 +61,10 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) { await this.escrow.deposit(payee1, { from: primary, value: amount }); await this.escrow.withdraw(payee1, { from: primary }); - (await balanceTracker.delta()).should.be.bignumber.equal(amount); + expect(await balanceTracker.delta()).to.be.bignumber.equal(amount); - (await balance.current(this.escrow.address)).should.be.bignumber.equal('0'); - (await this.escrow.depositsOf(payee1)).should.be.bignumber.equal('0'); + expect(await balance.current(this.escrow.address)).to.be.bignumber.equal('0'); + expect(await this.escrow.depositsOf(payee1)).to.be.bignumber.equal('0'); }); it('can do an empty withdrawal', async function () { diff --git a/test/payment/escrow/RefundEscrow.test.js b/test/payment/escrow/RefundEscrow.test.js index efd0e248f10..c87ca2fd68d 100644 --- a/test/payment/escrow/RefundEscrow.test.js +++ b/test/payment/escrow/RefundEscrow.test.js @@ -1,6 +1,8 @@ const { balance, constants, ether, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + const RefundEscrow = artifacts.require('RefundEscrow'); contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee2]) { @@ -20,14 +22,14 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee context('active state', function () { it('has beneficiary and state', async function () { - (await this.escrow.beneficiary()).should.be.equal(beneficiary); - (await this.escrow.state()).should.be.bignumber.equal('0'); + expect(await this.escrow.beneficiary()).to.equal(beneficiary); + expect(await this.escrow.state()).to.be.bignumber.equal('0'); }); it('accepts deposits', async function () { await this.escrow.deposit(refundee1, { from: primary, value: amount }); - (await this.escrow.depositsOf(refundee1)).should.be.bignumber.equal(amount); + expect(await this.escrow.depositsOf(refundee1)).to.be.bignumber.equal(amount); }); it('does not refund refundees', async function () { @@ -76,7 +78,7 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee it('allows beneficiary withdrawal', async function () { const balanceTracker = await balance.tracker(beneficiary); await this.escrow.beneficiaryWithdraw(); - (await balanceTracker.delta()).should.be.bignumber.equal(amount.muln(refundees.length)); + expect(await balanceTracker.delta()).to.be.bignumber.equal(amount.muln(refundees.length)); }); it('prevents entering the refund state', async function () { @@ -118,7 +120,7 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee for (const refundee of [refundee1, refundee2]) { const balanceTracker = await balance.tracker(refundee); await this.escrow.withdraw(refundee, { from: primary }); - (await balanceTracker.delta()).should.be.bignumber.equal(amount); + expect(await balanceTracker.delta()).to.be.bignumber.equal(amount); } }); diff --git a/test/token/ERC20/ERC20.behavior.js b/test/token/ERC20/ERC20.behavior.js index 1d21ad8f607..3934f34ea85 100644 --- a/test/token/ERC20/ERC20.behavior.js +++ b/test/token/ERC20/ERC20.behavior.js @@ -1,23 +1,25 @@ const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recipient, anotherAccount) { describe('total supply', function () { it('returns the total amount of tokens', async function () { - (await this.token.totalSupply()).should.be.bignumber.equal(initialSupply); + expect(await this.token.totalSupply()).to.be.bignumber.equal(initialSupply); }); }); describe('balanceOf', function () { describe('when the requested account has no tokens', function () { it('returns zero', async function () { - (await this.token.balanceOf(anotherAccount)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOf(anotherAccount)).to.be.bignumber.equal('0'); }); }); describe('when the requested account has some tokens', function () { it('returns the total amount of tokens', async function () { - (await this.token.balanceOf(initialHolder)).should.be.bignumber.equal(initialSupply); + expect(await this.token.balanceOf(initialHolder)).to.be.bignumber.equal(initialSupply); }); }); }); @@ -50,15 +52,15 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip it('transfers the requested amount', async function () { await this.token.transferFrom(tokenOwner, to, amount, { from: spender }); - (await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOf(tokenOwner)).to.be.bignumber.equal('0'); - (await this.token.balanceOf(to)).should.be.bignumber.equal(amount); + expect(await this.token.balanceOf(to)).to.be.bignumber.equal(amount); }); it('decreases the spender allowance', async function () { await this.token.transferFrom(tokenOwner, to, amount, { from: spender }); - (await this.token.allowance(tokenOwner, spender)).should.be.bignumber.equal('0'); + expect(await this.token.allowance(tokenOwner, spender)).to.be.bignumber.equal('0'); }); it('emits a transfer event', async function () { @@ -176,9 +178,9 @@ function shouldBehaveLikeERC20Transfer (errorPrefix, from, to, balance, transfer it('transfers the requested amount', async function () { await transfer.call(this, from, to, amount); - (await this.token.balanceOf(from)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOf(from)).to.be.bignumber.equal('0'); - (await this.token.balanceOf(to)).should.be.bignumber.equal(amount); + expect(await this.token.balanceOf(to)).to.be.bignumber.equal(amount); }); it('emits a transfer event', async function () { @@ -198,9 +200,9 @@ function shouldBehaveLikeERC20Transfer (errorPrefix, from, to, balance, transfer it('transfers the requested amount', async function () { await transfer.call(this, from, to, amount); - (await this.token.balanceOf(from)).should.be.bignumber.equal(balance); + expect(await this.token.balanceOf(from)).to.be.bignumber.equal(balance); - (await this.token.balanceOf(to)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOf(to)).to.be.bignumber.equal('0'); }); it('emits a transfer event', async function () { @@ -243,7 +245,7 @@ function shouldBehaveLikeERC20Approve (errorPrefix, owner, spender, supply, appr it('approves the requested amount', async function () { await approve.call(this, owner, spender, amount); - (await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount); + expect(await this.token.allowance(owner, spender)).to.be.bignumber.equal(amount); }); }); @@ -255,7 +257,7 @@ function shouldBehaveLikeERC20Approve (errorPrefix, owner, spender, supply, appr it('approves the requested amount and replaces the previous one', async function () { await approve.call(this, owner, spender, amount); - (await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount); + expect(await this.token.allowance(owner, spender)).to.be.bignumber.equal(amount); }); }); }); @@ -277,7 +279,7 @@ function shouldBehaveLikeERC20Approve (errorPrefix, owner, spender, supply, appr it('approves the requested amount', async function () { await approve.call(this, owner, spender, amount); - (await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount); + expect(await this.token.allowance(owner, spender)).to.be.bignumber.equal(amount); }); }); @@ -289,7 +291,7 @@ function shouldBehaveLikeERC20Approve (errorPrefix, owner, spender, supply, appr it('approves the requested amount and replaces the previous one', async function () { await approve.call(this, owner, spender, amount); - (await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount); + expect(await this.token.allowance(owner, spender)).to.be.bignumber.equal(amount); }); }); }); diff --git a/test/token/ERC20/ERC20.test.js b/test/token/ERC20/ERC20.test.js index 5f786b27d0d..af188ebe128 100644 --- a/test/token/ERC20/ERC20.test.js +++ b/test/token/ERC20/ERC20.test.js @@ -1,6 +1,8 @@ const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + const { shouldBehaveLikeERC20, shouldBehaveLikeERC20Transfer, @@ -51,12 +53,12 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { it('decreases the spender allowance subtracting the requested amount', async function () { await this.token.decreaseAllowance(spender, approvedAmount.subn(1), { from: initialHolder }); - (await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal('1'); + expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal('1'); }); it('sets the allowance to zero when all allowance is removed', async function () { await this.token.decreaseAllowance(spender, approvedAmount, { from: initialHolder }); - (await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal('0'); + expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal('1'); }); it('reverts when more than the full allowance is removed', async function () { @@ -114,7 +116,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { it('approves the requested amount', async function () { await this.token.increaseAllowance(spender, amount, { from: initialHolder }); - (await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal(amount); + expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal(amount); }); }); @@ -126,7 +128,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { it('increases the spender allowance adding the requested amount', async function () { await this.token.increaseAllowance(spender, amount, { from: initialHolder }); - (await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal(amount.addn(1)); + expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal(amount.addn(1)); }); }); }); @@ -148,7 +150,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { it('approves the requested amount', async function () { await this.token.increaseAllowance(spender, amount, { from: initialHolder }); - (await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal(amount); + expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal(amount); }); }); @@ -160,7 +162,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { it('increases the spender allowance adding the requested amount', async function () { await this.token.increaseAllowance(spender, amount, { from: initialHolder }); - (await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal(amount.addn(1)); + expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal(amount.addn(1)); }); }); }); @@ -193,11 +195,11 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { it('increments totalSupply', async function () { const expectedSupply = initialSupply.add(amount); - (await this.token.totalSupply()).should.be.bignumber.equal(expectedSupply); + expect(await this.token.totalSupply()).to.be.bignumber.equal(expectedSupply); }); it('increments recipient balance', async function () { - (await this.token.balanceOf(recipient)).should.be.bignumber.equal(amount); + expect(await this.token.balanceOf(recipient)).to.be.bignumber.equal(amount); }); it('emits Transfer event', async function () { @@ -206,7 +208,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { to: recipient, }); - event.args.value.should.be.bignumber.equal(amount); + expect(event.args.value).to.be.bignumber.equal(amount); }); }); }); @@ -233,12 +235,12 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { it('decrements totalSupply', async function () { const expectedSupply = initialSupply.sub(amount); - (await this.token.totalSupply()).should.be.bignumber.equal(expectedSupply); + expect(await this.token.totalSupply()).to.be.bignumber.equal(expectedSupply); }); it('decrements initialHolder balance', async function () { const expectedBalance = initialSupply.sub(amount); - (await this.token.balanceOf(initialHolder)).should.be.bignumber.equal(expectedBalance); + expect(await this.token.balanceOf(initialHolder)).to.be.bignumber.equal(expectedBalance); }); it('emits Transfer event', async function () { @@ -247,7 +249,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { to: ZERO_ADDRESS, }); - event.args.value.should.be.bignumber.equal(amount); + expect(event.args.value).to.be.bignumber.equal(amount); }); }); }; @@ -294,17 +296,17 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { it('decrements totalSupply', async function () { const expectedSupply = initialSupply.sub(amount); - (await this.token.totalSupply()).should.be.bignumber.equal(expectedSupply); + expect(await this.token.totalSupply()).to.be.bignumber.equal(expectedSupply); }); it('decrements initialHolder balance', async function () { const expectedBalance = initialSupply.sub(amount); - (await this.token.balanceOf(initialHolder)).should.be.bignumber.equal(expectedBalance); + expect(await this.token.balanceOf(initialHolder)).to.be.bignumber.equal(expectedBalance); }); it('decrements spender allowance', async function () { const expectedAllowance = allowance.sub(amount); - (await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal(expectedAllowance); + expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal(expectedAllowance); }); it('emits a Transfer event', async function () { @@ -313,7 +315,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { to: ZERO_ADDRESS, }); - event.args.value.should.be.bignumber.equal(amount); + expect(event.args.value).to.be.bignumber.equal(amount); }); it('emits an Approval event', async function () { diff --git a/test/token/ERC20/ERC20Detailed.test.js b/test/token/ERC20/ERC20Detailed.test.js index 1978350b266..2cb151e1147 100644 --- a/test/token/ERC20/ERC20Detailed.test.js +++ b/test/token/ERC20/ERC20Detailed.test.js @@ -1,5 +1,7 @@ const { BN } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const ERC20DetailedMock = artifacts.require('ERC20DetailedMock'); contract('ERC20Detailed', function () { @@ -12,14 +14,14 @@ contract('ERC20Detailed', function () { }); it('has a name', async function () { - (await this.detailedERC20.name()).should.be.equal(_name); + expect(await this.detailedERC20.name()).to.equal(_name); }); it('has a symbol', async function () { - (await this.detailedERC20.symbol()).should.be.equal(_symbol); + expect(await this.detailedERC20.symbol()).to.equal(_symbol); }); it('has an amount of decimals', async function () { - (await this.detailedERC20.decimals()).should.be.bignumber.equal(_decimals); + expect(await this.detailedERC20.decimals()).to.be.bignumber.equal(_decimals); }); }); diff --git a/test/token/ERC20/ERC20Pausable.test.js b/test/token/ERC20/ERC20Pausable.test.js index 210c3f5b645..9cc19250ebb 100644 --- a/test/token/ERC20/ERC20Pausable.test.js +++ b/test/token/ERC20/ERC20Pausable.test.js @@ -1,5 +1,7 @@ const { BN, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const ERC20PausableMock = artifacts.require('ERC20PausableMock'); const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior'); @@ -26,7 +28,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA describe('when the token is unpaused', function () { it('pauses the token', async function () { await this.token.pause({ from }); - (await this.token.paused()).should.equal(true); + expect(await this.token.paused()).to.equal(true); }); it('emits a Pause event', async function () { @@ -69,7 +71,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA it('unpauses the token', async function () { await this.token.unpause({ from }); - (await this.token.paused()).should.equal(false); + expect(await this.token.paused()).to.equal(false); }); it('emits an Unpause event', async function () { @@ -102,18 +104,18 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA describe('paused', function () { it('is not paused by default', async function () { - (await this.token.paused({ from })).should.equal(false); + expect(await this.token.paused({ from })).to.equal(false); }); it('is paused after being paused', async function () { await this.token.pause({ from }); - (await this.token.paused({ from })).should.equal(true); + expect(await this.token.paused({ from })).to.equal(true); }); it('is not paused after being paused and then unpaused', async function () { await this.token.pause({ from }); await this.token.unpause({ from }); - (await this.token.paused()).should.equal(false); + expect(await this.token.paused()).to.equal(false); }); }); @@ -121,8 +123,8 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA it('allows to transfer when unpaused', async function () { await this.token.transfer(recipient, initialSupply, { from: pauser }); - (await this.token.balanceOf(pauser)).should.be.bignumber.equal('0'); - (await this.token.balanceOf(recipient)).should.be.bignumber.equal(initialSupply); + expect(await this.token.balanceOf(pauser)).to.be.bignumber.equal('0'); + expect(await this.token.balanceOf(recipient)).to.be.bignumber.equal(initialSupply); }); it('allows to transfer when paused and then unpaused', async function () { @@ -131,8 +133,8 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA await this.token.transfer(recipient, initialSupply, { from: pauser }); - (await this.token.balanceOf(pauser)).should.be.bignumber.equal('0'); - (await this.token.balanceOf(recipient)).should.be.bignumber.equal(initialSupply); + expect(await this.token.balanceOf(pauser)).to.be.bignumber.equal('0'); + expect(await this.token.balanceOf(recipient)).to.be.bignumber.equal(initialSupply); }); it('reverts when trying to transfer when paused', async function () { @@ -150,7 +152,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA it('allows to approve when unpaused', async function () { await this.token.approve(anotherAccount, allowance, { from: pauser }); - (await this.token.allowance(pauser, anotherAccount)).should.be.bignumber.equal(allowance); + expect(await this.token.allowance(pauser, anotherAccount)).to.be.bignumber.equal(allowance); }); it('allows to approve when paused and then unpaused', async function () { @@ -159,7 +161,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA await this.token.approve(anotherAccount, allowance, { from: pauser }); - (await this.token.allowance(pauser, anotherAccount)).should.be.bignumber.equal(allowance); + expect(await this.token.allowance(pauser, anotherAccount)).to.be.bignumber.equal(allowance); }); it('reverts when trying to approve when paused', async function () { @@ -181,8 +183,8 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA it('allows to transfer from when unpaused', async function () { await this.token.transferFrom(pauser, recipient, allowance, { from: anotherAccount }); - (await this.token.balanceOf(recipient)).should.be.bignumber.equal(allowance); - (await this.token.balanceOf(pauser)).should.be.bignumber.equal(initialSupply.sub(allowance)); + expect(await this.token.balanceOf(recipient)).to.be.bignumber.equal(allowance); + expect(await this.token.balanceOf(pauser)).to.be.bignumber.equal(initialSupply.sub(allowance)); }); it('allows to transfer when paused and then unpaused', async function () { @@ -191,8 +193,8 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA await this.token.transferFrom(pauser, recipient, allowance, { from: anotherAccount }); - (await this.token.balanceOf(recipient)).should.be.bignumber.equal(allowance); - (await this.token.balanceOf(pauser)).should.be.bignumber.equal(initialSupply.sub(allowance)); + expect(await this.token.balanceOf(recipient)).to.be.bignumber.equal(allowance); + expect(await this.token.balanceOf(pauser)).to.be.bignumber.equal(initialSupply.sub(allowance)); }); it('reverts when trying to transfer from when paused', async function () { @@ -215,7 +217,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA it('allows to decrease approval when unpaused', async function () { await this.token.decreaseAllowance(anotherAccount, decrement, { from: pauser }); - (await this.token.allowance(pauser, anotherAccount)).should.be.bignumber.equal(allowance.sub(decrement)); + expect(await this.token.allowance(pauser, anotherAccount)).to.be.bignumber.equal(allowance.sub(decrement)); }); it('allows to decrease approval when paused and then unpaused', async function () { @@ -224,7 +226,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA await this.token.decreaseAllowance(anotherAccount, decrement, { from: pauser }); - (await this.token.allowance(pauser, anotherAccount)).should.be.bignumber.equal(allowance.sub(decrement)); + expect(await this.token.allowance(pauser, anotherAccount)).to.be.bignumber.equal(allowance.sub(decrement)); }); it('reverts when trying to transfer when paused', async function () { @@ -247,7 +249,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA it('allows to increase approval when unpaused', async function () { await this.token.increaseAllowance(anotherAccount, increment, { from: pauser }); - (await this.token.allowance(pauser, anotherAccount)).should.be.bignumber.equal(allowance.add(increment)); + expect(await this.token.allowance(pauser, anotherAccount)).to.be.bignumber.equal(allowance.add(increment)); }); it('allows to increase approval when paused and then unpaused', async function () { @@ -256,7 +258,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA await this.token.increaseAllowance(anotherAccount, increment, { from: pauser }); - (await this.token.allowance(pauser, anotherAccount)).should.be.bignumber.equal(allowance.add(increment)); + expect(await this.token.allowance(pauser, anotherAccount)).to.be.bignumber.equal(allowance.add(increment)); }); it('reverts when trying to increase approval when paused', async function () { diff --git a/test/token/ERC20/TokenTimelock.test.js b/test/token/ERC20/TokenTimelock.test.js index ac7dbfcad4d..42f8b343b8b 100644 --- a/test/token/ERC20/TokenTimelock.test.js +++ b/test/token/ERC20/TokenTimelock.test.js @@ -1,5 +1,7 @@ const { BN, expectRevert, time } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const ERC20Mintable = artifacts.require('ERC20Mintable'); const TokenTimelock = artifacts.require('TokenTimelock'); @@ -27,9 +29,9 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) { }); it('can get state', async function () { - (await this.timelock.token()).should.be.equal(this.token.address); - (await this.timelock.beneficiary()).should.be.equal(beneficiary); - (await this.timelock.releaseTime()).should.be.bignumber.equal(this.releaseTime); + expect(await this.timelock.token()).to.equal(this.token.address); + expect(await this.timelock.beneficiary()).to.equal(beneficiary); + expect(await this.timelock.releaseTime()).to.be.bignumber.equal(this.releaseTime); }); it('cannot be released before time limit', async function () { @@ -44,20 +46,20 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) { it('can be released just after limit', async function () { await time.increaseTo(this.releaseTime.add(time.duration.seconds(1))); await this.timelock.release(); - (await this.token.balanceOf(beneficiary)).should.be.bignumber.equal(amount); + expect(await this.token.balanceOf(beneficiary)).to.be.bignumber.equal(amount); }); it('can be released after time limit', async function () { await time.increaseTo(this.releaseTime.add(time.duration.years(1))); await this.timelock.release(); - (await this.token.balanceOf(beneficiary)).should.be.bignumber.equal(amount); + expect(await this.token.balanceOf(beneficiary)).to.be.bignumber.equal(amount); }); it('cannot be released twice', async function () { await time.increaseTo(this.releaseTime.add(time.duration.years(1))); await this.timelock.release(); await expectRevert(this.timelock.release(), 'TokenTimelock: no tokens to release'); - (await this.token.balanceOf(beneficiary)).should.be.bignumber.equal(amount); + expect(await this.token.balanceOf(beneficiary)).to.be.bignumber.equal(amount); }); }); }); diff --git a/test/token/ERC20/behaviors/ERC20Burnable.behavior.js b/test/token/ERC20/behaviors/ERC20Burnable.behavior.js index df645e3f7a2..b770f855ab0 100644 --- a/test/token/ERC20/behaviors/ERC20Burnable.behavior.js +++ b/test/token/ERC20/behaviors/ERC20Burnable.behavior.js @@ -1,6 +1,8 @@ const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { describe('burn', function () { describe('when the given amount is not greater than balance of the sender', function () { @@ -18,7 +20,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { }); it('burns the requested amount', async function () { - (await this.token.balanceOf(owner)).should.be.bignumber.equal(initialBalance.sub(amount)); + expect(await this.token.balanceOf(owner)).to.be.bignumber.equal(initialBalance.sub(amount)); }); it('emits a transfer event', async function () { @@ -62,11 +64,11 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { }); it('burns the requested amount', async function () { - (await this.token.balanceOf(owner)).should.be.bignumber.equal(initialBalance.sub(amount)); + expect(await this.token.balanceOf(owner)).to.be.bignumber.equal(initialBalance.sub(amount)); }); it('decrements allowance', async function () { - (await this.token.allowance(owner, burner)).should.be.bignumber.equal(originalAllowance.sub(amount)); + expect(await this.token.allowance(owner, burner)).to.be.bignumber.equal(originalAllowance.sub(amount)); }); it('emits a transfer event', async function () { diff --git a/test/token/ERC20/behaviors/ERC20Capped.behavior.js b/test/token/ERC20/behaviors/ERC20Capped.behavior.js index b4c74a1ab6e..c5e3968c47e 100644 --- a/test/token/ERC20/behaviors/ERC20Capped.behavior.js +++ b/test/token/ERC20/behaviors/ERC20Capped.behavior.js @@ -1,16 +1,18 @@ const { expectRevert } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + function shouldBehaveLikeERC20Capped (minter, [other], cap) { describe('capped token', function () { const from = minter; it('should start with the correct cap', async function () { - (await this.token.cap()).should.be.bignumber.equal(cap); + expect(await this.token.cap()).to.be.bignumber.equal(cap); }); it('should mint when amount is less than cap', async function () { await this.token.mint(other, cap.subn(1), { from }); - (await this.token.totalSupply()).should.be.bignumber.equal(cap.subn(1)); + expect(await this.token.totalSupply()).to.be.bignumber.equal(cap.subn(1)); }); it('should fail to mint if the amount exceeds the cap', async function () { diff --git a/test/token/ERC20/behaviors/ERC20Mintable.behavior.js b/test/token/ERC20/behaviors/ERC20Mintable.behavior.js index e4197209cbe..f505e57bea8 100644 --- a/test/token/ERC20/behaviors/ERC20Mintable.behavior.js +++ b/test/token/ERC20/behaviors/ERC20Mintable.behavior.js @@ -1,6 +1,8 @@ const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + function shouldBehaveLikeERC20Mintable (minter, [other]) { describe('as a mintable token', function () { describe('mint', function () { @@ -23,7 +25,7 @@ function shouldBehaveLikeERC20Mintable (minter, [other]) { }); it('mints the requested amount', async function () { - (await this.token.balanceOf(other)).should.be.bignumber.equal(amount); + expect(await this.token.balanceOf(other)).to.be.bignumber.equal(amount); }); it('emits a mint and a transfer event', async function () { diff --git a/test/token/ERC721/ERC721.behavior.js b/test/token/ERC721/ERC721.behavior.js index a2c9e53f880..04b5d9ed211 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -2,6 +2,8 @@ const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test- const { ZERO_ADDRESS } = constants; const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior'); +const { expect } = require('chai'); + const ERC721ReceiverMock = artifacts.require('ERC721ReceiverMock.sol'); function shouldBehaveLikeERC721 ( @@ -24,13 +26,13 @@ function shouldBehaveLikeERC721 ( describe('balanceOf', function () { context('when the given address owns some tokens', function () { it('returns the amount of tokens owned by the given address', async function () { - (await this.token.balanceOf(owner)).should.be.bignumber.equal('2'); + expect(await this.token.balanceOf(owner)).to.be.bignumber.equal('2'); }); }); context('when the given address does not own any tokens', function () { it('returns 0', async function () { - (await this.token.balanceOf(other)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOf(other)).to.be.bignumber.equal('0'); }); }); @@ -48,7 +50,7 @@ function shouldBehaveLikeERC721 ( const tokenId = firstTokenId; it('returns the owner of the given token ID', async function () { - (await this.token.ownerOf(tokenId)).should.be.equal(owner); + expect(await this.token.ownerOf(tokenId)).to.equal(owner); }); }); @@ -76,11 +78,11 @@ function shouldBehaveLikeERC721 ( const transferWasSuccessful = function ({ owner, tokenId, approved }) { it('transfers the ownership of the given token ID to the given address', async function () { - (await this.token.ownerOf(tokenId)).should.be.equal(this.toWhom); + expect(await this.token.ownerOf(tokenId)).to.equal(this.toWhom); }); it('clears the approval for the token ID', async function () { - (await this.token.getApproved(tokenId)).should.be.equal(ZERO_ADDRESS); + expect(await this.token.getApproved(tokenId)).to.equal(ZERO_ADDRESS); }); if (approved) { @@ -102,15 +104,15 @@ function shouldBehaveLikeERC721 ( } it('adjusts owners balances', async function () { - (await this.token.balanceOf(owner)).should.be.bignumber.equal('1'); + expect(await this.token.balanceOf(owner)).to.be.bignumber.equal('1'); }); it('adjusts owners tokens by index', async function () { if (!this.token.tokenOfOwnerByIndex) return; - (await this.token.tokenOfOwnerByIndex(this.toWhom, 0)).should.be.bignumber.equal(tokenId); + expect(await this.token.tokenOfOwnerByIndex(this.toWhom, 0)).to.be.bignumber.equal(tokenId); - (await this.token.tokenOfOwnerByIndex(owner, 0)).should.be.bignumber.not.equal(tokenId); + expect(await this.token.tokenOfOwnerByIndex(owner, 0)).to.be.bignumber.equal(tokenId); }); }; @@ -150,11 +152,11 @@ function shouldBehaveLikeERC721 ( }); it('keeps ownership of the token', async function () { - (await this.token.ownerOf(tokenId)).should.be.equal(owner); + expect(await this.token.ownerOf(tokenId)).to.equal(owner); }); it('clears the approval for the token ID', async function () { - (await this.token.getApproved(tokenId)).should.be.equal(ZERO_ADDRESS); + expect(await this.token.getApproved(tokenId)).to.equal(ZERO_ADDRESS); }); it('emits only a transfer event', async function () { @@ -166,7 +168,7 @@ function shouldBehaveLikeERC721 ( }); it('keeps the owner balance', async function () { - (await this.token.balanceOf(owner)).should.be.bignumber.equal('2'); + expect(await this.token.balanceOf(owner)).to.be.bignumber.equal('2'); }); it('keeps same tokens by index', async function () { @@ -174,7 +176,7 @@ function shouldBehaveLikeERC721 ( const tokensListed = await Promise.all( [0, 1].map(i => this.token.tokenOfOwnerByIndex(owner, i)) ); - tokensListed.map(t => t.toNumber()).should.have.members( + expect(tokensListed.map(t => t.toNumber())).to.have.members( [firstTokenId.toNumber(), secondTokenId.toNumber()] ); }); @@ -330,13 +332,13 @@ function shouldBehaveLikeERC721 ( const itClearsApproval = function () { it('clears approval for the token', async function () { - (await this.token.getApproved(tokenId)).should.be.equal(ZERO_ADDRESS); + expect(await this.token.getApproved(tokenId)).to.be.equal(ZERO_ADDRESS); }); }; const itApproves = function (address) { it('sets the approval for the target address', async function () { - (await this.token.getApproved(tokenId)).should.be.equal(address); + expect(await this.token.getApproved(tokenId)).to.equal(address); }); }; @@ -449,7 +451,7 @@ function shouldBehaveLikeERC721 ( it('approves the operator', async function () { await this.token.setApprovalForAll(operator, true, { from: owner }); - (await this.token.isApprovedForAll(owner, operator)).should.equal(true); + expect(await this.token.isApprovedForAll(owner, operator)).to.equal(true); }); it('emits an approval event', async function () { @@ -471,7 +473,7 @@ function shouldBehaveLikeERC721 ( it('approves the operator', async function () { await this.token.setApprovalForAll(operator, true, { from: owner }); - (await this.token.isApprovedForAll(owner, operator)).should.equal(true); + expect(await this.token.isApprovedForAll(owner, operator)).to.equal(true); }); it('emits an approval event', async function () { @@ -487,7 +489,7 @@ function shouldBehaveLikeERC721 ( it('can unset the operator approval', async function () { await this.token.setApprovalForAll(operator, false, { from: owner }); - (await this.token.isApprovedForAll(owner, operator)).should.equal(false); + expect(await this.token.isApprovedForAll(owner, operator)).to.equal(false); }); }); @@ -499,7 +501,7 @@ function shouldBehaveLikeERC721 ( it('keeps the approval to the given address', async function () { await this.token.setApprovalForAll(operator, true, { from: owner }); - (await this.token.isApprovedForAll(owner, operator)).should.equal(true); + expect(await this.token.isApprovedForAll(owner, operator)).to.equal(true); }); it('emits an approval event', async function () { diff --git a/test/token/ERC721/ERC721.test.js b/test/token/ERC721/ERC721.test.js index 20c927914af..484061e9684 100644 --- a/test/token/ERC721/ERC721.test.js +++ b/test/token/ERC721/ERC721.test.js @@ -1,6 +1,8 @@ const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + const { shouldBehaveLikeERC721 } = require('./ERC721.behavior'); const ERC721Mock = artifacts.require('ERC721Mock.sol'); @@ -31,8 +33,8 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { }); it('creates the token', async function () { - (await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('1'); - (await this.token.ownerOf(tokenId)).should.equal(tokenOwner); + expect(await this.token.balanceOf(tokenOwner)).to.be.bignumber.equal('1'); + expect(await this.token.ownerOf(tokenId)).to.equal(tokenOwner); }); it('reverts when adding a token id that already exists', async function () { @@ -69,7 +71,7 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { }); it('deletes the token', async function () { - (await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOf(tokenOwner)).to.be.bignumber.equal('0'); await expectRevert( this.token.ownerOf(tokenId), 'ERC721: owner query for nonexistent token' ); @@ -107,7 +109,7 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { }); it('deletes the token', async function () { - (await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOf(tokenOwner)).to.be.bignumber.equal('0'); await expectRevert( this.token.ownerOf(tokenId), 'ERC721: owner query for nonexistent token' ); diff --git a/test/token/ERC721/ERC721Full.test.js b/test/token/ERC721/ERC721Full.test.js index 003d2baee07..bacbf3e48d7 100644 --- a/test/token/ERC721/ERC721Full.test.js +++ b/test/token/ERC721/ERC721Full.test.js @@ -1,5 +1,7 @@ const { BN, expectRevert } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const { shouldBehaveLikeERC721 } = require('./ERC721.behavior'); const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior'); @@ -40,11 +42,11 @@ contract('ERC721Full', function ([ }); it('adjusts owner tokens by index', async function () { - (await this.token.tokenOfOwnerByIndex(newOwner, 0)).should.be.bignumber.equal(thirdTokenId); + expect(await this.token.tokenOfOwnerByIndex(newOwner, 0)).to.be.bignumber.equal(thirdTokenId); }); it('adjusts all tokens list', async function () { - (await this.token.tokenByIndex(2)).should.be.bignumber.equal(thirdTokenId); + expect(await this.token.tokenByIndex(2)).to.be.bignumber.equal(thirdTokenId); }); }); @@ -54,16 +56,16 @@ contract('ERC721Full', function ([ }); it('removes that token from the token list of the owner', async function () { - (await this.token.tokenOfOwnerByIndex(owner, 0)).should.be.bignumber.equal(secondTokenId); + expect(await this.token.tokenOfOwnerByIndex(owner, 0)).to.be.bignumber.equal(secondTokenId); }); it('adjusts all tokens list', async function () { - (await this.token.tokenByIndex(0)).should.be.bignumber.equal(secondTokenId); + expect(await this.token.tokenByIndex(0)).to.be.bignumber.equal(secondTokenId); }); it('burns all tokens', async function () { await this.token.burn(secondTokenId, { from: owner }); - (await this.token.totalSupply()).should.be.bignumber.equal('0'); + expect(await this.token.totalSupply()).to.be.bignumber.equal('0'); await expectRevert( this.token.tokenByIndex(0), 'ERC721Enumerable: global index out of bounds' ); @@ -74,16 +76,16 @@ contract('ERC721Full', function ([ const sampleUri = 'mock://mytoken'; it('has a name', async function () { - (await this.token.name()).should.be.equal(name); + expect(await this.token.name()).to.equal(name); }); it('has a symbol', async function () { - (await this.token.symbol()).should.be.equal(symbol); + expect(await this.token.symbol()).to.equal(symbol); }); it('sets and returns metadata for a token id', async function () { await this.token.setTokenURI(firstTokenId, sampleUri); - (await this.token.tokenURI(firstTokenId)).should.be.equal(sampleUri); + expect(await this.token.tokenURI(firstTokenId)).to.equal(sampleUri); }); it('reverts when setting metadata for non existent token id', async function () { @@ -95,11 +97,11 @@ contract('ERC721Full', function ([ it('can burn token with metadata', async function () { await this.token.setTokenURI(firstTokenId, sampleUri); await this.token.burn(firstTokenId, { from: owner }); - (await this.token.exists(firstTokenId)).should.equal(false); + expect(await this.token.exists(firstTokenId)).to.equal(false); }); it('returns empty metadata for token', async function () { - (await this.token.tokenURI(firstTokenId)).should.be.equal(''); + expect(await this.token.tokenURI(firstTokenId)).to.equal(''); }); it('reverts when querying metadata for non existent token id', async function () { @@ -112,22 +114,22 @@ contract('ERC721Full', function ([ describe('tokensOfOwner', function () { it('returns total tokens of owner', async function () { const tokenIds = await this.token.tokensOfOwner(owner); - tokenIds.length.should.equal(2); - tokenIds[0].should.be.bignumber.equal(firstTokenId); - tokenIds[1].should.be.bignumber.equal(secondTokenId); + expect(tokenIds.length).to.equal(2); + expect(tokenIds[0]).to.be.bignumber.equal(firstTokenId); + expect(tokenIds[1]).to.be.bignumber.equal(secondTokenId); }); }); describe('totalSupply', function () { it('returns total token supply', async function () { - (await this.token.totalSupply()).should.be.bignumber.equal('2'); + expect(await this.token.totalSupply()).to.be.bignumber.equal('2'); }); }); describe('tokenOfOwnerByIndex', 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 () { - (await this.token.tokenOfOwnerByIndex(owner, 0)).should.be.bignumber.equal(firstTokenId); + expect(await this.token.tokenOfOwnerByIndex(owner, 0)).to.be.bignumber.equal(firstTokenId); }); }); @@ -154,15 +156,15 @@ contract('ERC721Full', function ([ }); it('returns correct token IDs for target', async function () { - (await this.token.balanceOf(another)).should.be.bignumber.equal('2'); + expect(await this.token.balanceOf(another)).to.be.bignumber.equal('2'); const tokensListed = await Promise.all( [0, 1].map(i => this.token.tokenOfOwnerByIndex(another, i)) ); - tokensListed.map(t => t.toNumber()).should.have.members([firstTokenId.toNumber(), secondTokenId.toNumber()]); + expect(tokensListed.map(t => t.toNumber())).to.have.members([firstTokenId.toNumber(), secondTokenId.toNumber()]); }); it('returns empty collection for original owner', async function () { - (await this.token.balanceOf(owner)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOf(owner)).to.be.bignumber.equal('0'); await expectRevert( this.token.tokenOfOwnerByIndex(owner, 0), 'ERC721Enumerable: owner index out of bounds' ); @@ -175,7 +177,7 @@ contract('ERC721Full', function ([ const tokensListed = await Promise.all( [0, 1].map(i => this.token.tokenByIndex(i)) ); - tokensListed.map(t => t.toNumber()).should.have.members([firstTokenId.toNumber(), secondTokenId.toNumber()]); + expect(tokensListed.map(t => t.toNumber())).to.have.members([firstTokenId.toNumber(), secondTokenId.toNumber()]); }); it('should revert if index is greater than supply', async function () { @@ -193,7 +195,7 @@ contract('ERC721Full', function ([ await this.token.mint(newOwner, newTokenId, { from: minter }); await this.token.mint(newOwner, anotherNewTokenId, { from: minter }); - (await this.token.totalSupply()).should.be.bignumber.equal('3'); + expect(await this.token.totalSupply()).to.be.bignumber.equal('3'); const tokensListed = await Promise.all( [0, 1, 2].map(i => this.token.tokenByIndex(i)) @@ -201,7 +203,7 @@ contract('ERC721Full', function ([ const expectedTokens = [firstTokenId, secondTokenId, newTokenId, anotherNewTokenId].filter( x => (x !== tokenId) ); - tokensListed.map(t => t.toNumber()).should.have.members(expectedTokens.map(t => t.toNumber())); + expect(tokensListed.map(t => t.toNumber())).to.have.members(expectedTokens.map(t => t.toNumber())); }); }); }); diff --git a/test/token/ERC721/ERC721Holder.test.js b/test/token/ERC721/ERC721Holder.test.js index c37e112b089..cdc60343b71 100644 --- a/test/token/ERC721/ERC721Holder.test.js +++ b/test/token/ERC721/ERC721Holder.test.js @@ -1,5 +1,7 @@ const { BN } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const ERC721Holder = artifacts.require('ERC721Holder.sol'); const ERC721Mintable = artifacts.require('ERC721MintableBurnableImpl.sol'); @@ -13,6 +15,6 @@ contract('ERC721Holder', function ([creator]) { await token.approve(receiver.address, tokenId, { from: creator }); await token.safeTransferFrom(creator, receiver.address, tokenId); - (await token.ownerOf(tokenId)).should.be.equal(receiver.address); + expect(await token.ownerOf(tokenId)).to.be.equal(receiver.address); }); }); diff --git a/test/token/ERC721/ERC721MintBurn.behavior.js b/test/token/ERC721/ERC721MintBurn.behavior.js index 3431d5a1918..63d411b1089 100644 --- a/test/token/ERC721/ERC721MintBurn.behavior.js +++ b/test/token/ERC721/ERC721MintBurn.behavior.js @@ -1,6 +1,8 @@ const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + function shouldBehaveLikeMintAndBurnERC721 ( creator, minter, @@ -28,11 +30,11 @@ function shouldBehaveLikeMintAndBurnERC721 ( }); it('assigns the token to the new owner', async function () { - (await this.token.ownerOf(thirdTokenId)).should.be.equal(newOwner); + expect(await this.token.ownerOf(thirdTokenId)).to.equal(newOwner); }); it('increases the balance of its owner', async function () { - (await this.token.balanceOf(newOwner)).should.be.bignumber.equal('1'); + expect(await this.token.balanceOf(newOwner)).to.be.bignumber.equal('1'); }); it('emits a transfer and minted event', async function () { @@ -85,7 +87,7 @@ function shouldBehaveLikeMintAndBurnERC721 ( this.token.ownerOf(tokenId), 'ERC721: owner query for nonexistent token' ); - (await this.token.balanceOf(owner)).should.be.bignumber.equal('1'); + expect(await this.token.balanceOf(owner)).to.be.bignumber.equal('1'); }); it('emits a burn event', async function () { diff --git a/test/token/ERC721/ERC721PausedToken.behavior.js b/test/token/ERC721/ERC721PausedToken.behavior.js index b52787b5408..b758f1859db 100644 --- a/test/token/ERC721/ERC721PausedToken.behavior.js +++ b/test/token/ERC721/ERC721PausedToken.behavior.js @@ -1,6 +1,8 @@ const { BN, constants, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + function shouldBehaveLikeERC721PausedToken (owner, [recipient, operator]) { const firstTokenId = new BN(1); const mintedTokens = new BN(1); @@ -46,33 +48,33 @@ function shouldBehaveLikeERC721PausedToken (owner, [recipient, operator]) { describe('getApproved', function () { it('returns approved address', async function () { const approvedAccount = await this.token.getApproved(firstTokenId); - approvedAccount.should.be.equal(ZERO_ADDRESS); + expect(approvedAccount).to.equal(ZERO_ADDRESS); }); }); describe('balanceOf', function () { it('returns the amount of tokens owned by the given address', async function () { const balance = await this.token.balanceOf(owner); - balance.should.be.bignumber.equal(mintedTokens); + expect(balance).to.be.bignumber.equal(mintedTokens); }); }); describe('ownerOf', function () { it('returns the amount of tokens owned by the given address', async function () { const ownerOfToken = await this.token.ownerOf(firstTokenId); - ownerOfToken.should.be.equal(owner); + expect(ownerOfToken).to.equal(owner); }); }); describe('exists', function () { it('should return token existence', async function () { - (await this.token.exists(firstTokenId)).should.equal(true); + expect(await this.token.exists(firstTokenId)).to.equal(true); }); }); describe('isApprovedForAll', function () { it('returns the approval of the operator', async function () { - (await this.token.isApprovedForAll(owner, operator)).should.equal(false); + expect(await this.token.isApprovedForAll(owner, operator)).to.equal(false); }); }); }); diff --git a/test/token/ERC777/ERC777.behavior.js b/test/token/ERC777/ERC777.behavior.js index 90992e10826..f6f67ad3d6e 100644 --- a/test/token/ERC777/ERC777.behavior.js +++ b/test/token/ERC777/ERC777.behavior.js @@ -1,6 +1,8 @@ const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); const { ZERO_ADDRESS } = constants; +const { expect } = require('chai'); + const ERC777SenderRecipientMock = artifacts.require('ERC777SenderRecipientMock'); function shouldBehaveLikeERC777DirectSendBurn (holder, recipient, data) { @@ -217,9 +219,9 @@ function shouldSendTokens (from, operator, to, amount, data, operatorData) { const finalFromBalance = await this.token.balanceOf(from); const finalToBalance = await this.token.balanceOf(to); - finalTotalSupply.should.be.bignumber.equal(initialTotalSupply); - finalToBalance.sub(initialToBalance).should.be.bignumber.equal(amount); - finalFromBalance.sub(initialFromBalance).should.be.bignumber.equal(amount.neg()); + expect(finalTotalSupply).to.be.bignumber.equal(initialTotalSupply); + expect(finalToBalance.sub(initialToBalance)).to.be.bignumber.equal(amount); + expect(finalFromBalance.sub(initialFromBalance)).to.be.bignumber.equal(amount.neg()); }); } @@ -268,8 +270,8 @@ function shouldBurnTokens (from, operator, amount, data, operatorData) { const finalTotalSupply = await this.token.totalSupply(); const finalFromBalance = await this.token.balanceOf(from); - finalTotalSupply.sub(initialTotalSupply).should.be.bignumber.equal(amount.neg()); - finalFromBalance.sub(initialFromBalance).should.be.bignumber.equal(amount.neg()); + expect(finalTotalSupply.sub(initialTotalSupply)).to.be.bignumber.equal(amount.neg()); + expect(finalFromBalance.sub(initialFromBalance)).to.be.bignumber.equal(amount.neg()); }); } @@ -306,8 +308,8 @@ function shouldInternalMintTokens (operator, to, amount, data, operatorData) { const finalTotalSupply = await this.token.totalSupply(); const finalToBalance = await this.token.balanceOf(to); - finalTotalSupply.sub(initialTotalSupply).should.be.bignumber.equal(amount); - finalToBalance.sub(initialToBalance).should.be.bignumber.equal(amount); + expect(finalTotalSupply.sub(initialTotalSupply)).to.be.bignumber.equal(amount); + expect(finalToBalance.sub(initialToBalance)).to.be.bignumber.equal(amount); }); } @@ -505,7 +507,7 @@ function shouldBehaveLikeERC777SendBurnWithSendHook (operator, amount, data, ope function removeBalance (holder) { beforeEach(async function () { await this.token.burn(await this.token.balanceOf(holder), '0x', { from: holder }); - (await this.token.balanceOf(holder)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOf(holder)).to.be.bignumber.equal('0'); }); } diff --git a/test/token/ERC777/ERC777.test.js b/test/token/ERC777/ERC777.test.js index a13d2de4652..9c8ef4ceaf4 100644 --- a/test/token/ERC777/ERC777.test.js +++ b/test/token/ERC777/ERC777.test.js @@ -1,5 +1,7 @@ const { BN, expectEvent, expectRevert, singletons } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const { shouldBehaveLikeERC777DirectSendBurn, shouldBehaveLikeERC777OperatorSendBurn, @@ -44,56 +46,56 @@ contract('ERC777', function ([ describe('basic information', function () { it('returns the name', async function () { - (await this.token.name()).should.equal(name); + expect(await this.token.name()).to.equal(name); }); it('returns the symbol', async function () { - (await this.token.symbol()).should.equal(symbol); + expect(await this.token.symbol()).to.equal(symbol); }); it('returns a granularity of 1', async function () { - (await this.token.granularity()).should.be.bignumber.equal('1'); + expect(await this.token.granularity()).to.be.bignumber.equal('1'); }); it('returns the default operators', async function () { - (await this.token.defaultOperators()).should.deep.equal(defaultOperators); + expect(await this.token.defaultOperators()).to.deep.equal(defaultOperators); }); it('default operators are operators for all accounts', async function () { for (const operator of defaultOperators) { - (await this.token.isOperatorFor(operator, anyone)).should.equal(true); + expect(await this.token.isOperatorFor(operator, anyone)).to.equal(true); } }); it('returns the total supply', async function () { - (await this.token.totalSupply()).should.be.bignumber.equal(initialSupply); + expect(await this.token.totalSupply()).to.be.bignumber.equal(initialSupply); }); it('returns 18 when decimals is called', async function () { - (await this.token.decimals()).should.be.bignumber.equal('18'); + expect(await this.token.decimals()).to.be.bignumber.equal('18'); }); it('the ERC777Token interface is registered in the registry', async function () { - (await this.erc1820.getInterfaceImplementer(this.token.address, web3.utils.soliditySha3('ERC777Token'))) - .should.equal(this.token.address); + expect(await this.erc1820.getInterfaceImplementer(this.token.address, web3.utils.soliditySha3('ERC777Token'))) + .to.equal(this.token.address); }); it('the ERC20Token interface is registered in the registry', async function () { - (await this.erc1820.getInterfaceImplementer(this.token.address, web3.utils.soliditySha3('ERC20Token'))) - .should.equal(this.token.address); + expect(await this.erc1820.getInterfaceImplementer(this.token.address, web3.utils.soliditySha3('ERC20Token'))) + .to.equal(this.token.address); }); }); describe('balanceOf', function () { context('for an account with no tokens', function () { it('returns zero', async function () { - (await this.token.balanceOf(anyone)).should.be.bignumber.equal('0'); + expect(await this.token.balanceOf(anyone)).to.be.bignumber.equal('0'); }); }); context('for an account with tokens', function () { it('returns their balance', async function () { - (await this.token.balanceOf(holder)).should.be.bignumber.equal(initialSupply); + expect(await this.token.balanceOf(holder)).to.be.bignumber.equal(initialSupply); }); }); }); @@ -155,7 +157,7 @@ contract('ERC777', function ([ describe('operator management', function () { it('accounts are their own operator', async function () { - (await this.token.isOperatorFor(holder, holder)).should.equal(true); + expect(await this.token.isOperatorFor(holder, holder)).to.equal(true); }); it('reverts when self-authorizing', async function () { @@ -171,21 +173,21 @@ contract('ERC777', function ([ }); it('non-operators can be revoked', async function () { - (await this.token.isOperatorFor(newOperator, holder)).should.equal(false); + expect(await this.token.isOperatorFor(newOperator, holder)).to.equal(false); const { logs } = await this.token.revokeOperator(newOperator, { from: holder }); expectEvent.inLogs(logs, 'RevokedOperator', { operator: newOperator, tokenHolder: holder }); - (await this.token.isOperatorFor(newOperator, holder)).should.equal(false); + expect(await this.token.isOperatorFor(newOperator, holder)).to.equal(false); }); it('non-operators can be authorized', async function () { - (await this.token.isOperatorFor(newOperator, holder)).should.equal(false); + expect(await this.token.isOperatorFor(newOperator, holder)).to.equal(false); const { logs } = await this.token.authorizeOperator(newOperator, { from: holder }); expectEvent.inLogs(logs, 'AuthorizedOperator', { operator: newOperator, tokenHolder: holder }); - (await this.token.isOperatorFor(newOperator, holder)).should.equal(true); + expect(await this.token.isOperatorFor(newOperator, holder)).to.equal(true); }); describe('new operators', function () { @@ -194,21 +196,21 @@ contract('ERC777', function ([ }); it('are not added to the default operators list', async function () { - (await this.token.defaultOperators()).should.deep.equal(defaultOperators); + expect(await this.token.defaultOperators()).to.deep.equal(defaultOperators); }); it('can be re-authorized', async function () { const { logs } = await this.token.authorizeOperator(newOperator, { from: holder }); expectEvent.inLogs(logs, 'AuthorizedOperator', { operator: newOperator, tokenHolder: holder }); - (await this.token.isOperatorFor(newOperator, holder)).should.equal(true); + expect(await this.token.isOperatorFor(newOperator, holder)).to.equal(true); }); it('can be revoked', async function () { const { logs } = await this.token.revokeOperator(newOperator, { from: holder }); expectEvent.inLogs(logs, 'RevokedOperator', { operator: newOperator, tokenHolder: holder }); - (await this.token.isOperatorFor(newOperator, holder)).should.equal(false); + expect(await this.token.isOperatorFor(newOperator, holder)).to.equal(false); }); }); @@ -217,14 +219,14 @@ contract('ERC777', function ([ const { logs } = await this.token.authorizeOperator(defaultOperatorA, { from: holder }); expectEvent.inLogs(logs, 'AuthorizedOperator', { operator: defaultOperatorA, tokenHolder: holder }); - (await this.token.isOperatorFor(defaultOperatorA, holder)).should.equal(true); + expect(await this.token.isOperatorFor(defaultOperatorA, holder)).to.equal(true); }); it('can be revoked', async function () { const { logs } = await this.token.revokeOperator(defaultOperatorA, { from: holder }); expectEvent.inLogs(logs, 'RevokedOperator', { operator: defaultOperatorA, tokenHolder: holder }); - (await this.token.isOperatorFor(defaultOperatorA, holder)).should.equal(false); + expect(await this.token.isOperatorFor(defaultOperatorA, holder)).to.equal(false); }); it('cannot be revoked for themselves', async function () { @@ -240,22 +242,22 @@ contract('ERC777', function ([ }); it('default operator is not revoked for other holders', async function () { - (await this.token.isOperatorFor(defaultOperatorA, anyone)).should.equal(true); + expect(await this.token.isOperatorFor(defaultOperatorA, anyone)).to.equal(true); }); it('other default operators are not revoked', async function () { - (await this.token.isOperatorFor(defaultOperatorB, holder)).should.equal(true); + expect(await this.token.isOperatorFor(defaultOperatorB, holder)).to.equal(true); }); it('default operators list is not modified', async function () { - (await this.token.defaultOperators()).should.deep.equal(defaultOperators); + expect(await this.token.defaultOperators()).to.deep.equal(defaultOperators); }); it('revoked default operator can be re-authorized', async function () { const { logs } = await this.token.authorizeOperator(defaultOperatorA, { from: holder }); expectEvent.inLogs(logs, 'AuthorizedOperator', { operator: defaultOperatorA, tokenHolder: holder }); - (await this.token.isOperatorFor(defaultOperatorA, holder)).should.equal(true); + expect(await this.token.isOperatorFor(defaultOperatorA, holder)).to.equal(true); }); }); }); @@ -424,7 +426,7 @@ contract('ERC777', function ([ }); it('default operators list is empty', async function () { - (await this.token.defaultOperators()).should.deep.equal([]); + expect(await this.token.defaultOperators()).to.deep.equal([]); }); }); }); diff --git a/test/utils/Address.test.js b/test/utils/Address.test.js index f002c39d70d..b90ba5f9a0f 100644 --- a/test/utils/Address.test.js +++ b/test/utils/Address.test.js @@ -1,37 +1,21 @@ -const { constants } = require('openzeppelin-test-helpers'); +require('openzeppelin-test-helpers'); + +const { expect } = require('chai'); const AddressImpl = artifacts.require('AddressImpl'); const SimpleToken = artifacts.require('SimpleToken'); contract('Address', function ([_, other]) { - const ALL_ONES_ADDRESS = '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF'; - beforeEach(async function () { this.mock = await AddressImpl.new(); }); - describe('isContract', function () { - it('should return false for account address', async function () { - (await this.mock.isContract(other)).should.equal(false); - }); - - it('should return true for contract address', async function () { - const contract = await SimpleToken.new(); - (await this.mock.isContract(contract.address)).should.equal(true); - }); + it('should return false for account address', async function () { + expect(await this.mock.isContract(other)).to.equal(false); }); - describe('toPayable', function () { - it('should return a payable address when the account is the zero address', async function () { - (await this.mock.toPayable(constants.ZERO_ADDRESS)).should.equal(constants.ZERO_ADDRESS); - }); - - it('should return a payable address when the account is an arbitrary address', async function () { - (await this.mock.toPayable(other)).should.equal(other); - }); - - it('should return a payable address when the account is the all ones address', async function () { - (await this.mock.toPayable(ALL_ONES_ADDRESS)).should.equal(ALL_ONES_ADDRESS); - }); + it('should return true for contract address', async function () { + const contract = await SimpleToken.new(); + expect(await this.mock.isContract(contract.address)).to.equal(true); }); }); diff --git a/test/utils/Arrays.test.js b/test/utils/Arrays.test.js index 8a1125e33df..7301103eb70 100644 --- a/test/utils/Arrays.test.js +++ b/test/utils/Arrays.test.js @@ -1,5 +1,7 @@ require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const ArraysImpl = artifacts.require('ArraysImpl'); contract('Arrays', function () { @@ -11,23 +13,23 @@ contract('Arrays', function () { }); it('should return correct index for the basic case', async function () { - (await this.arrays.findUpperBound(16)).should.be.bignumber.equal('5'); + expect(await this.arrays.findUpperBound(16)).to.be.bignumber.equal('5'); }); it('should return 0 for the first element', async function () { - (await this.arrays.findUpperBound(11)).should.be.bignumber.equal('0'); + expect(await this.arrays.findUpperBound(11)).to.be.bignumber.equal('0'); }); it('should return index of the last element', async function () { - (await this.arrays.findUpperBound(20)).should.be.bignumber.equal('9'); + expect(await this.arrays.findUpperBound(20)).to.be.bignumber.equal('9'); }); it('should return first index after last element if searched value is over the upper boundary', async function () { - (await this.arrays.findUpperBound(32)).should.be.bignumber.equal('10'); + expect(await this.arrays.findUpperBound(32)).to.be.bignumber.equal('10'); }); it('should return 0 for the element under the lower boundary', async function () { - (await this.arrays.findUpperBound(2)).should.be.bignumber.equal('0'); + expect(await this.arrays.findUpperBound(2)).to.be.bignumber.equal('0'); }); }); @@ -39,23 +41,23 @@ contract('Arrays', function () { }); it('should return correct index for the basic case', async function () { - (await this.arrays.findUpperBound(16)).should.be.bignumber.equal('5'); + expect(await this.arrays.findUpperBound(16)).to.be.bignumber.equal('5'); }); it('should return 0 for the first element', async function () { - (await this.arrays.findUpperBound(11)).should.be.bignumber.equal('0'); + expect(await this.arrays.findUpperBound(11)).to.be.bignumber.equal('0'); }); it('should return index of the last element', async function () { - (await this.arrays.findUpperBound(21)).should.be.bignumber.equal('10'); + expect(await this.arrays.findUpperBound(21)).to.be.bignumber.equal('10'); }); it('should return first index after last element if searched value is over the upper boundary', async function () { - (await this.arrays.findUpperBound(32)).should.be.bignumber.equal('11'); + expect(await this.arrays.findUpperBound(32)).to.be.bignumber.equal('11'); }); it('should return 0 for the element under the lower boundary', async function () { - (await this.arrays.findUpperBound(2)).should.be.bignumber.equal('0'); + expect(await this.arrays.findUpperBound(2)).to.be.bignumber.equal('0'); }); }); @@ -67,7 +69,7 @@ contract('Arrays', function () { }); it('should return index of first element in next filled range', async function () { - (await this.arrays.findUpperBound(17)).should.be.bignumber.equal('5'); + expect(await this.arrays.findUpperBound(17)).to.be.bignumber.equal('5'); }); }); @@ -77,7 +79,7 @@ contract('Arrays', function () { }); it('should always return 0 for empty array', async function () { - (await this.arrays.findUpperBound(10)).should.be.bignumber.equal('0'); + expect(await this.arrays.findUpperBound(10)).to.be.bignumber.equal('0'); }); }); }); diff --git a/test/utils/ReentrancyGuard.test.js b/test/utils/ReentrancyGuard.test.js index 4d0f61413b0..611ce34fcdb 100644 --- a/test/utils/ReentrancyGuard.test.js +++ b/test/utils/ReentrancyGuard.test.js @@ -1,12 +1,14 @@ const { expectRevert } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); + const ReentrancyMock = artifacts.require('ReentrancyMock'); const ReentrancyAttack = artifacts.require('ReentrancyAttack'); contract('ReentrancyGuard', function () { beforeEach(async function () { this.reentrancyMock = await ReentrancyMock.new(); - (await this.reentrancyMock.counter()).should.be.bignumber.equal('0'); + expect(await this.reentrancyMock.counter()).to.be.bignumber.equal('0'); }); it('should not allow remote callback', async function () { From 043b5fe3d6b9aa5ccdd395ba0d4a02ec8ca56b60 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Jun 2019 09:44:33 -0400 Subject: [PATCH 2/8] Merged with latest branch --- test/helpers/merkleTree.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/helpers/merkleTree.js b/test/helpers/merkleTree.js index 6ebe19d9038..27a8b201d37 100644 --- a/test/helpers/merkleTree.js +++ b/test/helpers/merkleTree.js @@ -5,10 +5,10 @@ class MerkleTree { // Filter empty strings and hash elements this.elements = elements.filter(el => el).map(el => keccak256(el)); - // Sort elements - this.elements.sort(Buffer.compare); // Deduplicate elements this.elements = this.bufDedup(this.elements); + // Sort elements + this.elements.sort(Buffer.compare); // Create layers this.layers = this.getLayers(this.elements); @@ -113,7 +113,7 @@ class MerkleTree { bufDedup (elements) { return elements.filter((el, idx) => { - return idx === 0 || !elements[idx - 1].equals(el); + return this.bufIndexOf(el, elements) === idx; }); } From 2c40f0282031b4f9c94c99fc271f75429222c79e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Jun 2019 10:10:17 -0400 Subject: [PATCH 3/8] Updated merkleTree helper to latest master branch --- test/helpers/merkleTree.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/helpers/merkleTree.js b/test/helpers/merkleTree.js index 27a8b201d37..7aedd734713 100644 --- a/test/helpers/merkleTree.js +++ b/test/helpers/merkleTree.js @@ -5,10 +5,10 @@ class MerkleTree { // Filter empty strings and hash elements this.elements = elements.filter(el => el).map(el => keccak256(el)); - // Deduplicate elements - this.elements = this.bufDedup(this.elements); // Sort elements this.elements.sort(Buffer.compare); + // Deduplicate elements + this.elements = this.bufDedup(this.elements); // Create layers this.layers = this.getLayers(this.elements); @@ -113,7 +113,7 @@ class MerkleTree { bufDedup (elements) { return elements.filter((el, idx) => { - return this.bufIndexOf(el, elements) === idx; + return idx === 0 || !elements[idx - 1].equals(el); }); } @@ -132,4 +132,4 @@ class MerkleTree { module.exports = { MerkleTree, -}; +}; \ No newline at end of file From d3505da1e31a3965e68932a5ba55ebbab7bef930 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Thu, 20 Jun 2019 14:26:16 +0000 Subject: [PATCH 4/8] Made linting fixes --- package-lock.json | 18 ++++++------------ test/drafts/SignatureBouncer.test.js | 3 ++- test/helpers/merkleTree.js | 2 +- test/token/ERC721/ERC721.behavior.js | 17 ++++++++--------- test/token/ERC721/ERC721Full.test.js | 15 ++++++++------- 5 files changed, 25 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5e37acd01fd..9ef96e4a294 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6199,7 +6199,6 @@ "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -6218,7 +6217,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -6319,7 +6317,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -6405,8 +6402,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -6506,14 +6502,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -13725,7 +13719,7 @@ "req-cwd": "^1.0.1", "shelljs": "^0.7.4", "sol-explore": "^1.6.2", - "solidity-parser-sc": "github:maxsam4/solidity-parser#solidity-0.5", + "solidity-parser-sc": "github:maxsam4/solidity-parser#3f0a30b97b460861654771871bcd970e73d47459", "tree-kill": "^1.2.0", "web3": "^0.20.6" }, @@ -13753,7 +13747,7 @@ "integrity": "sha512-VU6/DSUX93d1fCzBz7WP/SGCQizO1rKZi4Px9j/3yRyfssHyFcZamMw2/sj4E8TlfMXONvZLoforR8B4bRoyTQ==", "dev": true, "requires": { - "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git", + "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", "crypto-js": "^3.1.4", "utf8": "^2.1.1", "xhr2-cookies": "^1.1.0", @@ -15603,7 +15597,7 @@ "requires": { "underscore": "1.8.3", "web3-core-helpers": "1.0.0-beta.37", - "websocket": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible" + "websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2" }, "dependencies": { "underscore": { diff --git a/test/drafts/SignatureBouncer.test.js b/test/drafts/SignatureBouncer.test.js index 516a4ca35a7..a03401a25d5 100644 --- a/test/drafts/SignatureBouncer.test.js +++ b/test/drafts/SignatureBouncer.test.js @@ -192,7 +192,8 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, other, authorize }); it('does not validate invalid signature with correct method and data for valid user', async function () { - expect(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE, INVALID_SIGNATURE) + expect( + await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE, INVALID_SIGNATURE) ).to.equal(false); }); diff --git a/test/helpers/merkleTree.js b/test/helpers/merkleTree.js index 7aedd734713..6ebe19d9038 100644 --- a/test/helpers/merkleTree.js +++ b/test/helpers/merkleTree.js @@ -132,4 +132,4 @@ class MerkleTree { module.exports = { MerkleTree, -}; \ No newline at end of file +}; diff --git a/test/token/ERC721/ERC721.behavior.js b/test/token/ERC721/ERC721.behavior.js index 04b5d9ed211..91a44aef364 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -1,9 +1,8 @@ const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); +const { expect } = require('chai'); const { ZERO_ADDRESS } = constants; const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior'); -const { expect } = require('chai'); - const ERC721ReceiverMock = artifacts.require('ERC721ReceiverMock.sol'); function shouldBehaveLikeERC721 ( @@ -50,7 +49,7 @@ function shouldBehaveLikeERC721 ( const tokenId = firstTokenId; it('returns the owner of the given token ID', async function () { - expect(await this.token.ownerOf(tokenId)).to.equal(owner); + expect(await this.token.ownerOf(tokenId)).to.be.equal(owner); }); }); @@ -78,11 +77,11 @@ function shouldBehaveLikeERC721 ( const transferWasSuccessful = function ({ owner, tokenId, approved }) { it('transfers the ownership of the given token ID to the given address', async function () { - expect(await this.token.ownerOf(tokenId)).to.equal(this.toWhom); + expect(await this.token.ownerOf(tokenId)).to.be.equal(this.toWhom); }); it('clears the approval for the token ID', async function () { - expect(await this.token.getApproved(tokenId)).to.equal(ZERO_ADDRESS); + expect(await this.token.getApproved(tokenId)).to.be.equal(ZERO_ADDRESS); }); if (approved) { @@ -112,7 +111,7 @@ function shouldBehaveLikeERC721 ( expect(await this.token.tokenOfOwnerByIndex(this.toWhom, 0)).to.be.bignumber.equal(tokenId); - expect(await this.token.tokenOfOwnerByIndex(owner, 0)).to.be.bignumber.equal(tokenId); + expect(await this.token.tokenOfOwnerByIndex(owner, 0)).to.be.bignumber.not.equal(tokenId); }); }; @@ -152,11 +151,11 @@ function shouldBehaveLikeERC721 ( }); it('keeps ownership of the token', async function () { - expect(await this.token.ownerOf(tokenId)).to.equal(owner); + expect(await this.token.ownerOf(tokenId)).to.be.equal(owner); }); it('clears the approval for the token ID', async function () { - expect(await this.token.getApproved(tokenId)).to.equal(ZERO_ADDRESS); + expect(await this.token.getApproved(tokenId)).to.be.equal(ZERO_ADDRESS); }); it('emits only a transfer event', async function () { @@ -338,7 +337,7 @@ function shouldBehaveLikeERC721 ( const itApproves = function (address) { it('sets the approval for the target address', async function () { - expect(await this.token.getApproved(tokenId)).to.equal(address); + expect(await this.token.getApproved(tokenId)).to.be.equal(address); }); }; diff --git a/test/token/ERC721/ERC721Full.test.js b/test/token/ERC721/ERC721Full.test.js index bacbf3e48d7..bc96df08019 100644 --- a/test/token/ERC721/ERC721Full.test.js +++ b/test/token/ERC721/ERC721Full.test.js @@ -1,5 +1,4 @@ const { BN, expectRevert } = require('openzeppelin-test-helpers'); - const { expect } = require('chai'); const { shouldBehaveLikeERC721 } = require('./ERC721.behavior'); @@ -76,16 +75,16 @@ contract('ERC721Full', function ([ const sampleUri = 'mock://mytoken'; it('has a name', async function () { - expect(await this.token.name()).to.equal(name); + expect(await this.token.name()).to.be.equal(name); }); it('has a symbol', async function () { - expect(await this.token.symbol()).to.equal(symbol); + expect(await this.token.symbol()).to.be.equal(symbol); }); it('sets and returns metadata for a token id', async function () { await this.token.setTokenURI(firstTokenId, sampleUri); - expect(await this.token.tokenURI(firstTokenId)).to.equal(sampleUri); + expect(await this.token.tokenURI(firstTokenId)).to.be.equal(sampleUri); }); it('reverts when setting metadata for non existent token id', async function () { @@ -101,7 +100,7 @@ contract('ERC721Full', function ([ }); it('returns empty metadata for token', async function () { - expect(await this.token.tokenURI(firstTokenId)).to.equal(''); + expect(await this.token.tokenURI(firstTokenId)).to.be.equal(''); }); it('reverts when querying metadata for non existent token id', async function () { @@ -160,7 +159,8 @@ contract('ERC721Full', function ([ const tokensListed = await Promise.all( [0, 1].map(i => this.token.tokenOfOwnerByIndex(another, i)) ); - expect(tokensListed.map(t => t.toNumber())).to.have.members([firstTokenId.toNumber(), secondTokenId.toNumber()]); + expect(tokensListed.map(t => t.toNumber())).to.have.members([firstTokenId.toNumber(), + secondTokenId.toNumber()]); }); it('returns empty collection for original owner', async function () { @@ -177,7 +177,8 @@ contract('ERC721Full', function ([ const tokensListed = await Promise.all( [0, 1].map(i => this.token.tokenByIndex(i)) ); - expect(tokensListed.map(t => t.toNumber())).to.have.members([firstTokenId.toNumber(), secondTokenId.toNumber()]); + expect(tokensListed.map(t => t.toNumber())).to.have.members([firstTokenId.toNumber(), + secondTokenId.toNumber()]); }); it('should revert if index is greater than supply', async function () { From e7903dae3530b7354dd0e3d3e744ebe00d869731 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Thu, 20 Jun 2019 14:55:53 +0000 Subject: [PATCH 5/8] Fix for test build --- test/token/ERC20/ERC20.behavior.js | 3 +-- test/token/ERC20/ERC20.test.js | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/test/token/ERC20/ERC20.behavior.js b/test/token/ERC20/ERC20.behavior.js index 3934f34ea85..662e0f30b22 100644 --- a/test/token/ERC20/ERC20.behavior.js +++ b/test/token/ERC20/ERC20.behavior.js @@ -1,7 +1,6 @@ const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); -const { ZERO_ADDRESS } = constants; - const { expect } = require('chai'); +const { ZERO_ADDRESS } = constants; function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recipient, anotherAccount) { describe('total supply', function () { diff --git a/test/token/ERC20/ERC20.test.js b/test/token/ERC20/ERC20.test.js index af188ebe128..a04bb8c3ac6 100644 --- a/test/token/ERC20/ERC20.test.js +++ b/test/token/ERC20/ERC20.test.js @@ -1,7 +1,6 @@ const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers'); -const { ZERO_ADDRESS } = constants; - const { expect } = require('chai'); +const { ZERO_ADDRESS } = constants; const { shouldBehaveLikeERC20, @@ -58,7 +57,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { it('sets the allowance to zero when all allowance is removed', async function () { await this.token.decreaseAllowance(spender, approvedAmount, { from: initialHolder }); - expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal('1'); + expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal('0'); }); it('reverts when more than the full allowance is removed', async function () { From 44bf3fd797cfd7f1470304972c858d34a98744d8 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Thu, 20 Jun 2019 17:23:51 +0000 Subject: [PATCH 6/8] updated for Coverage --- contracts/utils/Address.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/utils/Address.sol b/contracts/utils/Address.sol index ad2f7e72853..acaca9b7226 100644 --- a/contracts/utils/Address.sol +++ b/contracts/utils/Address.sol @@ -1,7 +1,7 @@ pragma solidity ^0.5.0; /** - * @dev Collection of functions related to the address type, + * @dev Collection of functions related to the address type */ library Address { /** From d29a9b7413c5c0d0878dae3c0760323ce6a05a7d Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Sat, 22 Jun 2019 15:05:50 +0000 Subject: [PATCH 7/8] Updated Address.test.js --- test/utils/Address.test.js | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/test/utils/Address.test.js b/test/utils/Address.test.js index b90ba5f9a0f..78853b5281d 100644 --- a/test/utils/Address.test.js +++ b/test/utils/Address.test.js @@ -1,21 +1,38 @@ -require('openzeppelin-test-helpers'); - +const { constants } = require('openzeppelin-test-helpers'); const { expect } = require('chai'); const AddressImpl = artifacts.require('AddressImpl'); const SimpleToken = artifacts.require('SimpleToken'); contract('Address', function ([_, other]) { + const ALL_ONES_ADDRESS = '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF'; + beforeEach(async function () { this.mock = await AddressImpl.new(); }); - it('should return false for account address', async function () { - expect(await this.mock.isContract(other)).to.equal(false); + describe('isContract', function () { + it('should return false for account address', async function () { + expect(await this.mock.isContract(other)).to.equal(false); + }); + + it('should return true for contract address', async function () { + const contract = await SimpleToken.new(); + expect(await this.mock.isContract(contract.address)).to.equal(true); + }); }); - it('should return true for contract address', async function () { - const contract = await SimpleToken.new(); - expect(await this.mock.isContract(contract.address)).to.equal(true); + describe('toPayable', function () { + it('should return a payable address when the account is the zero address', async function () { + expect(await this.mock.toPayable(constants.ZERO_ADDRESS)).to.equal(constants.ZERO_ADDRESS); + }); + + it('should return a payable address when the account is an arbitrary address', async function () { + expect(await this.mock.toPayable(other)).to.equal(other); + }); + + it('should return a payable address when the account is the all ones address', async function () { + expect(await this.mock.toPayable(ALL_ONES_ADDRESS)).to.equal(ALL_ONES_ADDRESS); + }); }); }); From 4a395a030f0841e25b0888f1f4fba7523174bec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Mon, 24 Jun 2019 17:12:07 -0300 Subject: [PATCH 8/8] Undo package-lock changes. --- package-lock.json | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9ef96e4a294..5e37acd01fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6199,6 +6199,7 @@ "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -6217,6 +6218,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -6317,6 +6319,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -6402,7 +6405,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -6502,12 +6506,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -13719,7 +13725,7 @@ "req-cwd": "^1.0.1", "shelljs": "^0.7.4", "sol-explore": "^1.6.2", - "solidity-parser-sc": "github:maxsam4/solidity-parser#3f0a30b97b460861654771871bcd970e73d47459", + "solidity-parser-sc": "github:maxsam4/solidity-parser#solidity-0.5", "tree-kill": "^1.2.0", "web3": "^0.20.6" }, @@ -13747,7 +13753,7 @@ "integrity": "sha512-VU6/DSUX93d1fCzBz7WP/SGCQizO1rKZi4Px9j/3yRyfssHyFcZamMw2/sj4E8TlfMXONvZLoforR8B4bRoyTQ==", "dev": true, "requires": { - "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", + "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git", "crypto-js": "^3.1.4", "utf8": "^2.1.1", "xhr2-cookies": "^1.1.0", @@ -15597,7 +15603,7 @@ "requires": { "underscore": "1.8.3", "web3-core-helpers": "1.0.0-beta.37", - "websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2" + "websocket": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible" }, "dependencies": { "underscore": {