예제 #1
0
    def test_stake_part_from_bytes_to_bytes(self):
        part1 = StakePart()
        part1.normalize(0, Revision.IISS.value)
        data = part1.to_bytes(Revision.IISS.value)
        self.assertTrue(isinstance(data, bytes))
        self.assertEqual(5, len(data))

        part2 = StakePart.from_bytes(data)
        part2.normalize(0, Revision.IISS.value)
        self.assertEqual(part1.stake, part2.stake)
        self.assertEqual(part1.unstake, part2.unstake)
        self.assertEqual(part1.unstake_block_height,
                         part2.unstake_block_height)

        part3 = StakePart(10, 20, 30)
        part3.normalize(0, Revision.IISS.value)
        part4 = StakePart.from_bytes(part3.to_bytes(Revision.IISS.value))
        part4.normalize(0, Revision.IISS.value)
        self.assertEqual(part3.stake, part4.stake)
        self.assertEqual(part3.unstake, part4.unstake)
        self.assertEqual(part3.unstake_block_height,
                         part4.unstake_block_height)
예제 #2
0
 def _convert_stake_parts(cls, key: bytes, value: bytes):
     ret = StakePart.from_bytes(value)
     return str(Address.from_bytes(key[len(StakePart.PREFIX):])), str(ret)