Esempio n. 1
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)
Esempio n. 2
0
    def test_idempotence(self):
        a = Address(self.addr)
        a_idem = Address(a)
        self.assertEqual(a, a_idem)
        a_idem = Address(str(a))
        self.assertEqual(a, a_idem)
        a_idem = address(a)
        self.assertEqual(a, a_idem)

        ia = IntegratedAddress(self.iaddr)
        ia_idem = IntegratedAddress(ia)
        self.assertEqual(ia, ia_idem)
        ia_idem = IntegratedAddress(str(ia))
        self.assertEqual(ia, ia_idem)
        ia_idem = address(ia)
        self.assertEqual(ia, ia_idem)
Esempio n. 3
0
 def test_check_private_spend_key(self):
     a = Address(self.addr)
     self.assertTrue(a.check_private_spend_key(self.ssk))
     self.assertFalse(a.check_private_spend_key(self.svk))
     self.assertFalse(a.check_private_spend_key(self.psk))
     self.assertFalse(a.check_private_spend_key(self.pvk))
     self.assertFalse(a.check_private_spend_key('0000000000000000000000000000000000000000000000000000000000000000'))
Esempio n. 4
0
    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)
Esempio n. 5
0
 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'
     )
Esempio n. 6
0
 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')
Esempio n. 7
0
 def test_payment_id(self):
     a = Address(self.addr)
     ia = a.with_payment_id(self.pid)
     self.assertIsInstance(ia, IntegratedAddress)
     self.assertEqual(ia.payment_id(), self.pid)
     self.assertEqual(str(ia), self.iaddr)