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'])
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']))
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'])
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)
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'])
def test_eq(self): self.assertEqual( PublicAddress('AA100000005033211991'), PublicAddress('AA100000005033211991') )
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'])
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))
def test_out_of_bound_error(self): with self.assertRaises(AddressOutOfBoundError): PublicAddress.txt2bin('ZZ999999999999999999')