Skip to content

Commit

Permalink
test(molecule): test check function with custom id
Browse files Browse the repository at this point in the history
  • Loading branch information
homura committed Dec 13, 2023
1 parent be1d723 commit 18e1643
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/molecule/tests/codec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,28 @@ test("should unpack only one WitnessArgs", (t) => {
}
);
});

test("checkDependencies should work correctly with union", (t) => {
checkDependencies([
{ type: "array", name: "Uint8", item: "byte", item_count: 1 },
{ type: "array", name: "Uint16", item: "byte", item_count: 2 },
{ type: "array", name: "Uint32", item: "byte", item_count: 4 },

// without custom id
{ type: "union", name: "Test1", items: ["Uint8", "Uint16", "Uint32"] },
// prettier-ignore
// with custom id
{ type: "union", name: "Test2", items: [["Uint8", 111], ["Uint16", 222], ["Uint32", 333]] },
]);

t.pass();
});

test("checkDependencies should throw when id is larger than uint32", (t) => {
t.throws(() =>
checkDependencies([
{ type: "array", name: "Uint8", item: "byte", item_count: 1 },
{ type: "union", name: "Test", items: [["Uint8", 0xff_ff_ff_ff + 1]] },
])
);
});

0 comments on commit 18e1643

Please sign in to comment.