Beispiel #1
0
 def test_hex_property(self):
     for addr in TEST_PUB_ADDRS:
         with self.subTest(addr=addr):
             pub = PublicAddress(addr['addr'])
             self.assertEqual(pub.hex, addr['hex'])
Beispiel #2
0
 def test_bin_property(self):
     for addr in TEST_PUB_ADDRS:
         with self.subTest(addr=addr):
             pub = PublicAddress(addr['addr'])
             self.assertEqual(pub.bin, bytes.fromhex(addr['hex']))
Beispiel #3
0
 def test_bin2txt(self):
     for addr in TEST_PUB_ADDRS:
         with self.subTest(addr=addr):
             txt_addr = PublicAddress.bin2txt(addr['hex'])
             self.assertEqual(txt_addr, addr['addr'])
Beispiel #4
0
 def test_from_bin(self):
     for addr in TEST_PUB_ADDRS:
         with self.subTest(addr=addr):
             pub1 = PublicAddress.from_bin(addr['hex'])
             pub2 = PublicAddress(addr['addr'])
             self.assertEqual(pub1, pub2)
Beispiel #5
0
 def test_txt2bin(self):
     for addr in TEST_PUB_ADDRS:
         with self.subTest(addr=addr):
             hex_addr = PublicAddress.txt2bin(addr['addr'])
             self.assertEqual(hex_addr, addr['hex'])
Beispiel #6
0
 def test_eq(self):
     self.assertEqual(
         PublicAddress('AA100000005033211991'),
         PublicAddress('AA100000005033211991')
     )
Beispiel #7
0
 def test_str(self):
     for pub_addr in TEST_PUB_ADDRS:
         with self.subTest(addr=pub_addr):
             a = PublicAddress(pub_addr['addr'])
             self.assertEqual(str(a), pub_addr['addr'])
Beispiel #8
0
 def test_repr(self):
     msg = "PublicAddress(addr='{addr}', hex='{hex}')"
     for pub_addr in TEST_PUB_ADDRS:
         with self.subTest(addr=pub_addr):
             a = PublicAddress(pub_addr['addr'])
             self.assertEqual(repr(a), msg.format(**pub_addr))
Beispiel #9
0
 def test_out_of_bound_error(self):
     with self.assertRaises(AddressOutOfBoundError):
         PublicAddress.txt2bin('ZZ999999999999999999')