HTTP integration test: hybrid route cache tier isolation (#306) #797

Merged
PlasticDigits merged 2 commits from cursor/gitlab-issue-workflow-1aaf into main 2026-06-05 12:45:24 +00:00
PlasticDigits commented 2026-06-05 11:12:08 +00:00 (Migrated from gitlab.com)

Summary

Closes the regression gap from GitLab #283 / MR !751 by adding HTTP-level integration tests that seed traders rows with different tier_id values and prove GET /api/v1/route/solve does not serve wrong-discount cached quotes across discount tiers.

Related issue: https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/306

Changes

  • seed_traders_with_tiers test helper in indexer/tests/common/mod.rs
  • start_tier_aware_route_optimizer_mock in indexer/tests/common/lcd_mock.rs — distinct router/hybrid amounts keyed on discount subject (trader if set, else sender)
  • route_solve_get_cache_tier_isolation — tier-0 then tier-5 sequential GETs return different estimated_amount_out; unknown sender resolves tier 0
  • route_solve_get_cache_same_tier_reuses_lcd — two tier-5 senders share cache (wiremock call count stable)
  • route_solve_invalid_sender_returns_400 — sender validation smoke test
  • Docs cross-links in skills/AGENTS_HYBRID_QUOTING.md and docs/indexer-invariants.md

Acceptance checklist

Criterion Verification Result
Merge origin/main (conflict-free; #323 max 4 hops in docs) git merge origin/main on cursor/gitlab-issue-workflow-1aaf PASS
New integration test(s) seed ≥2 traders with different tier_id cargo test --test api_route_solve route_solve_get_cache_tier -j 1 -- --test-threads=1 PASS (CI / Postgres)
Different tiers: sequential GETs return different estimated_amount_out route_solve_get_cache_tier_isolation PASS
Same tier: second GET reuses cache (LCD call count stable) route_solve_get_cache_same_tier_reuses_lcd PASS
Unknown sender resolves tier 0, no tier-5 collision route_solve_get_cache_tier_isolation (unknown sender assertion) PASS
Runs in existing CI job (api_route_solve) cargo test --test api_route_solve -j 1 -- --test-threads=1 PASS (CI)
Skills/docs cross-link test name grep route_solve_get_cache_tier in AGENTS_HYBRID_QUOTING.md + indexer-invariants.md PASS
#283 unit tests unchanged cargo test hybrid_cache_key --lib PASS (post-merge 0583223)

Third-party verification

cd indexer && cargo test route_solve_get_cache_tier -j 1 -- --test-threads=1
cd indexer && cargo test --test api_route_solve -j 1 -- --test-threads=1
cd indexer && cargo test hybrid_cache_key --lib

Requires Postgres at TEST_DATABASE_URL (default dex_indexer_test).

Closes #306

## Summary Closes the regression gap from [GitLab #283](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/283) / MR !751 by adding HTTP-level integration tests that seed `traders` rows with different `tier_id` values and prove `GET /api/v1/route/solve` does **not** serve wrong-discount cached quotes across discount tiers. Related issue: https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/306 ### Changes - `seed_traders_with_tiers` test helper in `indexer/tests/common/mod.rs` - `start_tier_aware_route_optimizer_mock` in `indexer/tests/common/lcd_mock.rs` — distinct router/hybrid amounts keyed on discount subject (`trader` if set, else `sender`) - `route_solve_get_cache_tier_isolation` — tier-0 then tier-5 sequential GETs return different `estimated_amount_out`; unknown sender resolves tier 0 - `route_solve_get_cache_same_tier_reuses_lcd` — two tier-5 senders share cache (wiremock call count stable) - `route_solve_invalid_sender_returns_400` — sender validation smoke test - Docs cross-links in `skills/AGENTS_HYBRID_QUOTING.md` and `docs/indexer-invariants.md` ## Acceptance checklist | Criterion | Verification | Result | |-----------|--------------|--------| | Merge `origin/main` (conflict-free; #323 max 4 hops in docs) | `git merge origin/main` on `cursor/gitlab-issue-workflow-1aaf` | PASS | | New integration test(s) seed ≥2 traders with different tier_id | `cargo test --test api_route_solve route_solve_get_cache_tier -j 1 -- --test-threads=1` | PASS (CI / Postgres) | | Different tiers: sequential GETs return different estimated_amount_out | `route_solve_get_cache_tier_isolation` | PASS | | Same tier: second GET reuses cache (LCD call count stable) | `route_solve_get_cache_same_tier_reuses_lcd` | PASS | | Unknown sender resolves tier 0, no tier-5 collision | `route_solve_get_cache_tier_isolation` (unknown sender assertion) | PASS | | Runs in existing CI job (api_route_solve) | `cargo test --test api_route_solve -j 1 -- --test-threads=1` | PASS (CI) | | Skills/docs cross-link test name | grep `route_solve_get_cache_tier` in AGENTS_HYBRID_QUOTING.md + indexer-invariants.md | PASS | | #283 unit tests unchanged | `cargo test hybrid_cache_key --lib` | PASS (post-merge `0583223`) | ## Third-party verification ```bash cd indexer && cargo test route_solve_get_cache_tier -j 1 -- --test-threads=1 cd indexer && cargo test --test api_route_solve -j 1 -- --test-threads=1 cd indexer && cargo test hybrid_cache_key --lib ``` Requires Postgres at `TEST_DATABASE_URL` (default `dex_indexer_test`). Closes #306
ghost1 commented 2026-06-05 11:12:15 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
PlasticDigits commented 2026-06-05 11:12:21 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
PlasticDigits commented 2026-06-05 11:12:21 +00:00 (Migrated from gitlab.com)

mentioned in issue #306

mentioned in issue #306
ghost1 commented 2026-06-05 11:12:23 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
PlasticDigits commented 2026-06-05 11:17:12 +00:00 (Migrated from gitlab.com)

Security review

Commit reviewed: 662cab65231b9c8f767f2e2a273180ab2db9c3f3
Scope: 5 files — integration tests (api_route_solve.rs), test helpers (lcd_mock.rs, mod.rs), and docs cross-links (indexer-invariants.md, AGENTS_HYBRID_QUOTING.md). No changes under indexer/src/, frontend-dapp/, or smartcontracts/.

Outcome: FINDINGS: 0 medium+

Security review: no medium+ findings on this diff.

What was reviewed

  • Production attack surface: None introduced. All new code lives in indexer/tests/ (wiremock LCD stubs, DB seed helpers, HTTP integration assertions). Test binaries are not shipped with the indexer service.
  • Injection: seed_traders_with_tiers uses parameterized sqlx binds ($1, $2); no string concatenation into SQL.
  • Authn/authz, SSRF, secrets, deserialization: No new endpoints, LCD client behavior, auth middleware, logging, or dependency changes in this diff.
  • Regression guard: route_solve_invalid_sender_returns_400 exercises existing sender validation (invalid address → 400); it does not weaken controls.

Prior review threads

No prior security-review inline comments on this MR. Nothing to re-report.

Inline threads

None (no medium+ findings).

## Security review **Commit reviewed:** `662cab65231b9c8f767f2e2a273180ab2db9c3f3` **Scope:** 5 files — integration tests (`api_route_solve.rs`), test helpers (`lcd_mock.rs`, `mod.rs`), and docs cross-links (`indexer-invariants.md`, `AGENTS_HYBRID_QUOTING.md`). No changes under `indexer/src/`, `frontend-dapp/`, or `smartcontracts/`. **Outcome:** `FINDINGS: 0` medium+ Security review: no medium+ findings on this diff. ### What was reviewed - **Production attack surface:** None introduced. All new code lives in `indexer/tests/` (wiremock LCD stubs, DB seed helpers, HTTP integration assertions). Test binaries are not shipped with the indexer service. - **Injection:** `seed_traders_with_tiers` uses parameterized `sqlx` binds (`$1`, `$2`); no string concatenation into SQL. - **Authn/authz, SSRF, secrets, deserialization:** No new endpoints, LCD client behavior, auth middleware, logging, or dependency changes in this diff. - **Regression guard:** `route_solve_invalid_sender_returns_400` exercises existing sender validation (invalid address → 400); it does not weaken controls. ### Prior review threads No prior security-review inline comments on this MR. Nothing to re-report. ### Inline threads None (no medium+ findings).
ghost1 commented 2026-06-05 12:43:27 +00:00 (Migrated from gitlab.com)

added 24 commits

  • 662cab65...b9121d83 - 23 commits from branch main
  • 0583223a - merge: resolve main conflicts for MR !797 (#306)

Compare with previous version

added 24 commits <ul><li>662cab65...b9121d83 - 23 commits from branch <code>main</code></li><li>0583223a - merge: resolve main conflicts for MR !797 (#306)</li></ul> [Compare with previous version](/PlasticDigits/cl8y-dex-terraclassic/-/merge_requests/79/diffs?diff_id=1836697895&start_sha=662cab65231b9c8f767f2e2a273180ab2db9c3f3)
ghost1 commented 2026-06-05 12:43:28 +00:00 (Migrated from gitlab.com)

mentioned in commit 0583223a6a

mentioned in commit 0583223a6af69ed46903d25ed5336eb9644b98dd
ghost1 commented 2026-06-05 12:43:42 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
PlasticDigits commented 2026-06-05 12:44:24 +00:00 (Migrated from gitlab.com)

Security review

Commit reviewed: 0583223a6af69ed46903d25ed5336eb9644b98dd
Scope: 6 files — integration tests (api_route_solve.rs), test helpers (lcd_mock.rs, mod.rs), docs cross-links (indexer-invariants.md, AGENTS_HYBRID_QUOTING.md), and a cosmetic import-format change in frontend-dapp/src/utils/__tests__/indexerErrors.test.ts. No changes under indexer/src/ or smartcontracts/.

Outcome: FINDINGS: 0 medium+

Security review: no medium+ findings on this diff.

What was reviewed

  • Production attack surface: None introduced. All new Rust code lives in indexer/tests/ (wiremock LCD stubs, DB seed helpers, HTTP integration assertions). Test binaries are not shipped with the indexer service.
  • Injection: seed_traders_with_tiers uses parameterized sqlx binds ($1, $2); no string concatenation into SQL.
  • Authn/authz, SSRF, secrets, deserialization: No new endpoints, LCD client behavior, auth middleware, logging, or dependency changes in this diff.
  • Regression guard: route_solve_invalid_sender_returns_400 exercises existing sender validation (invalid address → 400); it does not weaken controls.
  • Merge commit delta: Re-reviewed after merge with main (commit 0583223a…); diff unchanged in security-relevant terms — still test/docs only.

Prior review threads

Prior top-level review on 662cab65231b9c8f767f2e2a273180ab2db9c3f3 reached the same conclusion. No inline security threads to re-report; findings still do not apply.

Inline threads

None (no medium+ findings).

## Security review **Commit reviewed:** `0583223a6af69ed46903d25ed5336eb9644b98dd` **Scope:** 6 files — integration tests (`api_route_solve.rs`), test helpers (`lcd_mock.rs`, `mod.rs`), docs cross-links (`indexer-invariants.md`, `AGENTS_HYBRID_QUOTING.md`), and a cosmetic import-format change in `frontend-dapp/src/utils/__tests__/indexerErrors.test.ts`. No changes under `indexer/src/` or `smartcontracts/`. **Outcome:** `FINDINGS: 0` medium+ Security review: no medium+ findings on this diff. ### What was reviewed - **Production attack surface:** None introduced. All new Rust code lives in `indexer/tests/` (wiremock LCD stubs, DB seed helpers, HTTP integration assertions). Test binaries are not shipped with the indexer service. - **Injection:** `seed_traders_with_tiers` uses parameterized `sqlx` binds (`$1`, `$2`); no string concatenation into SQL. - **Authn/authz, SSRF, secrets, deserialization:** No new endpoints, LCD client behavior, auth middleware, logging, or dependency changes in this diff. - **Regression guard:** `route_solve_invalid_sender_returns_400` exercises existing sender validation (invalid address → 400); it does not weaken controls. - **Merge commit delta:** Re-reviewed after merge with `main` (commit `0583223a…`); diff unchanged in security-relevant terms — still test/docs only. ### Prior review threads Prior top-level review on `662cab65231b9c8f767f2e2a273180ab2db9c3f3` reached the same conclusion. No inline security threads to re-report; findings still do not apply. ### Inline threads None (no medium+ findings).
PlasticDigits commented 2026-06-05 12:44:27 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
PlasticDigits commented 2026-06-05 12:45:16 +00:00 (Migrated from gitlab.com)

resolved all threads

resolved all threads
PlasticDigits commented 2026-06-05 12:45:25 +00:00 (Migrated from gitlab.com)

mentioned in commit 1a2801a287

mentioned in commit 1a2801a287d77ba3f5a348a43a9213e53b37fb9b
PlasticDigits (Migrated from gitlab.com) merged commit 1a2801a287 into main 2026-06-05 12:45:25 +00:00
Sign in to join this conversation.
No reviewers
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!797
No description provided.