I have not been able to find any resources with usage instruction besides github and blog post by the author
On github an example is show as such:
truffleAssert.eventEmitted(result, 'TestEvent', (ev) => {
return ev.param1 === 10 && ev.param2 === ev.param3;
});
And on the blogpost the syntax is like this:
truffleAssert.eventEmitted(tx, 'Play', (ev) => {
return ev.player === bettingAccount && !ev.betNumber.eq(ev.winningNumber);
});
Both of these are rather similar.
This is the emit I am trying to test:
event Emittest(uint date, address indexed from, address indexed to, uint256 value);
My issues is that if I try to run the same format:
let emittest = await contract.function(accounts[1], 66500000,{from: accounts[0]});
truffleAssert.eventEmitted(emittest, 'Emittest', (ev) => {
return ev.value == set_value;
});
It fails with the error AssertionError: Event filter for Transfer returned no results
. I can extract the correct value by changing the code to:
truffleAssert.eventEmitted(emittest, 'Emittest', (ev) => {
return ev.value.words[0] == set_value;
});
As the tokens is of the following structure:
value ==== BN {
negative: 0,
words: [ 60475904, 14, <1 empty item> ],
length: 2,
red: null
}
Accessing .words[0]
doesn't seem like the correct way as it makes it much more difficult to check BigNumbers which are split across multiple indices of the array words:
without writing a helper function. Addresses extracted from the emit appear and can be accessed as expected.
Splitting between multiple words
happens much sooner than the 2^53 limit of javascript at around 66 million. I am new to javascript, and might be doing multiple things wrong. Thanks for help.