[Ethereum] Truffle solidity tests: out of gas & exceeds block gas limit

gasout-of-gastestingtruffle

I am trying to run some basic test w/ my contract, written with Truffle's Solidity tests (tests written in Solidity).

When runninng truffle test, I get

Error: VM Exception while processing transaction: out of gas

Note: This is caused by the contract constructor new ..., which is indeed doing a lot of things. And I can't break anything down in my code.

Is there any way to get this working with a test written in Solidity? Is there a way to configure the amount of gas the test contract has available?

UPDATE:

Actually I figured out changing the gas config value in truffle.js does have an effect. Yet, I am hitting now another roadblock

Error: Error: Exceeds block gas limit

I guess that I have no other choice than optimising the deployment (thus, the constructor) of my contract so as to make it lighter?

Best Answer

I ran into the same issue today - but for me the issue was, that my test-file.sol was seemingly too large. So I split up my tests into two files, and all the tests ran just fine again.

It probably makes sense anyways to structure test-files in multiple smaller suites than one big file that you'd have to scroll through.

Related Topic