add real GetResults coverage for swarm store, drop the inert found check - #381
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.