Skip to content

Commit 379a5a7

Browse files
committed
add failing test
1 parent 241c1f5 commit 379a5a7

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

packages/candid/src/idl.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,29 @@ test('IDL opt edge cases', () => {
740740
{a: []},
741741
'4449444c016c0161700100',
742742
// Motoko: {a = (): Any} : {a : Any}
743-
'opt expect type reserved on wire',
743+
'opt expected type reserved on wire',
744744
);
745+
testDecode(
746+
IDL.Record({a: IDL.Opt(IDL.Variant({ x: IDL.Null, y: IDL.Null }))}),
747+
{a: [{x: null}]},
748+
`4449444c026c0161016b02787f797f010000`,
749+
// Motoko: {a = #x } : {a : {#x;#y}}
750+
'opt expected type non-opt on wire',
751+
);
752+
/*
753+
testDecode(
754+
IDL.Record({a: IDL.Opt(IDL.Variant({ x: IDL.Null, y: IDL.Null }))}),
755+
{a: [{x: null}]},
756+
`4449444c026c0161016b03787f797f7a7f010000`,
757+
// Motoko: {a = #x } : {a : {#x;#y;#z}}
758+
'opt expected, wire type non-opt, extended, with expected tag',
759+
);
760+
testDecode(
761+
IDL.Record({a: IDL.Opt(IDL.Variant({ x: IDL.Null, y: IDL.Null }))}),
762+
{a: []},
763+
`4449444c026c0161016b03787f797f7a7f010002`,
764+
// Motoko: {a = #z } : {a : {#x;#y;#z}}
765+
'opt expected, wire type non-opt, extended, with unexpected tag - defaulting',
766+
);
767+
*/
745768
});

0 commit comments

Comments
 (0)