`truffle test` fails with 'out of gas' on all solidity tests
See original GitHub issue- I’ve asked for help in the Truffle Gitter before filing this issue.
Issue
Truffle v4.1.7 fails to run simple solidity test contract. Note that v4.1.6 works fine.
Steps to Reproduce
npm -g install truffle@4.1.7 Try to run test:
pragma solidity ^0.4.21;
import "truffle/Assert.sol";
contract Test {
function testRun() {
}
}
Expected Behavior
Test
✓ testRun (51ms)
1 passing (1s)
Actual Results
Test
1) "before all" hook: prepare suite
0 passing (989ms)
1 failing
1) Test "before all" hook: prepare suite:
Error: VM Exception while processing transaction: out of gas
at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)
at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:86:1
at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1
at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1)
at endReadableNT (_stream_readable.js:1101:12)
at process._tickCallback (internal/process/next_tick.js:114:19)
Environment
- Operating System: osx
- Ethereum client: n/a
- Truffle version (
truffle version
): 4.1.7 - node version (
node --version
): 9.9.0 - npm version (
npm --version
): 5.8.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Avoiding out of gas for Truffle tests - Solidity developer
We will talk about the actual case of running out of gas in Truffle tests. In most cases you will not care about...
Read more >Truffle solidity tests: out of gas & exceeds block gas limit
I am trying to run some basic test w/ my contract, written with Truffle's Solidity tests (tests written in Solidity). ... Note: This...
Read more >Truffle tests not working, recieving: VM Exception while ...
Try replacing this test: it("allows the user to buy a ticket and stores their details", async () => { await event.methods.
Read more >Test your contracts - Truffle Suite
You can obtain Solidity stack traces for failed transactions with truffle test --stacktrace . This will produce stack traces for transactions and deployments ......
Read more >Testing for Throws in Truffle Solidity Tests
Because a throw essentially uses up all gas, one must make doubly sure they catch the throw and not a legitimate out-of-gas (OOG)...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ahh… actually I see what’s going on. Turns out that simple test contract is getting more and more expensive. Does
truffle test
use a different default gas limit thantruffle migrate
? I had tuned it up to handle the migration and must have been lucky. It seems on v4.1.6 it cost5913212
gas and now on v4.1.7 it costs6109322
to deploy the test contract.I no longer work at that company and don’t have an environment setup to further investigate. If I recall correctly, I used a value higher than 6.7M – but at first I was trying to keep it high enough but not super close to the block limit. Things greatly improved when I turned on compiler optimizations… Sorry I’m not super interested anymore and can’t quite help you further.