Browse Source

tests: add a failing testcase for daemon.update_password_for_directory

related https://github.com/spesmilo/electrum/issues/8259
master
SomberNight 3 years ago
parent
commit
aac9afa7c1
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 1
      electrum/tests/__init__.py
  2. 41
      electrum/tests/test_daemon.py

1
electrum/tests/__init__.py

@ -50,6 +50,7 @@ class ElectrumTestCase(unittest.IsolatedAsyncioTestCase):
self.electrum_path = tempfile.mkdtemp()
async def asyncSetUp(self):
await super().asyncSetUp()
loop = util.get_asyncio_loop()
# IsolatedAsyncioTestCase creates event loops with debug=True, which makes the tests take ~4x time
if not (os.environ.get("PYTHONASYNCIODEBUG") or os.environ.get("PYTHONDEVMODE")):

41
electrum/tests/test_daemon.py

@ -0,0 +1,41 @@
import os
from electrum.daemon import Daemon
from electrum.simple_config import SimpleConfig
from electrum.wallet import restore_wallet_from_text, Abstract_Wallet, Standard_Wallet
from electrum import util
from . import ElectrumTestCase
class TestUnifiedPassword(ElectrumTestCase):
config: 'SimpleConfig'
def setUp(self):
super().setUp()
self.config = SimpleConfig({'electrum_path': self.electrum_path})
self.config.set_key("single_password", True)
self.wallet_dir = os.path.dirname(self.config.get_wallet_path())
assert "wallets" == os.path.basename(self.wallet_dir)
async def asyncSetUp(self):
await super().asyncSetUp()
self.daemon = Daemon(config=self.config, listen_jsonrpc=False)
async def asyncTearDown(self):
await self.daemon.stop()
await super().asyncTearDown()
async def test_update_password_for_directory(self):
wallet1: Standard_Wallet = restore_wallet_from_text(
"9dk", path=f"{self.wallet_dir}/w1", password=None, gap_limit=2, config=self.config)['wallet']
wallet2: Standard_Wallet = restore_wallet_from_text(
"x8", path=f"{self.wallet_dir}/w2", password="123456", gap_limit=2, config=self.config)['wallet']
can_be_unified, is_unified = self.daemon._check_password_for_directory(old_password="123456", wallet_dir=self.wallet_dir)
self.assertEqual((True, False), (can_be_unified, is_unified))
is_unified = self.daemon.update_password_for_directory(old_password="123456", new_password="123456")
self.assertTrue(is_unified)
Loading…
Cancel
Save