Use Prettier for JS files (#3913)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
@ -4,7 +4,7 @@ const { shouldBehaveLikeEscrow } = require('./Escrow.behavior');
|
||||
const ConditionalEscrowMock = artifacts.require('ConditionalEscrowMock');
|
||||
|
||||
contract('ConditionalEscrow', function (accounts) {
|
||||
const [ owner, payee, ...otherAccounts ] = accounts;
|
||||
const [owner, payee, ...otherAccounts] = accounts;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.escrow = await ConditionalEscrowMock.new({ from: owner });
|
||||
@ -28,7 +28,8 @@ contract('ConditionalEscrow', function (accounts) {
|
||||
it('reverts on withdrawals', async function () {
|
||||
await this.escrow.deposit(payee, { from: owner, value: amount });
|
||||
|
||||
await expectRevert(this.escrow.withdraw(payee, { from: owner }),
|
||||
await expectRevert(
|
||||
this.escrow.withdraw(payee, { from: owner }),
|
||||
'ConditionalEscrow: payee is not allowed to withdraw',
|
||||
);
|
||||
});
|
||||
|
||||
@ -2,7 +2,7 @@ const { balance, ether, expectEvent, expectRevert } = require('@openzeppelin/tes
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
|
||||
function shouldBehaveLikeEscrow(owner, [payee1, payee2]) {
|
||||
const amount = ether('42');
|
||||
|
||||
describe('as an escrow', function () {
|
||||
@ -20,9 +20,7 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
|
||||
});
|
||||
|
||||
it('only the owner can deposit', async function () {
|
||||
await expectRevert(this.escrow.deposit(payee1, { from: payee2 }),
|
||||
'Ownable: caller is not the owner',
|
||||
);
|
||||
await expectRevert(this.escrow.deposit(payee1, { from: payee2 }), 'Ownable: caller is not the owner');
|
||||
});
|
||||
|
||||
it('emits a deposited event', async function () {
|
||||
@ -72,9 +70,7 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
|
||||
});
|
||||
|
||||
it('only the owner can withdraw', async function () {
|
||||
await expectRevert(this.escrow.withdraw(payee1, { from: payee1 }),
|
||||
'Ownable: caller is not the owner',
|
||||
);
|
||||
await expectRevert(this.escrow.withdraw(payee1, { from: payee1 }), 'Ownable: caller is not the owner');
|
||||
});
|
||||
|
||||
it('emits a withdrawn event', async function () {
|
||||
|
||||
@ -4,7 +4,7 @@ const { shouldBehaveLikeEscrow } = require('./Escrow.behavior');
|
||||
const Escrow = artifacts.require('Escrow');
|
||||
|
||||
contract('Escrow', function (accounts) {
|
||||
const [ owner, ...otherAccounts ] = accounts;
|
||||
const [owner, ...otherAccounts] = accounts;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.escrow = await Escrow.new({ from: owner });
|
||||
|
||||
@ -6,14 +6,15 @@ const { expect } = require('chai');
|
||||
const RefundEscrow = artifacts.require('RefundEscrow');
|
||||
|
||||
contract('RefundEscrow', function (accounts) {
|
||||
const [ owner, beneficiary, refundee1, refundee2 ] = accounts;
|
||||
const [owner, beneficiary, refundee1, refundee2] = accounts;
|
||||
|
||||
const amount = ether('54');
|
||||
const refundees = [refundee1, refundee2];
|
||||
|
||||
it('requires a non-null beneficiary', async function () {
|
||||
await expectRevert(
|
||||
RefundEscrow.new(ZERO_ADDRESS, { from: owner }), 'RefundEscrow: beneficiary is the zero address',
|
||||
RefundEscrow.new(ZERO_ADDRESS, { from: owner }),
|
||||
'RefundEscrow: beneficiary is the zero address',
|
||||
);
|
||||
});
|
||||
|
||||
@ -36,23 +37,20 @@ contract('RefundEscrow', function (accounts) {
|
||||
|
||||
it('does not refund refundees', async function () {
|
||||
await this.escrow.deposit(refundee1, { from: owner, value: amount });
|
||||
await expectRevert(this.escrow.withdraw(refundee1),
|
||||
'ConditionalEscrow: payee is not allowed to withdraw',
|
||||
);
|
||||
await expectRevert(this.escrow.withdraw(refundee1), 'ConditionalEscrow: payee is not allowed to withdraw');
|
||||
});
|
||||
|
||||
it('does not allow beneficiary withdrawal', async function () {
|
||||
await this.escrow.deposit(refundee1, { from: owner, value: amount });
|
||||
await expectRevert(this.escrow.beneficiaryWithdraw(),
|
||||
await expectRevert(
|
||||
this.escrow.beneficiaryWithdraw(),
|
||||
'RefundEscrow: beneficiary can only withdraw while closed',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('only the owner can enter closed state', async function () {
|
||||
await expectRevert(this.escrow.close({ from: beneficiary }),
|
||||
'Ownable: caller is not the owner',
|
||||
);
|
||||
await expectRevert(this.escrow.close({ from: beneficiary }), 'Ownable: caller is not the owner');
|
||||
|
||||
const receipt = await this.escrow.close({ from: owner });
|
||||
expectEvent(receipt, 'RefundsClosed');
|
||||
@ -66,15 +64,14 @@ contract('RefundEscrow', function (accounts) {
|
||||
});
|
||||
|
||||
it('rejects deposits', async function () {
|
||||
await expectRevert(this.escrow.deposit(refundee1, { from: owner, value: amount }),
|
||||
await expectRevert(
|
||||
this.escrow.deposit(refundee1, { from: owner, value: amount }),
|
||||
'RefundEscrow: can only deposit while active',
|
||||
);
|
||||
});
|
||||
|
||||
it('does not refund refundees', async function () {
|
||||
await expectRevert(this.escrow.withdraw(refundee1),
|
||||
'ConditionalEscrow: payee is not allowed to withdraw',
|
||||
);
|
||||
await expectRevert(this.escrow.withdraw(refundee1), 'ConditionalEscrow: payee is not allowed to withdraw');
|
||||
});
|
||||
|
||||
it('allows beneficiary withdrawal', async function () {
|
||||
@ -84,22 +81,19 @@ contract('RefundEscrow', function (accounts) {
|
||||
});
|
||||
|
||||
it('prevents entering the refund state', async function () {
|
||||
await expectRevert(this.escrow.enableRefunds({ from: owner }),
|
||||
await expectRevert(
|
||||
this.escrow.enableRefunds({ from: owner }),
|
||||
'RefundEscrow: can only enable refunds while active',
|
||||
);
|
||||
});
|
||||
|
||||
it('prevents re-entering the closed state', async function () {
|
||||
await expectRevert(this.escrow.close({ from: owner }),
|
||||
'RefundEscrow: can only close while active',
|
||||
);
|
||||
await expectRevert(this.escrow.close({ from: owner }), 'RefundEscrow: can only close while active');
|
||||
});
|
||||
});
|
||||
|
||||
it('only the owner can enter refund state', async function () {
|
||||
await expectRevert(this.escrow.enableRefunds({ from: beneficiary }),
|
||||
'Ownable: caller is not the owner',
|
||||
);
|
||||
await expectRevert(this.escrow.enableRefunds({ from: beneficiary }), 'Ownable: caller is not the owner');
|
||||
|
||||
const receipt = await this.escrow.enableRefunds({ from: owner });
|
||||
expectEvent(receipt, 'RefundsEnabled');
|
||||
@ -113,7 +107,8 @@ contract('RefundEscrow', function (accounts) {
|
||||
});
|
||||
|
||||
it('rejects deposits', async function () {
|
||||
await expectRevert(this.escrow.deposit(refundee1, { from: owner, value: amount }),
|
||||
await expectRevert(
|
||||
this.escrow.deposit(refundee1, { from: owner, value: amount }),
|
||||
'RefundEscrow: can only deposit while active',
|
||||
);
|
||||
});
|
||||
@ -127,19 +122,19 @@ contract('RefundEscrow', function (accounts) {
|
||||
});
|
||||
|
||||
it('does not allow beneficiary withdrawal', async function () {
|
||||
await expectRevert(this.escrow.beneficiaryWithdraw(),
|
||||
await expectRevert(
|
||||
this.escrow.beneficiaryWithdraw(),
|
||||
'RefundEscrow: beneficiary can only withdraw while closed',
|
||||
);
|
||||
});
|
||||
|
||||
it('prevents entering the closed state', async function () {
|
||||
await expectRevert(this.escrow.close({ from: owner }),
|
||||
'RefundEscrow: can only close while active',
|
||||
);
|
||||
await expectRevert(this.escrow.close({ from: owner }), 'RefundEscrow: can only close while active');
|
||||
});
|
||||
|
||||
it('prevents re-entering the refund state', async function () {
|
||||
await expectRevert(this.escrow.enableRefunds({ from: owner }),
|
||||
await expectRevert(
|
||||
this.escrow.enableRefunds({ from: owner }),
|
||||
'RefundEscrow: can only enable refunds while active',
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user