tests: tighten coverage by retiring unreachable defensive code (wave 2)#2
Merged
Conversation
Source changes:
- saveEVMSigner (pkg/evm/key.go): identityFile struct is all strings
— drop the json.MarshalIndent error branch with a comment.
- saveLocalSigner (pkg/wallet/signer.go): identical to above for the
Ed25519 identityFile.
Test additions:
- TestEVMAccessors_WithBinding (pkg/wallet/zz_helpers_test.go): drives
the non-nil-evm branch of EVMAddress / EVMChainID / EVMToken so the
accessors are covered beyond the nil-binding shortcut.
- TestHexHelpers_ErrorPaths (pkg/evm/rpc_test.go): covers every
rejection branch of hexToUint64 / hexToBigInt (missing 0x prefix,
non-hex chars, value too large for uint64, empty-after-prefix).
Coverage: 84.4% → 85.3%. The remaining gap is largely input-validation
in crypto/financial code that fires on bad operator input — left as-is.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
Deletions
saveEVMSigner(pkg/evm/key.go):json.MarshalIndenterror branch on the all-stringsidentityFilestruct — cannot fail.saveLocalSigner(pkg/wallet/signer.go): identical pattern for the Ed25519 identityFile.Test additions
TestEVMAccessors_WithBinding: drives the non-nil-evm branch ofEVMAddress/EVMChainID/EVMTokenso the accessors are covered beyond the nil-binding shortcut.TestHexHelpers_ErrorPaths: covers every rejection branch ofhexToUint64/hexToBigInt.Coverage
The 88% target wasn't reached without compromising the conservative bar — most of the remaining uncovered code is real input-validation in crypto/financial paths (signatures, EIP-712 typed-data, ABI encoding) that catches malformed operator input. Those are exactly the defenses the playbook says to leave.
Test plan
go test -race -count=1 -timeout 120s ./...passes across all 4 packages