You have probably seen this error message a lot of times:

Error: VM Exception while processing transaction: out of gas

Truffle can surface confusing errors, especially in older versions. But when a transaction really runs out of gas, changing its gas price will not fix it: the gas limit controls the available execution work, while the gas price controls the fee per unit.

For an actual out-of-gas failure, inspect the execution, estimate the required gas and check the transaction and block limits. A function that grows without bound may need redesign rather than a larger limit.

There is a separate test convenience: on a local network configured to accept zero fees, gasPrice: 0 simplifies ETH-balance assertions. It does not make execution unlimited, and a network with a positive base fee will reject a zero-price transaction. In a compatible legacy Truffle setup, the defaults look like this:

javascript
MyContract.defaults({
    gasPrice: 0,
})

With zero fees accepted by your local test chain, ETH-balance assertions no longer need a transaction-fee adjustment. For realistic fee tests, use the receipt’s gas usage and effective gas price instead.

Keep testing gas limits

Even unit tests benefit from checking that important operations remain within realistic gas limits. A passing balance assertion does not prove that an operation is affordable or can execute on your target network.

Truffle and Ganache were sunset in 2023; preserve the snippet for legacy projects and use a maintained environment for new work.