* Sketch * Migrate all tests to test-env * Finish migration to test-env * Add config * Work on GSN tests * Migrate to newer test-env version and loader syntax * Add GSN setup * Finish test-env migration * Setup coverage using test-env * Migrate to npm package * Fix package.json * Add compile step to CI * Add comment on coverage setup * Remove dependency on @truffle/contract * Fix package-lock merge * Fix linter errors * Upgrade test-environment, depend locally on ganche-coverage * Improve coverage script * Improve sign.js API * Move accounts destructuring to describe block * Switch to prebuilt ethereumjs-vm package * Upgrade test-enviroment version * use workspace in circleci config * remove unnecessary npx
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
const { accounts, contract } = require('@openzeppelin/test-environment');
|
|
|
|
const { ether, expectRevert } = require('@openzeppelin/test-helpers');
|
|
const { shouldBehaveLikeEscrow } = require('./Escrow.behavior');
|
|
|
|
const ConditionalEscrowMock = contract.fromArtifact('ConditionalEscrowMock');
|
|
|
|
describe('ConditionalEscrow', function () {
|
|
const [ owner, payee, ...otherAccounts ] = accounts;
|
|
|
|
beforeEach(async function () {
|
|
this.escrow = await ConditionalEscrowMock.new({ from: owner });
|
|
});
|
|
|
|
context('when withdrawal is allowed', function () {
|
|
beforeEach(async function () {
|
|
await Promise.all(otherAccounts.map(payee => this.escrow.setAllowed(payee, true)));
|
|
});
|
|
|
|
shouldBehaveLikeEscrow(owner, otherAccounts);
|
|
});
|
|
|
|
context('when withdrawal is disallowed', function () {
|
|
const amount = ether('23');
|
|
|
|
beforeEach(async function () {
|
|
await this.escrow.setAllowed(payee, false);
|
|
});
|
|
|
|
it('reverts on withdrawals', async function () {
|
|
await this.escrow.deposit(payee, { from: owner, value: amount });
|
|
|
|
await expectRevert(this.escrow.withdraw(payee, { from: owner }),
|
|
'ConditionalEscrow: payee is not allowed to withdraw'
|
|
);
|
|
});
|
|
});
|
|
});
|