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

Commit 98eed2e

Browse files
committed
Add test of looking up function by signature
1 parent 6c6f8c0 commit 98eed2e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

packages/encoder/test/overload.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,4 +787,31 @@ describe("Overload resolution", () => {
787787
);
788788
});
789789
});
790+
791+
describe("Manual overload resolution by signature", () => {
792+
it("Allows specifying functions by signature", async () => {
793+
const { abi, tx } = await encoder.encodeTransaction("overloaded(bool)", [
794+
1
795+
]);
796+
assert.lengthOf(abi.inputs, 1);
797+
assert.strictEqual(abi.inputs[0].type, "bool");
798+
const selector = Codec.AbiData.Utils.abiSelector(abi);
799+
assert.strictEqual(
800+
tx.data,
801+
selector +
802+
"0000000000000000000000000000000000000000000000000000000000000001"
803+
);
804+
});
805+
806+
it("Rejects when no overload matches specified signature", async () => {
807+
try {
808+
await encoder.encodeTransaction("overloaded(uint192)", [1]);
809+
assert.fail("Should reject when specified signature does not exist");
810+
} catch (error) {
811+
if (error.name !== "NoFunctionByThatNameError") {
812+
throw error;
813+
}
814+
}
815+
});
816+
});
790817
});

0 commit comments

Comments
 (0)