Skip to content

Commit dae0196

Browse files
committed
changed exxpect to expect wherever applicable
1 parent b95d7e7 commit dae0196

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+566
-471
lines changed

test/access/Roles.test.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const { expectRevert, constants } = require('openzeppelin-test-helpers');
22
const { ZERO_ADDRESS } = constants;
33

4+
const { expect } = require('chai');
5+
46
const RolesMock = artifacts.require('RolesMock');
57

68
contract('Roles', function ([_, authorized, otherAuthorized, other]) {
@@ -14,16 +16,16 @@ contract('Roles', function ([_, authorized, otherAuthorized, other]) {
1416

1517
context('initially', function () {
1618
it('doesn\'t pre-assign roles', async function () {
17-
(await this.roles.has(authorized)).should.equal(false);
18-
(await this.roles.has(otherAuthorized)).should.equal(false);
19-
(await this.roles.has(other)).should.equal(false);
19+
expect(await this.roles.has(authorized)).to.equal(false);
20+
expect(await this.roles.has(otherAuthorized)).to.equal(false);
21+
expect(await this.roles.has(other)).to.equal(false);
2022
});
2123

2224
describe('adding roles', function () {
2325
it('adds roles to a single account', async function () {
2426
await this.roles.add(authorized);
25-
(await this.roles.has(authorized)).should.equal(true);
26-
(await this.roles.has(other)).should.equal(false);
27+
expect(await this.roles.has(authorized)).to.equal(true);
28+
expect(await this.roles.has(other)).to.equal(false);
2729
});
2830

2931
it('reverts when adding roles to an already assigned account', async function () {
@@ -46,8 +48,8 @@ contract('Roles', function ([_, authorized, otherAuthorized, other]) {
4648
describe('removing roles', function () {
4749
it('removes a single role', async function () {
4850
await this.roles.remove(authorized);
49-
(await this.roles.has(authorized)).should.equal(false);
50-
(await this.roles.has(otherAuthorized)).should.equal(true);
51+
expect(await this.roles.has(authorized)).to.equal(false);
52+
expect(await this.roles.has(otherAuthorized)).to.equal(true);
5153
});
5254

5355
it('reverts when removing unassigned roles', async function () {

test/behaviors/access/roles/PublicRole.behavior.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const { expectRevert, constants, expectEvent } = require('openzeppelin-test-helpers');
22
const { ZERO_ADDRESS } = constants;
33

4+
const { expect } = require('chai');
5+
46
function capitalize (str) {
57
return str.replace(/\b\w/g, l => l.toUpperCase());
68
}
@@ -25,9 +27,9 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen
2527

2628
describe('should behave like public role', function () {
2729
beforeEach('check preconditions', async function () {
28-
(await this.contract[`is${rolename}`](authorized)).should.equal(true);
29-
(await this.contract[`is${rolename}`](otherAuthorized)).should.equal(true);
30-
(await this.contract[`is${rolename}`](other)).should.equal(false);
30+
expect(await this.contract[`is${rolename}`](authorized)).to.equal(true);
31+
expect(await this.contract[`is${rolename}`](otherAuthorized)).to.equal(true);
32+
expect(await this.contract[`is${rolename}`](other)).to.equal(false);
3133
});
3234

3335
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
7072
context(`from ${manager ? 'the manager' : 'a role-haver'} account`, function () {
7173
it('adds role to a new account', async function () {
7274
await this.contract[`add${rolename}`](other, { from });
73-
(await this.contract[`is${rolename}`](other)).should.equal(true);
75+
expect(await this.contract[`is${rolename}`](other)).to.equal(true);
7476
});
7577

7678
it(`emits a ${rolename}Added event`, async function () {
@@ -99,8 +101,8 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen
99101
context(`from ${manager ? 'the manager' : 'any'} account`, function () {
100102
it('removes role from an already assigned account', async function () {
101103
await this.contract[`remove${rolename}`](authorized, { from });
102-
(await this.contract[`is${rolename}`](authorized)).should.equal(false);
103-
(await this.contract[`is${rolename}`](otherAuthorized)).should.equal(true);
104+
expect(await this.contract[`is${rolename}`](authorized)).to.equal(false);
105+
expect(await this.contract[`is${rolename}`](otherAuthorized)).to.equal(true);
104106
});
105107

106108
it(`emits a ${rolename}Removed event`, async function () {
@@ -125,7 +127,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen
125127
describe('renouncing roles', function () {
126128
it('renounces an assigned role', async function () {
127129
await this.contract[`renounce${rolename}`]({ from: authorized });
128-
(await this.contract[`is${rolename}`](authorized)).should.equal(false);
130+
expect(await this.contract[`is${rolename}`](authorized)).to.equal(false);
129131
});
130132

131133
it(`emits a ${rolename}Removed event`, async function () {

test/crowdsale/AllowanceCrowdsale.test.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const { balance, BN, constants, ether, expectEvent, expectRevert } = require('openzeppelin-test-helpers');
22
const { ZERO_ADDRESS } = constants;
33

4+
const { expect } = require('chai');
5+
46
const AllowanceCrowdsaleImpl = artifacts.require('AllowanceCrowdsaleImpl');
57
const SimpleToken = artifacts.require('SimpleToken');
68

@@ -18,7 +20,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
1820

1921
describe('accepting payments', function () {
2022
it('should have token wallet', async function () {
21-
(await this.crowdsale.tokenWallet()).should.be.equal(tokenWallet);
23+
expect(await this.crowdsale.tokenWallet()).to.equal(tokenWallet);
2224
});
2325

2426
it('should accept sends', async function () {
@@ -43,21 +45,21 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
4345

4446
it('should assign tokens to sender', async function () {
4547
await this.crowdsale.sendTransaction({ value: value, from: investor });
46-
(await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount);
48+
expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(expectedTokenAmount);
4749
});
4850

4951
it('should forward funds to wallet', async function () {
5052
const balanceTracker = await balance.tracker(wallet);
5153
await this.crowdsale.sendTransaction({ value, from: investor });
52-
(await balanceTracker.delta()).should.be.bignumber.equal(value);
54+
expect(await balanceTracker.delta()).to.be.bignumber.equal(value);
5355
});
5456
});
5557

5658
describe('check remaining allowance', function () {
5759
it('should report correct allowance left', async function () {
5860
const remainingAllowance = tokenAllowance.sub(expectedTokenAmount);
5961
await this.crowdsale.buyTokens(investor, { value: value, from: purchaser });
60-
(await this.crowdsale.remainingTokens()).should.be.bignumber.equal(remainingAllowance);
62+
expect(await this.crowdsale.remainingTokens()).to.be.bignumber.equal(remainingAllowance);
6163
});
6264

6365
context('when the allowance is larger than the token amount', function () {
@@ -67,7 +69,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
6769
});
6870

6971
it('should report the amount instead of the allowance', async function () {
70-
(await this.crowdsale.remainingTokens()).should.be.bignumber.equal(await this.token.balanceOf(tokenWallet));
72+
expect(await this.crowdsale.remainingTokens()).to.be.bignumber.equal(await this.token.balanceOf(tokenWallet));
7173
});
7274
});
7375
});

test/crowdsale/CappedCrowdsale.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const { BN, ether, expectRevert } = require('openzeppelin-test-helpers');
22

3+
const { expect } = require('chai');
4+
35
const CappedCrowdsaleImpl = artifacts.require('CappedCrowdsaleImpl');
46
const SimpleToken = artifacts.require('SimpleToken');
57

@@ -44,17 +46,17 @@ contract('CappedCrowdsale', function ([_, wallet]) {
4446
describe('ending', function () {
4547
it('should not reach cap if sent under cap', async function () {
4648
await this.crowdsale.send(lessThanCap);
47-
(await this.crowdsale.capReached()).should.equal(false);
49+
expect(await this.crowdsale.capReached()).to.equal(false);
4850
});
4951

5052
it('should not reach cap if sent just under cap', async function () {
5153
await this.crowdsale.send(cap.subn(1));
52-
(await this.crowdsale.capReached()).should.equal(false);
54+
expect(await this.crowdsale.capReached()).to.equal(false);
5355
});
5456

5557
it('should reach cap if cap sent', async function () {
5658
await this.crowdsale.send(cap);
57-
(await this.crowdsale.capReached()).should.equal(true);
59+
expect(await this.crowdsale.capReached()).to.equal(true);
5860
});
5961
});
6062
});

test/crowdsale/Crowdsale.test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const { balance, BN, constants, ether, expectEvent, expectRevert } = require('openzeppelin-test-helpers');
22
const { ZERO_ADDRESS } = constants;
33

4+
const { expect } = require('chai');
5+
46
const Crowdsale = artifacts.require('CrowdsaleMock');
57
const SimpleToken = artifacts.require('SimpleToken');
68

@@ -86,13 +88,13 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
8688

8789
it('should assign tokens to sender', async function () {
8890
await this.crowdsale.sendTransaction({ value: value, from: investor });
89-
(await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount);
91+
expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(expectedTokenAmount);
9092
});
9193

9294
it('should forward funds to wallet', async function () {
9395
const balanceTracker = await balance.tracker(wallet);
9496
await this.crowdsale.sendTransaction({ value, from: investor });
95-
(await balanceTracker.delta()).should.be.bignumber.equal(value);
97+
expect(await balanceTracker.delta()).to.be.bignumber.equal(value);
9698
});
9799
});
98100

@@ -109,13 +111,13 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
109111

110112
it('should assign tokens to beneficiary', async function () {
111113
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
112-
(await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount);
114+
expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(expectedTokenAmount);
113115
});
114116

115117
it('should forward funds to wallet', async function () {
116118
const balanceTracker = await balance.tracker(wallet);
117119
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
118-
(await balanceTracker.delta()).should.be.bignumber.equal(value);
120+
expect(await balanceTracker.delta()).to.be.bignumber.equal(value);
119121
});
120122
});
121123
});

test/crowdsale/IncreasingPriceCrowdsale.test.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const { BN, ether, expectRevert, time } = require('openzeppelin-test-helpers');
22

3+
const { expect } = require('chai');
4+
35
const IncreasingPriceCrowdsaleImpl = artifacts.require('IncreasingPriceCrowdsaleImpl');
46
const SimpleToken = artifacts.require('SimpleToken');
57

@@ -52,8 +54,8 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
5254
});
5355

5456
it('should have initial and final rate', async function () {
55-
(await this.crowdsale.initialRate()).should.be.bignumber.equal(initialRate);
56-
(await this.crowdsale.finalRate()).should.be.bignumber.equal(finalRate);
57+
expect(await this.crowdsale.initialRate()).to.be.bignumber.equal(initialRate);
58+
expect(await this.crowdsale.finalRate()).to.be.bignumber.equal(finalRate);
5759
});
5860

5961
it('reverts when the base Crowdsale\'s rate function is called', async function () {
@@ -63,54 +65,54 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
6365
});
6466

6567
it('returns a rate of 0 before the crowdsale starts', async function () {
66-
(await this.crowdsale.getCurrentRate()).should.be.bignumber.equal('0');
68+
expect(await this.crowdsale.getCurrentRate()).to.be.bignumber.equal('0');
6769
});
6870

6971
it('returns a rate of 0 after the crowdsale ends', async function () {
7072
await time.increaseTo(this.afterClosingTime);
71-
(await this.crowdsale.getCurrentRate()).should.be.bignumber.equal('0');
73+
expect(await this.crowdsale.getCurrentRate()).to.be.bignumber.equal('0');
7274
});
7375

7476
it('at start', async function () {
7577
await time.increaseTo(this.startTime);
7678
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
77-
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(initialRate));
79+
expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(initialRate));
7880
});
7981

8082
it('at time 150', async function () {
8183
await time.increaseTo(this.startTime.addn(150));
8284
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
83-
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime150));
85+
expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(rateAtTime150));
8486
});
8587

8688
it('at time 300', async function () {
8789
await time.increaseTo(this.startTime.addn(300));
8890
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
89-
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime300));
91+
expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(rateAtTime300));
9092
});
9193

9294
it('at time 1500', async function () {
9395
await time.increaseTo(this.startTime.addn(1500));
9496
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
95-
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime1500));
97+
expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(rateAtTime1500));
9698
});
9799

98100
it('at time 30', async function () {
99101
await time.increaseTo(this.startTime.addn(30));
100102
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
101-
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime30));
103+
expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(rateAtTime30));
102104
});
103105

104106
it('at time 150000', async function () {
105107
await time.increaseTo(this.startTime.addn(150000));
106108
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
107-
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime150000));
109+
expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(rateAtTime150000));
108110
});
109111

110112
it('at time 450000', async function () {
111113
await time.increaseTo(this.startTime.addn(450000));
112114
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
113-
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime450000));
115+
expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(value.mul(rateAtTime450000));
114116
});
115117
});
116118
});

