Replaced assertJump, assertRevert and expectThrow with shouldFail. (#1363)

* Replaced assertJump, assertRevert and expectThrow with shouldFail.

* Fixed linter errors.

* Fixed typo.

* Made the helpers async.

(cherry picked from commit b0da0fded0)
This commit is contained in:
Nicolás Venturo
2018-10-09 16:23:55 -03:00
committed by Leo Arias
parent 620d524398
commit 7cd0d5a452
45 changed files with 274 additions and 344 deletions

View File

@ -1,4 +1,4 @@
const { assertRevert } = require('../helpers/assertRevert');
const shouldFail = require('../helpers/shouldFail');
const expectEvent = require('../helpers/expectEvent');
const PausableMock = artifacts.require('PausableMock');
@ -37,7 +37,7 @@ contract('Pausable', function ([_, pauser, otherPauser, anyone, ...otherAccounts
});
it('cannot take drastic measure in non-pause', async function () {
await assertRevert(this.pausable.drasticMeasure({ from: anyone }));
await shouldFail.reverting(this.pausable.drasticMeasure({ from: anyone }));
(await this.pausable.drasticMeasureTaken()).should.equal(false);
});
@ -48,7 +48,7 @@ contract('Pausable', function ([_, pauser, otherPauser, anyone, ...otherAccounts
});
it('reverts when pausing from non-pauser', async function () {
await assertRevert(this.pausable.pause({ from: anyone }));
await shouldFail.reverting(this.pausable.pause({ from: anyone }));
});
context('when paused', function () {
@ -61,7 +61,7 @@ contract('Pausable', function ([_, pauser, otherPauser, anyone, ...otherAccounts
});
it('cannot perform normal process in pause', async function () {
await assertRevert(this.pausable.normalProcess({ from: anyone }));
await shouldFail.reverting(this.pausable.normalProcess({ from: anyone }));
});
it('can take a drastic measure in a pause', async function () {
@ -70,7 +70,7 @@ contract('Pausable', function ([_, pauser, otherPauser, anyone, ...otherAccounts
});
it('reverts when re-pausing', async function () {
await assertRevert(this.pausable.pause({ from: pauser }));
await shouldFail.reverting(this.pausable.pause({ from: pauser }));
});
describe('unpausing', function () {
@ -80,7 +80,7 @@ contract('Pausable', function ([_, pauser, otherPauser, anyone, ...otherAccounts
});
it('reverts when unpausing from non-pauser', async function () {
await assertRevert(this.pausable.unpause({ from: anyone }));
await shouldFail.reverting(this.pausable.unpause({ from: anyone }));
});
context('when unpaused', function () {
@ -99,11 +99,11 @@ contract('Pausable', function ([_, pauser, otherPauser, anyone, ...otherAccounts
});
it('should prevent drastic measure', async function () {
await assertRevert(this.pausable.drasticMeasure({ from: anyone }));
await shouldFail.reverting(this.pausable.drasticMeasure({ from: anyone }));
});
it('reverts when re-unpausing', async function () {
await assertRevert(this.pausable.unpause({ from: pauser }));
await shouldFail.reverting(this.pausable.unpause({ from: pauser }));
});
});
});