v3.22.4: the proactive-drain pending exemption

The runner's unexpected-pending-command guard fired for any non-expect step,
so a proactive-drain after a step that answered 91XX failed with
"unexpected proactive command pending (SW 91XX) - add an expect step or a
status action" - contradicting the drain's own doc ("consume whatever the
card announces") and the v3.22.2 RAM recipe ("an expect or a proactive-drain").

The guard now exempts a proactive-drain step: its STATUS poll re-announces
the unfetched command, fetches and answers it, and the drain's final-SW and
pending handling is unchanged (a still-pending card is handed to the next
step, an idle card passes).  No pending-length plumbing: STATUS-first keeps
the drain's attempts/log semantics and tolerates a card that dropped the
command.  The guard note now names the drain instead of the misleading
"status action" (a status action in that position also trips the guard).

Docs: the drain section in test-scripts.md, api.md's action list and the
help EN/RU drain bullet.  Tests: 839 frontend + 819 Python; sw cache
simple-v408.
This commit is contained in:
2026-10-06 21:22:22 +03:00
parent 7d997272ef
commit 320854eebc
9 changed files with 46 additions and 10 deletions
+9 -3
View File
@@ -36,7 +36,7 @@ from osmocom.tlv import BER_TLV_IE
from osmocom.utils import rpad
VERSION = '3.22.3'
VERSION = '3.22.4'
MAX_ENVELOPE_SEGMENTS = 5 # max SMS segments for outgoing C-APDU in ENVELOPE
@@ -7089,11 +7089,17 @@ def _test_run_script(server, script, preset, shared=None):
entry = _test_entry(step, index)
with _TEST_LOCK:
_TEST_RUN['steps'].append(entry)
if pending is not None and step['type'] != 'expect':
# A proactive-drain step is the tool that consumes a pending command
# (it polls STATUS - the card re-announces the unfetched command -
# then fetches and answers it), so the guard does not apply to it
# (v3.22.4 review).
drain_next = (step['type'] == 'action'
and step.get('kind') == 'proactive-drain')
if pending is not None and step['type'] != 'expect' and not drain_next:
_test_entry_update(entry, {
'status': 'error',
'note': 'unexpected proactive command pending (SW 91XX) - '
'add an expect step or a status action'})
'add an expect step or a proactive-drain'})
with _CARD_LOCK:
drained = _test_drain_pending(scc, pending)
fields = {k: v for k, v in drained.items() if k != 'note'}