test/crowdsale/IndividuallyCappedCrowdsale.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const { BN, ether, expectRevert } = require('openzeppelin-test-helpers');
22

3+
const { expect } = require('chai');
4+
35
const IndividuallyCappedCrowdsaleImpl = artifacts.require('IndividuallyCappedCrowdsaleImpl');
46
const SimpleToken = artifacts.require('SimpleToken');
57
const { shouldBehaveLikePublicRole } = require('../behaviors/access/roles/PublicRole.behavior');
@@ -30,7 +32,7 @@ contract('IndividuallyCappedCrowdsale', function (
3032
describe('individual caps', function () {
3133
it('sets a cap when the sender is a capper', async function () {
3234
await this.crowdsale.setCap(alice, capAlice, { from: capper });
33-
(await this.crowdsale.getCap(alice)).should.be.bignumber.equal(capAlice);
35+
expect(await this.crowdsale.getCap(alice)).to.be.bignumber.equal(capAlice);
3436
});
3537

3638
it('reverts when a non-capper sets a cap', async function () {
@@ -84,12 +86,12 @@ contract('IndividuallyCappedCrowdsale', function (
8486

8587
describe('reporting state', function () {
8688
it('should report correct cap', async function () {
87-
(await this.crowdsale.getCap(alice)).should.be.bignumber.equal(capAlice);
89+
expect(await this.crowdsale.getCap(alice)).to.be.bignumber.equal(capAlice);
8890
});
8991

9092
it('should report actual contribution', async function () {
9193
await this.crowdsale.buyTokens(alice, { value: lessThanCapAlice });
92-
(await this.crowdsale.getContribution(alice)).should.be.bignumber.equal(lessThanCapAlice);
94+
expect(await this.crowdsale.getContribution(alice)).to.be.bignumber.equal(lessThanCapAlice);
9395
});
9496
});
9597
});

test/crowdsale/MintedCrowdsale.behavior.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const { balance, expectEvent } = require('openzeppelin-test-helpers');
22

3+
const { expect } = require('chai');
4+
35
function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate, value) {
46
const expectedTokenAmount = rate.mul(value);
57

@@ -24,13 +26,13 @@ function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate
2426

2527
it('should assign tokens to sender', async function () {
2628
await this.crowdsale.sendTransaction({ value: value, from: investor });
27-
(await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount);
29+
expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(expectedTokenAmount);
2830
});
2931

3032
it('should forward funds to wallet', async function () {
3133
const balanceTracker = await balance.tracker(wallet);
3234
await this.crowdsale.sendTransaction({ value, from: investor });
33-
(await balanceTracker.delta()).should.be.bignumber.equal(value);
35+
expect(await balanceTracker.delta()).to.be.bignumber.equal(value);
3436
});
3537
});
3638
});

test/crowdsale/MintedCrowdsale.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const { BN, ether, expectRevert } = require('openzeppelin-test-helpers');
22
const { shouldBehaveLikeMintedCrowdsale } = require('./MintedCrowdsale.behavior');
33

4+
const { expect } = require('chai');
5+
46
const MintedCrowdsaleImpl = artifacts.require('MintedCrowdsaleImpl');
57
const ERC20Mintable = artifacts.require('ERC20Mintable');
68
const ERC20 = artifacts.require('ERC20');
@@ -19,7 +21,7 @@ contract('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser]
1921
});
2022

2123
it('crowdsale should be minter', async function () {
22-
(await this.token.isMinter(this.crowdsale.address)).should.equal(true);
24+
expect(await this.token.isMinter(this.crowdsale.address)).to.equal(true);
2325
});
2426

2527
shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value);

0 commit comments

Comments
 (0)