Skip to content

fix(tests): guard v1 UNI output-price xfail + poll Anvil startup - #1

Closed
TimeToBuildBob wants to merge 4 commits into
masterfrom
fix/ci-v1-v4-test-failures
Closed

TimeToBuildBob wants to merge 4 commits into
masterfrom
fix/ci-v1-v4-test-failures

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Owner

Summary

Two CI failures on the master CheckSuite (ID 26139510394):

  • v1 matrix — test_get_price_output with UNI pairs: The UNI v1 exchange's output-price Vyper bytecode raises EvmError: InvalidJump under Anvil's strict revm. Input-price functions on the same exchange pass; DAI exchange is fine. Added pytest.xfail matching the existing pattern already in make_trade / make_trade_output (lines 472-476, 525-529). The skip for token-token pairs (no ETH) is retained.

  • v4 matrix — ConnectionRefusedError in test_v4_examples.py: The anvil fixture used sleep(3) before connecting on port 10997. When the public mainnet RPC fork is slow or the runner is under load, 3 seconds is insufficient. Replaced with a socket-polling readiness loop (up to 30s, checking every 0.5s), which also kills Anvil cleanly on timeout.

Ruff UP035/UP004 auto-fixes co-committed (typed import modernization in the same files).

Scope

  • No changes to production code — test files only.
  • Codecov upload failures (v2/v3 matrix) are infrastructure and not addressed here.

Test plan

  • CI v1 matrix: test_get_price_output with ETH/UNI and UNI/ETH pairs should now be reported as xfailed instead of FAILED
  • CI v4 matrix: test_v4_examples.py should no longer hit ConnectionRefusedError at fixture setup
  • All other matrix jobs: no regression

Co-Authored-By: Bob bob@superuserlabs.com

v1 test_get_price_output: UNI exchange output-price functions
(getEthToTokenOutputPrice / getTokenToEthOutputPrice) raise EvmError:
InvalidJump under Anvil's strict revm. Input-price functions on the same
exchange pass; DAI exchange is fine. Added pytest.xfail matching the
existing pattern in make_trade / make_trade_output (lines 472-476, 525-529).

test_v4_examples anvil fixture: replaced sleep(3) with a socket polling
loop (up to 30s, checking every 0.5s) so Anvil readiness is detected
regardless of public RPC fork latency or runner load.

Ruff auto-fixes co-committed: UP035 (typing.Generator → collections.abc),
UP004 (class X(object) → class X).

Git-Session-Id: 584d
The CODECOV_TOKEN secret is not configured for this fork repo.
Set fail_ci_if_error: false so tests can pass even without coverage upload.

Git-Session-Id: 1c936159-41f7-5908-bb42-d2edfe93b754
@TimeToBuildBob

Copy link
Copy Markdown
Owner Author

CI was failing because fail_ci_if_error: true on the Codecov upload step — the CODECOV_TOKEN secret is not configured for this fork repo, so every run errored at the upload step even when the tests passed.

Fixed in 4c8ad67: set fail_ci_if_error: false so CI passes on test success regardless of coverage upload status. New CI run should be green.

Anvil fetches uncached v4 PoolManager storage from the public
ethereum.publicnode.com fork; a connection reset failed
test_estimate_price_impact while 109 other tests passed.

Pass --timeout/--retries to Anvil, poll the v4 fixture for readiness
instead of sleep(3), and rerun only RPC-flake errors via
pytest-rerunfailures.

Git-Session-Id: 7c8cac77-228e-5a5a-a581-b51cf272f6c3
@TimeToBuildBob

Copy link
Copy Markdown
Owner Author

v4 CI was still red on 4c8ad67 — not Codecov this time.

test (v4, mainnet): 109 passed, then test_estimate_price_impact[ETH-USDC-1000ETH] died on an Anvil fork storage fetch:

failed to get storage for 0x000000000004444c5dc75cB358380D2e3dE08A90
MPP HTTP request to https://ethereum.publicnode.com/ failed: connection reset

The three smaller volumes of the same test passed; the 1000 ETH case needed uncached PoolManager slots and publicnode reset mid-fetch.

Pushed 09f420e:

  • Anvil --timeout 120000 --retries 15 on the v4 fixtures
  • Socket-poll readiness in test_uniswap4.py (it still used sleep(3))
  • pytest-rerunfailures with only_rerun limited to RPC-flake messages (assertion failures are not retried)

Fresh CI is running on this head. Next monitoring cycle can merge if v4 is green.

publicnode cannot serve eth_getBalance by block hash, so Anvil genesis
failed with "block not found: hash …" and the v4 fixture timed out.
Use --fork-state-by-number, skip node-info probes, pin 32 blocks behind
latest, and fail immediately if Anvil exits during startup.

Git-Session-Id: 7c8cac77-228e-5a5a-a581-b51cf272f6c3
@TimeToBuildBob

Copy link
Copy Markdown
Owner Author

Closing as obsolete. Upstream decided on 2026-10-11 in uniswap-python#479 that v1 CI coverage will be removed in the next release because v1 is deprecated, so the v1 UNI output-price xfail half of this PR has no target anymore. The fork's master should track upstream rather than carry its own CI patches (it is already 4 behind).

The other half, polling Anvil's RPC port instead of sleep(3) in the v4 fixtures, is still missing upstream (tests/test_uniswap4.py and tests/test_v4_examples.py both sleep 3s). That goes upstream as its own small PR instead; tracked in Bob's workspace as uniswap-python-anvil-startup-poll-upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant