From 26680a00f01acf397a83d1d27167d7224ac19cee Mon Sep 17 00:00:00 2001 From: scgbckbone Date: Tue, 23 Sep 2025 18:58:42 +0200 Subject: [PATCH] test fixes --- testing/devtest/unit_addrs.py | 15 ++++++++------- testing/test_ephemeral.py | 10 ++++++---- testing/test_hsm.py | 14 +++++++------- testing/test_ownership.py | 2 ++ 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/testing/devtest/unit_addrs.py b/testing/devtest/unit_addrs.py index 299d7c21..f4355beb 100644 --- a/testing/devtest/unit_addrs.py +++ b/testing/devtest/unit_addrs.py @@ -4,41 +4,42 @@ from h import a2b_hex, b2a_hex from serializations import CTxOut from uio import BytesIO +from public_constants import AF_CLASSIC, AF_P2SH, AF_P2WPKH, AF_P2WSH cases = [ # TxOut, type, is_segwit, hash160/pubkey, ( 'c4f33d0000000000160014ad46a001d55bd55d157e716bf17c02f8964b5a19', - 'p2pkh', True, + AF_P2WPKH, True, 'ad46a001d55bd55d157e716bf17c02f8964b5a19' ), ( '202cb206000000001976a9148280b37df378db99f66f85c95a783a76ac7a6d5988ac', - 'p2pkh', False, + AF_CLASSIC, False, '8280b37df378db99f66f85c95a783a76ac7a6d59' ), # from legendary txid: 40eee3ae1760e3a8532263678cdf64569e6ad06abc133af64f735e52562bccc8 ( '301b0f000000000017a914e9c3dd0c07aac76179ebc76a6c78d4d67c6c160a87', - 'p2sh', False, + AF_P2SH, False, 'e9c3dd0c07aac76179ebc76a6c78d4d67c6c160a'), # from testnet: a4c89e0ffb84d06a1e62f0f9f0f5974db250878caa1f71f9992a1f865b8ff2fa # via ( 'b88201000000000017a914f0ca58dc8e539421a3cb4a9c22c059973075287c87', - 'p2sh', False, + AF_P2SH, False, 'f0ca58dc8e539421a3cb4a9c22c059973075287c'), # XXX missing: P2SH segwit, 1of1 and N of M ( 'd0f13d0000000000160014f2369bac6d24ed11313fa65adda1971d10e17bff', - 'p2pkh', True, + AF_P2WPKH, True, 'f2369bac6d24ed11313fa65adda1971d10e17bff') ] -for raw_txo, expect_type, expect_sw, expect_hash in cases: +for i, (raw_txo, expect_type, expect_sw, expect_hash) in enumerate(cases): expect_hash = a2b_hex(expect_hash) out = CTxOut() out.deserialize(BytesIO(a2b_hex(raw_txo))) - print("Case: %s... " % raw_txo[0:30]) + print("Case %d: %s... " % (i, raw_txo[0:30])) addr_type, addr_or_pubkey, is_segwit = out.get_address() assert is_segwit == expect_sw, 'wrong segwit' diff --git a/testing/test_ephemeral.py b/testing/test_ephemeral.py index 49eb6de8..be3a6f8b 100644 --- a/testing/test_ephemeral.py +++ b/testing/test_ephemeral.py @@ -1253,7 +1253,7 @@ def test_xfp_collision(reset_seed_words, settings_set, import_ephemeral_xprv, @pytest.mark.parametrize("refuse", [False, True]) def test_add_current_active(reset_seed_words, settings_set, import_ephemeral_xprv, goto_home, pick_menu_item, cap_story, cap_menu, - press_cancel, verify_ephemeral_secret_ui, + press_cancel, verify_ephemeral_secret_ui, is_q1, seed_vault_enable, refuse, press_select, set_bip39_pw, need_some_notes, need_some_passwords, import_ms_wallet, restore_main_seed, settings_get, clear_ms): @@ -1273,8 +1273,9 @@ def test_add_current_active(reset_seed_words, settings_set, import_ephemeral_xpr restore_main_seed(seed_vault=True) # add secure notes and passwords - need_some_notes() - need_some_passwords() + if is_q1: + need_some_notes() + need_some_passwords() # save multisig wallet to master settings ms_name = "aaa" @@ -1321,7 +1322,8 @@ def test_add_current_active(reset_seed_words, settings_set, import_ephemeral_xpr mss = settings_get("multisig") assert len(mss) == 1 assert mss[0][0] == ms_name - assert len(settings_get("notes")) == 3 + if is_q1: + assert len(settings_get("notes")) == 3 sv = settings_get("seeds") assert len(sv) == 2 assert sv[0][0] == xfp2str(sv_pass_xfp) # added passphrase wallet diff --git a/testing/test_hsm.py b/testing/test_hsm.py index b5e4d68e..fb9af23c 100644 --- a/testing/test_hsm.py +++ b/testing/test_hsm.py @@ -545,7 +545,7 @@ def test_simple_limit(dev, amount, over, start_hsm, fake_txn, attempt_psbt, twea tweak_rule(0, dict(max_amount=int(amount+over))) attempt_psbt(psbt) -def test_named_wallets(dev, start_hsm, tweak_rule, make_myself_wallet, hsm_status, +def test_named_wallets(dev, start_hsm, tweak_rule, hsm_status, import_ms_wallet, attempt_psbt, fake_txn, fake_ms_txn, amount=5E6, incl_xpubs=False): wname = 'Myself-4' M = 4 @@ -553,12 +553,11 @@ def test_named_wallets(dev, start_hsm, tweak_rule, make_myself_wallet, hsm_statu stat = hsm_status() assert not stat.active - for retry in range(3): - keys, _ = make_myself_wallet(4) # slow AF + keys = import_ms_wallet(M,M, name=wname, accept=True) + time.sleep(.2) - stat = hsm_status() - if wname in stat.wallets: - break + stat = hsm_status() + assert wname in stat.wallets # policy: only allow multisig w/ that name policy = DICT(rules=[dict(wallet=wname)]) @@ -1560,7 +1559,8 @@ def test_hsm_commands_disabled(dev, goto_home, pick_menu_item, hsm_reset, start_ # disable HSM related commands (now enabled because module scope fixture 'enable_hsm_commands') goto_home() pick_menu_item("Advanced/Tools") - pick_menu_item("Enable HSM") + pick_menu_item("Spending Policy") + pick_menu_item("HSM Mode") pick_menu_item("Default Off") goto_home() try: diff --git a/testing/test_ownership.py b/testing/test_ownership.py index 774c8fc0..830136c8 100644 --- a/testing/test_ownership.py +++ b/testing/test_ownership.py @@ -335,6 +335,8 @@ def test_address_explorer_saver(af, wipe_cache, settings_set, goto_address_explo assert 'Derivation path' in story if af == "Segwit P2WPKH": assert " P2WPKH " in story + elif af == "Classic P2PKH": + assert " P2PKH " in story else: assert af in story