-
Notifications
You must be signed in to change notification settings - Fork 11.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: bounty tests, superceeds #799 #1112
Conversation
assert.isFalse(reClaimedBounty); | ||
} | ||
try { | ||
await bounty.withdrawPayments({ from: researcher }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no idea what this was testing; the transaction actually goes through but obviously withdraws 0 wei. this is covered in pullpayment test, so I removed it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, thanks! The old test was a bit bizarre tbh.
I find the whole Bounty contract a bit confusing, and I'm not sure the mock contracts (SecureBountyTarget
and InsecureBountyTarget
) help in this regard. I wonder if a single mock, with a public function that 'broke' it (a la ConditionalEscrowMock) would be better suited for this test (requiring the researcher to 'break' the target before claiming the reward).
test/Bounty.test.js
Outdated
let reward = web3.toWei(1, 'ether'); | ||
let bounty = await SecureTargetBounty.new(); | ||
await sendReward(owner, bounty.address, reward); | ||
it('empties itself when destroyed', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we should be testing this: this is not Bounty
's code, but Destructible
's.
test/Bounty.test.js
Outdated
let reward = web3.toWei(1, 'ether'); | ||
let bounty = await SecureTargetBounty.new(); | ||
await sendReward(owner, bounty.address, reward); | ||
it('sets reward', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove this it
altogether, it's already being tested for in all other test cases (and if we were to add it, we should have it on both describe
s).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok to be explicit here. I've refactored the tests in the next commit to make this cleaner
test/Bounty.test.js
Outdated
const event = await expectEvent.inLogs( | ||
result.logs, | ||
'TargetCreated' | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, but why the newlines? The same line on the other it
doesn't have them.
test/Bounty.test.js
Outdated
balance.should.be.bignumber.eq(reward); | ||
|
||
await this.bounty.claim(targetAddress, { from: researcher }); | ||
const claim = await this.bounty.claimed.call(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you write .claimed()
?
test/Bounty.test.js
Outdated
|
||
await this.bounty.withdrawPayments({ from: researcher }); | ||
const updatedBalance = await ethGetBalance(this.bounty.address); | ||
updatedBalance.should.be.bignumber.eq(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also test:
a) that the researcher got the reward (curr - prev balances = reward)
b) that the bounty is no longer payable after claiming
replaces #799