Repository navigation
fix: use random port for Anvil instead of hardcoded 61611 - #1
Merged
Merged
Conversation
Remove ANVIL_DEFAULT_PORT constant and let the OS assign a random available port by default. This fixes port collisions in sequential and parallel tests where the previous fixed port 61611 would remain in TIME_WAIT for ~60s after each test, causing 'Address already in use' errors. The ANVIL_PORT env var is still respected for callers that need a specific port.
- Remove hardcoded ANVIL_DEFAULT_PORT, use OS-assigned random port
- Replace all .expect() in start_node() with proper Result propagation
- Replace direct keys()[N] indexing with .first()/.get(N) safe access
- Add TestnetError enum for structured error handling
- Make start_node(), Testnet::new(), default_wallet_private_key(),
and all deploy_* functions return Result
- Fix test_run_multiple_testnets_in_parallel to use tokio::join!
for actual concurrent testing
- Use inline format variables: format!("http://{host}:{port}")
- Import std::env at top level instead of inline std::env::var
jacderida
approved these changes
Mar 27, 2026
2 of 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.
Summary
Problem
Breaking changes
Downstream callers (ant-node, ant-client) need to add .unwrap() in test code or propagate errors in production code.
Test results (with this fix)
All tests run with --test-threads=4 (parallel):