Test/trading fixtures and harness#41
Conversation
Introduce JSON fixtures and load/regen tooling for trading scenarios. Add simulate tests for delegate lifecycle and permission matrix, plus unit tests for events, SDK inputs, and size formulas. Wire integration setup and existing simulate suites to shared helpers; extend market params and add WLP cancel/redeem probe script. Made-with: Cursor
- Add test/fixtures/trading/trading-config.json as single source for lifecycle rows, persistent perp, enabled bases, thresholds, and wallet mins; remove split lifecycle-markets.json and persistent-perp.json. - Delete dead helpers (trading-fixture-harness, lifecycle-oracle-usd-prices, wlp-pool-price-refresh); extract SCRATCH_EXPECT to scratch-scenario-steps.ts. - Rename execIntegrationOrSkipOracle in integration setup and scratch runner; align testnet/oracle comments with Pyth-only v2; trim compute-leverage-size. - Remove scripts/debug-oracle-aggregates.ts and setup-supra-oracle.sh; mark clear-supra-weights.sh as legacy migration; fix setup-pyth-identifiers.sh base types to market_symbol::*_USD. - Rewrite scripts/README.md; update MIGRATION.md, test docs, and preflight copy. Made-with: Cursor
…rage sim tests - Preflight and e2e:prepare require recent on-chain positions per activeLifecycleTestBases; document persistentPerp coverage for bootstrap/integration. - trading-config: add persistentPerp rows for xStock bases so bootstrap can open slots. - Simulate: use on-chain resize for above-max leverage tests; assertSimulateMoveAbortOneOf for 104/105. - Docs: README and e2e helper comments for preflight vs persistentPerp. Note: .e2e-fixed-positions.local.json left unstaged (local snapshot). Made-with: Cursor
- Add setup-e2e-delegate script, ensure-e2e-delegate helper, and simulate coverage for delegate flows; integrate with e2e-preflight, e2e-prepare, and npm scripts. - Update trading fixtures, load-trading-fixtures, and local e2e position metadata; refresh README notes. - Raise unit branch coverage: rawPrice bigint path; account PTB paths for bucketAccount and receiveCoin (v1 shape, amount, empty-input error). Add e2e-delegate-helpers unit tests. Made-with: Cursor
- Extend e2e-prepare, e2e-preflight, and bootstrap-e2e-lifecycle-positions - Add check-account-usdsui, check-eth-sui-positions, close-legacy-collateral-mismatch - Add e2e-tto-split-thresholds helper; update persistent state and scratch scenarios - Refresh integration/simulate tests and trading-config fixture; update docs - Remove scripts/clear-supra-weights.sh Made-with: Cursor
- Generalize ensure-tto helper for USDC/USDSUI; document auto-split limits - Add X_STOCK_BASES / isXStockBase for oracle market-hours gating - Extend e2e preflight/prepare and scratch integration lifecycle - Remove legacy one-off position/collateral scripts - Harden simulate tests (collateral order, lifecycle PTB, negative cases) Made-with: Cursor
Made-with: Cursor
bucket-bot
left a comment
There was a problem hiding this comment.
Code review
Found 1 issue:
- This PR is too broad for safe review/rollback and mixes unrelated change classes.
The stated scope is test fixtures/harness alignment, but this diff also changes CI workflows, CLAUDE/MIGRATION/docs, script inventory, and committed local e2e position state in one unit. That coupling increases merge risk and makes regression isolation difficult.
Please split into focused PRs at least by concern:
- test fixtures/harness/runtime behavior
- CI workflow trigger policy
- script cleanup/docs
- local e2e state snapshot updates
This makes approvals safer and rollback practical if one track regresses.
Generated with Rex via OpenClaw
Made-with: Cursor
bucket-bot
left a comment
There was a problem hiding this comment.
Code review
No issues found (>=80 confidence) after focused review on test harness changes for breaking SDK alignment.
Checked areas:
- multi-collateral test fixture migration (
trading-config.jsonas single source) - preflight/prepare behavior alignment (USDSUI + delegate + xStock oracle-hours skip semantics)
- CI trigger scope update (PRs to any base branch)
- simulate stability updates (order-id race retry path)
Given this PR is intentionally a one-shot breaking-test alignment, the changes are coherent and internally consistent.
🤖 Generated with Rex (OpenClaw)
bucket-bot
left a comment
There was a problem hiding this comment.
⚠️ Updated review — the PR scope expanded significantly since my first pass. This supersedes the earlier approval.
Excellent refactoring: 68 files moving hardcoded TypeScript test config into trading-config.json, generalizing USDC-only helpers to multi-collateral (USDC/USDSUI), cleaning out Supra oracle remnants, and adding solid delegate/permission test coverage. The code is remarkably well-organised for a change this size.
Highlights
trading-config.jsonas single source of truth — lifecycle rows, persistent perp, iteration order, wallet thresholds, delegate config all in one place.load-trading-fixtures.tsparser is clean.- Multi-collateral generalisation —
ensureTtoCollateralCoinsForSimulate,buildDepositCollateralFromWalletTx,ensureScratchLifecycleMinCollateral, per-rowcollateralAssetpiped through every builder call. Thorough. simulatePlaceCancelSinglePtbWithRetries— much better than the old single-shot orderId prediction. Re-fetchesnextOrderIdon 300, configurable max attempts.assertSimulateMoveAbortOneOf— handles the 104-or-105 ambiguity cleanly.- Delegate test suite —
delegate-lifecycle-simulate,delegate-permission-matrix-simulate,e2e-delegate-simulategive good coverage of the permission system. move-event-payload.ts— robust parser handling multiple JSON shapes + BCS fallback forPositionOpened.- Supra cleanup —
setup-supra-oracle.sh,clear-supra-weights.sh,debug-oracle-aggregates.tsremoved; all oracle references updated to Pyth-only v2. - Unit tests — good additions for
event-parsing,e2e-delegate-helpers,sdk-size-formula,sdk-input-type-contracts.
Nits / questions
-
DEEP in
persistentPerp.marketsbut notenabledE2eBases— the JSON has a full DEEP row underpersistentPerp.marketsandlifecycleMarkets, but DEEP is absent fromenabledE2eBases. SinceactiveE2ePersistentPerpBases()filters byENABLED_E2E_BASES, the DEEP perp row is dead config. Intentional "ready when we re-enable"? If so, a brief JSON comment or_disabledsuffix would make that clearer. -
test-cancel-redeem-wlp.tsis 435 lines — thorough documentation and three well-defined scenarios, but it's a large script to review in one shot. Consider splittingbuildRequestPlusCancelAndTransferPtbinto its own module if you plan to reuse it. -
integrationOracleSimMaxAttempts/integrationOracleSimRetryDelayMsenv-var helpers inscratch-lifecycle.ts— the max/min clamping is good (Math.min(10, Math.max(1, ...))) but there's no validation logging if someone passes a non-numeric string (it falls through to default silently via!Number.isFinite(n)). Fine for dev tooling, just noting. -
e2eDelegate.delegateAddresshardcoded in committed fixture —0xa221d2...is baked into the repo. The env override (WATERX_E2E_DELEGATE_ADDRESS) covers CI, but contributors forking the repo may get confused when preflight checks fail for this address. A note intest/README.mdunder the delegate section explaining this would help. -
.e2e-fixed-positions.local.jsonchanges — this file is checked in (not gitignored) and the diff updates position IDs. Is this expected to be committed, or should it be in.gitignore?
None of these are blocking — this is a clean, well-thought-out refactor.
LGTM 👍
- Rename requireOracleUsdOrSkip to oracleUsdForBaseOrSkip so esbuild/Vitest does not treat the import as CommonJS require (fixes runtime is not a function). - Extend bundled oracle pricing + e2e preflight, fixtures, and scratch harness. Made-with: Cursor
Summary
Generalizes integration/simulate test helpers for multi-collateral (USDC / USDSUI), tightens e2e preflight/prepare flows, and removes obsolete one-off scripts.
Changes
ensure-tto-usdc-coins-for-simulate→ensure-tto-collateral-coins-for-simulatewith documented behavior (USDC auto-split vs USDSUI requiringe2e:prepare).X_STOCK_BASESandisXStockBase()for xStock Pyth oracle / market-hours considerations.e2e-preflight/e2e-prepare; README touch.e2e-persistent-perp-slotsupdates.check-account-usdsui,check-eth-sui-positions,close-legacy-collateral-mismatch.Testing