|
@@ -61,12 +61,12 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
|
|
});
|
|
});
|
|
|
|
|
|
it('should throw if no funds to claim', async function () {
|
|
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 () {
|
|
it('should throw if non-payee want to claim', async function () {
|
|
await ethSendTransaction({ from: payer1, to: this.contract.address, value: amount });
|
|
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 () {
|
|
it('should distribute funds to payees', async function () {
|
|
@@ -78,17 +78,17 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
|
|
|
|
|
|
// distribute to payees
|
|
// distribute to payees
|
|
const initAmount1 = await ethGetBalance(payee1);
|
|
const initAmount1 = await ethGetBalance(payee1);
|
|
- await this.contract.claim({ from: payee1 });
|
|
|
|
|
|
+ await this.contract.release(payee1);
|
|
const profit1 = (await ethGetBalance(payee1)).sub(initAmount1);
|
|
const profit1 = (await ethGetBalance(payee1)).sub(initAmount1);
|
|
profit1.sub(web3.toWei(0.20, 'ether')).abs().should.be.bignumber.lt(1e16);
|
|
profit1.sub(web3.toWei(0.20, 'ether')).abs().should.be.bignumber.lt(1e16);
|
|
|
|
|
|
const initAmount2 = await ethGetBalance(payee2);
|
|
const initAmount2 = await ethGetBalance(payee2);
|
|
- await this.contract.claim({ from: payee2 });
|
|
|
|
|
|
+ await this.contract.release(payee2);
|
|
const profit2 = (await ethGetBalance(payee2)).sub(initAmount2);
|
|
const profit2 = (await ethGetBalance(payee2)).sub(initAmount2);
|
|
profit2.sub(web3.toWei(0.10, 'ether')).abs().should.be.bignumber.lt(1e16);
|
|
profit2.sub(web3.toWei(0.10, 'ether')).abs().should.be.bignumber.lt(1e16);
|
|
|
|
|
|
const initAmount3 = await ethGetBalance(payee3);
|
|
const initAmount3 = await ethGetBalance(payee3);
|
|
- await this.contract.claim({ from: payee3 });
|
|
|
|
|
|
+ await this.contract.release(payee3);
|
|
const profit3 = (await ethGetBalance(payee3)).sub(initAmount3);
|
|
const profit3 = (await ethGetBalance(payee3)).sub(initAmount3);
|
|
profit3.sub(web3.toWei(0.70, 'ether')).abs().should.be.bignumber.lt(1e16);
|
|
profit3.sub(web3.toWei(0.70, 'ether')).abs().should.be.bignumber.lt(1e16);
|
|
|
|
|