def test_invalid_network_prefix(self): key = self.expected_key key = (long_to_hex(BitcoinTestNet.EXT_SECRET_KEY, 8) + self.expected_key[8:]) self.assertRaises(IncompatibleNetworkException, Wallet.deserialize, key, BitcoinMainNet) self.assertTrue(Wallet.deserialize(key, BitcoinTestNet))
def test_public_export(self): """Export a node as public.""" child = self.master_key.get_child(0, as_private=False) self.assertEqual(child.private_key, None) key = child.serialize(private=False) self.assertTrue( long_to_hex(BitcoinMainNet.EXT_PUBLIC_KEY, 8) in key) self.assertEqual(Wallet.deserialize(key), child)
def test_random_wallet(self): w = Wallet.new_random_wallet() self.assertTrue(Wallet.deserialize(w.serialize()), w) self.assertEqual(w.depth, 0) self.assertEqual(w.parent_fingerprint, b'0x' + long_to_hex(0, 8)) self.assertEqual(w.child_number, 0)