commands: fix encrypt/decrypt
based on Electron-Cash/Electron-Cash@62aa08a0ff
This commit is contained in:
@@ -8,7 +8,7 @@ from electrum import constants
|
||||
# If set, unit tests that would normally test functions with multiple implementations,
|
||||
# will only be run once, using the fastest implementation.
|
||||
# e.g. libsecp256k1 vs python-ecdsa. pycryptodomex vs pyaes.
|
||||
FAST_TESTS = False
|
||||
FAST_TESTS = 1
|
||||
|
||||
|
||||
# some unit tests are modifying globals; sorry.
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import unittest
|
||||
from unittest import mock
|
||||
from decimal import Decimal
|
||||
|
||||
from electrum.commands import Commands, eval_bool
|
||||
from electrum import storage
|
||||
from electrum.wallet import restore_wallet_from_text
|
||||
|
||||
from . import TestCaseForTestnet
|
||||
|
||||
@@ -62,6 +65,16 @@ class TestCommands(unittest.TestCase):
|
||||
for xkey2, xtype2 in xprvs:
|
||||
self.assertEqual(xkey2, cmds.convert_xkey(xkey1, xtype2))
|
||||
|
||||
@mock.patch.object(storage.WalletStorage, '_write')
|
||||
def test_encrypt_decrypt(self, mock_write):
|
||||
wallet = restore_wallet_from_text('p2wpkh:L4rYY5QpfN6wJEF4SEKDpcGhTPnCe9zcGs6hiSnhpprZqVywFifN',
|
||||
path='if_this_exists_mocking_failed_648151893')['wallet']
|
||||
cmds = Commands(config=None, wallet=wallet, network=None)
|
||||
cleartext = "asdasd this is the message"
|
||||
pubkey = "021f110909ded653828a254515b58498a6bafc96799fb0851554463ed44ca7d9da"
|
||||
ciphertext = cmds.encrypt(pubkey, cleartext)
|
||||
self.assertEqual(cleartext, cmds.decrypt(pubkey, ciphertext))
|
||||
|
||||
|
||||
class TestCommandsTestnet(TestCaseForTestnet):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user