Files
wikideck/docs/night2/TESTNET.md
T
claudeanderic dbb89ce9c5 Night 2: 40-card Magic-style duel, PvP with owned decks, polite Wikimedia client, Android mining (#23)
Night 2 (2026-11-17), from the `claude/wikideck` fork's `night/2026-11-17` branch. It follows Night 1 (#22).

## What's in it
- **Duel engine** (fork #72, #80): 40-card decks of cards you own, Notability/Citations, keywords, effects T1–T12, Connected, a hidden-information-safe `viewFor`/`logFor`, and replay. Balance v1 tuning (#84) gives the first player about 51%.
- **Card profiles** (#70, #82): Figure, Location, Event, Institution or Doctrine, plus stats, keywords and rules text, all derived from real article data. Templates only.
- **Design and story** (#66, #69, #83): DUEL_DESIGN.md, plus the match log and the encyclopedic "Battle of X (2026)" recap.
- **PvP** (#74, #77, #81, #76, #85):
  - The server checks ownership, and 40-card eligibility is enforced.
  - Modes: Classic (ranked), Draft and Trending.
  - Invites, quick match, Elo, a ladder and recap pages. Online matches render on the duel board.
- **Duel board UI** (#79): MTG-style card faces and combat declaration, built for 360 px first.
- **Polite Wikimedia client** (#73, #75): throttled, cached and identified requests, the mint-path fix, and a prefetch pool.
- **Android mining** (#78): native RandomX, as a sideload build. The emulator mined a testnet block.
- **Testnet ops** (#67, #68).

PR numbers refer to `claude/wikideck`.

## Status
- **Tests:** 423, of which 422 pass, 0 fail and 1 is skipped. The build is OK (`node:24-alpine`, `--network none`).
- **Testnet:** running this commit (036489c) on r350.
- **Untouched:** no changes to `server/testnet/consensus.ts`, `randomx.ts`, `native/` or the mainnet compose.
- **Review:** night-review reviewed fork #66–#79. #80–#85 came from the agents' unfinished branches and were not reviewed.
- **Known gaps:**
  - The PvP end-to-end test hasn't been run (it needs two eom.dev accounts).
  - Bot matches aren't reachable from Play.
  - Card identity pre-bake hasn't been done.
  - The RandomX verifier latch (`server/testnet/randomx.ts:140`) is still open.

This PR is for Eric to merge.

🤖 Generated with [Claude Code](https://claude.com/claude-code)Reviewed-on: #23

Co-authored-by: Claude <claude@eom.dev>
2026-11-18 18:12:24 +00:00

5.9 KiB
Raw Blame History

Night 2 private testnet: how to test (testnet-ops, #63)

Testnet only, LAN only, on poweredge-r350. It is never mainnet and never the live wikideck namespace.

Nodes

node URL game modes (env from Night 1 #22)
node-a http://192.168.1.32:3101 classic, trending
node-b http://192.168.1.32:3102 draft
node-c http://192.168.1.32:3103 classic, draft, trending
  • Autodeploy: the nodes follow night/2026-11-17. A loop on r350 (deploy/night/autodeploy.sh, in a dedicated detached worktree) polls the branch every 3 min.
    • On a new head it rebuilds the image and restarts node-a, then b, then c, each after the previous one passes /healthz.
    • While any match or lobby is live it defers, for up to 15 min.
    • Lobbies are in memory, so a deploy that does go through ends games in progress. After night-lead merges, wait about 5 min, or check that all three nodes report the new head, before you start an end-to-end run.
  • Ledgers persist in the Docker volumes across deploys.

Test wallets

Four disposable wallets: alice, bob, carol and dave.

wallet address cards (confirmed)
alice ff9273368c225698d8ae34430800cfe30b10a1c3d8c21091d42960493db556df see #63
bob 80f17f10ca782efd16783d10d71ce43b2993aadccda36dbd0364dee1921cbc22 see #63
carol f2d908633c4313bd77e86650c13d11ac3e7e656223ebe881cc34ffba3f3e0524 leftovers
dave 02bb97f202e1616ab97b45e8938e384dcbf622a0b44a7f4c1589f44236d3ccef leftovers
  • Confirmed at height 91: alice 41, bob 40, carol 5, dave 5. Block #92 came from the Android emulator (#59).
  • alice and bob were consolidated to 40 cards each with on-chain NFT transfers from carol and dave, so production deckSize 40 works on the testnet and no lower-deckSize test mode is needed.
  • The encrypted browser backups are in a comment on #63, not in git.
    • Backup password: wikideck-night-testnet. It is public and testnet-only: never reuse it, and never put a real secret next to it.
    • Anyone who can read this repo's issues can open these wallets. Keep them on the LAN-only testnet, and never send them anything of value.
  • Re-check counts at any time: GET http://192.168.1.32:3101/api/decks/<address>?offset=0&limit=24 (pages of 24, follow next).

Load a wallet in the browser

First make the node origins a secure context (found by night-review on #63).

  • http://192.168.1.32:310x is plain HTTP on a LAN address, so the browser leaves crypto.subtle undefined. Open wallet then fails with "Cannot read properties of undefined (reading 'digest')" or "Wallet storage unavailable".
  • Chrome/Chromium: open chrome://flags/#unsafely-treat-insecure-origin-as-secure, add http://192.168.1.32:3101,http://192.168.1.32:3102,http://192.168.1.32:3103, then relaunch.
  • Command line: --unsafely-treat-insecure-origin-as-secure=http://192.168.1.32:3101,http://192.168.1.32:3102,http://192.168.1.32:3103 --user-data-dir=<fresh profile dir>.
  • Playwright: use the full chromium channel. The headless shell ignores this flag.
  • SSH tunnel to localhost: this also works for the wallet, but it breaks the Dex callback URLs, so you can't do the login/link step that way.
  • Firefox has no per-origin equivalent.

Use a separate browser profile per player, because a browser holds one wallet per origin.

  1. Open a node URL, then Open wallet.
  2. Recover from a local backup: choose the backup JSON file (save it from the #63 comment as alice.backup.json), and enter the backup password above.
  3. Set a new local encryption password (at least 12 characters, anything testnet-only), then confirm it.
  4. The wallet dialog should show the address above and its confirmed card count.

eom.dev login (Dex)

  • There is no new Dex config tonight. The existing wikideck client already allows the 3101–3103 callbacks.
  • Log in with Log in with eom.dev, then unlock the wallet and press Link wallet … to link it to the account.
  • PvP seats are keyed to the account, and ownership is checked on the server against the account's linked wallets. So for a two-player run you need two eom.dev accounts, one with alice linked and one with bob. Which accounts to use is night-lead's call (see #53/#63). Never use a real person's account without their OK.

Mining on the testnet

  • Mining isn't needed for tests. Only run a miner if night-lead asks for more blocks, or to confirm transfers.
  • deploy/night/testnet.sh mine N [workers] runs the native multi-worker miner in a container named wikideck-night-miner (at most 4 workers on r350).
    • Every template costs Wikipedia requests on the node, so it is paced by MIN_GAP.
    • testnet-ops stops any miner by 01:55 (docker rm -f wikideck-night-miner). The nodes stay up.
  • Difficulty (for mobile mining, #59): at block ~90, an accepted block took between about 2 K and 130 K hashes. That is up to ~8 min at the 4-worker r350 rate of ~250 H/s. One light-mode thread on the emulator is far slower, so expect a long wait per block, with high variance.

Card identity pre-bake (engineer WS E)

  • server/game/identity.ts is a persistent per-token store (node:sqlite). It freezes each card's off-chain identity at first sight and never rewrites it. The identity covers P31/P279 classes, description, categories, countries, years, coordinates and outlink pageIds. Its fields match duel-cards' CardProfile (#70), and toProfile() returns that view.
  • scripts/night2/prebake-identity.ts --node <url> [--store <file>] [--cards <cached.json> ...] reads the canonical chain from one node and freezes what the cached card files know. The store defaults to $WIKIDECK_DATA_DIR/card-identity.sqlite (identityStoreFile()), and hosts should open it at the same path.
    • It never calls Wikimedia itself.
    • Live facts arrive only through the wikimedia team's client on its background lane (#62), once that client has merged.
    • Cards that are still unknown stay unfrozen and are retried on a later run.