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

Commit cf4b56c

Browse files
committed
Add tests of raw calldata in txlog
1 parent add0a5d commit cf4b56c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

packages/debugger/test/txlog.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from "./helpers";
1313
import Debugger from "lib/debugger";
1414
import * as Codec from "@truffle/codec";
15+
import Web3 from "web3";
1516

1617
import txlog from "lib/txlog/selectors";
1718

@@ -228,6 +229,15 @@ describe("Transaction log (visualizer)", function () {
228229
assert.equal(call.functionName, "testCall");
229230
assert.equal(call.contractName, "VizTest");
230231
assert.equal(call.returnKind, "return");
232+
const expectedSelector = Web3.utils
233+
.soliditySha3("testCall(uint256)")
234+
.slice(0, 2 + 2 * Codec.Evm.Utils.SELECTOR_SIZE);
235+
const expectedArgument = Codec.Conversion.toHexString(
236+
108,
237+
Codec.Evm.Utils.WORD_SIZE
238+
).slice(2);
239+
assert.equal(call.raw.calldata, expectedSelector + expectedArgument);
240+
assert.notProperty(call.raw, "binary");
231241
debug("arguments: %O", call.arguments);
232242
let inputs = Codec.Export.unsafeNativizeVariables(byName(call.arguments));
233243
debug("nativized: %O", inputs);
@@ -281,6 +291,13 @@ describe("Transaction log (visualizer)", function () {
281291
assert.isUndefined(call.functionName);
282292
assert.equal(call.contractName, "Secondary");
283293
assert.equal(call.returnKind, "return");
294+
const expectedBytecode = abstractions.Secondary.binary;
295+
const expectedArgument = Codec.Conversion.toHexString(
296+
108,
297+
Codec.Evm.Utils.WORD_SIZE
298+
).slice(2);
299+
assert.equal(call.raw.binary, expectedBytecode + expectedArgument);
300+
assert.notProperty(call.raw, "calldata");
284301
let inputs = Codec.Export.unsafeNativizeVariables(byName(call.arguments));
285302
assert.deepEqual(inputs, {
286303
y: 108

0 commit comments

Comments
 (0)