test(x402): re-enable retry_with_x402 and direct request tests#1105
Open
yashhzd wants to merge 1 commit intocoinbase:mainfrom
Open
test(x402): re-enable retry_with_x402 and direct request tests#1105yashhzd wants to merge 1 commit intocoinbase:mainfrom
yashhzd wants to merge 1 commit intocoinbase:mainfrom
Conversation
… tests The disabled tests patched decode_x_payment_response on the x402 action provider module, but that symbol is no longer imported there — the provider inlines base64+JSON decoding of the payment-response header. The missing attribute made the patch fail inconsistently across environments, so the tests were commented out. Rewrite the tests against the current provider API: - Patch x402_requests at the provider module path (where it is actually bound) and stub _create_x402_client so tests do not need a real signer. - Drop the obsolete mock_x402_requests and mock_decode_payment fixtures from conftest, and add a mock_x402_session fixture + a pre-encoded payment-proof header constant. - Add coverage for retry_with_x402 (success with/without payment proof, non-200 response, unregistered service, non-USDC asset, amount above max_payment_usdc, network mismatch) and make_http_request_with_x402 (success with/without payment proof, non-200, unregistered service, unsupported wallet provider). Full python/coinbase-agentkit test suite: 675 passed.
🟡 Heimdall Review Status
|
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
Re-enables the Python
x402action provider tests forretry_with_x402andmake_http_request_with_x402that were commented out inpython/coinbase-agentkit/tests/action_providers/x402/test_x402_action_provider.pywith the note:Root cause
The disabled tests used:
@patch("coinbase_agentkit.action_providers.x402.x402_action_provider.decode_x_payment_response")but
decode_x_payment_responseis not imported inx402_action_provider.py. The current provider inlinesbase64.b64decode+json.loadson thepayment-response/x-payment-responseheader, so there is nodecode_x_payment_responseattribute to patch.mock.patchraisedAttributeErrorwherever it evaluated the target, which is why the tests failed in CI.The obsolete
mock_x402_requestsfixture inconftest.pyalso patchedx402.clients.requests.x402_requests, but the provider importsx402_requestsfromx402.http.clients.requests— another reason those old tests would not affect the provider's bound reference.What this PR does
mock_x402_requests,mock_decode_payment).conftest.py:mock_x402_sessionpatchesx402_requestsat the provider module path — the location actually bound by the provider — so the patch is stable across environments.patch_x402_clientstubsx402ActionProvider._create_x402_clientso tests don't need a real signable wallet.retry_with_x402: success with payment proof, success without proof, non-200 upstream response, unregistered service, non-USDC asset, payment abovemax_payment_usdc, network mismatch.make_http_request_with_x402: success with proof, success without proof, non-200 upstream, unregistered service (with dynamic registration hint), unsupported wallet provider.No production code is changed — this PR is scoped to test infrastructure only.
Verification
Run from
python/coinbase-agentkit/:Results on this branch:
tests/action_providers/x402/: 22 passed (was 10 passing + 3 commented-out).python/coinbase-agentkitsuite: 675 passed, 35 deselected.ruff format --checkandruff checkboth pass.Test plan
python/coinbase-agentkittest suite passes locallyruff format --checkpasses on touched filesruff checkpasses on touched files