Skip to content

Commit

Permalink
Merge 3a66098 into bd13be9
Browse files Browse the repository at this point in the history
  • Loading branch information
nventuro authored May 24, 2019
2 parents bd13be9 + 3a66098 commit dc8292a
Show file tree
Hide file tree
Showing 53 changed files with 365 additions and 358 deletions.
62 changes: 34 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"micromatch": "^4.0.2",
"nodemon": "^1.19.0",
"openzeppelin-docsite": "github:OpenZeppelin/openzeppelin-docsite#22388b7a891a6fcdd333efef9e4f7f584ae5b826",
"openzeppelin-test-helpers": "^0.3.2",
"openzeppelin-test-helpers": "^0.4",
"solhint": "^1.5.0",
"solidity-coverage": "github:rotcivegaf/solidity-coverage#5875f5b7bc74d447f3312c9c0e9fc7814b482477",
"solidity-docgen": "github:OpenZeppelin/solidity-docgen#03f42b5e271b1e1c1d0b814b921ecdc086055255",
Expand Down
12 changes: 6 additions & 6 deletions test/access/Roles.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { shouldFail, constants } = require('openzeppelin-test-helpers');
const { expectRevert, constants } = require('openzeppelin-test-helpers');
const { ZERO_ADDRESS } = constants;

const RolesMock = artifacts.require('RolesMock');
Expand All @@ -9,7 +9,7 @@ contract('Roles', function ([_, authorized, otherAuthorized, other]) {
});

it('reverts when querying roles for the zero account', async function () {
await shouldFail.reverting.withMessage(this.roles.has(ZERO_ADDRESS), 'Roles: account is the zero address');
await expectRevert(this.roles.has(ZERO_ADDRESS), 'Roles: account is the zero address');
});

context('initially', function () {
Expand All @@ -28,11 +28,11 @@ contract('Roles', function ([_, authorized, otherAuthorized, other]) {

it('reverts when adding roles to an already assigned account', async function () {
await this.roles.add(authorized);
await shouldFail.reverting.withMessage(this.roles.add(authorized), 'Roles: account already has role');
await expectRevert(this.roles.add(authorized), 'Roles: account already has role');
});

it('reverts when adding roles to the zero account', async function () {
await shouldFail.reverting.withMessage(this.roles.add(ZERO_ADDRESS), 'Roles: account is the zero address');
await expectRevert(this.roles.add(ZERO_ADDRESS), 'Roles: account is the zero address');
});
});
});
Expand All @@ -51,11 +51,11 @@ contract('Roles', function ([_, authorized, otherAuthorized, other]) {
});

it('reverts when removing unassigned roles', async function () {
await shouldFail.reverting.withMessage(this.roles.remove(other), 'Roles: account does not have role');
await expectRevert(this.roles.remove(other), 'Roles: account does not have role');
});

it('reverts when removing roles from the zero account', async function () {
await shouldFail.reverting.withMessage(this.roles.remove(ZERO_ADDRESS), 'Roles: account is the zero address');
await expectRevert(this.roles.remove(ZERO_ADDRESS), 'Roles: account is the zero address');
});
});
});
Expand Down
16 changes: 8 additions & 8 deletions test/behaviors/access/roles/PublicRole.behavior.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { shouldFail, constants, expectEvent } = require('openzeppelin-test-helpers');
const { expectRevert, constants, expectEvent } = require('openzeppelin-test-helpers');
const { ZERO_ADDRESS } = constants;

function capitalize (str) {
Expand Down Expand Up @@ -39,7 +39,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen
}

it('reverts when querying roles for the null account', async function () {
await shouldFail.reverting.withMessage(this.contract[`is${rolename}`](ZERO_ADDRESS),
await expectRevert(this.contract[`is${rolename}`](ZERO_ADDRESS),
'Roles: account is the zero address'
);
});
Expand All @@ -57,7 +57,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen
const from = other;

it('reverts', async function () {
await shouldFail.reverting.withMessage(this.contract[`only${rolename}Mock`]({ from }),
await expectRevert(this.contract[`only${rolename}Mock`]({ from }),
`${rolename}Role: caller does not have the ${rolename} role`
);
});
Expand All @@ -79,13 +79,13 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen
});

