Writing unit tests for the Truffle test platform and running them on Ganache CLI, when
1) an EVM snapshot is created (via evm_snapshot),
2) the EVM state changed,
3) the EVM snapshot reverted back (via evm_revert),
4) a new EVM snapshot created (via evm_snapshot),
5) the EVM state changed again
the EVM ends up in a state which contains information from the first (changed and then reverted) state.
After reverting to an snapshot, the EVM should contain no state changes that were made after the snapshot.
Ganache CLI behaves different from Truffle's builtin test net (an older version of Ganache?)
Check out my Truffle test project, navigate into the repo, install dependencies
git clone https://github.com/outofgas/ganache-snapshot-issue
cd ganache-snapshot-issue
npm install
Run the Truffle test suite on Truffle's internal test net
node_modules/.bin/truffle test
The tests should be successful.
Open a second terminal and navigate to the repo dir and start a Ganache CLI instance
node_modules/.bin/ganache-cli
Run the Truffle test suite on Ganache's test net
node_modules/.bin/truffle test --network ganache
The tests fail. Somehow, the EVM state changes are not completely rolled back when reverting to a snapshot. Interestingly, the spurious state values become visible only after(!) the first transaction carried out after the new snapshot.
uname -srm
FreeBSD 11.2-RELEASE amd64
node --version
v11.1.0
npm --version
6.4.1
truffle version
Truffle v4.1.14 (core: 4.1.14)
Solidity v0.4.24 (solc-js)
ganache-cli --version
Ganache CLI v6.2.3 (ganache-core: 2.3.1)
We are facing the same issue
https://github.com/PolymathNetwork/polymath-core/issues/417
Another slightly relevant issue https://github.com/trufflesuite/ganache-cli/issues/597
This issue is caused by the same bug that is causing https://github.com/trufflesuite/ganache-cli/issues/600
@maxsam4 Thanks for linking issue #593.
@outofgas, @maxsam4 Can you try the latest ganache-cli@beta (v6.2.4-beta.1) and let us know if you're still experiencing this issue during your unit tests?
@nicholasjpaterno I just ran our suite of tests on ganache-cli v6.2.4-beta.1 and everything went smoothly. Thanks for the fix!
Fixed in [email protected].
Seems to be fixed in 6.2.4. Thanks a lot...
Most helpful comment
Seems to be fixed in 6.2.4. Thanks a lot...