Testing: EVM, Terra Classic, and web portal coverage (no Telegram/Solana) #4

Closed
opened 2026-08-10 00:41:42 +00:00 by PlasticDigits · 11 comments
PlasticDigits commented 2026-08-10 00:41:42 +00:00 (Migrated from gitlab.com)

Summary

Raise automated test coverage for EVM, Terra Classic, and the web portal only. Explicitly postpone Telegram and Solana test work.

This issue bundles unit, integration, Playwright e2e, CI wiring, and abuse-path tests that support:

  • Terra/Keplr ADR-036 fix (issue #1)
  • Portal terms disclosure UX (issue #2)
  • Security ops hardening (issue #3)

Implement tests alongside or immediately after those features; do not merge “tests only green because paths are mocked incorrectly.”

Related gap analysis: gaps/GAP_1786322222.md § Testing.


Current codebase

API

  • Unit: EVM roundtrip (api/src/verify/evm.rs); Terra raw-byte roundtrip (api/src/verify/terra.rs) — not ADR-036; rate limit /update_terms (api/src/rate_limit.rs); message/timestamp (api/src/message.rs).
  • Integration: one EVM multi-property test (api/tests/integration_test.rs).
  • Missing: Terra wallet integration; admin auth negatives; XFF/proxy; authenticated /update_terms; redirect N/A on API.

Web

  • Vitest: web/src/ui.test.ts, web/src/query.test.ts, web/src/base58.test.ts (Solana-oriented — low priority now).
  • Missing: page-level tests for terms render/consent; redirect allowlist tests in ui.ts.

E2E (Playwright)

  • web/e2e/home.spec.ts, sign-pages.spec.ts (property required), evm-sign.spec.ts (mock wallet full path), telegram-config.spec.ts (out of scope / leave as-is).
  • web/e2e/global-setup.ts publishes terms via unauthenticated POST /update_terms (must track security issue auth change).
  • Config: web/playwright.config.ts — Chromium; workers already set for CI.

SDK

  • Message golden + client/poll/TermsGate tests exist; portal-focused work may add redirect validation helper tests if implemented in SDK.

CI

  • .gitlab-ci.yml: test:rust, test:web, test:e2e, test:clickwrap. No Terra e2e today.

Why this is needed

EVM is the only production-credible path under test. Terra Classic cannot be trusted without ADR-036 vectors and a portal e2e. Portal UX and security changes will regress without assertions. Gap analysis called out EVM-centric coverage as a primary risk for the in-scope networks.


Constraints / guardrails

  1. In scope networks/surfaces: EVM, Terra Classic, portal pages (/, /sign/evm, /sign/terra-classic), shared ui/query/api helpers, API wallet verify/submit/status, /update_terms auth, admin token boot behavior, redirect_uri, rate-limit IP trust.
  2. Out of scope: New Telegram/Solana e2e or fixing those verifiers; bot unit/e2e; OpenAPI generation.
  3. No false confidence: Terra tests must exercise ADR-036 (or skip with clear #[ignore] only while #1 unfinished — prefer implementing with #1).
  4. Secrets: Use fixture keys only; never commit production ADMIN_TOKEN / bot tokens.
  5. CI cost: Keep Playwright on Chromium unless a second browser is justified; reuse existing Postgres service pattern.
  6. Flake control: Mock Keplr/Ethereum in e2e; deterministic fixtures; avoid live Keplr extension in CI.
  7. Coordinate with #3: Update e2e/CI to send Bearer on /update_terms when auth lands.

Relevant files

Area Path
API tests api/tests/integration_test.rs, api/src/verify/{evm,terra}.rs, api/src/rate_limit.rs, api/src/routes/{update_terms,admin,signatures}.rs
Web unit web/src/*.test.ts, new page/helper tests
E2E web/e2e/*, web/e2e/helpers/evm-wallet.ts, new terra-wallet.ts mock
CI .gitlab-ci.yml
Playwright web/playwright.config.ts

  1. API: Add Terra ADR-036 unit vectors + integration submit/status; admin 401 tests; /update_terms 401/200; client_ip unit tests for trusted vs untrusted proxy.
  2. Web unit: Terms shell/consent helpers; renderSuccess redirect allowlist cases.
  3. E2E:
    • Extend sign-page specs: terms text visible on EVM + Terra.
    • Keep/enhance EVM mock wallet success path.
    • Add Terra Classic mock Keplr e2e (inject window.keplr.signArbitrary returning fixture sig only if API accepts that fixture — otherwise API-level integration is the gate).
    • Redirect allowlist: good URI navigates / bad URI does not.
  4. CI: Ensure new tests run in test:rust / test:web / test:e2e; document any new env vars (ADMIN_TOKEN, allowlists).
  5. Do not expand telegram-config.spec.ts except to keep CI green if env changes.

Acceptance criteria

  • API has ADR-036 Terra unit coverage and at least one Terra integration path (submit → status).
  • API tests cover /update_terms auth and XFF/trust behavior once #3 lands (or behind feature flags in the same MR train).
  • Portal unit or e2e asserts terms disclosure on EVM + Terra Classic pages (ties to #2).
  • EVM Playwright full sign remains green.
  • Terra Classic Playwright path exists or explicitly documented as API-integration-only with tracked follow-up if Keplr mock cannot produce valid ADR-036 in CI — prefer full e2e.
  • Redirect allowlist covered by automated test.
  • CI jobs updated; no reliance on unauthenticated /update_terms after #3.
  • No new Telegram/Solana test debt required for close.

Test plan (functional paths)

Path Layer Notes
EVM sign → status Unit + integration + e2e Already partly present; harden
Terra ADR-036 sign → status Unit + integration + e2e/mock Blocked on #1
Terms visible before CTA E2E (+ unit if shell extracted) Blocked on #2
Consent gate E2E If implemented in #2
Home → EVM/Terra links E2E Property + href
Missing property E2E Existing
Latest terms content fetch Web unit / e2e Error + success
Authenticated terms sync API + e2e setup #3
Allowlisted redirect Web unit + e2e #3
Signature status already true Optional e2e If UX short-circuit added

Test plan (attack / abuse / hack vectors)

Vector Layer Expectation
Unauth /update_terms API 401; no sync side effect
Invalid admin bearer API 401
XFF spoof without trust API Peer IP used for limits
Cross-property signature replay API Reject
Terra sig over wrong ADR-036 payload API Reject
EVM sig for different account/message API Reject
XSS in terms body / query params E2E or unit Text-only render
Evil redirect_uri E2E No navigation
Write rate-limit exhaustion API 429
Oversized wallet POST body API 4xx (document limit)

Verification criteria

  • cd api && cargo test green with new cases.
  • npm run test:web and npm run test:sdk green.
  • cd web && npm run test:e2e green in CI with Postgres + authenticated sync.
  • Coverage narrative in MR: what is proven for EVM vs Terra vs portal; explicit non-goals (Telegram/Solana).
  • Issues #1–#3 each have automated checks mapped in the MR description before those issues close.
## Summary Raise automated test coverage for **EVM**, **Terra Classic**, and the **web portal** only. Explicitly **postpone** Telegram and Solana test work. This issue bundles unit, integration, Playwright e2e, CI wiring, and abuse-path tests that support: - Terra/Keplr ADR-036 fix (issue #1) - Portal terms disclosure UX (issue #2) - Security ops hardening (issue #3) Implement tests alongside or immediately after those features; do not merge “tests only green because paths are mocked incorrectly.” **Related gap analysis:** `gaps/GAP_1786322222.md` § Testing. --- ## Current codebase ### API - Unit: EVM roundtrip (`api/src/verify/evm.rs`); Terra **raw-byte** roundtrip (`api/src/verify/terra.rs`) — not ADR-036; rate limit `/update_terms` (`api/src/rate_limit.rs`); message/timestamp (`api/src/message.rs`). - Integration: **one** EVM multi-property test (`api/tests/integration_test.rs`). - **Missing:** Terra wallet integration; admin auth negatives; XFF/proxy; authenticated `/update_terms`; redirect N/A on API. ### Web - Vitest: `web/src/ui.test.ts`, `web/src/query.test.ts`, `web/src/base58.test.ts` (Solana-oriented — low priority now). - **Missing:** page-level tests for terms render/consent; redirect allowlist tests in `ui.ts`. ### E2E (Playwright) - `web/e2e/home.spec.ts`, `sign-pages.spec.ts` (property required), `evm-sign.spec.ts` (mock wallet full path), `telegram-config.spec.ts` (**out of scope / leave as-is**). - `web/e2e/global-setup.ts` publishes terms via unauthenticated `POST /update_terms` (must track security issue auth change). - Config: `web/playwright.config.ts` — Chromium; workers already set for CI. ### SDK - Message golden + client/poll/TermsGate tests exist; portal-focused work may add redirect validation helper tests if implemented in SDK. ### CI - `.gitlab-ci.yml`: `test:rust`, `test:web`, `test:e2e`, `test:clickwrap`. No Terra e2e today. --- ## Why this is needed EVM is the only production-credible path under test. Terra Classic cannot be trusted without ADR-036 vectors and a portal e2e. Portal UX and security changes will regress without assertions. Gap analysis called out EVM-centric coverage as a primary risk for the in-scope networks. --- ## Constraints / guardrails 1. **In scope networks/surfaces:** EVM, Terra Classic, portal pages (`/`, `/sign/evm`, `/sign/terra-classic`), shared `ui`/`query`/`api` helpers, API wallet verify/submit/status, `/update_terms` auth, admin token boot behavior, redirect_uri, rate-limit IP trust. 2. **Out of scope:** New Telegram/Solana e2e or fixing those verifiers; bot unit/e2e; OpenAPI generation. 3. **No false confidence:** Terra tests must exercise **ADR-036** (or skip with clear `#[ignore]` only while #1 unfinished — prefer implementing with #1). 4. **Secrets:** Use fixture keys only; never commit production `ADMIN_TOKEN` / bot tokens. 5. **CI cost:** Keep Playwright on Chromium unless a second browser is justified; reuse existing Postgres service pattern. 6. **Flake control:** Mock Keplr/Ethereum in e2e; deterministic fixtures; avoid live Keplr extension in CI. 7. **Coordinate with #3:** Update e2e/CI to send Bearer on `/update_terms` when auth lands. --- ## Relevant files | Area | Path | |------|------| | API tests | `api/tests/integration_test.rs`, `api/src/verify/{evm,terra}.rs`, `api/src/rate_limit.rs`, `api/src/routes/{update_terms,admin,signatures}.rs` | | Web unit | `web/src/*.test.ts`, new page/helper tests | | E2E | `web/e2e/*`, `web/e2e/helpers/evm-wallet.ts`, new `terra-wallet.ts` mock | | CI | `.gitlab-ci.yml` | | Playwright | `web/playwright.config.ts` | --- ## Recommended direction 1. **API:** Add Terra ADR-036 unit vectors + integration submit/status; admin 401 tests; `/update_terms` 401/200; `client_ip` unit tests for trusted vs untrusted proxy. 2. **Web unit:** Terms shell/consent helpers; `renderSuccess` redirect allowlist cases. 3. **E2E:** - Extend sign-page specs: terms text visible on EVM + Terra. - Keep/enhance EVM mock wallet success path. - Add Terra Classic mock Keplr e2e (inject `window.keplr.signArbitrary` returning fixture sig **only if** API accepts that fixture — otherwise API-level integration is the gate). - Redirect allowlist: good URI navigates / bad URI does not. 4. **CI:** Ensure new tests run in `test:rust` / `test:web` / `test:e2e`; document any new env vars (`ADMIN_TOKEN`, allowlists). 5. **Do not** expand `telegram-config.spec.ts` except to keep CI green if env changes. --- ## Acceptance criteria - [ ] API has ADR-036 Terra unit coverage and at least one Terra integration path (submit → status). - [ ] API tests cover `/update_terms` auth and XFF/trust behavior once #3 lands (or behind feature flags in the same MR train). - [ ] Portal unit or e2e asserts terms disclosure on EVM + Terra Classic pages (ties to #2). - [ ] EVM Playwright full sign remains green. - [ ] Terra Classic Playwright path exists **or** explicitly documented as API-integration-only with tracked follow-up if Keplr mock cannot produce valid ADR-036 in CI — prefer full e2e. - [ ] Redirect allowlist covered by automated test. - [ ] CI jobs updated; no reliance on unauthenticated `/update_terms` after #3. - [ ] No new Telegram/Solana test debt required for close. --- ## Test plan (functional paths) | Path | Layer | Notes | |------|-------|-------| | EVM sign → status | Unit + integration + e2e | Already partly present; harden | | Terra ADR-036 sign → status | Unit + integration + e2e/mock | Blocked on #1 | | Terms visible before CTA | E2E (+ unit if shell extracted) | Blocked on #2 | | Consent gate | E2E | If implemented in #2 | | Home → EVM/Terra links | E2E | Property + href | | Missing `property` | E2E | Existing | | Latest terms content fetch | Web unit / e2e | Error + success | | Authenticated terms sync | API + e2e setup | #3 | | Allowlisted redirect | Web unit + e2e | #3 | | Signature status already true | Optional e2e | If UX short-circuit added | --- ## Test plan (attack / abuse / hack vectors) | Vector | Layer | Expectation | |--------|-------|-------------| | Unauth `/update_terms` | API | 401; no sync side effect | | Invalid admin bearer | API | 401 | | XFF spoof without trust | API | Peer IP used for limits | | Cross-property signature replay | API | Reject | | Terra sig over wrong ADR-036 payload | API | Reject | | EVM sig for different account/message | API | Reject | | XSS in terms body / query params | E2E or unit | Text-only render | | Evil `redirect_uri` | E2E | No navigation | | Write rate-limit exhaustion | API | 429 | | Oversized wallet POST body | API | 4xx (document limit) | --- ## Verification criteria - `cd api && cargo test` green with new cases. - `npm run test:web` and `npm run test:sdk` green. - `cd web && npm run test:e2e` green in CI with Postgres + authenticated sync. - Coverage narrative in MR: what is proven for EVM vs Terra vs portal; explicit non-goals (Telegram/Solana). - Issues #1–#3 each have automated checks mapped in the MR description before those issues close.
PlasticDigits commented 2026-08-10 00:41:44 +00:00 (Migrated from gitlab.com)

marked as related to #1

marked as related to #1
PlasticDigits commented 2026-08-10 00:41:46 +00:00 (Migrated from gitlab.com)

marked as related to #2

marked as related to #2
PlasticDigits commented 2026-08-10 00:41:48 +00:00 (Migrated from gitlab.com)

marked as related to #3

marked as related to #3
PlasticDigits commented 2026-08-10 01:11:28 +00:00 (Migrated from gitlab.com)

mentioned in merge request !23

mentioned in merge request !23
PlasticDigits commented 2026-08-10 02:29:46 +00:00 (Migrated from gitlab.com)

mentioned in commit 69e117eb88

mentioned in commit 69e117eb88d9f5e985ca1c0108fdf88810858a13
PlasticDigits commented 2026-08-10 02:29:57 +00:00 (Migrated from gitlab.com)

mentioned in merge request !24

mentioned in merge request !24
PlasticDigits commented 2026-08-11 00:38:35 +00:00 (Migrated from gitlab.com)

mentioned in commit 87227379a4

mentioned in commit 87227379a45a0a2be5ebb8df1c8cf0a32d35d6be
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-08-11 00:38:36 +00:00
PlasticDigits commented 2026-08-30 16:01:44 +00:00 (Migrated from gitlab.com)

mentioned in merge request !32

mentioned in merge request !32
PlasticDigits commented 2026-08-31 04:12:25 +00:00 (Migrated from gitlab.com)

mentioned in issue #16

mentioned in issue #16
PlasticDigits commented 2026-08-31 04:31:53 +00:00 (Migrated from gitlab.com)

marked as related to #17

marked as related to #17
PlasticDigits commented 2026-08-31 04:41:31 +00:00 (Migrated from gitlab.com)

mentioned in merge request !33

mentioned in merge request !33
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-ecosystem-legal#4
No description provided.