@@ -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