예제 #1
0
    def test_from_and_to_string(self):
        a = Address(self.addr)
        self.assertEqual(str(a), self.addr)
        self.assertEqual("{:s}".format(a), self.addr)
        self.assertEqual(a.spend_key(), self.psk)
        self.assertEqual(a.view_key(), self.pvk)
        self.assertEqual(hash(a), hash(self.addr))
        ba = Address(self.addr.encode())
        self.assertEqual(ba, a)
        ba = address(self.addr.encode())
        self.assertEqual(ba, a)

        ia = IntegratedAddress(self.iaddr)
        self.assertEqual(ia.payment_id(), self.pid)
        self.assertEqual(str(ia), self.iaddr)
        self.assertEqual("{:s}".format(ia), self.iaddr)
        self.assertEqual(ia.spend_key(), self.psk)
        self.assertEqual(ia.view_key(), self.pvk)
        self.assertEqual(ia.base_address(), a)
        ba = IntegratedAddress(self.iaddr.encode())
        self.assertEqual(ba, ia)
        ba = address(self.iaddr.encode())
        self.assertEqual(ba, ia)

        sa = SubAddress(self.subaddr)
        self.assertEqual(str(sa), self.subaddr)
        self.assertEqual("{:s}".format(sa), self.subaddr)
        ba = SubAddress(self.subaddr.encode())
        self.assertEqual(ba, sa)
        ba = address(self.subaddr.encode())
        self.assertEqual(ba, sa)
예제 #2
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_testnet(), self.testnet)
        self.assertEqual(a2.is_testnet(), self.testnet)

        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_testnet(), self.testnet)
        self.assertEqual(ia2.is_testnet(), self.testnet)
        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_testnet(), self.testnet)
        self.assertEqual(sa2.is_testnet(), self.testnet)

        self.assertNotEqual(a, 0)
예제 #3
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)
예제 #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(hash(a), hash(self.addr))
        self.assertEqual(a.net, self.net)
        with pytest.deprecated_call():
            self.assertEqual(a.is_mainnet(), self.net == const.NET_MAIN)
        with pytest.deprecated_call():
            self.assertEqual(a.is_testnet(), self.net == const.NET_TEST)
        with pytest.deprecated_call():
            self.assertEqual(a.is_stagenet(), self.net == const.NET_STAGE)
        self.assertEqual(a2.net, self.net)
        with pytest.deprecated_call():
            self.assertEqual(a2.is_mainnet(), self.net == const.NET_MAIN)
        with pytest.deprecated_call():
            self.assertEqual(a2.is_testnet(), self.net == const.NET_TEST)
        with pytest.deprecated_call():
            self.assertEqual(a2.is_stagenet(), self.net == const.NET_STAGE)

        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(hash(ia), hash(self.iaddr))
        self.assertEqual(ia.net, self.net)
        with pytest.deprecated_call():
            self.assertEqual(ia.is_mainnet(), self.net == const.NET_MAIN)
        with pytest.deprecated_call():
            self.assertEqual(ia.is_testnet(), self.net == const.NET_TEST)
        with pytest.deprecated_call():
            self.assertEqual(ia.is_stagenet(), self.net == const.NET_STAGE)
        self.assertEqual(ia2.net, self.net)
        with pytest.deprecated_call():
            self.assertEqual(ia2.is_mainnet(), self.net == const.NET_MAIN)
        with pytest.deprecated_call():
            self.assertEqual(ia2.is_testnet(), self.net == const.NET_TEST)
        with pytest.deprecated_call():
            self.assertEqual(ia2.is_stagenet(), self.net == const.NET_STAGE)
        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(hash(sa), hash(self.subaddr))
        self.assertEqual(sa.net, self.net)
        with pytest.deprecated_call():
            self.assertEqual(sa.is_mainnet(), self.net == const.NET_MAIN)
        with pytest.deprecated_call():
            self.assertEqual(sa.is_testnet(), self.net == const.NET_TEST)
        with pytest.deprecated_call():
            self.assertEqual(sa.is_stagenet(), self.net == const.NET_STAGE)
        self.assertEqual(sa2.net, self.net)
        with pytest.deprecated_call():
            self.assertEqual(sa2.is_mainnet(), self.net == const.NET_MAIN)
        with pytest.deprecated_call():
            self.assertEqual(sa2.is_testnet(), self.net == const.NET_TEST)
        with pytest.deprecated_call():
            self.assertEqual(sa2.is_stagenet(), self.net == const.NET_STAGE)

        self.assertNotEqual(a, 0)