def test_bcs_u128(self):
     self.assertEqual(
         bcs.serialize(st.uint128(0x0102030405060708090A0B0C0D0E0F10),
                       st.uint128),
         b"\x10\x0f\x0e\r\x0c\x0b\n\t\x08\x07\x06\x05\x04\x03\x02\x01",
     )
     self.assertEqual(bcs.deserialize(b"\xff" * 16, st.uint128),
                      (st.uint128((1 << 128) - 1), b""))
Beispiel #2
0
 ),
 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:
 lambda content: (
     st.uint128(
         int.from_bytes(content[:16], byteorder="little", signed=False)),
     content[16:],
 ),
 st.int8:
 lambda content: (
     st.int8(int.from_bytes(content[:1], byteorder="little", signed=True)),
     content[1:],
 ),
 st.int16:
 lambda content: (
     st.int16(int.from_bytes(content[:2], byteorder="little", signed=True)),
     content[2:],
 ),
 st.int32:
 lambda content: (
     st.int32(int.from_bytes(content[:4], byteorder="little", signed=True)),
 def deserialize_u128(self) -> st.uint128:
     return st.uint128(
         int.from_bytes(self.read(16), byteorder="little", signed=False)
     )
Beispiel #4
0
 def test_u128(self):
     x = 0x0102030405060708090A0B0C0D0E0F10
     y = st.uint128(x)
     self.assertEqual(y.high, 0x0102030405060708)
     self.assertEqual(y.low, 0x090A0B0C0D0E0F10)
     self.assertEqual(int(y), x)