Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save percybolmer/dbee8e94772f225a80d6e8fb6719570a to your computer and use it in GitHub Desktop.
Save percybolmer/dbee8e94772f225a80d6e8fb6719570a to your computer and use it in GitHub Desktop.
it("new stakeholder should have increased index", async () => {
let stake_amount = 100;
stakeID = await devToken.stake(stake_amount, { from: accounts[1] });
// Assert on the emittedevent using truffleassert
// This will capture the event and inside the event callback we can use assert on the values returned
truffleAssert.eventEmitted(
stakeID,
"Staked",
(ev) => {
// In here we can do our assertion on the ev variable (its the event and will contain the values we emitted)
assert.equal(ev.amount, stake_amount, "Stake amount in event was not correct");
assert.equal(ev.index, 2, "Stake index was not correct");
return true;
},
"Stake event should have triggered");
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment