diff --git a/test/contracts/gas/NonZero.sol b/test/contracts/gas/NonZero.sol index 712b1632ec..4b44198538 100644 --- a/test/contracts/gas/NonZero.sol +++ b/test/contracts/gas/NonZero.sol @@ -4,7 +4,7 @@ contract Target { } contract NonZero { Target private theInstance; - constructor() public{ + constructor() public { theInstance = new Target(); } function doCall() external payable { diff --git a/test/gas/gas.js b/test/gas/gas.js index 6b38bc34fd..b8f2cc0b24 100644 --- a/test/gas/gas.js +++ b/test/gas/gas.js @@ -197,7 +197,7 @@ describe("Gas", function() { }); }); await Promise.all(promises); - }).timeout(3000); + }).timeout(5000); it("Should estimate gas perfectly with EIP150 - CREATE2", async() => { const { accounts, instance, web3 } = Create2; @@ -290,24 +290,31 @@ describe("Gas", function() { } it("should correctly handle non-zero value child messages", async() => { - const { accounts, instance, send } = NonZero; - const tx = { - gasPrice: "0x77359400", - value: "1000000000000000000", // 1 ether - from: accounts[0], - to: instance._address - }; - const { result: gasLimit } = await send("eth_estimateGas", tx); - tx.gasLimit = "0x" + (parseInt(gasLimit.substring(2), 16) - 1).toString(16); - await assert.rejects(() => send("eth_sendTransaction", tx), { - message: "VM Exception while processing transaction: out of gas" - }); - tx.gasLimit = gasLimit; - await assert.doesNotReject( - () => send("eth_sendTransaction", tx), - undefined, - `SANITY CHECK. Still not enough gas? ${gasLimit} Our estimate is still too low` - ); + const { + accounts: [from], + instance: { _address: to, methods }, + send + } = NonZero; + const fns = [methods.doSend, methods.doTransfer, methods.doCall]; + for (let i = 0, l = fns; i < l.length; i++) { + const tx = { + from, + to, + value: "1000000000000000000", + data: fns[i]().encodeABI() + }; + const { result: gasLimit } = await send("eth_estimateGas", tx); + tx.gasLimit = "0x" + (parseInt(gasLimit) - 1).toString(16); + await assert.rejects(() => send("eth_sendTransaction", tx), { + message: "VM Exception while processing transaction: out of gas" + }); + tx.gasLimit = gasLimit; + await assert.doesNotReject( + () => send("eth_sendTransaction", tx), + undefined, + `SANITY CHECK. Still not enough gas? ${gasLimit} Our estimate is still too low` + ); + } }); });