(Deploy contracts)
evm_snapshot
(Pass first half of test A)
evm_increaseTime
(Pass second half of test A)
evm_revert
(Pass test B)
(Deploy contracts)
evm_snapshot
(Pass first half of test A)
evm_increaseTime
(Pass second half of test A)
evm_revert
(Fail test B)
Cause: evm_revert did not reset the time adjustment. Test B is now run in a different time than when the snapshot was taken, and fails.
increateTime.I'm trying to make my unit tests run faster by re-using setup transactions using snapshots.
Linux 4.10.0-33-generic #37-Ubuntu SMP x86_64 GNU/LinuxI am having same problem , How do i resolve it .
Environment
ubuntu 16.04.LTS
testrpc v4.0.1
truffle v3.4.5
You may wish to take a look at the pull request I created here. The fix is quite simple but I'm not sure it's the best way to do it. You can try that out in the meantime though.
@scnale How does one go about building testrpc using your fix, exactly? Thanks!
I haven't been using it in the last few weeks so the setup may need a few tweaks but here's what I did to test it:
devDependencies in the package.json(*) and replace the ganache-core version number with the path to the working tree of the ganache-core copy prepared in the previous step.node <path to testrpc working tree>/cli.js [list of testrpc arguments that you want to use].(*) I _think_ there is a cleaner way to do this with npm link. It should be able to create a symbolic link in the node_modules subfolder to whichever path you choose. But I haven't really tested that out because I didn't know about npm link at the time. You could also try manually creating the symbolic link you need if you prefer.
Creating a symbolic link or alias in your terminal to launch the custom testrpc may be a good idea if you're planning on using it frequently.
Edit: Satisfying the other dependencies in both packages is necessary for this to work and prone to errors in my limited experience using npm. Use whatever means you deem adequate to satisfy them.
Thanks, @scnale - got it 'working'. some dependencies failed to install, but it still works and all test cases work now. Cheers!
patch file
patch node_modules/ethereumjs-testrpc/build/cli.node.js testrpc-time.patch
83416c83416,83417
< blockNumber: blockNumber
---
> blockNumber: blockNumber,
> timeAdjustment: self.blockchain.timeAdjustment
83438a83440
> var timeAdjustment = this.snapshots[snapshot_id].timeAdjustment;
83465a83468,83469
> // The time adjustment is restored to its prior state
> self.blockchain.timeAdjustment = timeAdjustment;
status? will it be in soon?
There's an open PR on this trufflesuite/ganache-core#2. Last I knew the changes @scnale submitted there had problems that needed fixing (see this comment). I'll double check, but I don't think that's been done yet. If someone wants to submit another PR that finishes the work, I'd be all for it.
@scnale seems to have ghosted, and the changes he submitted were incomplete. If anyone else wants to take this on, I'd be much obliged.
Funny, just looking for a solution to this issue as well :)
Anyone knows a workaround?
Just made a very simple PR that helped me solve the problem for certains tests ; https://github.com/trufflesuite/ganache-core/pull/95
In addition, the PR mentioned above works as expected (see comment #377928638).
Fixed in current develop - thanks for following up on this, @PhABC!
I'm also running into this issue. Which version of ganach-cli has the fix?
Most helpful comment
You may wish to take a look at the pull request I created here. The fix is quite simple but I'm not sure it's the best way to do it. You can try that out in the meantime though.