Skip to content
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

Merged
merged 2 commits into from
Jul 26, 2018

Conversation

shrugs
Copy link
Contributor

@shrugs shrugs commented Jul 25, 2018

replaces #799

@shrugs shrugs requested a review from nventuro July 25, 2018 07:35
assert.isFalse(reClaimedBounty);
}
try {
await bounty.withdrawPayments({ from: researcher });
Copy link
Contributor Author

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

Copy link
Contributor

@nventuro nventuro left a 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).

let reward = web3.toWei(1, 'ether');
let bounty = await SecureTargetBounty.new();
await sendReward(owner, bounty.address, reward);
it('empties itself when destroyed', async function () {
Copy link
Contributor

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.

let reward = web3.toWei(1, 'ether');
let bounty = await SecureTargetBounty.new();
await sendReward(owner, bounty.address, reward);
it('sets reward', async function () {
Copy link
Contributor

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 describes).

Copy link
Contributor Author

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

const event = await expectEvent.inLogs(
result.logs,
'TargetCreated'
);
Copy link
Contributor

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.

balance.should.be.bignumber.eq(reward);

await this.bounty.claim(targetAddress, { from: researcher });
const claim = await this.bounty.claimed.call();
Copy link
Contributor

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()?


await this.bounty.withdrawPayments({ from: researcher });
const updatedBalance = await ethGetBalance(this.bounty.address);
updatedBalance.should.be.bignumber.eq(0);
Copy link
Contributor

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

@nventuro nventuro added bug kind:improvement tests Test suite and helpers. labels Jul 25, 2018
@nventuro nventuro added this to the v1.12.0 milestone Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug tests Test suite and helpers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants