Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions test/BreakInvariantBounty.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { ether } = require('./helpers/ether');
const { sendEther } = require('./helpers/sendTransaction');
const { balanceDifference } = require('./helpers/balanceDiff');
const expectEvent = require('./helpers/expectEvent');
const { assertRevert } = require('./helpers/assertRevert');
const shouldFail = require('./helpers/shouldFail');

const BreakInvariantBountyMock = artifacts.require('BreakInvariantBountyMock');
const TargetMock = artifacts.require('TargetMock');
Expand Down Expand Up @@ -48,7 +48,7 @@ contract('BreakInvariantBounty', function ([_, owner, researcher, anyone, nonTar

context('before exploiting vulnerability', async function () {
it('reverts when claiming reward', async function () {
await assertRevert(this.bounty.claim(this.target.address, { from: researcher }));
await shouldFail.reverting(this.bounty.claim(this.target.address, { from: researcher }));
});
});

Expand All @@ -74,19 +74,19 @@ contract('BreakInvariantBounty', function ([_, owner, researcher, anyone, nonTar
});

it('no longer accepts rewards', async function () {
await assertRevert(ethSendTransaction({ from: owner, to: this.bounty.address, value: reward }));
await shouldFail.reverting(ethSendTransaction({ from: owner, to: this.bounty.address, value: reward }));
});

it('reverts when reclaimed', async function () {
await assertRevert(this.bounty.claim(this.target.address, { from: researcher }));
await shouldFail.reverting(this.bounty.claim(this.target.address, { from: researcher }));
});
});
});
});

context('with non-target', function () {
it('reverts when claiming reward', async function () {
await assertRevert(this.bounty.claim(nonTarget, { from: researcher }));
await shouldFail.reverting(this.bounty.claim(nonTarget, { from: researcher }));
});
});
});
Expand All @@ -105,7 +105,7 @@ contract('BreakInvariantBounty', function ([_, owner, researcher, anyone, nonTar
});

it('reverts when canceled by anyone', async function () {
await assertRevert(this.bounty.cancelBounty({ from: anyone }));
await shouldFail.reverting(this.bounty.cancelBounty({ from: anyone }));
});
});

Expand All @@ -119,11 +119,11 @@ contract('BreakInvariantBounty', function ([_, owner, researcher, anyone, nonTar
});

it('no longer accepts rewards', async function () {
await assertRevert(ethSendTransaction({ from: owner, to: this.bounty.address, value: reward }));
await shouldFail.reverting(ethSendTransaction({ from: owner, to: this.bounty.address, value: reward }));
});

it('reverts when recanceled', async function () {
await assertRevert(this.bounty.cancelBounty({ from: owner }));
await shouldFail.reverting(this.bounty.cancelBounty({ from: owner }));
});
});
});
Expand Down
9 changes: 5 additions & 4 deletions test/access/Roles.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { assertRevert } = require('../helpers/assertRevert');
const shouldFail = require('../helpers/shouldFail');
const { ZERO_ADDRESS } = require('../helpers/constants');

const RolesMock = artifacts.require('RolesMock');

require('chai')
Expand All @@ -11,7 +12,7 @@ contract('Roles', function ([_, authorized, otherAuthorized, anyone]) {
});

it('reverts when querying roles for the null account', async function () {
await assertRevert(this.roles.has(ZERO_ADDRESS));
await shouldFail.reverting(this.roles.has(ZERO_ADDRESS));
});

context('initially', function () {
Expand All @@ -35,7 +36,7 @@ contract('Roles', function ([_, authorized, otherAuthorized, anyone]) {
});

it('reverts when adding roles to the null account', async function () {
await assertRevert(this.roles.add(ZERO_ADDRESS));
await shouldFail.reverting(this.roles.add(ZERO_ADDRESS));
});
});
});
Expand All @@ -58,7 +59,7 @@ contract('Roles', function ([_, authorized, otherAuthorized, anyone]) {
});

it('reverts when removing roles from the null account', async function () {
await assertRevert(this.roles.remove(ZERO_ADDRESS));
await shouldFail.reverting(this.roles.remove(ZERO_ADDRESS));
});
});
});
Expand Down
10 changes: 5 additions & 5 deletions test/access/roles/PublicRole.behavior.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { assertRevert } = require('../../helpers/assertRevert');
const shouldFail = require('../../helpers/shouldFail');
const { ZERO_ADDRESS } = require('../../helpers/constants');
const expectEvent = require('../../helpers/expectEvent');

Expand All @@ -20,7 +20,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
});

it('reverts when querying roles for the null account', async function () {
await assertRevert(this.contract[`is${rolename}`](ZERO_ADDRESS));
await shouldFail.reverting(this.contract[`is${rolename}`](ZERO_ADDRESS));
});