it('reverts when adding role to an already assigned account', async function () {
await shouldFail.reverting.withMessage(this.contract[`add${rolename}`](authorized, { from }),
await expectRevert(this.contract[`add${rolename}`](authorized, { from }),
'Roles: account already has role'
);
});

it('reverts when adding role to the null account', async function () {
await shouldFail.reverting.withMessage(this.contract[`add${rolename}`](ZERO_ADDRESS, { from }),
await expectRevert(this.contract[`add${rolename}`](ZERO_ADDRESS, { from }),
'Roles: account is the zero address'
);
});
Expand All @@ -109,13 +109,13 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen
});

it('reverts when removing from an unassigned account', async function () {
await shouldFail.reverting.withMessage(this.contract[`remove${rolename}`](other, { from }),
await expectRevert(this.contract[`remove${rolename}`](other, { from }),
'Roles: account does not have role'
);
});

it('reverts when removing role from the null account', async function () {
await shouldFail.reverting.withMessage(this.contract[`remove${rolename}`](ZERO_ADDRESS, { from }),
await expectRevert(this.contract[`remove${rolename}`](ZERO_ADDRESS, { from }),
'Roles: account is the zero address'
);
});
Expand All @@ -134,7 +134,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen
});

it('reverts when renouncing unassigned role', async function () {
await shouldFail.reverting.withMessage(this.contract[`renounce${rolename}`]({ from: other }),
await expectRevert(this.contract[`renounce${rolename}`]({ from: other }),
'Roles: account does not have role'
);
});
Expand Down
4 changes: 2 additions & 2 deletions test/crowdsale/AllowanceCrowdsale.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { balance, BN, constants, ether, expectEvent, shouldFail } = require('openzeppelin-test-helpers');
const { balance, BN, constants, ether, expectEvent, expectRevert } = require('openzeppelin-test-helpers');
const { ZERO_ADDRESS } = constants;

const AllowanceCrowdsaleImpl = artifacts.require('AllowanceCrowdsaleImpl');
Expand Down Expand Up @@ -75,7 +75,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
describe('when token wallet is the zero address', function () {
it('creation reverts', async function () {
this.token = await SimpleToken.new({ from: tokenWallet });
await shouldFail.reverting.withMessage(AllowanceCrowdsaleImpl.new(rate, wallet, this.token.address, ZERO_ADDRESS),
await expectRevert(AllowanceCrowdsaleImpl.new(rate, wallet, this.token.address, ZERO_ADDRESS),
'AllowanceCrowdsale: token wallet is the zero address'
);
});
Expand Down
8 changes: 4 additions & 4 deletions test/crowdsale/CappedCrowdsale.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { BN, ether, shouldFail } = require('openzeppelin-test-helpers');
const { BN, ether, expectRevert } = require('openzeppelin-test-helpers');

const CappedCrowdsaleImpl = artifacts.require('CappedCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken');
Expand All @@ -14,7 +14,7 @@ contract('CappedCrowdsale', function ([_, wallet]) {
});

it('rejects a cap of zero', async function () {
await shouldFail.reverting.withMessage(CappedCrowdsaleImpl.new(rate, wallet, this.token.address, 0),
await expectRevert(CappedCrowdsaleImpl.new(rate, wallet, this.token.address, 0),
'CappedCrowdsale: cap is 0'
);
});
Expand All @@ -33,11 +33,11 @@ contract('CappedCrowdsale', function ([_, wallet]) {

it('should reject payments outside cap', async function () {
await this.crowdsale.send(cap);
await shouldFail.reverting.withMessage(this.crowdsale.send(1), 'CappedCrowdsale: cap exceeded');
await expectRevert(this.crowdsale.send(1), 'CappedCrowdsale: cap exceeded');
});

it('should reject payments that exceed cap', async function () {
await shouldFail.reverting.withMessage(this.crowdsale.send(cap.addn(1)), 'CappedCrowdsale: cap exceeded');
await expectRevert(this.crowdsale.send(cap.addn(1)), 'CappedCrowdsale: cap exceeded');
});
});

Expand Down
14 changes: 7 additions & 7 deletions test/crowdsale/Crowdsale.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { balance, BN, constants, ether, expectEvent, shouldFail } = require('openzeppelin-test-helpers');
const { balance, BN, constants, ether, expectEvent, expectRevert } = require('openzeppelin-test-helpers');
const { ZERO_ADDRESS } = constants;

const Crowdsale = artifacts.require('CrowdsaleMock');
Expand All @@ -11,7 +11,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
const expectedTokenAmount = rate.mul(value);

it('requires a non-null token', async function () {
await shouldFail.reverting.withMessage(
await expectRevert(
Crowdsale.new(rate, wallet, ZERO_ADDRESS),
'Crowdsale: token is the zero address'
);
Expand All @@ -23,13 +23,13 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
});

it('requires a non-zero rate', async function () {
await shouldFail.reverting.withMessage(
await expectRevert(
Crowdsale.new(0, wallet, this.token.address), 'Crowdsale: rate is 0'
);
});

it('requires a non-null wallet', async function () {
await shouldFail.reverting.withMessage(
await expectRevert(
Crowdsale.new(rate, ZERO_ADDRESS, this.token.address), 'Crowdsale: wallet is the zero address'
);
});
Expand All @@ -47,7 +47,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
});

it('reverts on zero-valued payments', async function () {
await shouldFail.reverting.withMessage(
await expectRevert(
this.crowdsale.send(0, { from: purchaser }), 'Crowdsale: weiAmount is 0'
);
});
Expand All @@ -59,13 +59,13 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
});

it('reverts on zero-valued payments', async function () {
await shouldFail.reverting.withMessage(
await expectRevert(
this.crowdsale.buyTokens(investor, { value: 0, from: purchaser }), 'Crowdsale: weiAmount is 0'
);
});

it('requires a non-null beneficiary', async function () {
await shouldFail.reverting.withMessage(
await expectRevert(
this.crowdsale.buyTokens(ZERO_ADDRESS, { value: value, from: purchaser }),
'Crowdsale: beneficiary is the zero address'
);
Expand Down
6 changes: 3 additions & 3 deletions test/crowdsale/FinalizableCrowdsale.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { BN, expectEvent, shouldFail, time } = require('openzeppelin-test-helpers');
const { BN, expectEvent, expectRevert, time } = require('openzeppelin-test-helpers');

const FinalizableCrowdsaleImpl = artifacts.require('FinalizableCrowdsaleImpl');
const ERC20 = artifacts.require('ERC20');
Expand All @@ -23,7 +23,7 @@ contract('FinalizableCrowdsale', function ([_, wallet, other]) {
});

it('cannot be finalized before ending', async function () {
await shouldFail.reverting.withMessage(this.crowdsale.finalize({ from: other }),
await expectRevert(this.crowdsale.finalize({ from: other }),
'FinalizableCrowdsale: not closed'
);
});
Expand All @@ -36,7 +36,7 @@ contract('FinalizableCrowdsale', function ([_, wallet, other]) {
it('cannot be finalized twice', async function () {
await time.increaseTo(this.afterClosingTime);
await this.crowdsale.finalize({ from: other });
await shouldFail.reverting.withMessage(this.crowdsale.finalize({ from: other }),
await expectRevert(this.crowdsale.finalize({ from: other }),
'FinalizableCrowdsale: already finalized'
);
});
Expand Down
Loading

0 comments on commit dc8292a

Please sign in to comment.