def test_import_xor(incl_self, parts, expect, goto_home, pick_menu_item, cap_story, need_keypress, cap_menu, word_menu_entry, get_secrets, reset_seed_words, set_seed_words): # values from docs/seed-xor.md, and some easy cases if incl_self: set_seed_words(parts[0]) goto_home() pick_menu_item('Advanced') pick_menu_item('Danger Zone') pick_menu_item('Seed Functions') pick_menu_item('Seed XOR') pick_menu_item('Restore Seed XOR') time.sleep(.01) title, body = cap_story() assert 'all the parts' in body need_keypress('y') time.sleep(0.01) title, body = cap_story() assert 'you have a seed already' in body assert '(1) to include this Coldcard' in body if incl_self: need_keypress('1') else: need_keypress('y') #time.sleep(0.01) for n, part in enumerate(parts): if n == 0 and incl_self: continue word_menu_entry(part.split()) time.sleep(0.01) title, body = cap_story() assert f"You've entered {n} parts so far" assert "or (2) if done" if n != len(parts) - 1: need_keypress('1') else: # correct anticipated checksum word chk_word = expect.split()[-1] assert f"24: {chk_word}" in body if expect == zero32: assert 'ZERO WARNING' in body need_keypress('2') time.sleep(0.01) title, body = cap_story() assert 'New master key in effect' in body assert get_secrets()['mnemonic'] == expect reset_seed_words()
def test_xor_import_empty(parts, expect, goto_home, pick_menu_item, cap_story, need_keypress, cap_menu, word_menu_entry, get_secrets, reset_seed_words, unit_test): # test import when wallet empty unit_test('devtest/clear_seed.py') m = cap_menu() assert m[0] == 'New Wallet' pick_menu_item('Import Existing') pick_menu_item('Seed XOR') time.sleep(0.01) title, body = cap_story() assert 'all the parts' in body need_keypress('y') time.sleep(0.01) for n, part in enumerate(parts): word_menu_entry(part.split()) time.sleep(0.01) title, body = cap_story() assert f"You've entered {n} parts so far" assert "or (2) if done" if n != len(parts) - 1: assert 'ZERO WARNING' not in body need_keypress('1') else: # correct anticipated checksum word chk_word = expect.split()[-1] assert f"24: {chk_word}" in body if expect == zero32: assert 'ZERO WARNING' in body # install seed ... causes reset on real device need_keypress('2') time.sleep(0.01) title, body = cap_story() assert 'New master key in effect' not in body assert body == '' # main menu should be "ready to sign" now assert cap_menu()[0] == 'Ready To Sign' assert get_secrets()['mnemonic'] == expect reset_seed_words()
def test_import_zero_set(goto_home, pick_menu_item, cap_story, need_keypress, cap_menu, word_menu_entry, get_secrets, reset_seed_words, set_seed_words): # look for a warning goto_home() pick_menu_item('Advanced') pick_menu_item('Danger Zone') pick_menu_item('Seed Functions') pick_menu_item('Seed XOR') pick_menu_item('Restore Seed XOR') time.sleep(.01) title, body = cap_story() assert 'all the parts' in body need_keypress('y') time.sleep(0.01) title, body = cap_story() assert 'you have a seed already' in body assert '(1) to include this Coldcard' in body need_keypress('y') #time.sleep(0.01) for n in range(2): word_menu_entry(ones32.split()) time.sleep(0.01) title, body = cap_story() assert f"You've entered {n} parts so far" assert "or (2) if done" if n == 1: assert 'ZERO WARNING' in body return need_keypress('1') raise pytest.fail("reached")
def doit(words): for w in words.split(): pick_menu_item('Add Word') word_menu_entry([w.lower()]) pick_menu_item(w)