Fix/#1355 test helper to check balance difference (#1368)
* signing prefix added
* Minor improvement
* Tests changed
* Successfully tested
* Minor improvements
* Minor improvements
* Revert "Dangling commas are now required. (#1359)"
This reverts commit a6889776f4.
* fixex #1355
* linting
* suggested changes
* Update BreakInvariantBounty.test.js
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
const { ethGetBalance, ethSendTransaction } = require('./helpers/web3');
|
const { ethGetBalance, ethSendTransaction } = require('./helpers/web3');
|
||||||
const { sendEther } = require('./helpers/sendTransaction');
|
const { sendEther } = require('./helpers/sendTransaction');
|
||||||
|
const { balanceDifference } = require('./helpers/balanceDiff');
|
||||||
const expectEvent = require('./helpers/expectEvent');
|
const expectEvent = require('./helpers/expectEvent');
|
||||||
const { assertRevert } = require('./helpers/assertRevert');
|
const { assertRevert } = require('./helpers/assertRevert');
|
||||||
|
|
||||||
@ -72,12 +73,8 @@ contract('BreakInvariantBounty', function ([_, owner, researcher, anyone, nonTar
|
|||||||
|
|
||||||
it('sends the reward to the researcher', async function () {
|
it('sends the reward to the researcher', async function () {
|
||||||
await this.bounty.claim(this.target.address, { from: anyone });
|
await this.bounty.claim(this.target.address, { from: anyone });
|
||||||
|
(await balanceDifference(researcher, () => this.bounty.withdrawPayments(researcher)))
|
||||||
const researcherPreBalance = await ethGetBalance(researcher);
|
.should.be.bignumber.equal(reward);
|
||||||
await this.bounty.withdrawPayments(researcher);
|
|
||||||
const researcherPostBalance = await ethGetBalance(researcher);
|
|
||||||
|
|
||||||
researcherPostBalance.sub(researcherPreBalance).should.be.bignumber.equal(reward);
|
|
||||||
(await ethGetBalance(this.bounty.address)).should.be.bignumber.equal(0);
|
(await ethGetBalance(this.bounty.address)).should.be.bignumber.equal(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
10
test/helpers/balanceDiff.js
Normal file
10
test/helpers/balanceDiff.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
async function balanceDifference (account, promise) {
|
||||||
|
const balanceBefore = web3.eth.getBalance(account);
|
||||||
|
await promise();
|
||||||
|
const balanceAfter = web3.eth.getBalance(account);
|
||||||
|
return balanceAfter.minus(balanceBefore);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
balanceDifference,
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user