truffle-assertions
truffle-assertions copied to clipboard
Support numeric event parameter
Numeric event parameters (e.g. uint256 in solidity) are represented as bn.js instances. It looks like currently it is not possible to check these numbers, as the equality check is not aware of BN and thus fails.
Ideally i would be able to create a filter Object with BN instances. Assume a transaction emits the event "idEvent" with the parameter "id" being an uint256
, i would like to do:
truffleAssert.eventEmitted(result, 'IdEvent', {
id: new BN('1')
})
Describe alternatives you've considered Another option would be to check the string representation of a BN instance, so one could write the filter like this:
truffleAssert.eventEmitted(result, 'IdEvent', {
id: '1'
})
(This is what web3.eth.abi.decodeLog
does - any BN instance is decoded to it's string representation)
Thanks @TripleSpeeder! This should definitely be supported if it currently isn't. I will look into it.
This seems to be an available feature now. I'm currently able to create a filter to check for the parameter value
of type uint256
using this:
truffleAssert.eventEmitted(tx, 'IdEvent', { id: web3.utils.toBN(10000) });
I'm not sure if this was recently added and this issue was never closed, or if this always existed.