Skip to content

Commit f180cfb

Browse files
committed
mempool: add comprehensive PolicyEnforcer test suite
In this commit, we add extensive test coverage for the StandardPolicyEnforcer including unit tests for each validation method and property-based tests to verify correctness across a wide range of inputs. The test suite uses a mockGraph implementation that provides the minimal PolicyGraph interface needed for testing. This allows us to test policy logic in isolation without requiring a full txgraph.Graph implementation, making tests faster and easier to understand. Unit Test Coverage: We test each major feature independently with focused scenarios. For RBF signaling, we verify both explicit signaling via sequence numbers and inherited signaling through multiple generations of ancestors. The deep inheritance test confirms that signaling propagates correctly through arbitrarily long transaction chains. The replacement validation tests cover all BIP 125 rules including edge cases like insufficient fee rates, too many evictions, and attempts to spend from parent transactions. Each test uses realistic transaction structures with proper fee calculations. The ancestor and descendant limit tests verify both count and size limits, ensuring we correctly enforce Bitcoin Core's 25-transaction and 101 KB limits. We test both at-limit (passing) and over-limit (failing) scenarios. Fee validation tests cover the minimum relay fee logic and the exponentially decaying rate limiter for low-fee transactions. The rate limiter tests verify both rejection when limits are exceeded and proper decay over time. Property-Based Testing: Using the rapid library, we add three property-based tests that verify invariants across randomized inputs. TestPropertySignalsReplacementTransitive confirms that RBF signaling is correctly inherited through chains of random depth. TestPropertyAncestorLimitEnforced generates chains of varying lengths to ensure limits are enforced at exactly the configured threshold. TestPropertyFeeRateMonotonic verifies fee rate calculations are consistent. These property tests run 100 iterations each with randomized parameters, providing high confidence that the policy enforcement logic handles edge cases correctly. Test coverage: 80-100% across all PolicyEnforcer methods.
1 parent f88dd1c commit f180cfb

File tree

1 file changed

+828
-0
lines changed

1 file changed

+828
-0
lines changed

0 commit comments

Comments
 (0)