Allow non-beneficiaries to trigger release of their funds (#1275)
* add address argument to PullPayments#withdrawPayments * add argument to SplitPayment#claim * add address argument to PostDeliveryCrowdsale#withdrawTokens * add address argument to RefundableCrowdsale#claimRefund * rename SplitPayment#claim to SplitPayment#release
This commit is contained in:
committed by
GitHub
parent
2aa5dd26be
commit
4eb4d7114d
@ -61,12 +61,12 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
|
||||
});
|
||||
|
||||
it('should throw if no funds to claim', async function () {
|
||||
await expectThrow(this.contract.claim({ from: payee1 }), EVMRevert);
|
||||
await expectThrow(this.contract.release(payee1), EVMRevert);
|
||||
});
|
||||
|
||||
it('should throw if non-payee want to claim', async function () {
|
||||
await ethSendTransaction({ from: payer1, to: this.contract.address, value: amount });
|
||||
await expectThrow(this.contract.claim({ from: nonpayee1 }), EVMRevert);
|
||||
await expectThrow(this.contract.release(nonpayee1), EVMRevert);
|
||||
});
|
||||
|
||||
it('should distribute funds to payees', async function () {
|
||||
@ -78,17 +78,17 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
|
||||
|
||||
// distribute to payees
|
||||
const initAmount1 = await ethGetBalance(payee1);
|
||||
await this.contract.claim({ from: payee1 });
|
||||
await this.contract.release(payee1);
|
||||
const profit1 = (await ethGetBalance(payee1)).sub(initAmount1);
|
||||
profit1.sub(web3.toWei(0.20, 'ether')).abs().should.be.bignumber.lt(1e16);
|
||||
|
||||
const initAmount2 = await ethGetBalance(payee2);
|
||||
await this.contract.claim({ from: payee2 });
|
||||
await this.contract.release(payee2);
|
||||
const profit2 = (await ethGetBalance(payee2)).sub(initAmount2);
|
||||
profit2.sub(web3.toWei(0.10, 'ether')).abs().should.be.bignumber.lt(1e16);
|
||||
|
||||
const initAmount3 = await ethGetBalance(payee3);
|
||||
await this.contract.claim({ from: payee3 });
|
||||
await this.contract.release(payee3);
|
||||
const profit3 = (await ethGetBalance(payee3)).sub(initAmount3);
|
||||
profit3.sub(web3.toWei(0.70, 'ether')).abs().should.be.bignumber.lt(1e16);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user