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:
Nicolás Venturo
2018-11-26 15:41:39 -03:00
committed by GitHub
parent 5471fc808a
commit b9793abec6
10 changed files with 73 additions and 70 deletions

View File

@ -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);
});
});