Repository navigation
test(v4): poll Anvil startup instead of a fixed sleep - #486
Merged
ErikBjare merged 2 commits intoOct 13, 2026
Merged
Conversation
Both v4 test modules started anvil and then slept 3 seconds before connecting. On a slow fork that is not enough and the matrix fails with ConnectionRefusedError; on a fast machine it wastes time; and when anvil dies at genesis the fixture still waits out the sleep and then fails on the connection instead of the real cause. Poll the RPC port for up to 60s, fail immediately with the exit code if the process exits first, and kill it on timeout. Git-Session-Id: 9d44438c-8705-491c-9930-947968df9a94
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #486 +/- ##
=======================================
Coverage 73.26% 73.26%
=======================================
Files 12 12
Lines 2319 2319
=======================================
Hits 1699 1699
Misses 620 620 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
Git-Session-Id: 0fead8e2-e37e-58e4-b158-56598d831c9d
TimeToBuildBob
added a commit
to TimeToBuildBob/uniswap-python
that referenced
this pull request
Oct 14, 2026
- Restore @check_approval on make_trade/make_trade_output/add_liquidity/ remove_liquidity (P1: first token trades fail without router allowance) - Remove path overwrite after cost calculation in V2 exact-output branch (P1: custom route was silently replaced with default WETH route) - Raise ValueError when V3 route is given without fees in get_price and make_trade (P1: incomplete routes silently fell back to single-pool quote) - Fix async client init to derive provider URL from supplied AsyncWeb3 so PROVIDER env var is not required when web3 is given (P1) - Add asyncio.Lock (_nonce_lock) in AsyncUniswap4 and reserve nonce inside the lock before yielding to prevent concurrent trades sharing a nonce (P1) - Remove incorrect await on bytes32 _name.decode()/_symbol.decode() in AsyncUniswap4.get_token — decode() returns str, not awaitable (P2) - Restore Anvil startup readiness poll in test_uniswap4.py fixture, replacing sleep(3) that was reverted from uniswap-python#486 (P2) - Cache get_weth_address result per client instance to avoid repeated RPC calls on every quote/swap path (P2) Co-Authored-By: Bob <bob@superuserlabs.org> Git-Session-Id: d44b7f42-192e-588b-98db-435d6ad11d1c
ErikBjare
pushed a commit
that referenced
this pull request
Oct 14, 2026
…(clean branch) (#491) * feat(v4): UF grant work — async clients, ReservesLens, CI/test fixes Clean branch off master containing liquid-8's changes from dev/v4-fin: - Async Uniswap v2/v3/v4 clients (asyncuniswap.py, asyncuniswap4.py) - ReservesLens support and getPoolTVLBatch improvements - Universal Router and single/multi-hop swap fixes - Test suite fixes (RPC switch, Anvil startup, fixture fixes) - Adoption metrics snapshot script + daily workflow (UF grant D3/D4) - README updates Clean squash of dev/v4-fin changes reapplied on top of current master, resolving the 244-commit ancestry confusion from the original v4-fin squash merge (4c42f1f). Also fixes duplicate Generator import in tests/test_uniswap.py (ruff F811). Git-Session-Id: 15b18137-18fa-53a4-92e2-759ce27705c7 * fix: address Greptile P1/P2 findings from review - Restore @check_approval on make_trade/make_trade_output/add_liquidity/ remove_liquidity (P1: first token trades fail without router allowance) - Remove path overwrite after cost calculation in V2 exact-output branch (P1: custom route was silently replaced with default WETH route) - Raise ValueError when V3 route is given without fees in get_price and make_trade (P1: incomplete routes silently fell back to single-pool quote) - Fix async client init to derive provider URL from supplied AsyncWeb3 so PROVIDER env var is not required when web3 is given (P1) - Add asyncio.Lock (_nonce_lock) in AsyncUniswap4 and reserve nonce inside the lock before yielding to prevent concurrent trades sharing a nonce (P1) - Remove incorrect await on bytes32 _name.decode()/_symbol.decode() in AsyncUniswap4.get_token — decode() returns str, not awaitable (P2) - Restore Anvil startup readiness poll in test_uniswap4.py fixture, replacing sleep(3) that was reverted from #486 (P2) - Cache get_weth_address result per client instance to avoid repeated RPC calls on every quote/swap path (P2) Co-Authored-By: Bob <bob@superuserlabs.org> Git-Session-Id: d44b7f42-192e-588b-98db-435d6ad11d1c * fix(typecheck): remove unused type: ignore[return-value] on get_weth_address _weth_address_cache is typed as ChecksumAddress (same as return type), so the ignore comment is now redundant and mypy correctly flags it. Git-Session-Id: c95ac4a4-64bd-42b3-9f79-c55ca4dfb9cf
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
Both v4 test modules start
anviland thensleep(3)before connecting. On a slow fork 3s is not enough and the matrix fails withConnectionRefusedError; on a fast machine it wastes time; and when anvil dies at genesis the fixture still waits out the sleep and then fails on the connection instead of the real cause.This replaces the sleep in
tests/test_uniswap4.pyandtests/test_v4_examples.pywith a bounded poll of the RPC port (up to 60s) that fails immediately with the exit code if the process exits first and kills it on timeout. No behaviour change once anvil is up; the fixture just stops guessing.The same fixture change ran green on the v1–v4 matrix on my fork (TimeToBuildBob#1, since closed because it was bundled with the v1 xfail that #479 declined). Only the two fixture files change here.
Test plan
ruff check/ruff format --checkand the repo pre-commit hooks pass on both filespytest --collect-onlycollects all 96 tests in the two modulesanvil/PROVIDERhere)