question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`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:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
nbauernfeindcommented, Apr 25, 2018

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 than truffle migrate? I had tuned it up to handle the migration and must have been lucky. It seems on v4.1.6 it cost 5913212 gas and now on v4.1.7 it costs 6109322 to deploy the test contract.

0reactions
nbauernfeindcommented, Jun 20, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found