Fix cosmes patch, db_orderbook_sim, and add #293 indexer integration tests #420

Closed
opened 2026-06-25 14:12:58 +00:00 by PlasticDigits · 3 comments
PlasticDigits commented 2026-06-25 14:12:58 +00:00 (Migrated from gitlab.com)

Parent

#411 — Updated Gap Analysis (recommendation 13)

Current codebase

Gap analysis run (2026-06-25) reported:

Suite Result Failure
make test-frontend 1039/1040 cosmesPatch127.test.ts — patch SHA mismatch for @goblinhunt/cosmes@0.0.71-ghunt.22
make test-indexer-integration blocked at lib db_orderbook_sim::tests::zero_reserve_mirror_returns_no_output
Route slippage #293 manual only scripts/verify-issue-293.sh; not in indexer integration suite

cosmesPatch127.test.ts guards patch-package integrity (patches/.cosmes-patch-sha256). db_orderbook_sim.rs supports hybrid route solver (#319). route_slippage.rs implements #293 symmetric slippage.

Why needed

#411 retail UX work depends on green unit/integration gates. Hybrid quote alignment (#411 child) requires trustworthy db_orderbook_sim and #293 regression coverage.

Constraints / guardrails

  • Cosmes fix: update patches/.cosmes-patch-sha256 only after intentional patch change + npm ci (#367).
  • db_orderbook_sim fix must not mask real zero-reserve mirror conditions — test expectation may be wrong or sim logic regressed.
  • #293 integration tests should use Postgres fixtures pattern from api_route_solve tests (#324).

Relevant files

  • frontend-dapp/src/services/terraclassic/__tests__/cosmesPatch127.test.ts
  • frontend-dapp/patches/.cosmes-patch-sha256
  • frontend-dapp/patches/@goblinhunt+cosmes+*.patch
  • indexer/src/api/db_orderbook_sim.rs (test zero_reserve_mirror_returns_no_output)
  • indexer/src/api/route_slippage.rs
  • indexer/tests/api_route_solve.rs (or new integration test file)
  • scripts/verify-issue-293.sh
  • docs/testing.md
  1. Cosmes: reconcile patch SHA — either refresh hash after npm ci or fix drifted patch file.
  2. db_orderbook_sim: fix zero_reserve_mirror_returns_no_output — correct sim to return InsufficientLiquidity or update test if mirror semantics changed with #319.
  3. #293: add indexer integration test asserting slippage_percent on solve response for known fixture route.
  4. Document failures in docs/testing.md if new fixtures required.

Acceptance criteria

  • make test-frontend — 1040/1040 including cosmesPatch127.test.ts.
  • make test-indexer-integration completes (lib + integration).
  • New or extended integration test covers slippage_percent (#293).
  • db_orderbook_sim::zero_reserve_mirror_returns_no_output passes.

Test plan

  • cd frontend-dapp && npm ci && make test-frontend
  • make setup-indexer-postgres (if needed) + make test-indexer-integration
  • cd indexer && cargo test --lib api::db_orderbook_sim
  • bash scripts/verify-issue-293.sh (should align with new integration test)

Attack / abuse test plan

  • zero_reserve_mirror must not panic or return positive output on empty reserves (no divide-by-zero).
  • #293 slippage: symmetric formula edge cases (zero expected out) handled.

Verification criteria

  • CI-local make test-frontend and make test-indexer-integration green on Cloud Agent VM.
  • No allow_failure or skipped tests introduced.
## Parent [#411 — Updated Gap Analysis](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/411) (recommendation 13) ## Current codebase Gap analysis run (2026-06-25) reported: | Suite | Result | Failure | |-------|--------|---------| | `make test-frontend` | 1039/1040 | `cosmesPatch127.test.ts` — patch SHA mismatch for `@goblinhunt/cosmes@0.0.71-ghunt.22` | | `make test-indexer-integration` | blocked at lib | `db_orderbook_sim::tests::zero_reserve_mirror_returns_no_output` | | Route slippage #293 | manual only | `scripts/verify-issue-293.sh`; not in indexer integration suite | `cosmesPatch127.test.ts` guards patch-package integrity (`patches/.cosmes-patch-sha256`). `db_orderbook_sim.rs` supports hybrid route solver (#319). `route_slippage.rs` implements #293 symmetric slippage. ## Why needed #411 retail UX work depends on green unit/integration gates. Hybrid quote alignment (#411 child) requires trustworthy `db_orderbook_sim` and #293 regression coverage. ## Constraints / guardrails - Cosmes fix: update `patches/.cosmes-patch-sha256` only after intentional patch change + `npm ci` (#367). - `db_orderbook_sim` fix must not mask real zero-reserve mirror conditions — test expectation may be wrong or sim logic regressed. - #293 integration tests should use Postgres fixtures pattern from `api_route_solve` tests (#324). ## Relevant files - `frontend-dapp/src/services/terraclassic/__tests__/cosmesPatch127.test.ts` - `frontend-dapp/patches/.cosmes-patch-sha256` - `frontend-dapp/patches/@goblinhunt+cosmes+*.patch` - `indexer/src/api/db_orderbook_sim.rs` (test `zero_reserve_mirror_returns_no_output`) - `indexer/src/api/route_slippage.rs` - `indexer/tests/api_route_solve.rs` (or new integration test file) - `scripts/verify-issue-293.sh` - `docs/testing.md` ## Recommended direction 1. **Cosmes:** reconcile patch SHA — either refresh hash after `npm ci` or fix drifted patch file. 2. **`db_orderbook_sim`:** fix `zero_reserve_mirror_returns_no_output` — correct sim to return `InsufficientLiquidity` or update test if mirror semantics changed with #319. 3. **#293:** add indexer integration test asserting `slippage_percent` on solve response for known fixture route. 4. Document failures in `docs/testing.md` if new fixtures required. ## Acceptance criteria - [ ] `make test-frontend` — 1040/1040 including `cosmesPatch127.test.ts`. - [ ] `make test-indexer-integration` completes (lib + integration). - [ ] New or extended integration test covers `slippage_percent` (#293). - [ ] `db_orderbook_sim::zero_reserve_mirror_returns_no_output` passes. ## Test plan - `cd frontend-dapp && npm ci && make test-frontend` - `make setup-indexer-postgres` (if needed) + `make test-indexer-integration` - `cd indexer && cargo test --lib api::db_orderbook_sim` - `bash scripts/verify-issue-293.sh` (should align with new integration test) ## Attack / abuse test plan - `zero_reserve_mirror` must not panic or return positive output on empty reserves (no divide-by-zero). - #293 slippage: symmetric formula edge cases (zero expected out) handled. ## Verification criteria - CI-local `make test-frontend` and `make test-indexer-integration` green on Cloud Agent VM. - No `allow_failure` or skipped tests introduced.
PlasticDigits commented 2026-06-25 14:13:23 +00:00 (Migrated from gitlab.com)

mentioned in issue #411

mentioned in issue #411
PlasticDigits commented 2026-06-25 20:52:06 +00:00 (Migrated from gitlab.com)

mentioned in merge request !943

mentioned in merge request !943
PlasticDigits commented 2026-06-26 06:30:56 +00:00 (Migrated from gitlab.com)

Verification — #420 (PASS)

Verified on main @ 2f26b71d (merge of 4ad0ae14 — cosmes ghunt.22 patch, db_orderbook_sim zero-reserve fix, route_solve_slippage_percent_enrichment_293).

Acceptance criteria

Criterion Result How verified
make test-frontend including cosmesPatch127.test.ts PASS cd frontend-dapp && npm ci && make test-frontend → 184 files, 1084/1084 passed (includes 3/3 in cosmesPatch127.test.ts). Patch SHA fc717f07… matches patches/.cosmes-patch-sha256.
make test-indexer-integration (lib + integration) PASS make setup-indexer-postgres then make test-indexer-integration → exit 0 (~6 min).
slippage_percent (#293) integration coverage PASS cargo test --test api_route_solve route_solve_slippage_percent_enrichment_293 -- --test-threads=1 → ok. Fixture seed_route_slippage_293 asserts slippage_percent, spot_amount_out, token price fields.
db_orderbook_sim::zero_reserve_mirror_returns_no_output PASS cargo test --lib api::db_orderbook_sim → 8/8 ok; zero-reserve mirror with MirrorFreshness::EmptyPool returns DbSimError::InsufficientLiquidity (no panic, no positive output).

Test plan / attack items

Item Result How verified
cd indexer && cargo test --lib api::db_orderbook_sim PASS See above.
bash scripts/qa/verify-issue-293.sh alignment PASS (Postgres layer) Integration test route_solve_slippage_percent_enrichment_293 covers the slippage enrichment acceptance path documented in docs/testing.md. Live OE-1 layer [3] SKIP — LocalTerra/indexer not provisioned on this VM (make has-localterra → not running).
zero_reserve_mirror no divide-by-zero / no positive output PASS Unit test + InsufficientLiquidity assertion.
#293 symmetric slippage edge cases PASS cargo test --lib api::route_slippage → 3/3 ok.

Notes

  • First make test-frontend run hit a flaky unhandled window is not defined from PairSearchSelect debounce timer after TradePage.test.tsx teardown; immediate re-run passed cleanly. Unrelated to #420 scope; consider hardening timer cleanup in a follow-up.
  • verify-issue-293.sh [2] (packages/localnet-trading-swarm vitest) failed here with vitest: not found (deps not installed in that package); not an acceptance gate for #420.

No repo changes or MR opened during verification.

## Verification — #420 (PASS) Verified on `main` @ `2f26b71d` (merge of `4ad0ae14` — cosmes ghunt.22 patch, `db_orderbook_sim` zero-reserve fix, `route_solve_slippage_percent_enrichment_293`). ### Acceptance criteria | Criterion | Result | How verified | |-----------|--------|--------------| | `make test-frontend` including `cosmesPatch127.test.ts` | **PASS** | `cd frontend-dapp && npm ci && make test-frontend` → 184 files, **1084/1084** passed (includes 3/3 in `cosmesPatch127.test.ts`). Patch SHA `fc717f07…` matches `patches/.cosmes-patch-sha256`. | | `make test-indexer-integration` (lib + integration) | **PASS** | `make setup-indexer-postgres` then `make test-indexer-integration` → exit 0 (~6 min). | | `slippage_percent` (#293) integration coverage | **PASS** | `cargo test --test api_route_solve route_solve_slippage_percent_enrichment_293 -- --test-threads=1` → ok. Fixture `seed_route_slippage_293` asserts `slippage_percent`, `spot_amount_out`, token price fields. | | `db_orderbook_sim::zero_reserve_mirror_returns_no_output` | **PASS** | `cargo test --lib api::db_orderbook_sim` → 8/8 ok; zero-reserve mirror with `MirrorFreshness::EmptyPool` returns `DbSimError::InsufficientLiquidity` (no panic, no positive output). | ### Test plan / attack items | Item | Result | How verified | |------|--------|--------------| | `cd indexer && cargo test --lib api::db_orderbook_sim` | **PASS** | See above. | | `bash scripts/qa/verify-issue-293.sh` alignment | **PASS** (Postgres layer) | Integration test `route_solve_slippage_percent_enrichment_293` covers the slippage enrichment acceptance path documented in `docs/testing.md`. Live OE-1 layer **[3]** **SKIP** — LocalTerra/indexer not provisioned on this VM (`make has-localterra` → not running). | | `zero_reserve_mirror` no divide-by-zero / no positive output | **PASS** | Unit test + `InsufficientLiquidity` assertion. | | #293 symmetric slippage edge cases | **PASS** | `cargo test --lib api::route_slippage` → 3/3 ok. | ### Notes - First `make test-frontend` run hit a flaky unhandled `window is not defined` from `PairSearchSelect` debounce timer after `TradePage.test.tsx` teardown; immediate re-run passed cleanly. Unrelated to #420 scope; consider hardening timer cleanup in a follow-up. - `verify-issue-293.sh` **[2]** (`packages/localnet-trading-swarm` vitest) failed here with `vitest: not found` (deps not installed in that package); not an acceptance gate for #420. No repo changes or MR opened during verification.
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-06-26 06:31:03 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic#420
No description provided.