Commit fa7c55a
committed
test(dylib): screenshot regression for ringbuf capacity + canvas semantics
The existing test_dylib_confirm_flow covers the caller-driven polling
contract — Initialize / Wipe / LoadDevice / GetAddress — but never asks
the firmware for a layout. Two changes that just landed in the firmware
emulator runtime PR (BitHighlander/keepkey-firmware#217) need functional
coverage that confirm-flow doesn't provide:
1. RINGBUF_CAPACITY in lib/emulator/ringbuf.h was bumped from 32 to
128. DebugLinkState's 2048-byte `layout` plus the rest of the message
serializes to ~44 HID reports through the output ring; the previous
capacity left effective room for 31 reports, so screenshot capture
truncated mid-layout (msg_debug_write ignores emulatorSocketWrite's
0-on-full return).
2. fsm_msgDebugLinkGetState in lib/firmware/fsm_msg_debug.h now does a
single display_refresh() instead of force_animation_start() +
animate(). The old form overwrote static layouts with stale animation
frames or no-ops depending on queue state, so screenshots captured
something different from what the user was seeing.
Both fixes are functionally invisible to the existing test suite. Without
these tests, regressing either change ships green.
This commit adds:
- tests/test_dylib_screenshot.py — four tests:
* test_layout_round_trip_fits_through_ring (RINGBUF_CAPACITY)
* test_layout_repeated_reads_no_truncation (RINGBUF_CAPACITY)
* test_layout_stable_across_idle_reads (canvas semantics)
* test_layout_features_dont_corrupt_capture (iface separation)
Constructs a fresh KeepKeyDebuglinkClient against the dylib singleton
WITHOUT going through common.KeepKeyTest.setUp — that fixture wipes the
device on every test and exercises the confirm-flow path that
test_dylib_confirm_flow is itself a pending regression for. Reading a
layout doesn't require any of that; we just init and ask DebugLink for
the home-screen capture.
- tests/config.py — explicit-transport precedence fix:
Previously HID/WebUSB were always autodetected first. With a real
KeepKey plugged in, KK_TRANSPORT=dylib was silently overridden — the
dylib regression suite would either route to hardware or crash on
hid.pyx. Now the explicit env var (KK_TRANSPORT=dylib) skips hardware
enumeration entirely, the dylib path runs as requested, and the default
(no env var set) falls back to the existing UDP behavior.
Verified locally:
cmake -DKK_EMULATOR=1 -DKK_BUILD_DYLIB=1 -DKK_DEBUG_LINK=ON \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 -B build-emu .
cmake --build build-emu --target kkemulator_dylib
KK_TRANSPORT=dylib KK_DYLIB=build-emu/lib/libkkemu.dylib \
PYTHONPATH=keepkeylib:. python -m pytest tests/test_dylib_screenshot.py
======================== 4 passed in 0.36s ========================
Out of scope: SignTx + other multi-step flows that go through
confirm_helper. They share the same hang as test_dylib_confirm_flow's
test_load_device_with_auto_confirm — copying the pattern would just
produce a second red regression for the same underlying firmware bug,
not new coverage. Once the confirm-flow regression goes green, signtx
expansion is a follow-up.1 parent ebc0db7 commit fa7c55a
2 files changed
Lines changed: 175 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
38 | 36 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 37 | + | |
| 38 | + | |
44 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
45 | 54 | | |
46 | 55 | | |
47 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
0 commit comments