Explorar o código

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

* Replaced assertJump, assertRevert and expectThrow with shouldFail.

* Fixed linter errors.

* Fixed typo.

* Made the helpers async.
Nicolás Venturo %!s(int64=7) %!d(string=hai) anos
pai
achega
b0da0fded0
Modificáronse 46 ficheiros con 282 adicións e 352 borrados
  1. 8 8
      test/BreakInvariantBounty.test.js
  2. 5 4
      test/access/Roles.test.js
  3. 5 5
      test/access/roles/PublicRole.behavior.js
  4. 2 2
      test/crowdsale/AllowanceCrowdsale.test.js
  5. 4 14
      test/crowdsale/CappedCrowdsale.test.js
  6. 7 7
      test/crowdsale/Crowdsale.test.js
  7. 3 4
      test/crowdsale/FinalizableCrowdsale.test.js
  8. 3 3
      test/crowdsale/IncreasingPriceCrowdsale.test.js
  9. 7 8
      test/crowdsale/IndividuallyCappedCrowdsale.test.js
  10. 3 3
      test/crowdsale/MintedCrowdsale.test.js
  11. 3 4
      test/crowdsale/PostDeliveryCrowdsale.test.js
  12. 6 10
      test/crowdsale/RefundableCrowdsale.test.js
  13. 9 10
      test/crowdsale/TimedCrowdsale.test.js
  14. 7 6
      test/drafts/ERC20Migrator.test.js
  15. 13 13
      test/drafts/SignatureBouncer.test.js
  16. 7 15
      test/examples/SampleCrowdsale.test.js
  17. 0 5
      test/helpers/EVMRevert.js
  18. 0 5
      test/helpers/EVMThrow.js
  19. 0 15
      test/helpers/assertJump.js
  20. 0 16
      test/helpers/assertRevert.js
  21. 0 28
      test/helpers/expectThrow.js
  22. 31 0
      test/helpers/shouldFail.js
  23. 2 2
      test/introspection/ERC165.test.js
  24. 2 2
      test/library/ECDSA.test.js
  25. 8 8
      test/lifecycle/Pausable.test.js
  26. 6 6
      test/math/SafeMath.test.js
  27. 4 5
      test/ownership/Ownable.behavior.js
  28. 6 5
      test/ownership/Secondary.test.js
  29. 3 3
      test/payment/ConditionalEscrow.test.js
  30. 3 4
      test/payment/Escrow.behavior.js
  31. 14 15
      test/payment/RefundEscrow.test.js
  32. 9 10
      test/payment/SplitPayment.test.js
  33. 18 18
      test/token/ERC20/ERC20.test.js
  34. 2 2
      test/token/ERC20/ERC20Capped.test.js
  35. 10 10
      test/token/ERC20/ERC20Pausable.test.js
  36. 4 5
      test/token/ERC20/SafeERC20.test.js
  37. 5 5
      test/token/ERC20/TokenTimelock.test.js
  38. 6 16
      test/token/ERC20/TokenVesting.test.js
  39. 4 4
      test/token/ERC20/behaviors/ERC20Burnable.behavior.js
  40. 3 3
      test/token/ERC20/behaviors/ERC20Capped.behavior.js
  41. 2 2
      test/token/ERC20/behaviors/ERC20Mintable.behavior.js
  42. 22 16
      test/token/ERC721/ERC721.behavior.js
  43. 10 10
      test/token/ERC721/ERC721Full.test.js
  44. 6 6
      test/token/ERC721/ERC721MintBurn.behavior.js
  45. 6 6
      test/token/ERC721/ERC721PausedToken.behavior.js
  46. 4 4
      test/utils/ReentrancyGuard.test.js

+ 8 - 8
test/BreakInvariantBounty.test.js

@@ -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');
@@ -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 }));
           });
         });
 
@@ -74,11 +74,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 reclaimed', async function () {
-              await assertRevert(this.bounty.claim(this.target.address, { from: researcher }));
+              await shouldFail.reverting(this.bounty.claim(this.target.address, { from: researcher }));
             });
           });
         });
@@ -86,7 +86,7 @@ contract('BreakInvariantBounty', function ([_, owner, researcher, anyone, nonTar
 
       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 }));
         });
       });
     });
@@ -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 }));
         });
       });
 
@@ -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 }));
         });
       });
     });

+ 5 - 4
test/access/Roles.test.js

@@ -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')
@@ -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 () {
@@ -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));
       });
     });
   });
@@ -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));
       });
     });
   });

+ 5 - 5
test/access/roles/PublicRole.behavior.js

@@ -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');
 
@@ -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 () {
@@ -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 }));
         });
       });
     });
@@ -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 }));
       });
     });
 
@@ -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));
       });
     });
 

+ 2 - 2
test/crowdsale/AllowanceCrowdsale.test.js

@@ -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');
 
@@ -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));
     });
   });
 });

+ 4 - 14
test/crowdsale/CappedCrowdsale.test.js

@@ -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;
 
@@ -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 () {
@@ -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)));
       });
     });
 

+ 7 - 7
test/crowdsale/Crowdsale.test.js

@@ -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');
@@ -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)
     );
   });
@@ -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)
       );
     });
@@ -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 })
             );
           });
@@ -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 })
             );
           });

+ 3 - 4
test/crowdsale/FinalizableCrowdsale.test.js

@@ -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;
 
@@ -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 () {
@@ -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 () {

+ 3 - 3
test/crowdsale/IncreasingPriceCrowdsale.test.js

@@ -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;
 
@@ -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
       ));
     });

+ 7 - 8
test/crowdsale/IndividuallyCappedCrowdsale.test.js

@@ -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;
 
@@ -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 () {
@@ -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 }));
         });
       });
 

+ 3 - 3
test/crowdsale/MintedCrowdsale.test.js

@@ -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;
 
@@ -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 }));
     });
   });
 });

+ 3 - 4
test/crowdsale/PostDeliveryCrowdsale.test.js

@@ -1,7 +1,6 @@
 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 { ether } = require('../helpers/ether');
 
 const BigNumber = web3.BigNumber;
@@ -51,7 +50,7 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
       });
 
       it('does not allow beneficiaries to withdraw tokens before crowdsale ends', async function () {
-        await expectThrow(this.crowdsale.withdrawTokens(investor), EVMRevert);
+        await shouldFail.reverting(this.crowdsale.withdrawTokens(investor));
       });
 
       context('after closing time', function () {
@@ -67,7 +66,7 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
 
         it('rejects multiple withdrawals', async function () {
           await this.crowdsale.withdrawTokens(investor);
-          await expectThrow(this.crowdsale.withdrawTokens(investor), EVMRevert);
+          await shouldFail.reverting(this.crowdsale.withdrawTokens(investor));
         });
       });
     });

+ 6 - 10
test/crowdsale/RefundableCrowdsale.test.js

@@ -1,8 +1,7 @@
 const { ether } = require('../helpers/ether');
 const { advanceBlock } = require('../helpers/advanceToBlock');
+const shouldFail = require('../helpers/shouldFail');
 const time = require('../helpers/time');
-const { expectThrow } = require('../helpers/expectThrow');
-const { EVMRevert } = require('../helpers/EVMRevert');
 const { ethGetBalance } = require('../helpers/web3');
 
 const BigNumber = web3.BigNumber;
