Skip to content

add real GetResults coverage for swarm store, drop the inert found check - #381

Merged
gerardrecinto merged 1 commit into
masterfrom
add-swarm-store-tests-and-drop-dead-check
Sep 20, 2026
Merged

gerardrecinto merged 1 commit into
masterfrom
add-swarm-store-tests-and-drop-dead-check

Conversation

@gerardrecinto

Copy link
Copy Markdown
Collaborator

staticcheck SA4006 flagged the found value in swarm/store.go's GetResults as a dead store. Reading it, the if !found block right after it was comments only, no actual handling, and the author's own comment admitted the uncertainty directly ('For now, let's assume standard SOP behavior...').

swarm/store.go had zero tests at all before this. Before touching anything, wrote 3 real tests against the actual storage engine, not a mock: an empty store, a jobID that sorts past every key already in the tree (the case most likely to expose a stale-cursor bug if the found flag genuinely mattered), and a positive multi-result case. All three passed against the code exactly as it already was, confirming the prefix-check loop right after Find is a correct and sufficient guard on its own, independent of found.

Removed the dead if-block and replaced the uncertain comment with what's now verified fact instead of a guess. Build+vet+gofmt+test clean.

staticcheck SA4006 flagged found in GetResults as a dead store, the
if !found block right after it was comments only, no actual handling.
zero tests existed for this file at all, so before touching anything
wrote 3 tests against the real storage engine, not a mock: empty
store, a jobID that sorts past every key already in the tree (the
case most likely to expose a stale-cursor bug if found actually
mattered), and a real multi-result positive case. all three passed
against the code exactly as it was, confirming the prefix-check loop
right after Find is a correct, sufficient guard on its own regardless
of the found flag. removed the dead if-block, replaced the author's
own uncertain comment ('for now, let's assume...') with what's now
verified fact.
@gerardrecinto
gerardrecinto merged commit 39b66f7 into master Sep 20, 2026
20 of 21 checks passed
@gerardrecinto
gerardrecinto deleted the add-swarm-store-tests-and-drop-dead-check branch September 20, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant