A useful swap fixture suite tests where an application might authorize the wrong operation, lose an uncertain result or misreport settlement. Replaying one successful quote many times does little to cover those risks.
Start from observable invariants
Write down what must remain true: a wallet request matches the reviewed account and chain; amounts stay exact; approvals target the intended spender; and an unknown broadcast outcome does not trigger a second trade automatically.
Provider documentation supplies concrete response branches. For example, the 0x issues reference distinguishes funding, allowance and simulation observations. Build fixtures around those meanings rather than snapshotting every incidental field.
| Boundary | Useful fixture |
|---|---|
| Amount parser | Smallest unit, excessive precision, integer above safe Number range |
| Quote response | No liquidity, missing execution field, stale request generation |
| Wallet context | Account switch while signing, chain switch while quoting |
| Submission | Rejected prompt, acknowledgement lost after broadcast |
| Settlement | Revert receipt, duplicate fill, partial fill then expiry |
Keep fixtures safe and maintainable
Use synthetic addresses or carefully sanitized public records. Remove API keys, authentication headers and reusable signatures. Label whether the fixture was invented for a condition or captured from an actual response.
Store the provider version and the purpose of each fixture. Otherwise, a later developer may “fix” a deliberately incomplete response into an ordinary successful one.
Assert decisions
Check whether signing is enabled, which amount and spender reach review, and whether history retains a pending hash. A full JSON snapshot may change without affecting safety, while one ignored field can change behavior substantially.
These fixtures validate application handling. They do not establish live liquidity, contract safety or present provider availability; those require separate evidence appropriate to the integration.
Sources & verification (1)
Source-check date is recorded in the article details. URLs are provided for manual verification. Use Copy to keep this page open.
- Issues & Error Codes
Distinct allowance, balance and incomplete simulation issues
https://docs.0x.org/docs/introduction/api-issues