Conversation
Replace all unwrap() calls in production Rust code that could cause panics from malformed P2P messages or poisoned locks (DoS vectors). - message_handler.rs: Replace 5 SystemTime unwrap() with map_err/? - persistence.rs: Replace 6 RwLock unwrap() with map_err/? returning Persistence errors - circuit_breaker.rs: Replace 9 RwLock unwrap() with unwrap_or_else(|e| e.into_inner()) to recover from poison - rate_limit.rs: Replace NonZeroU32 unwrap() with expect() (guarded), header parse unwrap() with if-let, Response builder with expect() - arbitration.rs: Replace SystemTime unwrap() with map_err/? - embedding.rs: Replace NonZeroUsize unwrap() with ok_or_else/? - multichain.rs: Replace errors.next().unwrap() with expect() (guarded) - error.rs: Add Internal variant for system-level failures All 608 tests pass (556 unit + 21 integration + 21 API + 10 load). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add 55 new test cases covering previously untested functions and paths: Newly tested functions (zero coverage before): - withdrawFees: admin withdrawal, empty pool revert, access control - registerArbiter: success, zero address, duplicate, access control - unregisterArbiter: success, swap-and-pop, non-existent noop, access - getEligibleArbiters: full list, empty after removal - getDispute: correct data, non-existent returns zero - getVotes: empty before voting, correct vote details - getArbiters: before/after selection, no duplicates, parties excluded Additional coverage for partially-tested functions: - createDispute: tier 3, duplicate revert, provider creation, fee pool - submitEvidence: non-party revert, both parties submit - submitAIAnalysis: invalid share, evidence period, tier 1 revert - castVote: already voted, invalid split share - finalizeRuling: provider majority, split averaging, tie 50/50, wrong state, voting not ended - appeal: wrong state, non-party, client appeal, clears votes/arbiters - executeSettlement: wrong state revert - checkAutoResolution: non-existent, non-tier1, during evidence, both evidence 50/50, no client evidence - executeAutoResolution: provider executes, not tier 1, not ended, not party - getArbiterCount: rounds 2/3/4+ - calculateFee/determineTier: edge cases Coverage results (94 tests, all passing): - Functions: 51.25% -> 87.50% (41/80 -> 70/80) - Lines: 82.52% -> 97.97% (203/246 -> 241/246) - Branches: 82.76% -> 96.55% (240/290 -> 280/290) - Statements: 86.96% -> 100.00% (20/23 -> 23/23) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
69dd6d6 to
75f45d2
Compare
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.
Security Fixes
1. Rust unwrap() → proper error handling
2. TieredDisputeResolution test coverage
Motivation
Security audit identified 546× unwrap() in Rust node as DoS vector (malformed P2P messages could crash the node). TieredDisputeResolution had only 51% function coverage — critical dispute logic was untested.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com