From bc8fa0b83cc3eb1231736c64a8e776da7364f14e Mon Sep 17 00:00:00 2001 From: scgbckbone Date: Tue, 13 Feb 2024 08:36:10 +0100 Subject: [PATCH] better --eject implementation via fixture --- testing/conftest.py | 11 +++++++++++ testing/test_vdisk.py | 3 ++- unix/sim_boot.py | 10 ---------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/testing/conftest.py b/testing/conftest.py index 748e9825..d3f5af65 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -2019,6 +2019,17 @@ def seed_story_to_words(): return doit +@pytest.fixture +def sd_cards_eject(is_q1, sim_exec): + def doit(slot_a=1, slot_b=1): + cmd = (f'from machine import Pin;' + f'import files;' + f'files.CardSlot.sd_detect = Pin("SD_DETECT",value={slot_a});') + if is_q1: + cmd += f'files.CardSlot.sd_detect2 = Pin("SD_DETECT2",value={slot_b});' + assert sim_exec(cmd) == '' + return doit + # useful fixtures from test_backup import backup_system diff --git a/testing/test_vdisk.py b/testing/test_vdisk.py index 921247ee..3ba125c4 100644 --- a/testing/test_vdisk.py +++ b/testing/test_vdisk.py @@ -175,8 +175,9 @@ def try_sign_virtdisk(press_select, virtdisk_path, cap_story, virtdisk_wipe, pre @pytest.mark.parametrize('encoding', ['binary', 'hex', 'base64']) @pytest.mark.parametrize('num_outs', [1,2]) @pytest.mark.parametrize('partial', [1, 0]) -def test_virtdisk_signing(encoding, num_outs, partial, try_sign_virtdisk, fake_txn, dev): +def test_virtdisk_signing(encoding, num_outs, partial, try_sign_virtdisk, fake_txn, dev, sd_cards_eject): xp = dev.master_xpub + sd_cards_eject() def hack(psbt): if partial: diff --git a/unix/sim_boot.py b/unix/sim_boot.py index 06ac3b9e..7b1e07ee 100644 --- a/unix/sim_boot.py +++ b/unix/sim_boot.py @@ -30,16 +30,6 @@ if '--sflash' not in sys.argv: #glob.settings.current = dict(sim_defaults) -if '--eject' in sys.argv: - is_ejected = True - class SimulatedCardSlot(files.CardSlot): - def is_inserted(cls): - # debounce? - global is_ejected - return not is_ejected - - files.CardSlot = SimulatedCardSlot - # Install various hacks and workarounds import mk4 import sim_mk4