Skip to content

Commit 6ac5a35

Browse files
committed
test: refactor to remove duplicated test code
1 parent 17e318a commit 6ac5a35

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

test/functional/wallet_migration.py

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -621,39 +621,18 @@ def test_wallet_with_relative_path(self):
621621
assert_equal(info["descriptors"], False)
622622
assert_equal(info["format"], "bdb")
623623

624-
def test_wallet_with_path_ending_in_slash(self):
625-
self.log.info("Test migrating a wallet with a name/path ending in '/'")
626-
627-
# The last directory in the wallet's path
628-
final_dir = "mywallet"
629-
wallet_name = f"path/to/{final_dir}/"
630-
wallet = self.create_legacy_wallet(wallet_name)
631-
default = self.master_node.get_wallet_rpc(self.default_wallet_name)
632-
633-
addr = wallet.getnewaddress()
634-
txid = default.sendtoaddress(addr, 1)
635-
self.generate(self.master_node, 1)
636-
bals = wallet.getbalances()
637-
638-
_, wallet = self.migrate_and_get_rpc(wallet_name)
639-
640-
assert wallet.gettransaction(txid)
641-
642-
assert_equal(bals, wallet.getbalances())
643-
644-
def test_wallet_with_path_ending_in_relative_specifier(self):
645-
self.log.info("Test migrating a wallet with a name/path ending in a relative specifier, '..'")
646-
wallet_ending_in_relative = "path/that/ends/in/.."
624+
def test_wallet_with_path(self, wallet_path):
625+
self.log.info("Test migrating a wallet with the following path/name: %s", wallet_path)
647626
# the wallet data is actually inside of path/that/ends/
648-
wallet = self.create_legacy_wallet(wallet_ending_in_relative)
627+
wallet = self.create_legacy_wallet(wallet_path)
649628
default = self.master_node.get_wallet_rpc(self.default_wallet_name)
650629

651630
addr = wallet.getnewaddress()
652631
txid = default.sendtoaddress(addr, 1)
653632
self.generate(self.master_node, 1)
654633
bals = wallet.getbalances()
655634

656-
_, wallet = self.migrate_and_get_rpc(wallet_ending_in_relative)
635+
_, wallet = self.migrate_and_get_rpc(wallet_path)
657636

658637
assert wallet.gettransaction(txid)
659638

@@ -1558,8 +1537,8 @@ def run_test(self):
15581537
self.test_nonexistent()
15591538
self.test_unloaded_by_path()
15601539
self.test_wallet_with_relative_path()
1561-
self.test_wallet_with_path_ending_in_slash()
1562-
self.test_wallet_with_path_ending_in_relative_specifier()
1540+
self.test_wallet_with_path("path/to/mywallet/")
1541+
self.test_wallet_with_path("path/that/ends/in/..")
15631542
self.test_default_wallet()
15641543
self.test_direct_file()
15651544
self.test_addressbook()

0 commit comments

Comments
 (0)