fix(test): add transport keypair uniqueness verification #2225
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.
Problem
CI occasionally fails on
test_three_node_network_connectivitydue to duplicate transport keypairs being generated for different nodes. When two nodes have the same public key, routing breaks and PUT operations time out.Evidence from CI run 19970986958:
v6MWKgqJxtAjv5xtv6MWKgqK9qaZcuaYv6MWKgqK9qaZcuaY← Same as peer1!The test shows all nodes connecting successfully (full mesh with 2 connections each), but PUT operations hang because routing fails when two nodes share the same identity.
The issue is intermittent - the test passes consistently locally and passed on CI re-run.
Root Cause Investigation
TransportKeypair::new()usesOsRngwhich should give unique keys each time. However, in CI environments under load, RNG behavior can sometimes produce collisions due to:This Solution
Generate all transport keypairs upfront at the start of each test and verify they're unique before proceeding:
The fix is in the
#[freenet_test]macro codegen, so all tests using the macro benefit from this protection.Testing
cargo test --package freenet --test connectivitypasses (4 tests)cargo test --package freenet --test operationspasses (9 tests)[AI-assisted - Claude]