def deserialize_u16(self) -> st.uint16: return st.uint16(int.from_bytes(self.read(2), byteorder="little", signed=False))
primitive_decode_map = { st.bool: lambda content: ( st.bool(int.from_bytes(content[:1], byteorder="little", signed=False)), content[1:], ), st.uint8: lambda content: ( st.uint8(int.from_bytes(content[:1], byteorder="little", signed=False) ), content[1:], ), st.uint16: lambda content: ( st.uint16(int.from_bytes(content[:2], byteorder="little", signed=False) ), content[2:], ), st.uint32: lambda content: ( st.uint32(int.from_bytes(content[:4], byteorder="little", signed=False) ), content[4:], ), st.uint64: lambda content: ( st.uint64(int.from_bytes(content[:8], byteorder="little", signed=False) ), content[8:], ), st.uint128:
def test_deserialize_long_sequence(self): Seq = typing.Sequence[st.uint16] five = st.uint16(5) v = [five] * 1000000 b = bcs.serialize(v, Seq) self.assertEqual(bcs.deserialize(b, Seq), (v, b""))