← Back to Pull requests

htlcswitch: fail fast when hodl tests run without the dev tag #11623

Merged
Roasbeef merged 2 files (29 lines) on Nov 25, 2026 01:32 UTC
View on GitHub
Roasbeef Roasbeef commented on Nov 24, 2026 22:54 UTC
Author

Running go test ./htlcswitch/ without -tags=dev produces a misleading failure. The production hodl.Mask never reports a flag as active, so tests that set HodlMask don't fail where the problem is. TestSwitchDustForwarding, for example, waits about 20 seconds and then reports got totalDust=0 mSAT, expectedDust=70000000 mSAT ... timeout checking dust. That looks like a product bug, but nothing is wrong with the product code. The tests need the dev tag, which make unit and CI always set.

In this PR, we add a small requireDevBuild test helper that calls t.Fatalf with a message saying the test depends on hodl flags and must be run with -tags=dev. It replaces the two inline build.IsDevBuild() checks in link_test.go, one of which had an unbalanced quote in its message. It is also added to the three other tests that set a hodl mask: TestSwitchDustForwarding, TestChannelLinkCleanupSpuriousResponses and TestPipelineSettle.

The helper fails the test instead of skipping it, so a missing tag can't turn into a silently passing run. Behavior with -tags=dev is unchanged.

Verified: untagged runs of the five guarded tests now fail in under a millisecond with the explanation; go test -tags=dev ./htlcswitch/ -count=1 passes (108s); -run 'TestSwitchDustForwarding$' -count=3 passes; gofmt and go vet (tagged and untagged) are clean.

Test-only change, so no release note.

Diff: 29 lines (+23 / -6) across 2 files Reviewer: Roasbeef Review duration: 158m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.56)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 29 lines diff across 2 files
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.35 · 1 substantive comment(s)
0.35
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.203
Self Review self_review
0.140
Real PR Conversation Timeline
2 items
Roasbeef Roasbeef commented on Nov 25, 2026 01:20 UTC
Reviewer

LGTM. I verified the thing that matters for this change — that the sweep is actually complete — and it is.

I enumerated every test in htlcswitch that touches a hodl mask or hodl flags on your head (72fe529474):

  • TestChannelLinkBandwidthConsistency — HodlMask at 2514, guarded

  • TestChannelLinkTrimCircuitsNoCommit — HodlMask at 3294 plus hodl.Commit passed through alice.restart(...) at 3372/3406/3474, guarded

  • TestChannelLinkCleanupSpuriousResponses — HodlMask at 5538, guarded

  • TestPipelineSettle — HodlMask at 7579, guarded

  • TestSwitchDustForwarding — guarded
  • The only other HodlMask assignment is at 4963 inside persistentLinkHarness.restartLink, which is a helper taking hodlFlags []hodl.Flag; the only call site that passes real flags (4795) is reached from TestChannelLinkTrimCircuitsNoCommit, which is guarded. So no unguarded test in either file depends on the mask being live.

    That also matches what I found empirically when this flake bit me: go test ./htlcswitch/ without tags fails TestSwitchDustForwarding in ~20s with got totalDust=0 mSAT, expectedDust=70000000 mSAT ... timeout checking dust, and -tags=dev passes in ~6s. The failure is a silent no-op mask plus a downstream timeout, which is exactly what a fail-fast message fixes.

    Two small notes, neither blocking:

  • The message says "must be run with '-tags=dev'" — worth adding "or via make unit, which sets it" inline, since that is the common path and someone hitting this locally will otherwise assume they need to remember the flag rather than just use the make target.

  • You replaced two existing t.Fatalf("htlcswitch tests must be run with '-tags dev") calls with the helper. Good — the old ones had an unclosed quote, and centralising means the next hodl-dependent test gets the message for free.
  • I could not find anything to object to. Shipping this would have saved me an hour I spent chasing the dust test as a regression before you identified it as a build-tag artifact.

    Reviewers
    Assignees
    Roasbeef Roasbeef
    Labels
    risk: low confidence: 56.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 38.8% (MEDIUM) · Higher = larger blast radius
    38.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.2% · Lower = rushed or shallow review
    56.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.0% · Safe to merge
    17.0%