From 8c553b162aebefd61a143412566c49af69836cbf Mon Sep 17 00:00:00 2001 From: Vijit Singh Date: Wed, 22 Jul 2026 18:16:51 -0500 Subject: [PATCH 1/4] fix(e2e): ground-truth pool verdict + earned Tari lag tolerance (#746) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two Tor-timing flakes hit 2 of 4 runs during the v1.12.0 cut; neither was a code defect (same ref passed 374/0 and 380/0 on the clean runs): - pool type: after a sidechain switch the dashboard's peer-port classifier can keep reporting the PRE-switch pool — determinate, wrong, and transient — and both assert_scenario and assert_pool_switched hard-failed it as a "render bug". New shared assert_pool_type consults the ground truth the harness never checked: the rendered P2POOL_FLAGS (--mini/--nano; main carries neither). Correct flags -> classifier-lag WARN (same class as Unknown, #454/#687); wrong flags -> FAIL. The mismatch path now verifies actual flags, so the check is stronger than before, not looser. - tari synced (required): every per-scenario restart sends Tari back through "discovering the target height" ('loading'), which can outlast wait_tari_synced over Tor; the bare assert_eq then fired on an in-progress state — the same cold-read anti-pattern the #687 comment describes. New assert_tari_synced_required earns its tolerance: "done" passes and records TARI_SEEN_DONE; loading/syncing AFTER that proof warns as re-discovery lag; a Tari that never syncs still fails the gate. Both helpers live in lib.sh so the selftest covers every branch (stubbed emitters; 148/0): flags ground truth per pool, all four pool verdicts, and the earned-tolerance matrix including first-look-loading -> FAIL. Co-Authored-By: Claude Opus 4.8 --- tests/integration/lib.sh | 65 +++++++++++++++++++++++++++-------- tests/integration/run.sh | 27 +++++---------- tests/integration/selftest.sh | 54 +++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 32 deletions(-) diff --git a/tests/integration/lib.sh b/tests/integration/lib.sh index c5f34055..a218276b 100644 --- a/tests/integration/lib.sh +++ b/tests/integration/lib.sh @@ -478,23 +478,60 @@ wait_monero_synced() { wait_for "${1:-300}" 10 "Monero sync complete" _pred_mone wait_miner_running() { wait_for "${1:-180}" 5 "miner released" _pred_miner_running; } wait_tari_synced() { wait_for "${1:-300}" 10 "Tari sync complete" _pred_tari_synced; } wait_pool_ready() { wait_for "${1:-180}" 5 "pool type determinate (${2})" _pred_pool_ready "$2"; } -# Assert a pool switch settled, WITHOUT flaking red on peer luck (#687). p2pool infers its sidechain -# from connected peers' ports, so a freshly-switched chain (nano over Tor is the slowest to populate) -# can read "Unknown" past the wait window. A bare assert_eq after `wait_pool_ready … || true` then -# fires cold and fails on a timing state, not a bug. Three-way verdict, same as assert_scenario's -# #454 handling: determinate match → pass; still Unknown/empty → peer-timing WARN; a WRONG determinate -# type (Main when we set Mini) → fail. The 420s window is Tor-realistic; the wait polls, so a fast -# bench that classifies in seconds pays nothing. + +# Ground truth for the sidechain axis (#746): the rendered P2POOL_FLAGS in the box's .env carry +# --mini / --nano (main carries neither). The dashboard classifies the sidechain by counting +# connected peers' ports, so right after a pool SWITCH p2pool runs the NEW flags while the +# classifier can still report the OLD sidechain until enough new-chain peers connect over Tor — +# determinate, wrong, and transient. The flags tell a real render bug apart from that lag. +pool_flags_correct() { # + local flags + flags="$(rx "grep -E '^P2POOL_FLAGS=' .env 2>/dev/null | head -n1 | cut -d= -f2-")" + case "$1" in + Mini) [[ "$flags" == *"--mini"* ]] ;; + Nano) [[ "$flags" == *"--nano"* ]] ;; + *) [[ "$flags" != *"--mini"* && "$flags" != *"--nano"* ]] ;; + esac +} + +# Shared pool-type verdict (#454/#687/#746), used by assert_scenario and assert_pool_switched: +# determinate match → pass; Unknown/empty → peer-timing WARN (nano/Tor is slow to populate); +# determinate-but-wrong with CORRECT P2POOL_FLAGS → classifier-lag WARN (#746, the post-switch +# stale read); wrong type AND wrong flags → a real config/render bug → FAIL. The mismatch path +# now checks the actual flags, so this is a stronger check than the old hard-fail, not a looser one. +assert_pool_type() { #