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?

up vote 1 down vote accepted

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.

  • Thanks a lot! It works great now! – Emul Dec 6 at 10:44

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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