Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save percybolmer/984d2e6773f339ef119b038fea9bc427 to your computer and use it in GitHub Desktop.
Save percybolmer/984d2e6773f339ef119b038fea9bc427 to your computer and use it in GitHub Desktop.
// Stake again on owner because we want hasStake test to assert summary
stakeID = await devToken.stake(stake_amount, { from: owner });
// 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, 1, "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