From 48908c134dca8915f03cc086e993545283cf516d Mon Sep 17 00:00:00 2001 From: Daniel Freire Date: Tue, 30 Jul 2024 17:41:28 -0300 Subject: [PATCH] test: contract deployment availability --- e2e/test/automine/e2e-json-rpc.test.ts | 10 +++++++++- e2e/test/external/e2e-json-rpc.test.ts | 12 +++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/e2e/test/automine/e2e-json-rpc.test.ts b/e2e/test/automine/e2e-json-rpc.test.ts index 918f7e190..e58813cf2 100644 --- a/e2e/test/automine/e2e-json-rpc.test.ts +++ b/e2e/test/automine/e2e-json-rpc.test.ts @@ -82,7 +82,14 @@ 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"); }); @@ -91,6 +98,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); diff --git a/e2e/test/external/e2e-json-rpc.test.ts b/e2e/test/external/e2e-json-rpc.test.ts index 453254e63..3ee36bbd4 100644 --- a/e2e/test/external/e2e-json-rpc.test.ts +++ b/e2e/test/external/e2e-json-rpc.test.ts @@ -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"); }); @@ -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);