2

Given some contract A, that depends on another contract B, what would be the best way to unit test functions from A without inadvertently testing code from B.

Normally, we could use stubs to return data that is the same every time, but this is cumbersome to do manually with even a moderate amount of code (generate, compile, and deploy the stub).

Is there a framework or library out there yet that has this sort of functionality built in?

Also would be happy to provide a code example if the description above is too abstract; just comment.

I'm using:

  • mochajs with chai assertions
  • truffle for a testing framework
  • ethereumjs-testrpc for test network
0

You can create a stub contract. Deploying it in the test using truffle is not cumbersome. You can do it like so:

token1 = await Token.new()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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