Example #1
0
    def test_coin_part_from_bytes_to_bytes_old_db_load_revision_4(self):
        part1 = CoinPart()

        balance = 1024
        part1.type = CoinPartType.GENERAL
        part1.deposit(balance)

        part2 = CoinPart.from_bytes(part1.to_bytes(Revision.THREE.value))
        self.assertEqual(part1, part2)

        data: bytes = part1.to_bytes(Revision.FOUR.value)
        part3 = CoinPart.from_bytes(data)
        self.assertEqual(part1, part3)
Example #2
0
    def test_coin_part_from_bytes_to_bytes_revision_4(self):
        part1 = CoinPart()

        data = part1.to_bytes(Revision.FOUR.value)
        self.assertTrue(isinstance(data, bytes))

        part2 = CoinPart.from_bytes(data)
        self.assertEqual(part1, part2)
        self.assertEqual(CoinPartType.GENERAL, part2.type)
        self.assertEqual(0, part2.balance)
        self.assertEqual(CoinPartFlag.NONE, part2.flags)

        part1.type = CoinPartType.GENESIS
        part1.deposit(1024)

        part3 = CoinPart.from_bytes(part1.to_bytes(Revision.FOUR.value))
        self.assertEqual(CoinPartType.GENESIS, part3.type)
        self.assertEqual(1024, part3.balance)
Example #3
0
    def test_coin_part_from_bytes_to_bytes_revision_3(self):
        part1 = CoinPart()
        revision = 3

        data = part1.to_bytes(revision)
        self.assertTrue(isinstance(data, bytes))
        self.assertEqual(36, len(data))

        part2 = CoinPart.from_bytes(data)
        self.assertEqual(CoinPartType.GENERAL, part2.type)
        self.assertEqual(0, part2.balance)

        part1.type = CoinPartType.GENESIS
        part1.deposit(1024)

        part3 = CoinPart.from_bytes(part1.to_bytes(revision))
        self.assertEqual(CoinPartType.GENESIS, part3.type)
        self.assertEqual(1024, part3.balance)