@@ -35,11 +34,8 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
   });
 
   it('rejects a goal of zero', async function () {
-    await expectThrow(
-      RefundableCrowdsaleImpl.new(
-        this.openingTime, this.closingTime, rate, wallet, this.token.address, 0,
-      ),
-      EVMRevert,
+    await shouldFail.reverting(
+      RefundableCrowdsaleImpl.new(this.openingTime, this.closingTime, rate, wallet, this.token.address, 0)
     );
   });
 
@@ -54,7 +50,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
 
     context('before opening time', function () {
       it('denies refunds', async function () {
-        await expectThrow(this.crowdsale.claimRefund(investor), EVMRevert);
+        await shouldFail.reverting(this.crowdsale.claimRefund(investor));
       });
     });
 
@@ -64,7 +60,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
       });
 
       it('denies refunds', async function () {
-        await expectThrow(this.crowdsale.claimRefund(investor), EVMRevert);
+        await shouldFail.reverting(this.crowdsale.claimRefund(investor));
       });
 
       context('with unreached goal', function () {
@@ -99,7 +95,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
           });
 
           it('denies refunds', async function () {
-            await expectThrow(this.crowdsale.claimRefund(investor), EVMRevert);
+            await shouldFail.reverting(this.crowdsale.claimRefund(investor));
           });
 
           it('forwards funds to wallet', async function () {

+ 9 - 10
test/crowdsale/TimedCrowdsale.test.js

@@ -1,8 +1,7 @@
 const { ether } = require('../helpers/ether');
 const { advanceBlock } = require('../helpers/advanceToBlock');
+const shouldFail = require('../helpers/shouldFail');
 const time = require('../helpers/time');
-const { expectThrow } = require('../helpers/expectThrow');
-const { EVMRevert } = require('../helpers/EVMRevert');
 
 const BigNumber = web3.BigNumber;
 
@@ -31,15 +30,15 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) {
   });
 
   it('rejects an opening time in the past', async function () {
-    await expectThrow(TimedCrowdsaleImpl.new(
+    await shouldFail.reverting(TimedCrowdsaleImpl.new(
       (await time.latest()) - time.duration.days(1), this.closingTime, rate, wallet, this.token.address
-    ), EVMRevert);
+    ));
   });
 
   it('rejects a closing time before the opening time', async function () {
-    await expectThrow(TimedCrowdsaleImpl.new(
+    await shouldFail.reverting(TimedCrowdsaleImpl.new(
       this.openingTime, this.openingTime - time.duration.seconds(1), rate, wallet, this.token.address
-    ), EVMRevert);
+    ));
   });
 
   context('with crowdsale', function () {
@@ -60,8 +59,8 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) {
     describe('accepting payments', function () {
       it('should reject payments before start', async function () {
         (await this.crowdsale.isOpen()).should.equal(false);
-        await expectThrow(this.crowdsale.send(value), EVMRevert);
-        await expectThrow(this.crowdsale.buyTokens(investor, { from: purchaser, value: value }), EVMRevert);
+        await shouldFail.reverting(this.crowdsale.send(value));
+        await shouldFail.reverting(this.crowdsale.buyTokens(investor, { from: purchaser, value: value }));
       });
 
       it('should accept payments after start', async function () {
@@ -73,8 +72,8 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) {
 
       it('should reject payments after end', async function () {
         await time.increaseTo(this.afterClosingTime);
-        await expectThrow(this.crowdsale.send(value), EVMRevert);
-        await expectThrow(this.crowdsale.buyTokens(investor, { value: value, from: purchaser }), EVMRevert);
+        await shouldFail.reverting(this.crowdsale.send(value));
+        await shouldFail.reverting(this.crowdsale.buyTokens(investor, { value: value, from: purchaser }));
       });
     });
   });

+ 7 - 6
test/drafts/ERC20Migrator.test.js

@@ -1,5 +1,6 @@
-const { assertRevert } = require('../helpers/assertRevert');
+const shouldFail = require('../helpers/shouldFail');
 const { ZERO_ADDRESS } = require('../helpers/constants');
+
 const ERC20Mock = artifacts.require('ERC20Mock');
 const ERC20Mintable = artifacts.require('ERC20Mintable');
 const ERC20Migrator = artifacts.require('ERC20Migrator');
@@ -14,7 +15,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
   const totalSupply = 200;
 
   it('reverts with a null legacy token address', async function () {
-    await assertRevert(ERC20Migrator.new(ZERO_ADDRESS));
+    await shouldFail.reverting(ERC20Migrator.new(ZERO_ADDRESS));
   });
 
   describe('with tokens and migrator', function () {
@@ -30,11 +31,11 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
 
     describe('beginMigration', function () {
       it('reverts with a null new token address', async function () {
-        await assertRevert(this.migrator.beginMigration(ZERO_ADDRESS));
+        await shouldFail.reverting(this.migrator.beginMigration(ZERO_ADDRESS));
       });
 
       it('reverts if not a minter of the token', async function () {
-        await assertRevert(this.migrator.beginMigration(this.newToken.address));
+        await shouldFail.reverting(this.migrator.beginMigration(this.newToken.address));
       });
 
       it('succeeds if it is a minter of the token', async function () {
@@ -45,7 +46,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
       it('reverts the second time it is called', async function () {
         await this.newToken.addMinter(this.migrator.address);
         await this.migrator.beginMigration(this.newToken.address);
-        await assertRevert(this.migrator.beginMigration(this.newToken.address));
+        await shouldFail.reverting(this.migrator.beginMigration(this.newToken.address));
       });
     });
 
@@ -145,7 +146,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
           const amount = baseAmount + 1;
 
           it('reverts', async function () {
-            await assertRevert(this.migrator.migrate(owner, amount));
+            await shouldFail.reverting(this.migrator.migrate(owner, amount));
           });
         });
       });

+ 13 - 13
test/drafts/SignatureBouncer.test.js

@@ -1,4 +1,4 @@
-const { assertRevert } = require('../helpers/assertRevert');
+const shouldFail = require('../helpers/shouldFail');
 const { getSignFor } = require('../helpers/sign');
 const { shouldBehaveLikePublicRole } = require('../access/roles/PublicRole.behavior');
 
@@ -36,19 +36,19 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
       });
 
       it('does not allow invalid signature for sender', async function () {
-        await assertRevert(
+        await shouldFail.reverting(
           this.sigBouncer.onlyWithValidSignature(INVALID_SIGNATURE, { from: authorizedUser })
         );
       });
 
       it('does not allow valid signature for other sender', async function () {
-        await assertRevert(
+        await shouldFail.reverting(
           this.sigBouncer.onlyWithValidSignature(this.signFor(authorizedUser), { from: anyone })
         );
       });
 
       it('does not allow valid signature for method for sender', async function () {
-        await assertRevert(
+        await shouldFail.reverting(
           this.sigBouncer.onlyWithValidSignature(this.signFor(authorizedUser, 'onlyWithValidSignature'),
             { from: authorizedUser })
         );
@@ -63,13 +63,13 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
       });
 
       it('does not allow invalid signature with correct method for sender', async function () {
-        await assertRevert(
+        await shouldFail.reverting(
           this.sigBouncer.onlyWithValidSignatureAndMethod(INVALID_SIGNATURE, { from: authorizedUser })
         );
       });
 
       it('does not allow valid signature with correct method for other sender', async function () {
-        await assertRevert(
+        await shouldFail.reverting(
           this.sigBouncer.onlyWithValidSignatureAndMethod(
             this.signFor(authorizedUser, 'onlyWithValidSignatureAndMethod'), { from: anyone }
           )
@@ -77,14 +77,14 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
       });
 
       it('does not allow valid method signature with incorrect method for sender', async function () {
-        await assertRevert(
+        await shouldFail.reverting(
           this.sigBouncer.onlyWithValidSignatureAndMethod(this.signFor(authorizedUser, 'theWrongMethod'),
             { from: authorizedUser })
         );
       });
 
       it('does not allow valid non-method signature method for sender', async function () {
-        await assertRevert(
+        await shouldFail.reverting(
           this.sigBouncer.onlyWithValidSignatureAndMethod(this.signFor(authorizedUser), { from: authorizedUser })
         );
       });
@@ -98,13 +98,13 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
       });
 
       it('does not allow invalid signature with correct method and data for sender', async function () {
-        await assertRevert(
+        await shouldFail.reverting(
           this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE, INVALID_SIGNATURE, { from: authorizedUser })
         );
       });
 
       it('does not allow valid signature with correct method and incorrect data for sender', async function () {
-        await assertRevert(
+        await shouldFail.reverting(
           this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE + 10,
             this.signFor(authorizedUser, 'onlyWithValidSignatureAndData', [UINT_VALUE]),
             { from: authorizedUser }
@@ -113,7 +113,7 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
       });
 
       it('does not allow valid signature with correct method and data for other sender', async function () {
-        await assertRevert(
+        await shouldFail.reverting(
           this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE,
             this.signFor(authorizedUser, 'onlyWithValidSignatureAndData', [UINT_VALUE]),
             { from: anyone }
@@ -122,7 +122,7 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
       });
 
       it('does not allow valid non-method signature for sender', async function () {
-        await assertRevert(
+        await shouldFail.reverting(
           this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE,
             this.signFor(authorizedUser), { from: authorizedUser }
           )
@@ -130,7 +130,7 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authoriz
       });
 
       it('does not allow msg.data shorter than SIGNATURE_SIZE', async function () {
-        await assertRevert(
+        await shouldFail.reverting(
           this.sigBouncer.tooShortMsgData({ from: authorizedUser })
         );
       });

+ 7 - 15
test/examples/SampleCrowdsale.test.js

@@ -1,9 +1,7 @@
 const { ether } = require('../helpers/ether');
 const { advanceBlock } = require('../helpers/advanceToBlock');
+const shouldFail = require('../helpers/shouldFail');
 const time = require('../helpers/time');
-const { expectThrow } = require('../helpers/expectThrow');
-const { EVMRevert } = require('../helpers/EVMRevert');
-const { assertRevert } = require('../helpers/assertRevert');
 const { ethGetBalance } = require('../helpers/web3');
 
 const BigNumber = web3.BigNumber;
@@ -53,14 +51,8 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
   });
 
   it('should not accept payments before start', async function () {
-    await expectThrow(
-      this.crowdsale.send(ether(1)),
-      EVMRevert,
-    );
-    await expectThrow(
-      this.crowdsale.buyTokens(investor, { from: investor, value: ether(1) }),
-      EVMRevert,
-    );
+    await shouldFail.reverting(this.crowdsale.send(ether(1)));
+    await shouldFail.reverting(this.crowdsale.buyTokens(investor, { from: investor, value: ether(1) }));
   });
 
   it('should accept payments during the sale', async function () {
@@ -76,14 +68,14 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
 
   it('should reject payments after end', async function () {
     await time.increaseTo(this.afterClosingTime);
-    await expectThrow(this.crowdsale.send(ether(1)), EVMRevert);
-    await expectThrow(this.crowdsale.buyTokens(investor, { value: ether(1), from: investor }), EVMRevert);
+    await shouldFail.reverting(this.crowdsale.send(ether(1)));
+    await shouldFail.reverting(this.crowdsale.buyTokens(investor, { value: ether(1), from: investor }));
   });
 
   it('should reject payments over cap', async function () {
     await time.increaseTo(this.openingTime);
     await this.crowdsale.send(CAP);
-    await expectThrow(this.crowdsale.send(1), EVMRevert);
+    await shouldFail.reverting(this.crowdsale.send(1));
   });
 
   it('should allow finalization and transfer funds to wallet if the goal is reached', async function () {
@@ -117,7 +109,7 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
     const HIGH_GOAL = ether(30);
 
     it('creation reverts', async function () {
-      await assertRevert(SampleCrowdsale.new(
+      await shouldFail.reverting(SampleCrowdsale.new(
         this.openingTime, this.closingTime, RATE, wallet, CAP, this.token.address, HIGH_GOAL
       ));
     });

+ 0 - 5
test/helpers/EVMRevert.js

@@ -1,5 +0,0 @@
-const EVMRevert = 'revert';
-
-module.exports = {
-  EVMRevert,
-};

+ 0 - 5
test/helpers/EVMThrow.js

@@ -1,5 +0,0 @@
-const EVMThrow = 'invalid opcode';
-
-module.exports = {
-  EVMThrow,
-};

+ 0 - 15
test/helpers/assertJump.js

@@ -1,15 +0,0 @@
-const should = require('chai')
-  .should();
-
-async function assertJump (promise) {
-  try {
-    await promise;
-    should.fail('Expected invalid opcode not received');
-  } catch (error) {
-    error.message.should.include('invalid opcode', `Expected "invalid opcode", got ${error} instead`);
-  }
-}
-
-module.exports = {
-  assertJump,
-};

+ 0 - 16
test/helpers/assertRevert.js

@@ -1,16 +0,0 @@
-const should = require('chai')
-  .should();
-
-async function assertRevert (promise) {
-  try {
-    await promise;
-  } catch (error) {
-    error.message.should.include('revert', `Expected "revert", got ${error} instead`);
-    return;
-  }
-  should.fail('Expected revert not received');
-}
-
-module.exports = {
-  assertRevert,
-};

+ 0 - 28
test/helpers/expectThrow.js

@@ -1,28 +0,0 @@
-const should = require('chai')
-  .should();
-
-async function expectThrow (promise, message) {
-  try {
-    await promise;
-  } catch (error) {
-    // Message is an optional parameter here
-    if (message) {
-      error.message.should.include(message, 'Expected \'' + message + '\', got \'' + error + '\' instead');
-      return;
-    } else {
-      // TODO: Check jump destination to destinguish between a throw
-      //       and an actual invalid jump.
-      // TODO: When we contract A calls contract B, and B throws, instead
-      //       of an 'invalid jump', we get an 'out of gas' error. How do
-      //       we distinguish this from an actual out of gas event? (The
-      //       ganache log actually show an 'invalid jump' event.)
-      error.message.should.match(/[invalid opcode|out of gas|revert]/, 'Expected throw, got \'' + error + '\' instead');
-      return;
-    }
-  }
-  should.fail('Expected throw not received');
-}
-
-module.exports = {
-  expectThrow,
-};

+ 31 - 0
test/helpers/shouldFail.js

@@ -0,0 +1,31 @@
+const should = require('chai')
+  .should();
+
+async function shouldFailWithMessage (promise, message) {
+  try {
+    await promise;
+  } catch (error) {
+    error.message.should.include(message, 'Wrong failure type');
+    return;
+  }
+
+  should.fail(`Expected '${message}' failure not received`);
+}
+
+async function reverting (promise) {
+  await shouldFailWithMessage(promise, 'revert');
+}
+
+async function throwing (promise) {
+  await shouldFailWithMessage(promise, 'invalid opcode');
+}
+
+async function outOfGas (promise) {
+  await shouldFailWithMessage(promise, 'out of gas');
+}
+
+module.exports = {
+  reverting,
+  throwing,
+  outOfGas,
+};

+ 2 - 2
test/introspection/ERC165.test.js

@@ -1,5 +1,5 @@
 const { shouldSupportInterfaces } = require('./SupportsInterface.behavior');
-const { assertRevert } = require('../helpers/assertRevert');
+const shouldFail = require('../helpers/shouldFail');
 
 const ERC165Mock = artifacts.require('ERC165Mock');
 
@@ -12,7 +12,7 @@ contract('ERC165', function () {
   });
 
   it('does not allow 0xffffffff', async function () {
-    await assertRevert(
+    await shouldFail.reverting(
       this.mock.registerInterface(0xffffffff)
     );
   });

+ 2 - 2
test/library/ECDSA.test.js

@@ -1,5 +1,5 @@
 const { signMessage, toEthSignedMessageHash } = require('../helpers/sign');
-const { expectThrow } = require('../helpers/expectThrow');
+const shouldFail = require('../helpers/shouldFail');
 
 const ECDSAMock = artifacts.require('ECDSAMock');
 
@@ -113,7 +113,7 @@ contract('ECDSA', function ([_, anyone]) {
     it.skip('reverts', async function () {
       // Create the signature
       const signature = signMessage(anyone, TEST_MESSAGE);
-      await expectThrow(
+      await shouldFail.reverting(
         this.ecdsa.recover(TEST_MESSAGE.substring(2), signature)
       );
     });

+ 8 - 8
test/lifecycle/Pausable.test.js

@@ -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 }));
             });
           });
         });

+ 6 - 6
test/math/SafeMath.test.js

@@ -1,4 +1,4 @@
-const { assertRevert } = require('../helpers/assertRevert');
+const shouldFail = require('../helpers/shouldFail');
 const { MAX_UINT256 } = require('../helpers/constants');
 
 const BigNumber = web3.BigNumber;
@@ -25,7 +25,7 @@ contract('SafeMath', function () {
       const a = MAX_UINT256;
       const b = new BigNumber(1);
 
-      await assertRevert(this.safeMath.add(a, b));
+      await shouldFail.reverting(this.safeMath.add(a, b));
     });
   });
 
@@ -41,7 +41,7 @@ contract('SafeMath', function () {
       const a = new BigNumber(1234);
       const b = new BigNumber(5678);
 
-      await assertRevert(this.safeMath.sub(a, b));
+      await shouldFail.reverting(this.safeMath.sub(a, b));
     });
   });
 
@@ -64,7 +64,7 @@ contract('SafeMath', function () {
       const a = MAX_UINT256;
       const b = new BigNumber(2);
 
-      await assertRevert(this.safeMath.mul(a, b));
+      await shouldFail.reverting(this.safeMath.mul(a, b));
     });
   });
 
@@ -80,7 +80,7 @@ contract('SafeMath', function () {
       const a = new BigNumber(5678);
       const b = new BigNumber(0);
 
-      await assertRevert(this.safeMath.div(a, b));
+      await shouldFail.reverting(this.safeMath.div(a, b));
     });
   });
 
@@ -119,7 +119,7 @@ contract('SafeMath', function () {
       const a = new BigNumber(5678);
       const b = new BigNumber(0);
 
-      await assertRevert(this.safeMath.mod(a, b));
+      await shouldFail.reverting(this.safeMath.mod(a, b));
     });
   });
 });

+ 4 - 5
test/ownership/Ownable.behavior.js

@@ -1,5 +1,4 @@
-const { expectThrow } = require('../helpers/expectThrow');
-const { EVMRevert } = require('../helpers/EVMRevert');
+const shouldFail = require('../helpers/shouldFail');
 const expectEvent = require('../helpers/expectEvent');
 const { ZERO_ADDRESS } = require('../helpers/constants');
 
@@ -22,11 +21,11 @@ function shouldBehaveLikeOwnable (owner, [anyone]) {
     });
 
     it('should prevent non-owners from transfering', async function () {
-      await expectThrow(this.ownable.transferOwnership(anyone, { from: anyone }), EVMRevert);
+      await shouldFail.reverting(this.ownable.transferOwnership(anyone, { from: anyone }));
     });
 
     it('should guard ownership against stuck state', async function () {
-      await expectThrow(this.ownable.transferOwnership(null, { from: owner }), EVMRevert);
+      await shouldFail.reverting(this.ownable.transferOwnership(null, { from: owner }));
     });
 
     it('loses owner after renouncement', async function () {
@@ -37,7 +36,7 @@ function shouldBehaveLikeOwnable (owner, [anyone]) {
     });
 
     it('should prevent non-owners from renouncement', async function () {
-      await expectThrow(this.ownable.renounceOwnership({ from: anyone }), EVMRevert);
+      await shouldFail.reverting(this.ownable.renounceOwnership({ from: anyone }));
     });
   });
 }

+ 6 - 5
test/ownership/Secondary.test.js

@@ -1,5 +1,6 @@
-const { assertRevert } = require('../helpers/assertRevert');
+const shouldFail = require('../helpers/shouldFail');
 const { ZERO_ADDRESS } = require('../helpers/constants');
+
 const SecondaryMock = artifacts.require('SecondaryMock');
 
 require('chai')
@@ -20,7 +21,7 @@ contract('Secondary', function ([_, primary, newPrimary, anyone]) {
     });
 
     it('reverts when anyone calls onlyPrimary functions', async function () {
-      await assertRevert(this.secondary.onlyPrimaryMock({ from: anyone }));
+      await shouldFail.reverting(this.secondary.onlyPrimaryMock({ from: anyone }));
     });
   });
 
@@ -31,11 +32,11 @@ contract('Secondary', function ([_, primary, newPrimary, anyone]) {
     });
 
     it('reverts when transfering to the null address', async function () {
-      await assertRevert(this.secondary.transferPrimary(ZERO_ADDRESS, { from: primary }));
+      await shouldFail.reverting(this.secondary.transferPrimary(ZERO_ADDRESS, { from: primary }));
     });
 
     it('reverts when called by anyone', async function () {
-      await assertRevert(this.secondary.transferPrimary(newPrimary, { from: anyone }));
+      await shouldFail.reverting(this.secondary.transferPrimary(newPrimary, { from: anyone }));
     });
 
     context('with new primary', function () {
@@ -48,7 +49,7 @@ contract('Secondary', function ([_, primary, newPrimary, anyone]) {
       });
 
       it('reverts when the old primary account calls onlyPrimary functions', async function () {
-        await assertRevert(this.secondary.onlyPrimaryMock({ from: primary }));
+        await shouldFail.reverting(this.secondary.onlyPrimaryMock({ from: primary }));
       });
     });
   });

+ 3 - 3
test/payment/ConditionalEscrow.test.js

@@ -1,6 +1,6 @@
 const { shouldBehaveLikeEscrow } = require('./Escrow.behavior');
-const { expectThrow } = require('../helpers/expectThrow');
-const { EVMRevert } = require('../helpers/EVMRevert');
+
+const shouldFail = require('../helpers/shouldFail');
 const { ether } = require('../helpers/ether');
 
 const BigNumber = web3.BigNumber;
@@ -34,7 +34,7 @@ contract('ConditionalEscrow', function ([_, owner, payee, ...otherAccounts]) {
     it('reverts on withdrawals', async function () {
       await this.escrow.deposit(payee, { from: owner, value: amount });
 
-      await expectThrow(this.escrow.withdraw(payee, { from: owner }), EVMRevert);
+      await shouldFail.reverting(this.escrow.withdraw(payee, { from: owner }));
     });
   });
 });

+ 3 - 4
test/payment/Escrow.behavior.js

@@ -1,6 +1,5 @@
 const expectEvent = require('../helpers/expectEvent');
-const { expectThrow } = require('../helpers/expectThrow');
-const { EVMRevert } = require('../helpers/EVMRevert');
+const shouldFail = require('../helpers/shouldFail');
 const { ethGetBalance } = require('../helpers/web3');
 const { ether } = require('../helpers/ether');
 
@@ -28,7 +27,7 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) {
       });
 
       it('only the primary account can deposit', async function () {
-        await expectThrow(this.escrow.deposit(payee1, { from: payee2 }), EVMRevert);
+        await shouldFail.reverting(this.escrow.deposit(payee1, { from: payee2 }));
       });
 
       it('emits a deposited event', async function () {
@@ -80,7 +79,7 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) {
       });
 
       it('only the primary account can withdraw', async function () {
-        await expectThrow(this.escrow.withdraw(payee1, { from: payee1 }), EVMRevert);
+        await shouldFail.reverting(this.escrow.withdraw(payee1, { from: payee1 }));
       });
 
       it('emits a withdrawn event', async function () {

+ 14 - 15
test/payment/RefundEscrow.test.js

@@ -1,5 +1,4 @@
-const { expectThrow } = require('../helpers/expectThrow');
-const { EVMRevert } = require('../helpers/EVMRevert');
+const shouldFail = require('../helpers/shouldFail');
 const expectEvent = require('../helpers/expectEvent');
 const { ethGetBalance } = require('../helpers/web3');
 const { ether } = require('../helpers/ether');
@@ -18,7 +17,7 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee
   const refundees = [refundee1, refundee2];
 
   it('requires a non-null beneficiary', async function () {
-    await expectThrow(
+    await shouldFail.reverting(
       RefundEscrow.new(ZERO_ADDRESS, { from: primary })
     );
   });
@@ -42,17 +41,17 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee
 
       it('does not refund refundees', async function () {
         await this.escrow.deposit(refundee1, { from: primary, value: amount });
-        await expectThrow(this.escrow.withdraw(refundee1), EVMRevert);
+        await shouldFail.reverting(this.escrow.withdraw(refundee1));
       });
 
       it('does not allow beneficiary withdrawal', async function () {
         await this.escrow.deposit(refundee1, { from: primary, value: amount });
-        await expectThrow(this.escrow.beneficiaryWithdraw(), EVMRevert);
+        await shouldFail.reverting(this.escrow.beneficiaryWithdraw());
       });
     });
 
     it('only the primary account can enter closed state', async function () {
-      await expectThrow(this.escrow.close({ from: beneficiary }), EVMRevert);
+      await shouldFail.reverting(this.escrow.close({ from: beneficiary }));
 
       const { logs } = await this.escrow.close({ from: primary });
       expectEvent.inLogs(logs, 'Closed');
@@ -66,11 +65,11 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee
       });
 
       it('rejects deposits', async function () {
-        await expectThrow(this.escrow.deposit(refundee1, { from: primary, value: amount }), EVMRevert);
+        await shouldFail.reverting(this.escrow.deposit(refundee1, { from: primary, value: amount }));
       });
 
       it('does not refund refundees', async function () {
-        await expectThrow(this.escrow.withdraw(refundee1), EVMRevert);
+        await shouldFail.reverting(this.escrow.withdraw(refundee1));
       });
 
       it('allows beneficiary withdrawal', async function () {
@@ -82,16 +81,16 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee
       });
 
       it('prevents entering the refund state', async function () {
-        await expectThrow(this.escrow.enableRefunds({ from: primary }), EVMRevert);
+        await shouldFail.reverting(this.escrow.enableRefunds({ from: primary }));
       });
 
       it('prevents re-entering the closed state', async function () {
-        await expectThrow(this.escrow.close({ from: primary }), EVMRevert);
+        await shouldFail.reverting(this.escrow.close({ from: primary }));
       });
     });
 
     it('only the primary account can enter refund state', async function () {
-      await expectThrow(this.escrow.enableRefunds({ from: beneficiary }), EVMRevert);
+      await shouldFail.reverting(this.escrow.enableRefunds({ from: beneficiary }));
 
       const { logs } = await this.escrow.enableRefunds({ from: primary });
       expectEvent.inLogs(logs, 'RefundsEnabled');
@@ -105,7 +104,7 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee
       });
 
       it('rejects deposits', async function () {
-        await expectThrow(this.escrow.deposit(refundee1, { from: primary, value: amount }), EVMRevert);
+        await shouldFail.reverting(this.escrow.deposit(refundee1, { from: primary, value: amount }));
       });
 
       it('refunds refundees', async function () {
@@ -119,15 +118,15 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee
       });
 
       it('does not allow beneficiary withdrawal', async function () {
-        await expectThrow(this.escrow.beneficiaryWithdraw(), EVMRevert);
+        await shouldFail.reverting(this.escrow.beneficiaryWithdraw());
       });
 
       it('prevents entering the closed state', async function () {
-        await expectThrow(this.escrow.close({ from: primary }), EVMRevert);
+        await shouldFail.reverting(this.escrow.close({ from: primary }));
       });
 
       it('prevents re-entering the refund state', async function () {
-        await expectThrow(this.escrow.enableRefunds({ from: primary }), EVMRevert);
+        await shouldFail.reverting(this.escrow.enableRefunds({ from: primary }));
       });
     });
   });

+ 9 - 10
test/payment/SplitPayment.test.js

@@ -9,35 +9,34 @@ require('chai')
   .use(require('chai-bignumber')(BigNumber))
   .should();
 
-const { expectThrow } = require('../helpers/expectThrow');
-const { EVMRevert } = require('../helpers/EVMRevert.js');
+const shouldFail = require('../helpers/shouldFail');
 const SplitPayment = artifacts.require('SplitPayment');
 
 contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, payer1]) {
   const amount = ether(1.0);
 
   it('rejects an empty set of payees', async function () {
-    await expectThrow(SplitPayment.new([], []), EVMRevert);
+    await shouldFail.reverting(SplitPayment.new([], []));
   });
 
   it('rejects more payees than shares', async function () {
-    await expectThrow(SplitPayment.new([payee1, payee2, payee3], [20, 30]), EVMRevert);
+    await shouldFail.reverting(SplitPayment.new([payee1, payee2, payee3], [20, 30]));
   });
 
   it('rejects more shares than payees', async function () {
-    await expectThrow(SplitPayment.new([payee1, payee2], [20, 30, 40]), EVMRevert);
+    await shouldFail.reverting(SplitPayment.new([payee1, payee2], [20, 30, 40]));
   });
 
   it('rejects null payees', async function () {
-    await expectThrow(SplitPayment.new([payee1, ZERO_ADDRESS], [20, 30]), EVMRevert);
+    await shouldFail.reverting(SplitPayment.new([payee1, ZERO_ADDRESS], [20, 30]));
   });
 
   it('rejects zero-valued shares', async function () {
-    await expectThrow(SplitPayment.new([payee1, payee2], [20, 0]), EVMRevert);
+    await shouldFail.reverting(SplitPayment.new([payee1, payee2], [20, 0]));
   });
 
   it('rejects repeated payees', async function () {
-    await expectThrow(SplitPayment.new([payee1, payee1], [20, 30]), EVMRevert);
+    await shouldFail.reverting(SplitPayment.new([payee1, payee1], [20, 30]));
   });
 
   context('once deployed', function () {
@@ -74,12 +73,12 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
     });
 
     it('should throw if no funds to claim', async function () {
-      await expectThrow(this.contract.release(payee1), EVMRevert);
+      await shouldFail.reverting(this.contract.release(payee1));
     });
 
     it('should throw if non-payee want to claim', async function () {
       await sendEther(payer1, this.contract.address, amount);
-      await expectThrow(this.contract.release(nonpayee1), EVMRevert);
+      await shouldFail.reverting(this.contract.release(nonpayee1));
     });
 
     it('should distribute funds to payees', async function () {

+ 18 - 18
test/token/ERC20/ERC20.test.js

@@ -1,4 +1,4 @@
-const { assertRevert } = require('../../helpers/assertRevert');
+const shouldFail = require('../../helpers/shouldFail');
 const expectEvent = require('../../helpers/expectEvent');
 const { ZERO_ADDRESS } = require('../../helpers/constants');
 
@@ -43,7 +43,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
         const amount = 101;
 
         it('reverts', async function () {
-          await assertRevert(this.token.transfer(to, amount, { from: owner }));
+          await shouldFail.reverting(this.token.transfer(to, amount, { from: owner }));
         });
       });
 
@@ -74,7 +74,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
       const to = ZERO_ADDRESS;
 
       it('reverts', async function () {
-        await assertRevert(this.token.transfer(to, 100, { from: owner }));
+        await shouldFail.reverting(this.token.transfer(to, 100, { from: owner }));
       });
     });
   });
@@ -157,7 +157,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
       const spender = ZERO_ADDRESS;
 
       it('reverts', async function () {
-        await assertRevert(this.token.approve(spender, amount, { from: owner }));
+        await shouldFail.reverting(this.token.approve(spender, amount, { from: owner }));
       });
     });
   });
@@ -205,7 +205,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
           const amount = 101;
 
           it('reverts', async function () {
-            await assertRevert(this.token.transferFrom(owner, to, amount, { from: spender }));
+            await shouldFail.reverting(this.token.transferFrom(owner, to, amount, { from: spender }));
           });
         });
       });
@@ -219,7 +219,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
           const amount = 100;
 
           it('reverts', async function () {
-            await assertRevert(this.token.transferFrom(owner, to, amount, { from: spender }));
+            await shouldFail.reverting(this.token.transferFrom(owner, to, amount, { from: spender }));
           });
         });
 
@@ -227,7 +227,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
           const amount = 101;
 
           it('reverts', async function () {
-            await assertRevert(this.token.transferFrom(owner, to, amount, { from: spender }));
+            await shouldFail.reverting(this.token.transferFrom(owner, to, amount, { from: spender }));
           });
         });
       });
@@ -242,7 +242,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
       });
 
       it('reverts', async function () {
-        await assertRevert(this.token.transferFrom(owner, to, amount, { from: spender }));
+        await shouldFail.reverting(this.token.transferFrom(owner, to, amount, { from: spender }));
       });
     });
   });
@@ -254,7 +254,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
       function shouldDecreaseApproval (amount) {
         describe('when there was no approved amount before', function () {
           it('reverts', async function () {
-            await assertRevert(this.token.decreaseAllowance(spender, amount, { from: owner }));
+            await shouldFail.reverting(this.token.decreaseAllowance(spender, amount, { from: owner }));
           });
         });
 
@@ -287,7 +287,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
           });
 
           it('reverts when more than the full allowance is removed', async function () {
-            await assertRevert(this.token.decreaseAllowance(spender, approvedAmount + 1, { from: owner }));
+            await shouldFail.reverting(this.token.decreaseAllowance(spender, approvedAmount + 1, { from: owner }));
           });
         });
       }
@@ -310,7 +310,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
       const spender = ZERO_ADDRESS;
 
       it('reverts', async function () {
-        await assertRevert(this.token.decreaseAllowance(spender, amount, { from: owner }));
+        await shouldFail.reverting(this.token.decreaseAllowance(spender, amount, { from: owner }));
       });
     });
   });
@@ -392,7 +392,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
       const spender = ZERO_ADDRESS;
 
       it('reverts', async function () {
-        await assertRevert(this.token.increaseAllowance(spender, amount, { from: owner }));
+        await shouldFail.reverting(this.token.increaseAllowance(spender, amount, { from: owner }));
       });
     });
   });
