commit 712c3f1248cf1002e733dc72134c10e6d7c5c510
parent edf186da0d1414b444514211898344a70117a2c7
Author: SomberNight <somber.night@protonmail.com>
Date: Thu, 5 Sep 2019 23:22:11 +0200
commands: try to fix tests
Diffstat:
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/electrum/commands.py b/electrum/commands.py
@@ -662,7 +662,7 @@ class Commands:
return out
@command('n')
- async def gettransaction(self, txid):
+ async def gettransaction(self, txid, wallet=None):
"""Retrieve a transaction. """
tx = None
if wallet:
@@ -689,7 +689,7 @@ class Commands:
return encrypted.decode('utf-8')
@command('wp')
- async def decrypt(self, pubkey, encrypted, password=None) -> str:
+ async def decrypt(self, pubkey, encrypted, password=None, wallet=None) -> str:
"""Decrypt a message encrypted with a public key."""
if not is_hex_str(pubkey):
raise Exception(f"pubkey must be a hex string instead of {repr(pubkey)}")
diff --git a/electrum/tests/test_commands.py b/electrum/tests/test_commands.py
@@ -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):