def test_recognition_and_comparisons(self): a = Address(self.addr) a2 = address(self.addr) self.assertIsInstance(a2, Address) self.assertEqual(a, a2) self.assertEqual(a, self.addr) self.assertEqual(self.addr, a) self.assertEqual(a.is_mainnet(), self.mainnet) self.assertEqual(a.is_testnet(), self.testnet) self.assertEqual(a.is_stagenet(), self.stagenet) self.assertEqual(a2.is_mainnet(), self.mainnet) self.assertEqual(a2.is_testnet(), self.testnet) self.assertEqual(a2.is_stagenet(), self.stagenet) ia = IntegratedAddress(self.iaddr) ia2 = address(self.iaddr) self.assertIsInstance(ia, IntegratedAddress) self.assertEqual(ia, ia2) self.assertEqual(ia, self.iaddr) self.assertEqual(self.iaddr, ia) self.assertEqual(ia.is_mainnet(), self.mainnet) self.assertEqual(ia.is_testnet(), self.testnet) self.assertEqual(ia.is_stagenet(), self.stagenet) self.assertEqual(ia2.is_mainnet(), self.mainnet) self.assertEqual(ia2.is_testnet(), self.testnet) self.assertEqual(ia2.is_stagenet(), self.stagenet) self.assertEqual(ia2.base_address(), a) self.assertEqual(ia.view_key(), a.view_key()) self.assertEqual(ia.spend_key(), a.spend_key()) sa = SubAddress(self.subaddr) sa2 = address(self.subaddr) self.assertIsInstance(sa2, SubAddress) self.assertEqual(sa, sa2) self.assertEqual(sa, self.subaddr) self.assertEqual(self.subaddr, sa) self.assertEqual(sa.is_mainnet(), self.mainnet) self.assertEqual(sa.is_testnet(), self.testnet) self.assertEqual(sa.is_stagenet(), self.stagenet) self.assertEqual(sa2.is_mainnet(), self.mainnet) self.assertEqual(sa2.is_testnet(), self.testnet) self.assertEqual(sa2.is_stagenet(), self.stagenet) self.assertNotEqual(a, 0)
def test_from_and_to_string(self): a = Address(self.addr) self.assertEqual(str(a), self.addr) self.assertEqual(a.spend_key(), self.psk) self.assertEqual(a.view_key(), self.pvk) ia = IntegratedAddress(self.iaddr) self.assertEqual(ia.payment_id(), self.pid) self.assertEqual(str(ia), self.iaddr) self.assertEqual(ia.spend_key(), self.psk) self.assertEqual(ia.view_key(), self.pvk) self.assertEqual(ia.base_address(), a) sa = SubAddress(self.subaddr) self.assertEqual(str(sa), self.subaddr)
def test_invalid(self): self.assertRaises(ValueError, Address, self.addr_invalid) self.assertRaises(ValueError, Address, self.iaddr_invalid) a = Address(self.addr) self.assertRaises(TypeError, a.with_payment_id, 2**64 + 1) self.assertRaises(TypeError, a.with_payment_id, "%x" % (2**64 + 1)) s = SubAddress(self.subaddr) self.assertRaises(TypeError, s.with_payment_id, 0) self.assertRaises(ValueError, address, 'whatever') self.assertRaises(ValueError, Address, 'whatever') self.assertRaises(ValueError, SubAddress, 'whatever') self.assertRaises(ValueError, IntegratedAddress, 'whatever') # Aeon self.assertRaises( ValueError, address, 'Wmtj8UAJhdrhbKvwyBJmLEUZKHcffv2VHNBaq6oTxJFwJjUj3QwMUSS32mddSX7vchbxXdmb4QuZA9TsN47441f61yAYLQYTo' ) # invalid netbyte self.assertRaises( ValueError, address, 'Cf6RinMUztY5otm6NEFjg3UWBBkXK6Lh23wKrLFMEcCY7i3A6aPLH9i4QMCkf6CdWk8Q9N7yoJf7ANKgtQMuPM6JANXgCWs' )
def test_invalid(self): self.assertRaises(ValueError, Address, self.addr_invalid) self.assertRaises(ValueError, Address, self.iaddr_invalid) a = Address(self.addr) self.assertRaises(TypeError, a.with_payment_id, 2**64+1) self.assertRaises(TypeError, a.with_payment_id, "%x" % (2**64+1)) s = SubAddress(self.subaddr) self.assertRaises(TypeError, s.with_payment_id, 0) self.assertRaises(ValueError, address, 'whatever') self.assertRaises(ValueError, Address, 'whatever') self.assertRaises(ValueError, SubAddress, 'whatever') self.assertRaises(ValueError, IntegratedAddress, 'whatever') # Aeon self.assertRaises( ValueError, address, 'UPX1qwugRf6Z8X9vcRpu6tTsPis76HkLq2RWPo2bN9ZUcUfnZACaGgzcmYnb18vGnAdzUvbWdLGf146Ccw88zeJb5VzbQoCCcX') # invalid netbyte self.assertRaises( ValueError, address, 'Cf6RinMUztY5otm6NEFjg3UWBBkXK6Lh23wKrLFMEcCY7i3A6aPLH9i4QMCkf6CdWk8Q9N7yoJf7ANKgtQMuPM6JANXgCWs')
def test_subaddress_cannot_into_integrated(self): sa = SubAddress(self.subaddr) self.assertRaises(TypeError, sa.with_payment_id, self.pid)