Skip to content

test: add deploy coverage test (orphan-read invariant)#12

Merged
AquiGorka merged 2 commits into
mainfrom
chore/add-deploy-coverage-test
May 7, 2026
Merged

test: add deploy coverage test (orphan-read invariant)#12
AquiGorka merged 2 commits into
mainfrom
chore/add-deploy-coverage-test

Conversation

@AquiGorka
Copy link
Copy Markdown
Contributor

Why this PR exists

Mirrors the test landed in moonlight-pay PR #27 to catch the orphan-read class of bug across the other 3 Moonlight frontends:

  • Frontend reads `config.X` (via a runtime config object).
  • Deploy.yml is supposed to write `X` into the bundled `public/config.js`.
  • If a dev adds a new field to the config interface but forgets to wire it in deploy.yml, the field is silently `undefined` in production. No error, no warning — the feature is just dead.

The original moonlight-pay incident: `adminWallets` had been read by `isAdmin()` since the admin route shipped, but no part of deploy.yml wrote it. The `/#/admin` page was unreachable from day one.

This PR closes the gap on `network-dashboard`.

How it works

`src/lib/config_deploy_test.ts` is a pure static check (no build, no env vars, no runtime):

  1. Extracts the keys declared on `interface DashboardConfig` in `src/lib/config.ts`.
  2. Extracts the keys written by each `Generate ... config` step in `.github/workflows/deploy.yml`, between the `Generate {production,mainnet} config` and `Build production bundle` markers. (This repo's deploy uses `deno eval` rather than a heredoc, but the same line-level regex picks up the JS object keys.)
  3. Fails if any source-side key is missing, unless it's in the per-network `DEFAULT_OK` allowlist (for keys whose source-side default is intentionally correct for that network).

Two assertions: one for testnet (`Generate production config`), one for mainnet (`Generate mainnet config`).

Per-network audit

4 keys declared on `DashboardConfig` (`environment`, `stellarNetwork`, `rpcUrl`, `councilPlatformUrl`).

  • testnet: heredoc writes all 4. `DEFAULT_OK.testnet = ∅`.
  • mainnet: heredoc writes all 4. `DEFAULT_OK.mainnet = ∅`.

No hard orphans, no soft orphans.

Negative-test evidence

Before opening: removed `rpcUrl: Deno.env.get('RPC_URL'),` from the `Generate production config` step → `deno task test` reported failure with `rpcUrl` missing from testnet deploy. Restored the line → green.

```
deploy.yml writes every DashboardConfig key on testnet (or it's in DEFAULT_OK) ...
[Diff] Actual / Expected

  • [
  • "rpcUrl",
    
  • ]
  • []
    FAILED | 1 passed | 1 failed
    ```

Test plan

  • `deno task test` green locally (30 passed total)
  • `deno fmt --check` clean
  • `deno lint` clean
  • `deno task build` clean
  • CI green

AquiGorka added 2 commits May 7, 2026 15:39
Cross-checks every key declared on the DashboardConfig interface in
src/lib/config.ts against the keys written by each 'Generate ... config'
step in .github/workflows/deploy.yml (testnet + mainnet sections). Fails
CI if any read has no matching write, unless the key is in the per-network
DEFAULT_OK allowlist for keys whose source-side default is intentionally
correct.

Mirrors the moonlight-pay test added in PR #27 to catch the same orphan-read
class of bug (e.g. moonlight-pay's adminWallets, which was read by isAdmin()
since the admin route shipped but never written by deploy.yml).

This repo's deploy uses 'deno eval' rather than a heredoc, but the same
'Generate {production,mainnet} config' / 'Build production bundle' markers
delimit the relevant block, and the line-level <word>: regex captures the
config keys identically.
@AquiGorka AquiGorka merged commit 1fbfe6e into main May 7, 2026
4 checks passed
@AquiGorka AquiGorka deleted the chore/add-deploy-coverage-test branch May 7, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant