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:
committed by
Leo Arias
parent
620d524398
commit
7cd0d5a452
@ -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 }));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user