describe('access control', function () {
Expand All @@ -36,7 +36,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
const from = anyone;

it('reverts', async function () {
await assertRevert(this.contract[`only${rolename}Mock`]({ from }));
await shouldFail.reverting(this.contract[`only${rolename}Mock`]({ from }));
});
});
});
Expand All @@ -58,7 +58,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
});

it('reverts when adding role to the null account', async function () {
await assertRevert(this.contract[`add${rolename}`](ZERO_ADDRESS, { from: authorized }));
await shouldFail.reverting(this.contract[`add${rolename}`](ZERO_ADDRESS, { from: authorized }));
});
});

Expand All @@ -79,7 +79,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
});

it('reverts when removing role from the null account', async function () {
await assertRevert(this.contract[`remove${rolename}`](ZERO_ADDRESS));
await shouldFail.reverting(this.contract[`remove${rolename}`](ZERO_ADDRESS));
});
});

Expand Down
4 changes: 2 additions & 2 deletions test/crowdsale/AllowanceCrowdsale.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expectEvent = require('../helpers/expectEvent');
const { ether } = require('../helpers/ether');
const { assertRevert } = require('../helpers/assertRevert');
const shouldFail = require('../helpers/shouldFail');
const { ethGetBalance } = require('../helpers/web3');
const { ZERO_ADDRESS } = require('../helpers/constants');

Expand Down Expand Up @@ -74,7 +74,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
describe('when token wallet is different from token address', function () {
it('creation reverts', async function () {
this.token = await SimpleToken.new({ from: tokenWallet });
await assertRevert(AllowanceCrowdsaleImpl.new(rate, wallet, this.token.address, ZERO_ADDRESS));
await shouldFail.reverting(AllowanceCrowdsaleImpl.new(rate, wallet, this.token.address, ZERO_ADDRESS));
});
});
});
18 changes: 4 additions & 14 deletions test/crowdsale/CappedCrowdsale.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { ether } = require('../helpers/ether');
const { expectThrow } = require('../helpers/expectThrow');
const { EVMRevert } = require('../helpers/EVMRevert');
const shouldFail = require('../helpers/shouldFail');

const BigNumber = web3.BigNumber;

Expand All @@ -22,10 +21,7 @@ contract('CappedCrowdsale', function ([_, wallet]) {
});

it('rejects a cap of zero', async function () {
await expectThrow(
CappedCrowdsaleImpl.new(rate, wallet, this.token.address, 0),
EVMRevert,
);
await shouldFail.reverting(CappedCrowdsaleImpl.new(rate, wallet, this.token.address, 0));
});

