Truffle: What's the recommended way to test a contract with constructor params?

Created on 15 May 2016  Â·  5Comments  Â·  Source: trufflesuite/truffle

I understand that truffle's deploy and test flow intentionally do not support contracts with parameters. It seems like this would still be double with a custom exec script. I am going to need be able to unit test the constructor for my contract since it is an important part of the dapp's overall functionality. Could you provide a basic example of how one might approach this, or give some suggestions for someone relatively new to Solidity/Truffle development? Thank you!

All 5 comments

Hey @raineorshine,

I apologize for not responding to this. The way I do it is to have the test set up a new version of the contract using MyContract.new(), passing constructor parameters, then I write tests against that contract using further transactions and calls. Let me know if you need a code example, and I can provide one.

Closing for housekeeping, but I hope I helped (even though my response was way late!). Thanks!

Okay, thank you!
On Fri, Jul 22, 2016 at 11:25 AM Tim Coulter [email protected]
wrote:

Closed #159 https://github.com/ConsenSys/truffle/issues/159.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ConsenSys/truffle/issues/159#event-732037575, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAtyxGZeI0GUv8JG5O2R2Co00oOyXCBOks5qYP0EgaJpZM4IevxJ
.

@tcoulter How can I send payment and gas to the constructor?

@tcoulter can you provide some code. Thanks in advance :)

Was this page helpful?
0 / 5 - 0 ratings