* Added basic Escrow

* PullPayment now uses an Escrow, removing all trust from the contract

* Abstracted the Escrow tests to a behaviour

* Added ConditionalEscrow

* Added RefundableEscrow.

* RefundableCrowdsale now uses a RefundEscrow, removed RefundVault.

* Renaming after code review.

* Added log test helper.

* Now allowing empty deposits and withdrawals.

* Style fixes.

* Minor review comments.

* Add Deposited and Withdrawn events, removed Refunded

* The base Escrow is now Ownable, users of it (owners) must provide methods to access it.
This commit is contained in:
Nicolás Venturo
2018-07-03 18:54:55 -03:00
committed by Francisco Giordano
parent c2ad8c3f57
commit 8fd072cf8e
16 changed files with 490 additions and 207 deletions

View File

@ -0,0 +1,41 @@
import shouldBehaveLikeEscrow from './Escrow.behaviour';
import EVMRevert from '../helpers/EVMRevert';
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
const ConditionalEscrowMock = artifacts.require('ConditionalEscrowMock');
contract('ConditionalEscrow', function (accounts) {
const owner = accounts[0];
beforeEach(async function () {
this.escrow = await ConditionalEscrowMock.new({ from: owner });
});
context('when withdrawal is allowed', function () {
beforeEach(async function () {
await Promise.all(accounts.map(payee => this.escrow.setAllowed(payee, true)));
});
shouldBehaveLikeEscrow(owner, accounts.slice(1));
});
context('when withdrawal is disallowed', function () {
const amount = web3.toWei(23.0, 'ether');
const payee = accounts[1];
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 this.escrow.withdraw(payee, { from: owner }).should.be.rejectedWith(EVMRevert);
});
});
});