trufflesuite / truffle

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
14.02k stars 2.32k forks source link

eth_increaseTime breaks subsequent contract calls #2653

Open coventry opened 4 years ago

coventry commented 4 years ago

https://gitter.im/ConsenSys/truffle?at=5de5c3d91659720ca8eb0c4c


Issue

I'm seeing the failure reported here: https://ethereum.stackexchange.com/questions/15101/how-to-use-the-testrpc-evm-increasetime-parameter-from-truffle-console#comment89683_21515

Namely, if I use eth_increaseTime, then invoke a contract, I get Uncaught TypeError: callback is not a function.

There's a test case here: https://github.com/coventry/white_elephant/blob/failing-eth_increaseTime/test/white_elephant_test.js#L117

Remove line 117, and the test passes. Remove lines 115-116, and I get a proper revert from the contract. Only with the two lines together do I get the above error.

Steps to Reproduce

Clone the above white_elephant repo, install truffle, run truffle test. Fails with

Uncaught TypeError: callback is not a function

It's unclear which callback this error is referring to.

Expected Behavior

Revert on the contract transaction on line 117 of white_elephant_test.js.

Actual Results

See above.

Environment

$ truffle version
Truffle v5.0.21 (core: 5.0.21)
Solidity - 0.5.1 (solc-js)
Node v10.17.0
Web3.js v1.0.0-beta.37
CruzMolina commented 4 years ago

Having difficulty diagnosing this issue, although the error message definitely appears to happen when hitting the web3.currentProvider.send call on line 115.

Can't seem to find an older v5.0.x version of truffle that works with this test because of unpinned Web3 dependencies 😬.

CruzMolina commented 4 years ago

Okay, so AFAICT, web3.currentProvider.send expects a callback to be passed.

See Synthetix and JoinColony's use of web3.currentProvider in their test helpers :

It would be pretty useful to document this. We can likely also do some things on our end to enable not having to pass a callback.