Use Prettier for JS files (#3913)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Francisco
2023-01-04 11:03:40 -03:00
committed by GitHub
parent 88754d0b36
commit a28aafdc85
135 changed files with 2737 additions and 3121 deletions

View File

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