@@ -154,4 +154,33 @@ contract CborDecodeTest {
154154 (num, index) = input.readUInt8 (index);
155155 require (num == 111 , "num is not 111 " );
156156 }
157+
158+ function test_decodeMap () public pure {
159+ bytes memory input = hex "A3616101616202616303 " ;
160+
161+ uint index = 0 ;
162+ uint mapLen = 0 ;
163+ (mapLen, index) = input.readFixedMap (index);
164+ require (mapLen == 3 , "map len is not 2 " );
165+
166+ string memory mapKey;
167+ uint8 mapValue;
168+ (mapKey, index) = input.readString (index);
169+ require (keccak256 (abi.encodePacked (mapKey)) == keccak256 (abi.encodePacked ("a " )), "map key is not 'a' " );
170+
171+ (mapValue, index) = input.readUInt8 (index);
172+ require (mapValue == 1 , "map value is not 1 " );
173+
174+ (mapKey, index) = input.readString (index);
175+ require (keccak256 (abi.encodePacked (mapKey)) == keccak256 (abi.encodePacked ("b " )), "map key is not 'b' " );
176+
177+ (mapValue, index) = input.readUInt8 (index);
178+ require (mapValue == 2 , "map value is not 2 " );
179+
180+ (mapKey, index) = input.readString (index);
181+ require (keccak256 (abi.encodePacked (mapKey)) == keccak256 (abi.encodePacked ("c " )), "map key is not 'c' " );
182+
183+ (mapValue, index) = input.readUInt8 (index);
184+ require (mapValue == 3 , "map value is not 3 " );
185+ }
157186}
0 commit comments