Bindu icon indicating copy to clipboard operation
Bindu copied to clipboard

[Feature]: Add Integration Tests for Payment Flows

Open Suvam-paul145 opened this issue 8 months ago • 5 comments

Unit tests exist for individual payment components (test_payment_handler.py, test_payment_session_manager.py, test_x402_middleware.py) but there are no integration tests that exercise a full payment lifecycle from request to settlement.

What needs to happen:

  • Create an integration test that simulates a paid task request end-to-end.
  • Cover scenarios: successful payment, insufficient balance, payment timeout, and settlement failure.
  • Place tests in tests/integration/ following existing patterns.

Relevant files:

  • tests/unit/test_payment_handler.py
  • tests/unit/test_x402_middleware.py
  • bindu/server/middleware/x402/x402_middleware.py

Suvam-paul145 avatar Mar 07 '26 13:03 Suvam-paul145

@anikait1 please assign me this issue

Suvam-paul145 avatar Mar 07 '26 13:03 Suvam-paul145

Hey Suvam, I am not working on this project anymore. Please feel free to tag the current maintainers for any help related to getting issues assigned.

anikait1 avatar Mar 07 '26 13:03 anikait1

@raahulrahl please assign me this issue

Suvam-paul145 avatar Mar 07 '26 13:03 Suvam-paul145

Hi, @raahulrahl I would like to work on this issue.

Proposed Solution Implement end-to-end integration tests for the payment lifecycle.

Simulate a paid task request from API request → x402 middleware → settlement.

Cover scenarios:

  1. Successful payment
  2. Insufficient balance
  3. Payment timeout
  4. Settlement failure

Add tests under tests/integration/ following existing unit test patterns.

Please assign this issue to me.

A-VISHAL avatar Mar 09 '26 15:03 A-VISHAL

For the live payer counterparty in end-to-end payment tests, ATXP provides a test-friendly agent wallet that could be used here.

An ATXP agent account:

  • Self-registers without browser login (npx atxp@latest agent register)
  • Gets a USDC wallet on Base + $5 test credits
  • Can send real USDC payments to x402-compatible endpoints

This would let you write integration tests against a real funded wallet instead of mocking:

import subprocess, json

def setup_test_payer():
    """Register a real ATXP wallet for integration tests."""
    result = subprocess.run(
        ["npx", "atxp@latest", "agent", "register", "--json"],
        capture_output=True, text=True
    )
    return json.loads(result.stdout)

# In your test fixture:
payer = setup_test_payer()
# payer["wallet"] = "0x..." on Base mainnet
# payer["balance"] = $5 real credits
# Can make real x402 payments against your Bindu endpoints

The account costs nothing and the test credits cover a batch of integration runs. Might be cleaner than testnet faucets for CI.

Disclosure: I'm with ATXP — sharing because Bindu's x402 integration is exactly the use case.

lamira-the-human avatar Mar 17 '26 18:03 lamira-the-human