2

I just updated to Solidity 5 and Truffle Beta and am testing my contracts in JavaScript.

I am trying to test my constructor events and want to use as per truffle-assertions documentation :

truffle-assertions offers the possibility to create a transaction result object from a contract instance and a transaction hash, which can then be used in the other functions that the library offers.

let contractInstance = await Contract.new(); let result = await
truffleAssert.createTransactionResult(contractInstance,
contractInstance.transactionHash);

truffleAssert.eventEmitted(result, 'TestEvent');

When I run the following line of code but applied to my contract and then check the event it doesn't work anymore (but did fine with the previous version):

let result = await truffleAssert.createTransactionResult(contractInst, contractInst.transactionHash);
truffleAssert.eventEmitted(result, 'Started');

Here is the following error that is returned in the Terminal when I run truffle test:

AssertionError: Event of type ContractStarted was not emitted
    No events emitted in tx 0x8ed0e7489....

I console.log(result) and it does return a transaction hash. I'm not sure what I should do to get it to work and wonder if it might be due to truffle-assertions createTransactionResult not having been updated for the latest version? Or am I missing a line of code that I now need with the newer version?

1 Answer 1

3

Thank you for using my truffle-assertions library. Apparently this was caused by a bug in the function. I fixed the bug, and published a new version 0.7.1 to npm that you can use. Using this version should fix your issue.

If there are any remaining issues, please open an issue on the repository.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.