Moved Escrows into an escrow subdirectory, improved docs. (#1430)

* Moved Escrows into an escrow subdirectory, improved docs.

* Fixed escrow mock.

* Fixed some more imports.
This commit is contained in:
Nicolás Venturo
2018-10-17 17:22:25 -03:00
committed by GitHub
parent cfef58361f
commit f3df2dab3d
10 changed files with 35 additions and 24 deletions

View File

@ -0,0 +1,40 @@
const { shouldBehaveLikeEscrow } = require('./Escrow.behavior');
const shouldFail = require('../../helpers/shouldFail');
const { ether } = require('../../helpers/ether');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
const ConditionalEscrowMock = artifacts.require('ConditionalEscrowMock');
contract('ConditionalEscrow', function ([_, owner, payee, ...otherAccounts]) {
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.0);
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 shouldFail.reverting(this.escrow.withdraw(payee, { from: owner }));
});
});
});