Repository navigation
test: cover full x402 paid message lifecycle - #602
esreekarreddy wants to merge 5 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe tests verify X402 payment state propagation and a complete paid HTTP ChangesX402 payment coverage
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant HTTPClient
participant X402Middleware
participant A2ARouting
participant TaskScheduler
participant Worker
participant PaymentFacilitator
HTTPClient->>X402Middleware: Send paid message/send request
X402Middleware->>PaymentFacilitator: Verify payment
X402Middleware->>A2ARouting: Forward verified request
A2ARouting->>TaskScheduler: Schedule task
TaskScheduler->>Worker: Execute task
Worker->>PaymentFacilitator: Settle payment
Worker-->>HTTPClient: Return completed task and artifact
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/integration/x402/test_e2e_scenarios.py (1)
533-534: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCheck metadata on every history entry.
The assertion checks only
task["history"][0]. A later history entry can expose_payment_contextwhile this test passes. Assert the condition for every entry intask["history"].🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/integration/x402/test_e2e_scenarios.py` around lines 533 - 534, Update the history metadata assertion in the test to iterate over every entry in task["history"], retrieving each entry’s metadata and asserting that "_payment_context" is absent. Preserve the existing empty-metadata fallback for entries without metadata.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/integration/x402/test_e2e_scenarios.py`:
- Around line 419-420: Replace the two diagnostic print calls near the
end-to-end scenario with module logging: import get_logger from
bindu.utils.logging, define a module-level logger using get_logger(__name__),
and emit both messages through logger.info(...).
---
Nitpick comments:
In `@tests/integration/x402/test_e2e_scenarios.py`:
- Around line 533-534: Update the history metadata assertion in the test to
iterate over every entry in task["history"], retrieving each entry’s metadata
and asserting that "_payment_context" is absent. Preserve the existing
empty-metadata fallback for entries without metadata.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b85917a9-7072-42db-abc3-17e11f4da4c8
📒 Files selected for processing (1)
tests/integration/x402/test_e2e_scenarios.py
Summary
Describe the problem and fix in 2-5 bullets:
message/sendsuccess-path test proving payment context survived middleware, A2A routing, scheduling, worker execution, and settlement.message/sendintegration test with realX402Middleware,agent_run_endpoint,TaskManager,InMemoryScheduler,ManifestWorker, andInMemoryStorage, while mocking facilitator verification/settlement at the external boundary.Change Type (select all that apply)
Scope (select all touched areas)
Linked Issue/PR
User-Visible / Behavior Changes
None.
Security Impact (required)
Yes/No): NoYes/No): NoYes/No): NoYes/No): NoYes/No): NoYes, explain risk + mitigation: N/AVerification
Environment
InMemoryStorageInMemorySchedulerSteps to Test
uv run pytest tests/unit/server/middleware/x402/ -quv run pytest tests/integration/x402/ -quv run pytest tests/unit/ -quv run pytest tests/integration/ -quv run pre-commit run --files tests/integration/x402/test_e2e_scenarios.py tests/unit/server/middleware/x402/test_x402_middleware.pygit diff --checkExpected Behavior
message/sendrequest verifies x402 payment, reaches the A2A endpoint, schedules a task, settles before manifest execution, completes the task, persists receipt metadata, and does not leak the internal_payment_contextinto task history.payment_payload,payment_requirements,verify_response, andpayerto request state before forwarding downstream.Actual Behavior
uv run pytest tests/unit/server/middleware/x402/ -q-> 30 passeduv run pytest tests/integration/x402/ -q-> 5 passed, 2 skippeduv run pytest tests/unit/ -q-> 1087 passed, 3 skippeduv run pytest tests/integration/ -q-> 20 passed, 3 skippeduv run pre-commit run --files tests/integration/x402/test_e2e_scenarios.py tests/unit/server/middleware/x402/test_x402_middleware.py-> passedgit diff --check-> passedEvidence (attach at least one)
Human Verification (required)
What you personally verified (not just CI):
message/sendhappy path; existing x402 integration scenarios for insufficient balance/settlement failure, settlement timeout, parallel nonce double-spend, and replay rejection; middleware happy path state handoff._payment_context, receipt metadata is attached, mocked facilitatorverify_paymentandsettleare each awaited once, settle receives the expected nonce/network, and middleware exposes verified state to downstream handlers.Compatibility / Migration
Yes/No): YesYes/No): NoYes/No): NoFailure Recovery (if this breaks)
tests/integration/x402/test_e2e_scenarios.py::test_full_http_paid_message_send_settles_and_completes.tests/integration/x402/test_e2e_scenarios.py,tests/unit/server/middleware/x402/test_x402_middleware.pyRisks and Mitigations
Checklist
uv run pytest)AI assistance
This patch was prepared with AI assistance and manually reviewed/validated before submission.
Summary by CodeRabbit