test(node): add unit tests and extract testable seams in NewBee#5471
Draft
martinconic wants to merge 1 commit into
Draft
test(node): add unit tests and extract testable seams in NewBee#5471martinconic wants to merge 1 commit into
martinconic wants to merge 1 commit into
Conversation
7 tasks
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.
Checklist
Description
pkg/node/node.go(theNewBeebootstrap) had almost no test coverage, sochanges to it carried a high risk of silently breaking node startup. This PR
adds unit tests around the parts of
pkg/nodethat can be tested in isolation,and extracts three orchestration blocks from
NewBeebehind smalldependency-injection seams so their gating logic and error paths can be tested
without standing up a real chain backend, libp2p, or disk.
Validators / helpers
validateOptionsextended to coverPaymentThreshold(parse + min/maxrange),
PaymentTolerance,PaymentEarly, andTargetNeighborhood.validateChainContractOptions(o, chainID)covering postage / staking /redistribution contract-address validation, the missing postage start-block
case, and the unknown-chain case.
parsePaymentThresholdshared between validation andNewBee.InitStateStore,InitStamperStore,overlayNonceExists,setOverlay,checkOverlay,InitChain(chain-disabled path), and thefull
Shutdownlifecycle.Orchestration seams
setupSwap,setupPostageContract,setupSwapServiceextracted fromNewBee. Each takes a deps struct wired to the real constructors inproduction (
defaultXxxDeps) and to fakes in tests, enabling table-drivencoverage of every config combination and error path.
Behavior changes
NewBee(at entry / right afterInitChain) rather than mid-startup. Theerror strings themselves are unchanged.
RedistributionContractAddresswithEnableStorageIncentivesdisabled is still silently accepted — preserved deliberately to avoid a
behavior change.
Open API Spec Version Changes (if applicable)
Motivation and Context (Optional)
Related Issue (Optional)
Screenshots (if appropriate):
AI Disclosure