Skip to content

fix(scanner_ws_parse): flatten block arm so llvm-cov tracks line 37 - #91

Merged
TaprootFreak merged 1 commit into
developfrom
fix/scanner-ws-parse-coverage
May 23, 2026
Merged

fix(scanner_ws_parse): flatten block arm so llvm-cov tracks line 37#91
TaprootFreak merged 1 commit into
developfrom
fix/scanner-ws-parse-coverage

Conversation

@TaprootFreak

Copy link
Copy Markdown
Contributor

Problem

PR #87 (event-driven scanner) merged into develop with a Coverage Gate FAILURE: server/src/scanner_ws_parse.rs:37 is reported as uncovered by llvm-cov despite parse_ws_frame_returns_empty_when_block_id_is_invalid_hex exercising that exact path in local cargo test.

Root cause: the nested if let Some(block) { if let Some(hash) { if let Ok(h) = BlockHash::from_str(hash) { ... } } } shape produces a closing-brace region at line 37 that llvm-cov reports as an untaken region, even though every reachable input either short-circuits earlier or returns on the inner success arm. This is an llvm-cov region-tracking quirk with nested if let, not a real coverage hole.

Consequence: every PR based on develop now inherits a red Coverage Gate. This is currently blocking:

Fix

Flatten the block arm to a single Option chain. Behavior is byte-identical across every input shape the existing 6 tests cover; only LLVM's region tracking changes (the closing-brace region at line 37 no longer exists as a distinct sub-region).

// before
if let Some(block) = value.get("block") {
    if let Some(hash) = block.get("id").and_then(|v| v.as_str()) {
        if let Ok(h) = BlockHash::from_str(hash) {
            return vec![h];
        }
    }
    return Vec::new();
}

// after
if let Some(block) = value.get("block") {
    return block
        .get("id")
        .and_then(|v| v.as_str())
        .and_then(|s| BlockHash::from_str(s).ok())
        .map(|h| vec![h])
        .unwrap_or_default();
}

The blocks arm and frame_signals_tx_seen are untouched. No new tests needed — the existing 6 tests cover every input shape (valid hex, invalid hex via "not-a-real-hash" and "zzzz", missing id, non-string id, array shape, malformed JSON, unknown shapes).

Test plan

PR #87 merged with the nested `if let Some(block) { if let Some(hash)
{ if let Ok(h) = BlockHash::from_str(hash) { ... } } }` shape. The
closing brace at line 37 (the path where `block.id` is a string but
not a valid hex) reads as covered by the
`parse_ws_frame_returns_empty_when_block_id_is_invalid_hex` test in
local `cargo test`, but llvm-cov's region tracking reports the
closing-brace region as untaken — the Coverage Gate flags
`server/src/scanner_ws_parse.rs:37` as the only uncovered line.

Flatten the block arm to a single Option chain
(`block.get("id").and_then(...).and_then(...).map(...).unwrap_or_default()`).
Behavior is identical across every input shape the existing tests
cover; LLVM's region tracking collapses cleanly because the closing
brace no longer exists as a distinct sub-region.

Affects PR #18 (Release: develop -> main) and any open PR based on
develop (e.g. #90).
@TaprootFreak TaprootFreak added the ci:full Trigger heavy CI jobs (Server + Shared Tests + Coverage Gate, ~60-90 min on M3 Ultra) label May 23, 2026
@TaprootFreak
TaprootFreak marked this pull request as ready for review May 23, 2026 19:25
@TaprootFreak
TaprootFreak merged commit 0ed6de8 into develop May 23, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Trigger heavy CI jobs (Server + Shared Tests + Coverage Gate, ~60-90 min on M3 Ultra)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mint state-desync class: num_pubkeys advances past on-chain commitments after absorbed publisher errors

1 participant