Documentation
¶
Index ¶
Constants ¶
const (
// USDCBaseSepolia is the USDC contract address on Base Sepolia.
USDCBaseSepolia = "0x036CbD53842c5426634e7929541eC2318f3dCF7e"
)
Variables ¶
This section is empty.
Functions ¶
func PatchVerifierFacilitator ¶
PatchVerifierFacilitator patches the x402-pricing ConfigMap to use the given facilitator URL, restarts the x402-verifier deployment, waits for the new pod to log the updated URL, and registers t.Cleanup to restore the original ConfigMap contents.
kubectlBin is the absolute path to the kubectl binary. kubeconfig is the absolute path to the kubeconfig file. newURL is the facilitator URL to inject (e.g. "http://host.docker.internal:54321").
func SignRealPaymentHeader ¶
func SignRealPaymentHeader(t *testing.T, signerKeyHex string, payTo string, amount string, chainID int64) string
SignRealPaymentHeader constructs a real EIP-712 TransferWithAuthorization (ERC-3009) payment header and returns it as a base64-encoded string compatible with the x402 v2 wire format.
The signerKey is the buyer's private key (signs the authorization). payTo is the seller's address (from ServiceOffer payment.payTo). amount is the USDC amount in micro-units (e.g. "1000000" = 1 USDC). chainID is the EVM chain ID (84532 for Base Sepolia).
Critical x402-rs wire format requirements:
- validAfter/validBefore must be STRINGS (x402-rs UnixTimestamp deserializes from string)
- value must be a STRING (x402-rs U256 uses decimal_u256 serde)
- nonce must be a hex-encoded 32-byte value with 0x prefix
Types ¶
type MockFacilitator ¶
type MockFacilitator struct {
Server *httptest.Server
Port int
ClusterURL string // e.g. "http://host.k3d.internal:54321"
VerifyCalls atomic.Int32
SettleCalls atomic.Int32
}
MockFacilitator wraps an httptest.Server that speaks the x402 facilitator protocol. Accessible from inside k3d cluster via http://host.k3d.internal:<port> (Linux) or http://host.docker.internal:<port> (macOS).
func StartMockFacilitator ¶
func StartMockFacilitator(t *testing.T) *MockFacilitator
StartMockFacilitator starts a mock facilitator on a free port. Follows the pattern from x402/go/test/mocks/cash/cash.go. Handles: GET /supported, POST /verify, POST /settle. Registers t.Cleanup to stop the server.