GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test(v4): poll Anvil startup instead of a fixed sleep by TimeToBuildBob · Pull Request #486 · uniswap-python/uniswap-python

Conversation

@TimeToBuildBob

@TimeToBuildBob TimeToBuildBob commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Both v4 test modules start anvil and then sleep(3) before connecting. On a slow fork 3s 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.

This replaces the sleep in tests/test_uniswap4.py and tests/test_v4_examples.py with 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 --check and the repo pre-commit hooks pass on both files
  • pytest --collect-only collects all 96 tests in the two modules
  • v4 mainnet matrix green on CI (no local anvil/PROVIDER here)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

greptile-apps[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@TimeToBuildBob
test(v4): poll Anvil startup instead of a fixed sleep
baff47d
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

codecov Bot commented Oct 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.26%. Comparing base (43420bc) to head (44371ed).
⚠️ Report is 3 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Low impact] Test setup replaces fixed sleep with connection polling.

The PR appears safe to merge, with non-blocking improvements to timeout cleanup and elapsed-time measurement.

Findings

  1. P2 Timeout skips child cleanup ▶
  2. P2 Clock changes alter the wait ▶

Summary

Both V4 test modules replace the fixed startup sleep with a connection poll.

  • The v4 test fixtures wait for Anvil to accept connections.

Reviews (1) · Last reviewed commit: "test(v4): poll Anvil startup instead of ..." · Reviewed by Greptile

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

greptile-apps[bot]
greptile-apps Bot reviewed Oct 13, 2026
View reviewed changes
Comment thread tests/test_uniswap4.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/test_uniswap4.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@TimeToBuildBob
fix(tests): reap timed-out Anvil and use monotonic deadlines
44371ed
Git-Session-Id: 0fead8e2-e37e-58e4-b158-56598d831c9d
@ErikBjare
ErikBjare merged commit aa2c09a into uniswap-python:master Oct 13, 2026
6 checks passed

Uh oh!

There was an error while loading. Please reload this page.

TimeToBuildBob added a commit to TimeToBuildBob/uniswap-python that referenced this pull request Oct 14, 2026
@TimeToBuildBob
fix: address Greptile P1/P2 findings from review
d464d8f
- 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 <[email protected]>
Git-Session-Id: d44b7f42-192e-588b-98db-435d6ad11d1c
@TimeToBuildBob TimeToBuildBob mentioned this pull request Oct 14, 2026
feat(v4): UF grant work — async clients, ReservesLens, CI/test fixes (clean branch) #491
Merged
ErikBjare pushed a commit that referenced this pull request Oct 14, 2026
@TimeToBuildBob
feat(v4): UF grant work — async clients, ReservesLens, CI/test fixes …
02c0368
…(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 <[email protected]>
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@greptile-apps greptile-apps[bot] greptile-apps[bot] left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@TimeToBuildBob @ErikBjare
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.