context('with crowdsale', function () {
Expand All @@ -42,17 +38,11 @@ contract('CappedCrowdsale', function ([_, wallet]) {

it('should reject payments outside cap', async function () {
await this.crowdsale.send(cap);
await expectThrow(
this.crowdsale.send(1),
EVMRevert,
);
await shouldFail.reverting(this.crowdsale.send(1));
});

it('should reject payments that exceed cap', async function () {
await expectThrow(
this.crowdsale.send(cap.plus(1)),
EVMRevert,
);
await shouldFail.reverting(this.crowdsale.send(cap.plus(1)));
});
});

Expand Down
14 changes: 7 additions & 7 deletions test/crowdsale/Crowdsale.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const expectEvent = require('../helpers/expectEvent');
const { assertRevert } = require('../helpers/assertRevert');
const shouldFail = require('../helpers/shouldFail');
const { ether } = require('../helpers/ether');
const { ethGetBalance } = require('../helpers/web3');
const { ZERO_ADDRESS } = require('../helpers/constants');
Expand All @@ -20,7 +20,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
const expectedTokenAmount = rate.mul(value);

it('requires a non-null token', async function () {
await assertRevert(
await shouldFail.reverting(
Crowdsale.new(rate, wallet, ZERO_ADDRESS)
);
});
Expand All @@ -31,13 +31,13 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
});

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

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

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

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

it('requires a non-null beneficiary', async function () {
await assertRevert(
await shouldFail.reverting(
this.crowdsale.buyTokens(ZERO_ADDRESS, { value: value, from: purchaser })
);
});
Expand Down
7 changes: 3 additions & 4 deletions test/crowdsale/FinalizableCrowdsale.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const expectEvent = require('../helpers/expectEvent');
const { advanceBlock } = require('../helpers/advanceToBlock');
const time = require('../helpers/time');
const { expectThrow } = require('../helpers/expectThrow');
const { EVMRevert } = require('../helpers/EVMRevert');
const shouldFail = require('../helpers/shouldFail');

const BigNumber = web3.BigNumber;

Expand Down Expand Up @@ -33,7 +32,7 @@ contract('FinalizableCrowdsale', function ([_, wallet, anyone]) {
});

it('cannot be finalized before ending', async function () {
await expectThrow(this.crowdsale.finalize({ from: anyone }), EVMRevert);
await shouldFail.reverting(this.crowdsale.finalize({ from: anyone }));
});

it('can be finalized by anyone after ending', async function () {
Expand All @@ -44,7 +43,7 @@ contract('FinalizableCrowdsale', function ([_, wallet, anyone]) {
it('cannot be finalized twice', async function () {
await time.increaseTo(this.afterClosingTime);
await this.crowdsale.finalize({ from: anyone });
await expectThrow(this.crowdsale.finalize({ from: anyone }), EVMRevert);
await shouldFail.reverting(this.crowdsale.finalize({ from: anyone }));
});

it('logs finalized', async function () {
Expand Down
6 changes: 3 additions & 3 deletions test/crowdsale/IncreasingPriceCrowdsale.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { ether } = require('../helpers/ether');
const { advanceBlock } = require('../helpers/advanceToBlock');
const time = require('../helpers/time');
const { assertRevert } = require('../helpers/assertRevert');
const shouldFail = require('../helpers/shouldFail');

const BigNumber = web3.BigNumber;

Expand Down Expand Up @@ -35,13 +35,13 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
});

it('rejects a final rate larger than the initial rate', async function () {
await assertRevert(IncreasingPriceCrowdsaleImpl.new(
await shouldFail.reverting(IncreasingPriceCrowdsaleImpl.new(
this.startTime, this.closingTime, wallet, this.token.address, initialRate, initialRate.plus(1)
));
});

it('rejects a final rate of zero', async function () {
await assertRevert(IncreasingPriceCrowdsaleImpl.new(
await shouldFail.reverting(IncreasingPriceCrowdsaleImpl.new(
this.startTime, this.closingTime, wallet, this.token.address, initialRate, 0
));
});
Expand Down
15 changes: 7 additions & 8 deletions test/crowdsale/IndividuallyCappedCrowdsale.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { ether } = require('../helpers/ether');
const { expectThrow } = require('../helpers/expectThrow');
const { EVMRevert } = require('../helpers/EVMRevert');
const shouldFail = require('../helpers/shouldFail');

const BigNumber = web3.BigNumber;

Expand Down Expand Up @@ -42,7 +41,7 @@ contract('IndividuallyCappedCrowdsale', function (
});

it('reverts when a non-capper sets a cap', async function () {
await expectThrow(this.crowdsale.setCap(alice, capAlice, { from: anyone }), EVMRevert);
await shouldFail.reverting(this.crowdsale.setCap(alice, capAlice, { from: anyone }));
});

context('with individual caps', function () {
Expand All @@ -60,21 +59,21 @@ contract('IndividuallyCappedCrowdsale', function (

it('should reject payments outside cap', async function () {
await this.crowdsale.buyTokens(alice, { value: capAlice });
await expectThrow(this.crowdsale.buyTokens(alice, { value: 1 }), EVMRevert);
await shouldFail.reverting(this.crowdsale.buyTokens(alice, { value: 1 }));
});

it('should reject payments that exceed cap', async function () {
await expectThrow(this.crowdsale.buyTokens(alice, { value: capAlice.plus(1) }), EVMRevert);
await expectThrow(this.crowdsale.buyTokens(bob, { value: capBob.plus(1) }), EVMRevert);
await shouldFail.reverting(this.crowdsale.buyTokens(alice, { value: capAlice.plus(1) }));
await shouldFail.reverting(this.crowdsale.buyTokens(bob, { value: capBob.plus(1) }));
});

it('should manage independent caps', async function () {
await this.crowdsale.buyTokens(alice, { value: lessThanCapAlice });
await expectThrow(this.crowdsale.buyTokens(bob, { value: lessThanCapAlice }), EVMRevert);
await shouldFail.reverting(this.crowdsale.buyTokens(bob, { value: lessThanCapAlice }));
});

it('should default to a cap of zero', async function () {
await expectThrow(this.crowdsale.buyTokens(charlie, { value: lessThanCapBoth }), EVMRevert);
await shouldFail.reverting(this.crowdsale.buyTokens(charlie, { value: lessThanCapBoth }));
});
});

Expand Down
6 changes: 3 additions & 3 deletions test/crowdsale/MintedCrowdsale.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { shouldBehaveLikeMintedCrowdsale } = require('./MintedCrowdsale.behavior');
const { ether } = require('../helpers/ether');
const { assertRevert } = require('../helpers/assertRevert');
const shouldFail = require('../helpers/shouldFail');

const BigNumber = web3.BigNumber;

Expand Down Expand Up @@ -35,11 +35,11 @@ contract('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser]
});

it('rejects bare payments', async function () {
await assertRevert(this.crowdsale.send(value));
await shouldFail.reverting(this.crowdsale.send(value));
});

it('rejects token purchases', async function () {
await assertRevert(this.crowdsale.buyTokens(investor, { value: value, from: purchaser }));
await shouldFail.reverting(this.crowdsale.buyTokens(investor, { value: value, from: purchaser }));
});
});
});
Loading