|
|
|
|
@ -83,7 +83,7 @@ class TestCommands(unittest.TestCase):
|
|
|
|
|
cleartext = "asdasd this is the message" |
|
|
|
|
pubkey = "021f110909ded653828a254515b58498a6bafc96799fb0851554463ed44ca7d9da" |
|
|
|
|
ciphertext = cmds._run('encrypt', (pubkey, cleartext)) |
|
|
|
|
self.assertEqual(cleartext, cmds._run('decrypt', (pubkey, ciphertext))) |
|
|
|
|
self.assertEqual(cleartext, cmds._run('decrypt', (pubkey, ciphertext), wallet=wallet)) |
|
|
|
|
|
|
|
|
|
@mock.patch.object(storage.WalletStorage, '_write') |
|
|
|
|
def test_export_private_key_imported(self, mock_write): |
|
|
|
|
@ -92,16 +92,16 @@ class TestCommands(unittest.TestCase):
|
|
|
|
|
cmds = Commands(config=None) |
|
|
|
|
# single address tests |
|
|
|
|
with self.assertRaises(Exception): |
|
|
|
|
cmds._run('getprivatekeys', ("asdasd",)) # invalid addr, though might raise "not in wallet" |
|
|
|
|
cmds._run('getprivatekeys', ("asdasd",), wallet=wallet) # invalid addr, though might raise "not in wallet" |
|
|
|
|
with self.assertRaises(Exception): |
|
|
|
|
cmds._run('getprivatekeys', ("bc1qgfam82qk7uwh5j2xxmcd8cmklpe0zackyj6r23",)) # not in wallet |
|
|
|
|
cmds._run('getprivatekeys', ("bc1qgfam82qk7uwh5j2xxmcd8cmklpe0zackyj6r23",), wallet=wallet) # not in wallet |
|
|
|
|
self.assertEqual("p2wpkh:L4jkdiXszG26SUYvwwJhzGwg37H2nLhrbip7u6crmgNeJysv5FHL", |
|
|
|
|
cmds._run('getprivatekeys', ("bc1q2ccr34wzep58d4239tl3x3734ttle92a8srmuw",))) |
|
|
|
|
cmds._run('getprivatekeys', ("bc1q2ccr34wzep58d4239tl3x3734ttle92a8srmuw",), wallet=wallet)) |
|
|
|
|
# list of addresses tests |
|
|
|
|
with self.assertRaises(Exception): |
|
|
|
|
cmds._run('getprivatekeys', (['bc1q2ccr34wzep58d4239tl3x3734ttle92a8srmuw', 'asd'], )) |
|
|
|
|
cmds._run('getprivatekeys', (['bc1q2ccr34wzep58d4239tl3x3734ttle92a8srmuw', 'asd'], ), wallet=wallet) |
|
|
|
|
self.assertEqual(['p2wpkh:L4jkdiXszG26SUYvwwJhzGwg37H2nLhrbip7u6crmgNeJysv5FHL', 'p2wpkh:L4rYY5QpfN6wJEF4SEKDpcGhTPnCe9zcGs6hiSnhpprZqVywFifN'], |
|
|
|
|
cmds._run('getprivatekeys', (['bc1q2ccr34wzep58d4239tl3x3734ttle92a8srmuw', 'bc1q9pzjpjq4nqx5ycnywekcmycqz0wjp2nq604y2n'], ))) |
|
|
|
|
cmds._run('getprivatekeys', (['bc1q2ccr34wzep58d4239tl3x3734ttle92a8srmuw', 'bc1q9pzjpjq4nqx5ycnywekcmycqz0wjp2nq604y2n'], ), wallet=wallet)) |
|
|
|
|
|
|
|
|
|
@mock.patch.object(storage.WalletStorage, '_write') |
|
|
|
|
def test_export_private_key_deterministic(self, mock_write): |
|
|
|
|
@ -111,16 +111,16 @@ class TestCommands(unittest.TestCase):
|
|
|
|
|
cmds = Commands(config=None) |
|
|
|
|
# single address tests |
|
|
|
|
with self.assertRaises(Exception): |
|
|
|
|
cmds._run('getprivatekeys', ("asdasd",)) # invalid addr, though might raise "not in wallet" |
|
|
|
|
cmds._run('getprivatekeys', ("asdasd",), wallet=wallet) # invalid addr, though might raise "not in wallet" |
|
|
|
|
with self.assertRaises(Exception): |
|
|
|
|
cmds._run('getprivatekeys', ("bc1qgfam82qk7uwh5j2xxmcd8cmklpe0zackyj6r23",)) # not in wallet |
|
|
|
|
cmds._run('getprivatekeys', ("bc1qgfam82qk7uwh5j2xxmcd8cmklpe0zackyj6r23",), wallet=wallet) # not in wallet |
|
|
|
|
self.assertEqual("p2wpkh:L15oxP24NMNAXxq5r2aom24pHPtt3Fet8ZutgL155Bad93GSubM2", |
|
|
|
|
cmds._run('getprivatekeys', ("bc1q3g5tmkmlvxryhh843v4dz026avatc0zzr6h3af",))) |
|
|
|
|
cmds._run('getprivatekeys', ("bc1q3g5tmkmlvxryhh843v4dz026avatc0zzr6h3af",), wallet=wallet)) |
|
|
|
|
# list of addresses tests |
|
|
|
|
with self.assertRaises(Exception): |
|
|
|
|
cmds._run('getprivatekeys', (['bc1q3g5tmkmlvxryhh843v4dz026avatc0zzr6h3af', 'asd'],)) |
|
|
|
|
cmds._run('getprivatekeys', (['bc1q3g5tmkmlvxryhh843v4dz026avatc0zzr6h3af', 'asd'],), wallet=wallet) |
|
|
|
|
self.assertEqual(['p2wpkh:L15oxP24NMNAXxq5r2aom24pHPtt3Fet8ZutgL155Bad93GSubM2', 'p2wpkh:L4rYY5QpfN6wJEF4SEKDpcGhTPnCe9zcGs6hiSnhpprZqVywFifN'], |
|
|
|
|
cmds._run('getprivatekeys', (['bc1q3g5tmkmlvxryhh843v4dz026avatc0zzr6h3af', 'bc1q9pzjpjq4nqx5ycnywekcmycqz0wjp2nq604y2n'], ))) |
|
|
|
|
cmds._run('getprivatekeys', (['bc1q3g5tmkmlvxryhh843v4dz026avatc0zzr6h3af', 'bc1q9pzjpjq4nqx5ycnywekcmycqz0wjp2nq604y2n'], ), wallet=wallet)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestCommandsTestnet(TestCaseForTestnet): |
|
|
|
|
|