Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

Support numeric event parameter #34

Closed
TripleSpeeder opened this issue Jan 29, 2020 · 3 comments
Closed

Support numeric event parameter #34

TripleSpeeder opened this issue Jan 29, 2020 · 3 comments

Comments

@TripleSpeeder
Copy link

TripleSpeeder commented Jan 29, 2020

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)

@rkalis
Copy link
Owner

rkalis commented Jan 29, 2020

Thanks @TripleSpeeder! This should definitely be supported if it currently isn't. I will look into it.

@dpurhar27
Copy link

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.

@rkalis
Copy link
Owner

rkalis commented Oct 26, 2023

Since Truffle is being sunset, I don't plan to add new features, so I'm closing this issue.

@rkalis rkalis closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants