Skip to content

Commit

Permalink
test: add e2e for debug_traceBlockByNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
grw-ms committed Oct 10, 2023
1 parent 17b621e commit 734a9f5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions e2e-tests/test/debug-apis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,28 @@ describe("debug namespace", function () {
const trace = traces[0].result;
expect(trace.input).to.equal(txReceipt.data);
});

it("debug_traceBlockByNumber should trace prior blocks", async function () {
const wallet = new Wallet(RichAccounts[0].PrivateKey);
const deployer = new Deployer(hre, wallet);

const greeter = await deployContract(deployer, "Greeter", ["Hi"]);

const txReceipt = await greeter.setGreeting("Luke Skywalker");

// latest block will be empty, check we get no traces for it
const empty_traces = await provider.send("debug_traceBlockByNumber", ["latest"]);
expect(empty_traces.length).to.equal(0);

// latest - 1 should contain our traces
const latestBlock = await provider.getBlock("latest");
const traces = await provider.send("debug_traceBlockByNumber", [(latestBlock.number - 1).toString(16)]);

// block should have 1 traces
expect(traces.length).to.equal(1);

// should contain trace for our tx
const trace = traces[0].result;
expect(trace.input).to.equal(txReceipt.data);
});
});

0 comments on commit 734a9f5

Please sign in to comment.