@@ -402,7 +402,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
     const amount = new BigNumber(50);
 
     it('rejects a null account', async function () {
-      await assertRevert(this.token.mint(ZERO_ADDRESS, amount));
+      await shouldFail.reverting(this.token.mint(ZERO_ADDRESS, amount));
     });
 
     describe('for a non null account', function () {
@@ -435,12 +435,12 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
     const initialSupply = new BigNumber(100);
 
     it('rejects a null account', async function () {
-      await assertRevert(this.token.burn(ZERO_ADDRESS, 1));
+      await shouldFail.reverting(this.token.burn(ZERO_ADDRESS, 1));
     });
 
     describe('for a non null account', function () {
       it('rejects burning more than balance', async function () {
-        await assertRevert(this.token.burn(owner, initialSupply.plus(1)));
+        await shouldFail.reverting(this.token.burn(owner, initialSupply.plus(1)));
       });
 
       const describeBurn = function (description, amount) {
@@ -487,16 +487,16 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
     });
 
     it('rejects a null account', async function () {
-      await assertRevert(this.token.burnFrom(ZERO_ADDRESS, 1));
+      await shouldFail.reverting(this.token.burnFrom(ZERO_ADDRESS, 1));
     });
 
     describe('for a non null account', function () {
       it('rejects burning more than allowance', async function () {
-        await assertRevert(this.token.burnFrom(owner, allowance.plus(1)));
+        await shouldFail.reverting(this.token.burnFrom(owner, allowance.plus(1)));
       });
 
       it('rejects burning more than balance', async function () {
-        await assertRevert(this.token.burnFrom(owner, initialSupply.plus(1)));
+        await shouldFail.reverting(this.token.burnFrom(owner, initialSupply.plus(1)));
       });
 
       const describeBurnFrom = function (description, amount) {

+ 2 - 2
test/token/ERC20/ERC20Capped.test.js

@@ -1,4 +1,4 @@
-const { assertRevert } = require('../../helpers/assertRevert');
+const shouldFail = require('../../helpers/shouldFail');
 const { ether } = require('../../helpers/ether');
 const { shouldBehaveLikeERC20Mintable } = require('./behaviors/ERC20Mintable.behavior');
 const { shouldBehaveLikeERC20Capped } = require('./behaviors/ERC20Capped.behavior');
@@ -9,7 +9,7 @@ contract('ERC20Capped', function ([_, minter, ...otherAccounts]) {
   const cap = ether(1000);
 
   it('requires a non-zero cap', async function () {
-    await assertRevert(
+    await shouldFail.reverting(
       ERC20Capped.new(0, { from: minter })
     );
   });

+ 10 - 10
test/token/ERC20/ERC20Pausable.test.js

@@ -1,5 +1,5 @@
 const expectEvent = require('../../helpers/expectEvent');
-const { assertRevert } = require('../../helpers/assertRevert');
+const shouldFail = require('../../helpers/shouldFail');
 
 const ERC20PausableMock = artifacts.require('ERC20PausableMock');
 const { shouldBehaveLikePublicRole } = require('../../access/roles/PublicRole.behavior');
@@ -41,7 +41,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA
         });
 
         it('reverts', async function () {
-          await assertRevert(this.token.pause({ from }));
+          await shouldFail.reverting(this.token.pause({ from }));
         });
       });
     });
@@ -50,7 +50,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA
       const from = anotherAccount;
 
       it('reverts', async function () {
-        await assertRevert(this.token.pause({ from }));
+        await shouldFail.reverting(this.token.pause({ from }));
       });
     });
   });
@@ -78,7 +78,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA
 
       describe('when the token is unpaused', function () {
         it('reverts', async function () {
-          await assertRevert(this.token.unpause({ from }));
+          await shouldFail.reverting(this.token.unpause({ from }));
         });
       });
     });
@@ -87,7 +87,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA
       const from = anotherAccount;
 
       it('reverts', async function () {
-        await assertRevert(this.token.unpause({ from }));
+        await shouldFail.reverting(this.token.unpause({ from }));
       });
     });
   });
@@ -133,7 +133,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA
       it('reverts when trying to transfer when paused', async function () {
         await this.token.pause({ from: pauser });
 
-        await assertRevert(this.token.transfer(recipient, 100, { from: pauser }));
+        await shouldFail.reverting(this.token.transfer(recipient, 100, { from: pauser }));
       });
     });
 
@@ -156,7 +156,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA
       it('reverts when trying to transfer when paused', async function () {
         await this.token.pause({ from: pauser });
 
-        await assertRevert(this.token.approve(anotherAccount, 40, { from: pauser }));
+        await shouldFail.reverting(this.token.approve(anotherAccount, 40, { from: pauser }));
       });
     });
 
@@ -185,7 +185,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA
       it('reverts when trying to transfer from when paused', async function () {
         await this.token.pause({ from: pauser });
 
-        await assertRevert(this.token.transferFrom(pauser, recipient, 40, { from: anotherAccount }));
+        await shouldFail.reverting(this.token.transferFrom(pauser, recipient, 40, { from: anotherAccount }));
       });
     });
 
@@ -212,7 +212,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA
       it('reverts when trying to transfer when paused', async function () {
         await this.token.pause({ from: pauser });
 
-        await assertRevert(this.token.decreaseAllowance(anotherAccount, 40, { from: pauser }));
+        await shouldFail.reverting(this.token.decreaseAllowance(anotherAccount, 40, { from: pauser }));
       });
     });
 
@@ -239,7 +239,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA
       it('reverts when trying to increase approval when paused', async function () {
         await this.token.pause({ from: pauser });
 
-        await assertRevert(this.token.increaseAllowance(anotherAccount, 40, { from: pauser }));
+        await shouldFail.reverting(this.token.increaseAllowance(anotherAccount, 40, { from: pauser }));
       });
     });
   });

+ 4 - 5
test/token/ERC20/SafeERC20.test.js

@@ -1,5 +1,4 @@
-const { expectThrow } = require('../../helpers/expectThrow');
-const { EVMRevert } = require('../../helpers/EVMRevert');
+const shouldFail = require('../../helpers/shouldFail');
 
 require('chai')
   .should();
@@ -12,15 +11,15 @@ contract('SafeERC20', function () {
   });
 
   it('should throw on failed transfer', async function () {
-    await expectThrow(this.helper.doFailingTransfer(), EVMRevert);
+    await shouldFail.reverting(this.helper.doFailingTransfer());
   });
 
   it('should throw on failed transferFrom', async function () {
-    await expectThrow(this.helper.doFailingTransferFrom(), EVMRevert);
+    await shouldFail.reverting(this.helper.doFailingTransferFrom());
   });
 
   it('should throw on failed approve', async function () {
-    await expectThrow(this.helper.doFailingApprove(), EVMRevert);
+    await shouldFail.reverting(this.helper.doFailingApprove());
   });
 
   it('should not throw on succeeding transfer', async function () {

+ 5 - 5
test/token/ERC20/TokenTimelock.test.js

@@ -1,5 +1,5 @@
+const shouldFail = require('../../helpers/shouldFail');
 const time = require('../../helpers/time');
-const { expectThrow } = require('../../helpers/expectThrow');
 
 const BigNumber = web3.BigNumber;
 
@@ -20,7 +20,7 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) {
 
     it('rejects a release time in the past', async function () {
       const pastReleaseTime = (await time.latest()) - time.duration.years(1);
-      await expectThrow(
+      await shouldFail.reverting(
         TokenTimelock.new(this.token.address, beneficiary, pastReleaseTime)
       );
     });
@@ -39,12 +39,12 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) {
       });
 
       it('cannot be released before time limit', async function () {
-        await expectThrow(this.timelock.release());
+        await shouldFail.reverting(this.timelock.release());
       });
 
       it('cannot be released just before time limit', async function () {
         await time.increaseTo(this.releaseTime - time.duration.seconds(3));
-        await expectThrow(this.timelock.release());
+        await shouldFail.reverting(this.timelock.release());
       });
 
       it('can be released just after limit', async function () {
@@ -62,7 +62,7 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) {
       it('cannot be released twice', async function () {
         await time.increaseTo(this.releaseTime + time.duration.years(1));
         await this.timelock.release();
-        await expectThrow(this.timelock.release());
+        await shouldFail.reverting(this.timelock.release());
         (await this.token.balanceOf(beneficiary)).should.be.bignumber.equal(amount);
       });
     });

+ 6 - 16
test/token/ERC20/TokenVesting.test.js

@@ -1,5 +1,4 @@
-const { expectThrow } = require('../../helpers/expectThrow');
-const { EVMRevert } = require('../../helpers/EVMRevert');
+const shouldFail = require('../../helpers/shouldFail');
 const time = require('../../helpers/time');
 const { ethGetBlock } = require('../../helpers/web3');
 const { ZERO_ADDRESS } = require('../../helpers/constants');
@@ -29,13 +28,13 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
 
     cliffDuration.should.be.gt(duration);
 
-    await expectThrow(
+    await shouldFail.reverting(
       TokenVesting.new(beneficiary, this.start, cliffDuration, duration, true, { from: owner })
     );
   });
 
   it('requires a valid beneficiary', async function () {
-    await expectThrow(
+    await shouldFail.reverting(
       TokenVesting.new(ZERO_ADDRESS, this.start, this.cliffDuration, this.duration, true, { from: owner })
     );
   });
@@ -58,10 +57,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
     });
 
     it('cannot be released before cliff', async function () {
-      await expectThrow(
-        this.vesting.release(this.token.address),
-        EVMRevert,
-      );
+      await shouldFail.reverting(this.vesting.release(this.token.address));
     });
 
     it('can be released after cliff', async function () {
@@ -113,10 +109,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
         beneficiary, this.start, this.cliffDuration, this.duration, false, { from: owner }
       );
 
-      await expectThrow(
-        vesting.revoke(this.token.address, { from: owner }),
-        EVMRevert,
-      );
+      await shouldFail.reverting(vesting.revoke(this.token.address, { from: owner }));
     });
 
     it('should return the non-vested tokens when revoked by owner', async function () {
@@ -148,10 +141,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
 
       await this.vesting.revoke(this.token.address, { from: owner });
 
-      await expectThrow(
-        this.vesting.revoke(this.token.address, { from: owner }),
-        EVMRevert,
-      );
+      await shouldFail.reverting(this.vesting.revoke(this.token.address, { from: owner }));
     });
   });
 });

