Skip to content

Commit

Permalink
test: contract availability after deployment (#1572)
Browse files Browse the repository at this point in the history
  • Loading branch information
carneiro-cw authored Jul 30, 2024
1 parent 3cdfd39 commit fb66633
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion e2e/test/automine/e2e-json-rpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ describe("JSON-RPC", () => {
(await sendExpect("eth_getBalance", [ALICE])).eq(TEST_BALANCE);
(await sendExpect("eth_getBalance", [ALICE, "latest"])).eq(TEST_BALANCE);
});
it("eth_getCode", () => {
describe("eth_getCode", () => {
it("contract code is available in the block it was deployed", async () => {
await sendReset();
const contract = await deployTestContractBalances();
(await sendExpect("eth_getCode", [contract.target, "latest"])).not.eq("0x");
(await sendExpect("eth_getCode", [contract.target, "0x1"])).not.eq("0x");
});
it("code for non-existent contract is 0x", async () => {
(await sendExpect("eth_getCode", [ALICE.address, "latest"])).eq("0x");
});
Expand All @@ -91,6 +97,7 @@ describe("JSON-RPC", () => {

describe("Block", () => {
it("eth_blockNumber", async function () {
await sendReset();
(await sendExpect("eth_blockNumber")).eq(ZERO);
await sendEvmMine();
(await sendExpect("eth_blockNumber")).eq(ONE);
Expand Down
12 changes: 11 additions & 1 deletion e2e/test/external/e2e-json-rpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,16 @@ describe("JSON-RPC", () => {
(await sendExpect("eth_getBalance", [ALICE])).eq(TEST_BALANCE);
(await sendExpect("eth_getBalance", [ALICE, "latest"])).eq(TEST_BALANCE);
});
it("eth_getCode", () => {

describe("eth_getCode", () => {
it("contract code is available in the block it was deployed", async () => {
await sendReset();
const contract = await deployTestContractBalances();
await sendEvmMine();
(await sendExpect("eth_getCode", [contract.target, "latest"])).not.eq("0x");
(await sendExpect("eth_getCode", [contract.target, "0x1"])).not.eq("0x");
});

it("code for non-existent contract is 0x", async () => {
(await sendExpect("eth_getCode", [ALICE.address, "latest"])).eq("0x");
});
Expand All @@ -98,6 +107,7 @@ describe("JSON-RPC", () => {

describe("Block", () => {
it("eth_blockNumber", async function () {
await sendReset();
(await sendExpect("eth_blockNumber")).eq(ZERO);
await sendEvmMine();
(await sendExpect("eth_blockNumber")).eq(ONE);
Expand Down

0 comments on commit fb66633

Please sign in to comment.