Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Test the things
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmurdoch authored and nicholasjpaterno committed Sep 26, 2019
1 parent e2016f5 commit 5b9f2f3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion test/contracts/gas/NonZero.sol
Expand Up @@ -4,7 +4,7 @@ contract Target {
}
contract NonZero {
Target private theInstance;
constructor() public{
constructor() public {
theInstance = new Target();
}
function doCall() external payable {
Expand Down
45 changes: 26 additions & 19 deletions test/gas/gas.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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`
);
}
});
});

Expand Down

0 comments on commit 5b9f2f3

Please sign in to comment.