Skip to content

Commit

Permalink
test debug_traceCall rpc method
Browse files Browse the repository at this point in the history
  • Loading branch information
RomarQ committed May 6, 2024
1 parent bada11e commit b952009
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/suites/tracing-tests/test-trace-call.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { customDevRpcRequest, describeSuite, expect } from "@moonwall/cli";
import { ALITH_PRIVATE_KEY, alith, createEthersTransaction } from "@moonwall/util";

Check failure on line 2 in test/suites/tracing-tests/test-trace-call.ts

View workflow job for this annotation

GitHub Actions / Check with EsLint

'ALITH_PRIVATE_KEY' is defined but never used

Check failure on line 2 in test/suites/tracing-tests/test-trace-call.ts

View workflow job for this annotation

GitHub Actions / Check with EsLint

'alith' is defined but never used

Check failure on line 2 in test/suites/tracing-tests/test-trace-call.ts

View workflow job for this annotation

GitHub Actions / Check with EsLint

'createEthersTransaction' is defined but never used
import { encodeFunctionData } from "viem";
import { createContracts, nestedSingle } from "../../helpers";

Check failure on line 4 in test/suites/tracing-tests/test-trace-call.ts

View workflow job for this annotation

GitHub Actions / Check with EsLint

'nestedSingle' is defined but never used

describeSuite({
id: "T16",
title: "Test 'debug_traceCall'",
foundationMethods: "dev",
testCases: ({ context, it }) => {
it({
id: "T01",
title: "should trace nested contract calls",
test: async function () {
const contracts = await createContracts(context);
const callParams = {
to: contracts.callerAddr,
data: encodeFunctionData({
abi: contracts.abiCaller,
functionName: "someAction",
args: [contracts.calleeAddr, 6],
})
};
const traceTx = await customDevRpcRequest("debug_traceCall", [callParams, "latest"]);
const logs: any[] = [];
for (const log of traceTx.structLogs) {
if (logs.length == 1) {
logs.push(log);
}
if (log.op == "RETURN") {
logs.push(log);
}
}
expect(logs).to.be.lengthOf(2);
expect(logs[0].depth).to.be.equal(2);
expect(logs[1].depth).to.be.equal(1);
},
});
},
});

0 comments on commit b952009

Please sign in to comment.