I have a token and crowdfund that works fine, except in tests. I can use all the methods, but I get invalid opcode on any of them that have a call to another contract that has a modifier on that function.

For instance, if I have ContractA, ContractB, and ContractC, and I call ContractA from addressA, and ContractA has a modifier to only accept calls from addressA, and all the functions on ContractA call out to ContractB and the functions on ContractB all have modifiers to only accept calls from ContractA.

This works great in practice, breaks when I run my tests. If I remove the modifiers, the tests run. Is this a known bug? I can confirm the modifiers all use msg.sender - perhaps testrpc isn't forwarding this correctly?

  • TestRPC forwards msg.sender correctly. Please include your deployment scripts as there may be sth wrong with the way you deploy your contracts to test network. Jul 17, 2017 at 20:18

1 Answer 1


OK, I finally debugged it. In my tests I was using Token.address syntax to get an address when I should have been using my tokenInstance.address variable that returns on Token.deployed(). Thanks!


Your Answer

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

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