balanceDifference tests and application (#1514)
* Added balanceDifference tests. * Added balanceDifference tests. * Now using balanceDifference in all (most) tests. * Fixed typo.pull/1526/head
parent
5471fc808a
commit
b9793abec6
@ -1,6 +1,6 @@ |
||||
async function balanceDifference (account, promise) { |
||||
async function balanceDifference (account, promiseFunc) { |
||||
const balanceBefore = web3.eth.getBalance(account); |
||||
await promise(); |
||||
await promiseFunc(); |
||||
const balanceAfter = web3.eth.getBalance(account); |
||||
return balanceAfter.minus(balanceBefore); |
||||
} |
@ -0,0 +1,22 @@ |
||||
const { balanceDifference } = require('../balanceDifference'); |
||||
const { sendEther } = require('../sendTransaction'); |
||||
const { ether } = require('../ether'); |
||||
|
||||
const BigNumber = web3.BigNumber; |
||||
require('chai') |
||||
.use(require('chai-bignumber')(BigNumber)) |
||||
.should(); |
||||
|
||||
contract('balanceDifference', function ([sender, receiver]) { |
||||
it('returns balance increments', async function () { |
||||
(await balanceDifference(receiver, () => |
||||
sendEther(sender, receiver, ether(1))) |
||||
).should.be.bignumber.equal(ether(1)); |
||||
}); |
||||
|
||||
it('returns balance decrements', async function () { |
||||
(await balanceDifference(sender, () => |
||||
sendEther(sender, receiver, ether(1))) |
||||
).should.be.bignumber.equal(ether(-1)); |
||||
}); |
||||
}); |
Loading…
Reference in new issue