balanceDifference tests and application (#1514)
* Added balanceDifference tests. * Added balanceDifference tests. * Now using balanceDifference in all (most) tests. * Fixed typo.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
const { ethGetBalance } = require('../helpers/web3');
|
||||
const { balanceDifference } = require('../helpers/balanceDifference');
|
||||
const { ether } = require('../helpers/ether');
|
||||
|
||||
const BigNumber = web3.BigNumber;
|
||||
@ -37,16 +37,13 @@ contract('PullPayment', function ([_, payer, payee1, payee2]) {
|
||||
});
|
||||
|
||||
it('can withdraw payment', async function () {
|
||||
const initialBalance = await ethGetBalance(payee1);
|
||||
(await balanceDifference(payee1, async () => {
|
||||
await this.contract.callTransfer(payee1, amount, { from: payer });
|
||||
(await this.contract.payments(payee1)).should.be.bignumber.equal(amount);
|
||||
|
||||
await this.contract.callTransfer(payee1, amount, { from: payer });
|
||||
await this.contract.withdrawPayments(payee1);
|
||||
})).should.be.bignumber.equal(amount);
|
||||
|
||||
(await this.contract.payments(payee1)).should.be.bignumber.equal(amount);
|
||||
|
||||
await this.contract.withdrawPayments(payee1);
|
||||
(await this.contract.payments(payee1)).should.be.bignumber.equal(0);
|
||||
|
||||
const balance = await ethGetBalance(payee1);
|
||||
Math.abs(balance - initialBalance - amount).should.be.lt(1e16);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user