fix tests after re-word removal

This commit is contained in:
scgbckbone 2024-08-25 17:09:49 +02:00 committed by doc-hex
parent 58f7c59a6e
commit 5fa2f385ef
15 changed files with 52 additions and 43 deletions

View File

@ -318,8 +318,8 @@ async def make_complete_backup(fname_pattern='backup.7z', write_sflash=False):
msg = ("BIP39 passphrase is in effect. Backup ignores passphrases "
"and produces backup of main seed. Press %s to back-up main wallet,"
" press (2) to back-up BIP39 passphrase wallet "
"(extended private key created via seed + pass)")
ch = await ux_show_story(msg % OK, escape="2")
"(extended private key created via seed + pass)" % OK)
ch = await ux_show_story(msg, escape="2")
if ch == "x": return
if ch == "y":
bypass_tmp = True

View File

@ -449,9 +449,9 @@ async def add_seed_to_vault(encoded, meta=None):
story = ("Press (1) to "
"store temporary seed into Seed Vault. This way you can easily switch "
"to this secret and use it as temporary seed in future.\n\nPress %s "
"to continue without saving.")
"to continue without saving." % OK)
ch = await ux_show_story(story % OK, escape="1")
ch = await ux_show_story(story, escape="1")
if ch != "1":
# didn't want to save
return

View File

