bugfix: brick me option for If Wrong PIN lacks num arguemnt which caused yikes

(cherry picked from commit 0c4977af91)
This commit is contained in:
scgbckbone 2024-01-31 11:38:33 +01:00 committed by doc-hex
parent 131c717f0f
commit 9890b0a8b9
3 changed files with 29 additions and 5 deletions

View File

@ -2,6 +2,7 @@
- Bugfix: Saving passphrase on SD Card caused a freeze that required reboot
- Bugfix: Properly handle and finalize framing error response
- Bugfix: `Brick Me` option for `If Wrong` PIN caused yikes
## 5.2.2 - 2023-12-21

View File

@ -633,7 +633,7 @@ setting) the Coldcard will always brick after 13 failed PIN attempts.''')
arg=num, flags=TC_WIPE|TC_REBOOT),
StoryMenuItem('Silent Wipe', "Seed is silently wiped and Coldcard acts as if PIN code was just wrong.",
arg=num, flags=TC_WIPE|TC_FAKE_OUT),
StoryMenuItem('Brick Self', "Become a brick instantly and forever.", flags=TC_BRICK),
StoryMenuItem('Brick Self', "Become a brick instantly and forever.", flags=TC_BRICK, arg=num),
StoryMenuItem('Last Chance', "Wipe seed, then give one more try and then brick if wrong PIN.", arg=num, flags=TC_WIPE|TC_BRICK),
StoryMenuItem('Just Reboot', "Reboot when this happens. Doesn't do anything else.", arg=num, flags=TC_REBOOT),
])

View File

@ -379,10 +379,22 @@ def test_ux_add_simple(new_pin, op_mode, expect, but_dont, xflags,
('Just Reboot', 'Reboot when this ', TC_REBOOT),
])
def test_ux_wrong_pin(num_wrong, op_mode, expect, xflags, enter_number,
cap_menu, pick_menu_item, cap_story, press_cancel,
goto_trick_menu, new_pin_confirmed, press_select, enter_pin):
cap_menu, pick_menu_item, cap_story, goto_trick_menu,
new_pin_confirmed, press_select, enter_pin):
# wrong pin choices, not implementation
goto_trick_menu()
m = cap_menu()
if not ('Add If Wrong' in m):
# already has "if wrong"
pick_menu_item('↳WRONG PIN')
pick_menu_item('Delete Trick')
time.sleep(.1)
_, story = cap_story()
assert "Are you SURE" in story
assert "Remove special handling of wrong PINs?" in story
press_select()
time.sleep(.1)
pick_menu_item('Add If Wrong')
time.sleep(.1)
@ -395,9 +407,12 @@ def test_ux_wrong_pin(num_wrong, op_mode, expect, xflags, enter_number,
time.sleep(.1)
m = cap_menu()
real_num_wrong = num_wrong
if num_wrong <= 1:
real_num_wrong = 1
assert m[0] == '[ANY WRONG PIN]'
elif num_wrong >= 12:
real_num_wrong = 12
assert m[0] == '[12th WRONG PIN]'
else:
assert m[0][0:2] == f'[{num_wrong}'
@ -410,9 +425,17 @@ def test_ux_wrong_pin(num_wrong, op_mode, expect, xflags, enter_number,
assert expect in story
time.sleep(.1)
press_cancel()
press_select()
time.sleep(.1)
press_cancel()
_, story = cap_story()
assert f"{real_num_wrong} Wrong PINs" in story
assert op_mode in story
assert "Ok?" in story
press_select()
time.sleep(.1)
m = cap_menu()
assert 'Add If Wrong' not in m
@pytest.mark.parametrize('subchoice, expect, xflags', [
( 'Wipe & Reboot', 'wiped and Coldcard reboots', TC_WIPE|TC_REBOOT ),