+ 4 - 4
test/token/ERC20/behaviors/ERC20Burnable.behavior.js

@@ -1,4 +1,4 @@
-const { assertRevert } = require('../../../helpers/assertRevert');
+const shouldFail = require('../../../helpers/shouldFail');
 const expectEvent = require('../../../helpers/expectEvent');
 const { ZERO_ADDRESS } = require('../../../helpers/constants');
 
@@ -42,7 +42,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) {
       const amount = initialBalance + 1;
 
       it('reverts', async function () {
-        await assertRevert(this.token.burn(amount, { from: owner }));
+        await shouldFail.reverting(this.token.burn(amount, { from: owner }));
       });
     });
   });
@@ -88,7 +88,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) {
       const amount = initialBalance + 1;
       it('reverts', async function () {
         await this.token.approve(burner, amount, { from: owner });
-        await assertRevert(this.token.burnFrom(owner, amount, { from: burner }));
+        await shouldFail.reverting(this.token.burnFrom(owner, amount, { from: burner }));
       });
     });
 
@@ -96,7 +96,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) {
       const amount = 100;
       it('reverts', async function () {
         await this.token.approve(burner, amount - 1, { from: owner });
-        await assertRevert(this.token.burnFrom(owner, amount, { from: burner }));
+        await shouldFail.reverting(this.token.burnFrom(owner, amount, { from: burner }));
       });
     });
   });

+ 3 - 3
test/token/ERC20/behaviors/ERC20Capped.behavior.js

@@ -1,4 +1,4 @@
-const { expectThrow } = require('../../../helpers/expectThrow');
+const shouldFail = require('../../../helpers/shouldFail');
 
 const BigNumber = web3.BigNumber;
 
@@ -21,12 +21,12 @@ function shouldBehaveLikeERC20Capped (minter, [anyone], cap) {
 
     it('should fail to mint if the ammount exceeds the cap', async function () {
       await this.token.mint(anyone, cap.sub(1), { from });
-      await expectThrow(this.token.mint(anyone, 100, { from }));
+      await shouldFail.reverting(this.token.mint(anyone, 100, { from }));
     });
 
     it('should fail to mint after cap is reached', async function () {
       await this.token.mint(anyone, cap, { from });
-      await expectThrow(this.token.mint(anyone, 1, { from }));
+      await shouldFail.reverting(this.token.mint(anyone, 1, { from }));
     });
   });
 }

+ 2 - 2
test/token/ERC20/behaviors/ERC20Mintable.behavior.js

@@ -1,4 +1,4 @@
-const { assertRevert } = require('../../../helpers/assertRevert');
+const shouldFail = require('../../../helpers/shouldFail');
 const expectEvent = require('../../../helpers/expectEvent');
 const { ZERO_ADDRESS } = require('../../../helpers/constants');
 
@@ -47,7 +47,7 @@ function shouldBehaveLikeERC20Mintable (minter, [anyone]) {
         const from = anyone;
 
         it('reverts', async function () {
-          await assertRevert(this.token.mint(anyone, amount, { from }));
+          await shouldFail.reverting(this.token.mint(anyone, amount, { from }));
         });
       });
     });

+ 22 - 16
test/token/ERC721/ERC721.behavior.js

@@ -1,6 +1,6 @@
 const expectEvent = require('../../helpers/expectEvent');
 const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
-const { assertRevert } = require('../../helpers/assertRevert');
+const shouldFail = require('../../helpers/shouldFail');
 const { ZERO_ADDRESS } = require('../../helpers/constants');
 const { decodeLogs } = require('../../helpers/decodeLogs');
 const { sendTransaction } = require('../../helpers/sendTransaction');
@@ -44,7 +44,7 @@ function shouldBehaveLikeERC721 (
 
       context('when querying the zero address', function () {
         it('throws', async function () {
-          await assertRevert(this.token.balanceOf(0));
+          await shouldFail.reverting(this.token.balanceOf(0));
         });
       });
     });
@@ -62,7 +62,7 @@ function shouldBehaveLikeERC721 (
         const tokenId = unknownTokenId;
 
         it('reverts', async function () {
-          await assertRevert(this.token.ownerOf(tokenId));
+          await shouldFail.reverting(this.token.ownerOf(tokenId));
         });
       });
     });
@@ -184,28 +184,28 @@ function shouldBehaveLikeERC721 (
 
         context('when the address of the previous owner is incorrect', function () {
           it('reverts', async function () {
-            await assertRevert(transferFunction.call(this, anyone, anyone, tokenId, { from: owner })
+            await shouldFail.reverting(transferFunction.call(this, anyone, anyone, tokenId, { from: owner })
             );
           });
         });
 
         context('when the sender is not authorized for the token id', function () {
           it('reverts', async function () {
-            await assertRevert(transferFunction.call(this, owner, anyone, tokenId, { from: anyone })
+            await shouldFail.reverting(transferFunction.call(this, owner, anyone, tokenId, { from: anyone })
             );
           });
         });
 
         context('when the given token ID does not exist', function () {
           it('reverts', async function () {
-            await assertRevert(transferFunction.call(this, owner, anyone, unknownTokenId, { from: owner })
+            await shouldFail.reverting(transferFunction.call(this, owner, anyone, unknownTokenId, { from: owner })
             );
           });
         });
 
         context('when the address to transfer the token to is the zero address', function () {
           it('reverts', async function () {
-            await assertRevert(transferFunction.call(this, owner, ZERO_ADDRESS, tokenId, { from: owner }));
+            await shouldFail.reverting(transferFunction.call(this, owner, ZERO_ADDRESS, tokenId, { from: owner }));
           });
         });
       };
@@ -274,7 +274,7 @@ function shouldBehaveLikeERC721 (
 
             describe('with an invalid token id', function () {
               it('reverts', async function () {
-                await assertRevert(
+                await shouldFail.reverting(
                   transferFun.call(
                     this,
                     owner,
@@ -299,21 +299,27 @@ function shouldBehaveLikeERC721 (
         describe('to a receiver contract returning unexpected value', function () {
           it('reverts', async function () {
             const invalidReceiver = await ERC721ReceiverMock.new('0x42', false);
-            await assertRevert(this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }));
+            await shouldFail.reverting(
+              this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner })
+            );
           });
         });
 
         describe('to a receiver contract that throws', function () {
           it('reverts', async function () {
             const invalidReceiver = await ERC721ReceiverMock.new(RECEIVER_MAGIC_VALUE, true);
-            await assertRevert(this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }));
+            await shouldFail.reverting(
+              this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner })
+            );
           });
         });
 
         describe('to a contract that does not implement the required function', function () {
           it('reverts', async function () {
             const invalidReceiver = this.token;
-            await assertRevert(this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }));
+            await shouldFail.reverting(
+              this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner })
+            );
           });
         });
       });
