I'm testing Open Zepplins crowdsale code: https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/test/CappedCrowdsale.test.js

After I compile and run truffle test it works fine, but then the second time I run truffle test (even without changing the code at all) I get this error:

Error: VM Exception while processing transaction: revert
at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:43303:16)

I can resolve the problem by shutting down testrpc and truffle migrate --reset again, but its pretty annoying to have to do that before each test.

Any idea how I can fix this? Thanks!

  • Have you done any modification to the test? Which test is failing? When testing with truffle each run should be independent of the previous, ie migrate should not affect running the tests. – Ismael Dec 19 '17 at 21:08

You should review the test you are running. The "problem" you are facing doesn't have to do with testrpc itself but with what the test you are running does.

One of the test cases invest the maximum allowed funds to reach the crowdsale's cap, meaning that after the test runs, the crowdsale will not be "usable" anymore.

Restarting testrpc erases the deployed contract and its data, so that's why doing that "solves" your problem.

If you want to "fix" that you would have to remove the test cases that alter the state of your deployed contract permanently, but you would be missing the point of running the automated tests.

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.