1
0

test_daemon: add test the wallet can be loaded by basename

This commit is contained in:
ThomasV
2025-06-05 09:06:02 +02:00
parent 85c3c77096
commit 8019ceb568

View File

@@ -189,44 +189,43 @@ class TestUnifiedPassword(DaemonTestCase):
class TestCommandsWithDaemon(DaemonTestCase): class TestCommandsWithDaemon(DaemonTestCase):
TESTNET = True TESTNET = True
SEED = "bitter grass shiver impose acquire brush forget axis eager alone wine silver"
async def test_wp_command_with_inmemory_wallet_has_password(self): async def test_wp_command_with_inmemory_wallet_has_password(self):
cmds = Commands(config=self.config, daemon=self.daemon) cmds = Commands(config=self.config, daemon=self.daemon)
wallet = restore_wallet_from_text('bitter grass shiver impose acquire brush forget axis eager alone wine silver', wallet = restore_wallet_from_text(self.SEED,
gap_limit=2, gap_limit=2,
path=None, path=None,
password="123456", password="123456",
config=self.config)['wallet'] config=self.config)['wallet']
self.assertEqual("bitter grass shiver impose acquire brush forget axis eager alone wine silver", self.assertEqual(self.SEED, await cmds.getseed(wallet=wallet, password="123456"))
await cmds.getseed(wallet=wallet, password="123456"))
async def test_wp_command_with_inmemory_wallet_no_password(self): async def test_wp_command_with_inmemory_wallet_no_password(self):
cmds = Commands(config=self.config, daemon=self.daemon) cmds = Commands(config=self.config, daemon=self.daemon)
wallet = restore_wallet_from_text('bitter grass shiver impose acquire brush forget axis eager alone wine silver', wallet = restore_wallet_from_text(self.SEED,
gap_limit=2, gap_limit=2,
path=None, path=None,
config=self.config)['wallet'] config=self.config)['wallet']
self.assertEqual("bitter grass shiver impose acquire brush forget axis eager alone wine silver", self.assertEqual(self.SEED, await cmds.getseed(wallet=wallet))
await cmds.getseed(wallet=wallet))
async def test_wp_command_with_diskfile_wallet_has_password(self): async def test_wp_command_with_diskfile_wallet_has_password(self):
cmds = Commands(config=self.config, daemon=self.daemon) cmds = Commands(config=self.config, daemon=self.daemon)
wpath = self._restore_wallet_from_text("bitter grass shiver impose acquire brush forget axis eager alone wine silver", password="123456", encrypt_file=True) wpath = self._restore_wallet_from_text(self.SEED, password="123456", encrypt_file=True)
basename = os.path.basename(wpath)
await cmds.load_wallet(wallet_path=wpath, password="123456") await cmds.load_wallet(wallet_path=wpath, password="123456")
wallet = self.daemon.get_wallet(wpath) wallet = self.daemon.get_wallet(wpath)
self.assertIsInstance(wallet, Abstract_Wallet) self.assertIsInstance(wallet, Abstract_Wallet)
self.assertEqual("bitter grass shiver impose acquire brush forget axis eager alone wine silver", self.assertEqual(self.SEED, await cmds.getseed(wallet_path=wpath, password="123456"))
await cmds.getseed(wallet_path=wpath, password="123456")) self.assertEqual(self.SEED, await cmds.getseed(wallet_path=basename, password='123456'))
self.assertEqual("bitter grass shiver impose acquire brush forget axis eager alone wine silver", self.assertEqual(self.SEED, await cmds.getseed(wallet=wallet, password="123456"))
await cmds.getseed(wallet=wallet, password="123456"))
async def test_wp_command_with_diskfile_wallet_no_password(self): async def test_wp_command_with_diskfile_wallet_no_password(self):
cmds = Commands(config=self.config, daemon=self.daemon) cmds = Commands(config=self.config, daemon=self.daemon)
wpath = self._restore_wallet_from_text("bitter grass shiver impose acquire brush forget axis eager alone wine silver", password=None) wpath = self._restore_wallet_from_text(self.SEED, password=None)
basename = os.path.basename(wpath)
await cmds.load_wallet(wallet_path=wpath, password=None) await cmds.load_wallet(wallet_path=wpath, password=None)
wallet = self.daemon.get_wallet(wpath) wallet = self.daemon.get_wallet(wpath)
self.assertIsInstance(wallet, Abstract_Wallet) self.assertIsInstance(wallet, Abstract_Wallet)
self.assertEqual("bitter grass shiver impose acquire brush forget axis eager alone wine silver", self.assertEqual(self.SEED, await cmds.getseed(wallet_path=wpath))
await cmds.getseed(wallet_path=wpath)) self.assertEqual(self.SEED, await cmds.getseed(wallet_path=basename))
self.assertEqual("bitter grass shiver impose acquire brush forget axis eager alone wine silver", self.assertEqual(self.SEED, await cmds.getseed(wallet=wallet))
await cmds.getseed(wallet=wallet))