@@ -400,7 +406,7 @@ function shouldBehaveLikeERC721 (
 
       context('when the address that receives the approval is the owner', function () {
         it('reverts', async function () {
-          await assertRevert(
+          await shouldFail.reverting(
             this.token.approve(owner, tokenId, { from: owner })
           );
         });
@@ -408,14 +414,14 @@ function shouldBehaveLikeERC721 (
 
       context('when the sender does not own the given token ID', function () {
         it('reverts', async function () {
-          await assertRevert(this.token.approve(approved, tokenId, { from: anyone }));
+          await shouldFail.reverting(this.token.approve(approved, tokenId, { from: anyone }));
         });
       });
 
       context('when the sender is approved for the given token ID', function () {
         it('reverts', async function () {
           await this.token.approve(approved, tokenId, { from: owner });
-          await assertRevert(this.token.approve(anotherApproved, tokenId, { from: approved }));
+          await shouldFail.reverting(this.token.approve(anotherApproved, tokenId, { from: approved }));
         });
       });
 
@@ -431,7 +437,7 @@ function shouldBehaveLikeERC721 (
 
       context('when the given token ID does not exist', function () {
         it('reverts', async function () {
-          await assertRevert(this.token.approve(approved, unknownTokenId, { from: operator }));
+          await shouldFail.reverting(this.token.approve(approved, unknownTokenId, { from: operator }));
         });
       });
     });
@@ -509,7 +515,7 @@ function shouldBehaveLikeERC721 (
 
       context('when the operator is the owner', function () {
         it('reverts', async function () {
-          await assertRevert(this.token.setApprovalForAll(owner, true, { from: owner }));
+          await shouldFail.reverting(this.token.setApprovalForAll(owner, true, { from: owner }));
         });
       });
     });

+ 10 - 10
test/token/ERC721/ERC721Full.test.js

@@ -1,4 +1,4 @@
-const { assertRevert } = require('../../helpers/assertRevert');
+const shouldFail = require('../../helpers/shouldFail');
 const { shouldBehaveLikeERC721 } = require('./ERC721.behavior');
 const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
 
@@ -69,13 +69,13 @@ contract('ERC721Full', function ([
       it('burns all tokens', async function () {
         await this.token.burn(secondTokenId, { from: owner });
         (await this.token.totalSupply()).toNumber().should.be.equal(0);
-        await assertRevert(this.token.tokenByIndex(0));
+        await shouldFail.reverting(this.token.tokenByIndex(0));
       });
     });
 
     describe('removeTokenFrom', function () {
       it('reverts if the correct owner is not passed', async function () {
-        await assertRevert(
+        await shouldFail.reverting(
           this.token.removeTokenFrom(anyone, firstTokenId, { from: owner })
         );
       });
@@ -86,7 +86,7 @@ contract('ERC721Full', function ([
         });
 
         it('has been removed', async function () {
-          await assertRevert(this.token.tokenOfOwnerByIndex(owner, 1));
+          await shouldFail.reverting(this.token.tokenOfOwnerByIndex(owner, 1));
         });
 
         it('adjusts token list', async function () {
@@ -120,7 +120,7 @@ contract('ERC721Full', function ([
       });
 
       it('reverts when setting metadata for non existent token id', async function () {
-        await assertRevert(this.token.setTokenURI(nonExistentTokenId, sampleUri));
+        await shouldFail.reverting(this.token.setTokenURI(nonExistentTokenId, sampleUri));
       });
 
       it('can burn token with metadata', async function () {
@@ -134,7 +134,7 @@ contract('ERC721Full', function ([
       });
 
       it('reverts when querying metadata for non existent token id', async function () {
-        await assertRevert(this.token.tokenURI(nonExistentTokenId));
+        await shouldFail.reverting(this.token.tokenURI(nonExistentTokenId));
       });
     });
 
@@ -153,13 +153,13 @@ contract('ERC721Full', function ([
 
       describe('when the index is greater than or equal to the total tokens owned by the given address', function () {
         it('reverts', async function () {
-          await assertRevert(this.token.tokenOfOwnerByIndex(owner, 2));
+          await shouldFail.reverting(this.token.tokenOfOwnerByIndex(owner, 2));
         });
       });
 
       describe('when the given address does not own any token', function () {
         it('reverts', async function () {
-          await assertRevert(this.token.tokenOfOwnerByIndex(another, 0));
+          await shouldFail.reverting(this.token.tokenOfOwnerByIndex(another, 0));
         });
       });
 
@@ -179,7 +179,7 @@ contract('ERC721Full', function ([
 
         it('returns empty collection for original owner', async function () {
           (await this.token.balanceOf(owner)).toNumber().should.be.equal(0);
-          await assertRevert(this.token.tokenOfOwnerByIndex(owner, 0));
+          await shouldFail.reverting(this.token.tokenOfOwnerByIndex(owner, 0));
         });
       });
     });
@@ -193,7 +193,7 @@ contract('ERC721Full', function ([
       });
 
       it('should revert if index is greater than supply', async function () {
-        await assertRevert(this.token.tokenByIndex(2));
+        await shouldFail.reverting(this.token.tokenByIndex(2));
       });
 
       [firstTokenId, secondTokenId].forEach(function (tokenId) {

+ 6 - 6
test/token/ERC721/ERC721MintBurn.behavior.js

@@ -1,4 +1,4 @@
-const { assertRevert } = require('../../helpers/assertRevert');
+const shouldFail = require('../../helpers/shouldFail');
 const expectEvent = require('../../helpers/expectEvent');
 const { ZERO_ADDRESS } = require('../../helpers/constants');
 const BigNumber = web3.BigNumber;
@@ -52,13 +52,13 @@ function shouldBehaveLikeMintAndBurnERC721 (
 
       describe('when the given owner address is the zero address', function () {
         it('reverts', async function () {
-          await assertRevert(this.token.mint(ZERO_ADDRESS, thirdTokenId, { from: minter }));
+          await shouldFail.reverting(this.token.mint(ZERO_ADDRESS, thirdTokenId, { from: minter }));
         });
       });
 
       describe('when the given token ID was already tracked by this contract', function () {
         it('reverts', async function () {
-          await assertRevert(this.token.mint(owner, firstTokenId, { from: minter }));
+          await shouldFail.reverting(this.token.mint(owner, firstTokenId, { from: minter }));
         });
       });
     });
@@ -82,7 +82,7 @@ function shouldBehaveLikeMintAndBurnERC721 (
         });
 
         it('burns the given token ID and adjusts the balance of the owner', async function () {
-          await assertRevert(this.token.ownerOf(tokenId));
+          await shouldFail.reverting(this.token.ownerOf(tokenId));
           (await this.token.balanceOf(owner)).should.be.bignumber.equal(1);
         });
 
@@ -104,14 +104,14 @@ function shouldBehaveLikeMintAndBurnERC721 (
 
         context('getApproved', function () {
           it('reverts', async function () {
-            await assertRevert(this.token.getApproved(tokenId));
+            await shouldFail.reverting(this.token.getApproved(tokenId));
           });
         });
       });
 
       describe('when the given token ID was not tracked by this contract', function () {
         it('reverts', async function () {
-          await assertRevert(
+          await shouldFail.reverting(
             this.token.burn(unknownTokenId, { from: creator })
           );
         });

+ 6 - 6
test/token/ERC721/ERC721PausedToken.behavior.js

@@ -1,4 +1,4 @@
-const { assertRevert } = require('../../helpers/assertRevert');
+const shouldFail = require('../../helpers/shouldFail');
 const { sendTransaction } = require('../../helpers/sendTransaction');
 const { ZERO_ADDRESS } = require('../../helpers/constants');
 
@@ -19,23 +19,23 @@ function shouldBehaveLikeERC721PausedToken (owner, [recipient, operator]) {
     });
 
     it('reverts when trying to approve', async function () {
-      await assertRevert(this.token.approve(recipient, firstTokenId, { from: owner }));
+      await shouldFail.reverting(this.token.approve(recipient, firstTokenId, { from: owner }));
     });
 
     it('reverts when trying to setApprovalForAll', async function () {
-      await assertRevert(this.token.setApprovalForAll(operator, true, { from: owner }));
+      await shouldFail.reverting(this.token.setApprovalForAll(operator, true, { from: owner }));
     });
 
     it('reverts when trying to transferFrom', async function () {
-      await assertRevert(this.token.transferFrom(owner, recipient, firstTokenId, { from: owner }));
+      await shouldFail.reverting(this.token.transferFrom(owner, recipient, firstTokenId, { from: owner }));
     });
 
     it('reverts when trying to safeTransferFrom', async function () {
-      await assertRevert(this.token.safeTransferFrom(owner, recipient, firstTokenId, { from: owner }));
+      await shouldFail.reverting(this.token.safeTransferFrom(owner, recipient, firstTokenId, { from: owner }));
     });
 
     it('reverts when trying to safeTransferFrom with data', async function () {
-      await assertRevert(
+      await shouldFail.reverting(
         sendTransaction(
           this.token,
           'safeTransferFrom',

+ 4 - 4
test/utils/ReentrancyGuard.test.js

@@ -1,4 +1,4 @@
-const { expectThrow } = require('../helpers/expectThrow');
+const shouldFail = require('../helpers/shouldFail');
 const ReentrancyMock = artifacts.require('ReentrancyMock');
 const ReentrancyAttack = artifacts.require('ReentrancyAttack');
 
@@ -16,7 +16,7 @@ contract('ReentrancyGuard', function () {
 
   it('should not allow remote callback', async function () {
     const attacker = await ReentrancyAttack.new();
-    await expectThrow(this.reentrancyMock.countAndCall(attacker.address));
+    await shouldFail.reverting(this.reentrancyMock.countAndCall(attacker.address));
   });
 
   // The following are more side-effects than intended behavior:
@@ -24,10 +24,10 @@ contract('ReentrancyGuard', function () {
   // in the side-effects.
 
   it('should not allow local recursion', async function () {
-    await expectThrow(this.reentrancyMock.countLocalRecursive(10));
+    await shouldFail.reverting(this.reentrancyMock.countLocalRecursive(10));
   });
 
   it('should not allow indirect local recursion', async function () {
-    await expectThrow(this.reentrancyMock.countThisRecursive(10));
+    await shouldFail.reverting(this.reentrancyMock.countThisRecursive(10));
   });
 });