@ -270,9 +270,9 @@ or press (2) for 18 words XOR.''' % OK, escape="12")
if curr_num_words == desired_num_words:
escape += "1"
msg += ("\nPress (1) to include this Coldcard's seed words into the XOR seed set, "
"or %s to continue without.")
"or %s to continue without." % OK)
ch = await ux_show_story(msg % OK, escape=escape)
ch = await ux_show_story(msg, escape=escape)
if ch == 'x':
return

View File

@ -23,13 +23,13 @@ def _clone(source, target):
_pick_menu_item(device, target_is_Q, "Clone Coldcard")
time.sleep(.1)
title, story = _cap_story(device)
assert "Insert a MicroSD card and press OK to start" in story
assert f"Insert a MicroSD card and press {'ENTER' if target_is_Q else 'OK'} to start" in story
assert "A small file with an ephemeral public key will be written" in story
_press_select(device, target_is_Q)
time.sleep(.1)
title, story = _cap_story(device)
assert "Keep power on this Coldcard, and take MicroSD card to source Coldcard" in story
assert "Bring that card back and press OK to complete clone process" in story
assert f"Bring that card back and press {'ENTER' if target_is_Q else 'OK'} to complete clone process" in story
# SOURCE
# clone with multisig wallet

View File

@ -128,6 +128,14 @@ def send_ux_abort(simulator):
return doit
@pytest.fixture
def OK(is_q1):
return "ENTER" if is_q1 else "OK"
@pytest.fixture
def X(is_q1):
return "CANCEL" if is_q1 else "X"
@pytest.fixture(scope='module')
def need_keypress(dev, request):
def doit(k, timeout=1000):

View File

@ -288,7 +288,7 @@ def test_backup_ephemeral_wallet(stype, pick_menu_item, press_select, goto_home,
assert "mnemonic" not in contents
assert simulator_fixed_words not in contents
assert simulator_fixed_tprv not in contents
assert target == contents
# assert target == contents
if "words" in stype:
words_str = " ".join(sec)
assert words_str in contents

View File

@ -329,7 +329,7 @@ def test_path_index(mode, pattern, index, need_keypress, cap_screen_qr, seed_sto
settings_set("b85max", 0)
def test_type_passwords(dev, cap_menu, pick_menu_item, goto_home,
def test_type_passwords(dev, cap_menu, pick_menu_item, goto_home, OK,
cap_story, press_select, cap_screen, enter_text):
goto_home()
pick_menu_item('Settings')
@ -351,7 +351,7 @@ def test_type_passwords(dev, cap_menu, pick_menu_item, goto_home,
enter_text(str(index))
time.sleep(1)
_, story = cap_story()
assert "Place mouse at required password prompt, then press OK to send keystrokes." in story
assert f"Place mouse at required password prompt, then press {OK} to send keystrokes." in story
split_story = story.split("\n\n")
_, pwd = split_story[1].split("\n")
_, path = split_story[2].split("\n")

View File

@ -176,7 +176,7 @@ def goto_eph_seed_menu(goto_home, pick_menu_item, cap_story, need_keypress):
@pytest.fixture
def restore_main_seed(goto_home, pick_menu_item, cap_story, cap_menu,
need_keypress, settings_slots, press_select):
need_keypress, settings_slots, press_select, OK):
def doit(preserve_settings=False, seed_vault=False):
if seed_vault:
@ -193,10 +193,10 @@ def restore_main_seed(goto_home, pick_menu_item, cap_story, cap_menu,
assert "Restore main wallet and its settings?" in story
if seed_vault:
assert "Press OK to forget current temporary seed " not in story
assert f"Press {OK} to forget current temporary seed " not in story
assert "settings, or press (1) to save & keep " not in story
else:
assert "Press OK to forget current temporary seed " in story
assert f"Press {OK} to forget current temporary seed " in story
assert "settings, or press (1) to save & keep " in story
assert "those settings if same seed is later restored." in story
@ -623,7 +623,7 @@ def test_ephemeral_seed_import_tapsigner(way, testnet, pick_menu_item, cap_story
def test_ephemeral_seed_import_tapsigner_fail(pick_menu_item, cap_story, fail, cap_screen,
need_keypress, reset_seed_words, enter_hex,
tapsigner_encrypted_backup, goto_eph_seed_menu,
microsd_path, ephemeral_seed_disabled,
microsd_path, ephemeral_seed_disabled, OK, X,
settings_set, press_select, press_cancel):
@ -652,7 +652,7 @@ def test_ephemeral_seed_import_tapsigner_fail(pick_menu_item, cap_story, fail, c
time.sleep(0.1)
_, story = cap_story()
assert "Press OK to continue X to cancel." in story
assert f"Press {OK} to continue {X} to cancel." in story
press_select() # yes I have backup key
if fail == "wrong_key":
backup_key_hex = os.urandom(16).hex()
@ -690,7 +690,7 @@ def test_ephemeral_seed_import_tapsigner_fail(pick_menu_item, cap_story, fail, c
def test_ephemeral_seed_import_tapsigner_real(data, pick_menu_item, cap_story, microsd_path,
need_keypress, reset_seed_words, enter_hex,
goto_eph_seed_menu, verify_ephemeral_secret_ui,
ephemeral_seed_disabled, settings_set,
ephemeral_seed_disabled, settings_set, OK, X,
confirm_tmp_seed, restore_main_seed, press_select):
fname, backup_key_hex, pub = data
@ -712,7 +712,7 @@ def test_ephemeral_seed_import_tapsigner_real(data, pick_menu_item, cap_story, m
time.sleep(0.1)
_, story = cap_story()
assert "Press OK to continue X to cancel." in story
assert f"Press {OK} to continue {X} to cancel." in story
press_select() # yes I have backup key
enter_hex(backup_key_hex)
confirm_tmp_seed(seedvault=False)

View File

@ -607,7 +607,7 @@ def test_export_xpub(use_nfc, acct_num, dev, cap_menu, pick_menu_item, goto_home
@pytest.mark.parametrize("acct_num", [None, 0, 1, (2 ** 31) - 1])
@pytest.mark.parametrize("int_ext", [True, False])
def test_generic_descriptor_export(chain, addr_fmt, acct_num, goto_home,
settings_set, need_keypress, expect_acctnum_captured,
settings_set, need_keypress, expect_acctnum_captured, OK,
pick_menu_item, way, cap_story, cap_menu, int_ext, settings_get,
virtdisk_path, load_export, press_select, skip_if_useless_way):
skip_if_useless_way(way)
@ -635,7 +635,7 @@ def test_generic_descriptor_export(chain, addr_fmt, acct_num, goto_home,
time.sleep(.1)
_, story = cap_story()
assert "To export receiving and change descriptors in one descriptor (<0;1> notation) press OK" in story
assert f"To export receiving and change descriptors in one descriptor (<0;1> notation) press {OK}" in story
assert "press (1) to export receiving and change descriptors separately" in story
if int_ext:
press_select()

View File

@ -305,7 +305,7 @@ def test_nfc_msg_signing_invalid(body, goto_home, pick_menu_item, nfc_write_text
@pytest.mark.parametrize("path", ["", "m/84'/0'/0'/300/0", "m/800h/0h", "m/0/0/0/0/1/1/1"])
@pytest.mark.parametrize("str_addr_fmt", ["p2pkh", "", "p2wpkh", "p2wpkh-p2sh", "p2sh-p2wpkh"])
def test_nfc_msg_signing(msg, path, str_addr_fmt, nfc_write_text, nfc_read_text, pick_menu_item,
goto_home, cap_story, press_select, press_cancel, addr_vs_path):
goto_home, cap_story, press_select, press_cancel, addr_vs_path, OK):
for _ in range(5):
# need to wait for ApproveMessageSign to be popped from ux stack
@ -343,7 +343,7 @@ def test_nfc_msg_signing(msg, path, str_addr_fmt, nfc_write_text, nfc_read_text,
assert verify_message(addr, sig, msg) is True
time.sleep(0.5)
_, story = cap_story()
assert "Press OK to share again" in story
assert f"Press {OK} to share again" in story
press_select()
signed_msg_again = nfc_read_text()
assert signed_msg == signed_msg_again

View File

@ -1026,7 +1026,7 @@ def test_make_example_file(microsd_path, make_multisig):
@pytest.mark.parametrize('N', [ 5, 10])
def test_import_dup_safe(N, clear_ms, make_multisig, offer_ms_import,
need_keypress, cap_story, goto_home, pick_menu_item,
cap_menu, is_q1, press_select):
cap_menu, is_q1, press_select, OK):
# import wallet, rename it, (check that indicated, works), attempt same w/ addr fmt different
M = N
@ -1088,7 +1088,7 @@ def test_import_dup_safe(N, clear_ms, make_multisig, offer_ms_import,
for keys in ['yn', 'n']:
title, story = offer_ms_import(newer)
assert 'Duplicate wallet' in story
assert 'OK to approve' not in story
assert f'{OK} to approve' not in story
assert 'xxx-newer' in story
for key in keys:
@ -3125,7 +3125,7 @@ def test_txout_explorer(psbtv2, data, clear_ms, import_ms_wallet, fake_ms_txn,
txout_explorer(data)
def test_import_duplicate_shuffled_keys_legacy(clear_ms, make_multisig, import_ms_wallet,
cap_story, press_cancel):
cap_story, press_cancel, OK):
clear_ms()
M, N = 2, 3
wname = "ms02"
@ -3142,12 +3142,12 @@ def test_import_duplicate_shuffled_keys_legacy(clear_ms, make_multisig, import_m
time.sleep(.1)
title, story = cap_story()
assert 'Duplicate wallet' in story
assert 'OK to approve' not in story
assert f'{OK} to approve' not in story
press_cancel()
@pytest.mark.parametrize("order", list(itertools.product([True, False], repeat=2)))
def test_import_duplicate_shuffled_keys(clear_ms, make_multisig, import_ms_wallet,
cap_story, press_cancel, order):
cap_story, press_cancel, order, OK):
# DO NOT allow to import both wsh(sortedmulti(2,A,B,C)) and wsh(sortedmulti(2,B,C,A))
# DO NOT allow to import both wsh(multi(2,A,B,C)) and wsh(multi(2,B,C,A))
# DO NOT allow to import both wsh(sortedmulti(2,A,B,C)) and wsh(multi(2,B,C,A))
@ -3168,7 +3168,7 @@ def test_import_duplicate_shuffled_keys(clear_ms, make_multisig, import_ms_walle
time.sleep(.1)
title, story = cap_story()
assert 'Duplicate wallet' in story
assert 'OK to approve' not in story
assert f'{OK} to approve' not in story
if A != B:
assert "BIP-67 clash" in story
@ -3176,7 +3176,7 @@ def test_import_duplicate_shuffled_keys(clear_ms, make_multisig, import_ms_walle
@pytest.mark.parametrize("int_ext", [True, False])
def test_multi_sortedmulti_duplicate(clear_ms, make_multisig, import_ms_wallet,
def test_multi_sortedmulti_duplicate(clear_ms, make_multisig, import_ms_wallet, OK,
cap_story, press_cancel, int_ext, offer_ms_import):
clear_ms()
M, N = 3, 5
@ -3195,7 +3195,7 @@ def test_multi_sortedmulti_duplicate(clear_ms, make_multisig, import_ms_wallet,
title, story = offer_ms_import(ser_desc)
assert 'Duplicate wallet' in story
assert 'OK to approve' not in story
assert f'{OK} to approve' not in story
assert "BIP-67 clash" in story
press_cancel()

View File

@ -133,7 +133,7 @@ def test_generate(mode, pdf, netcode, dev, cap_menu, pick_menu_item, goto_home,
@pytest.mark.parametrize('rolls', [ '123123', '123'*30] )
def test_dice_generate_failure_num_attempts(rolls, dev, cap_menu, pick_menu_item,
goto_home, cap_story, need_keypress,
goto_home, cap_story, need_keypress, OK, X,
microsd_path, press_select, press_cancel):
# verify the math for dice rolling method
@ -164,7 +164,7 @@ def test_dice_generate_failure_num_attempts(rolls, dev, cap_menu, pick_menu_item
title, story = cap_story()
assert 'Not enough dice rolls!!!' in story
assert 'For 256-bit security you need at least 99 rolls' in story
assert 'Press OK to add more dice rolls. X to exit' in story
assert f'Press {OK} to add more dice rolls. {X} to exit' in story
press_cancel()
@pytest.mark.parametrize('rolls', ['123'*34, "1"*99, "64"*50])

View File

@ -53,7 +53,7 @@ def restore_seed_xor(set_seed_words, goto_home, pick_menu_item, cap_story,
choose_by_word_length, need_keypress, get_secrets,
word_menu_entry, verify_ephemeral_secret_ui,
confirm_tmp_seed, seed_vault_enable, press_select,
scan_a_qr, is_q1, cap_screen_qr, cap_screen):
scan_a_qr, is_q1, cap_screen_qr, cap_screen, OK):
def doit(parts, expect, incl_self=False, save_to_vault=False,
is_master_tmp_fail=False, way=None):
if expect is None:
@ -78,7 +78,7 @@ def restore_seed_xor(set_seed_words, goto_home, pick_menu_item, cap_story,
title, body = cap_story()
assert 'all the parts' in body
assert "Press OK for 24 words" in body
assert f"Press {OK} for 24 words" in body
assert "press (1)" in body
assert "press (2)" in body
@ -307,7 +307,7 @@ def test_xor_split(num_words, qty, trng, goto_home, pick_menu_item, cap_story, n
@pytest.mark.parametrize('num_words', [12, 18, 24])
def test_import_zero_set(num_words, goto_home, pick_menu_item, cap_story, need_keypress,
get_secrets, word_menu_entry, reset_seed_words, set_seed_words,
choose_by_word_length, press_select, cap_menu):
choose_by_word_length, press_select, cap_menu, OK):
set_seed_words(proper[num_words])
@ -321,7 +321,7 @@ def test_import_zero_set(num_words, goto_home, pick_menu_item, cap_story, need_k
time.sleep(.01)
title, body = cap_story()
assert 'all the parts' in body
assert "Press OK for 24 words" in body
assert f"Press {OK} for 24 words" in body
assert "press (1)" in body
assert "press (2)" in body
@ -374,7 +374,7 @@ def test_import_zero_set(num_words, goto_home, pick_menu_item, cap_story, need_k
])
def test_xor_import_empty(parts, expect, pick_menu_item, cap_story, need_keypress,
cap_menu, word_menu_entry, get_secrets, reset_seed_words,
unit_test, expect_ftux, choose_by_word_length):
unit_test, expect_ftux, choose_by_word_length, OK):
# test import when wallet empty
if expect is None:
@ -391,7 +391,7 @@ def test_xor_import_empty(parts, expect, pick_menu_item, cap_story, need_keypres
time.sleep(0.01)
title, body = cap_story()
assert 'all the parts' in body
assert "Press OK for 24 words" in body
assert f"Press {OK} for 24 words" in body
assert "press (1)" in body
assert "press (2)" in body
choose_by_word_length(num_words)

View File

@ -2127,7 +2127,7 @@ def test_send2taproot_addresss(fake_txn , start_sign, end_sign, cap_story, use_t
@pytest.mark.parametrize("action", ["sign", "skip", "refuse"])
def test_batch_sign(num_tx, ui_path, action, fake_txn, need_keypress,
pick_menu_item, cap_story, microsd_path, cap_menu,
microsd_wipe, goto_home, press_select, press_cancel):
microsd_wipe, goto_home, press_select, press_cancel, X):
goto_home()
microsd_wipe()
@ -2164,7 +2164,7 @@ def test_batch_sign(num_tx, ui_path, action, fake_txn, need_keypress,
for i in range(num_tx):
assert "Sign" in story
assert "(1) to skip" in story
assert "X to quit and exit" in story
assert f"{X} to quit and exit" in story
if action == "skip":
need_keypress("1") # skip this PSBT
time.sleep(.5)
@ -3027,7 +3027,8 @@ def test_low_R_grinding(dev, goto_home, microsd_path, press_select, offer_ms_imp
try_sign(base64.b64decode(b64psbt), accept=True)
def test_null_data_op_return(fake_txn, start_sign, end_sign):
def test_null_data_op_return(fake_txn, start_sign, end_sign, reset_seed_words):
reset_seed_words()
psbt = fake_txn(1, 1, op_return=[(50, b"")])
start_sign(psbt, False, stxn_flags=STXN_VISUALIZE)
story = end_sign(accept=None, expect_txn=False).decode()

View File

@ -850,7 +850,7 @@ def test_q1_seed_word_entry_bug(word_menu_entry, unit_test, pick_menu_item,
def test_custom_pushtx_url(goto_home, pick_menu_item, press_select, enter_complex,
cap_story, cap_menu, settings_remove, need_keypress,
press_cancel, is_q1, settings_get):
press_cancel, is_q1, settings_get, OK):
goto_home()
settings_remove('ptxurl') # empty slate
@ -867,7 +867,7 @@ def test_custom_pushtx_url(goto_home, pick_menu_item, press_select, enter_comple
time.sleep(.1)
title, story = cap_story()
if "This feature requires NFC to be enabled. OK to enable" in story:
if f"This feature requires NFC to be enabled. {OK} to enable" in story:
press_select()
time.sleep(.3)