Skip to content

fix(cli)(sphere-sdk#455): mint test tokens locally (drop HTTP faucet)#45

Merged
vrogojin merged 1 commit into
mainfrom
fix/sphere-sdk-455
Jun 10, 2026
Merged

fix(cli)(sphere-sdk#455): mint test tokens locally (drop HTTP faucet)#45
vrogojin merged 1 commit into
mainfrom
fix/sphere-sdk-455

Conversation

@vrogojin

@vrogojin vrogojin commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Closes upstream: unicity-sphere/sphere-sdk#455

Summary

  • sphere faucet / topup / top-up now mint test tokens directly via the L3 aggregator (sphere.payments.mintFungibleToken()).
  • External https://faucet.unicity.network HTTP service is no longer touched. This removes the dominant cause of sphere-sdk#455 single-coin soak flakiness (the HTTP→Nostr→relay→subscriber race).
  • Nametag precondition dropped — local mint goes to the wallet's own signing key.
  • Default bulk-mint coin set unchanged: UCT 100, BTC 1, ETH 42, SOL 1000, USDT 1000, USDC 1000, USDU 1000.

Why

sphere-sdk#455 documents manual-test-swap-roundtrip.sh failing consistently at §2 because sphere faucet 100 UCT (single-coin path) returned HTTP 200 but the receiver's wallet never materialized the token. Bulk sphere faucet (7 events) usually survived; single-event runs lost their event in a relay TTL / subscription-window race. Cutting the HTTP faucet and minting locally bypasses the whole race.

Test plan

  • npm run build — clean
  • npx tsc --noEmit — exit 0
  • npx vitest run — 127/127 unit tests pass
  • npx vitest run --config vitest.integration.config.ts test/integration/cli-faucet.integration.test.ts — 3 pass + 1 skipped (live mint gated by E2E_RUN_FAUCET)
  • E2E_RUN_FAUCET=1 ... — 4/4 including live mint of 1 UCT against testnet aggregator (no nametag, ~4s)
  • Manual smoke test on a fresh wallet against testnet — bulk sphere faucet minted all 7 coins, exit 0
  • Re-run manual-test-swap-roundtrip.sh — Scenarios A (happy-path) + B (reject) both ALL GREEN. §2 baselines materialize on first try (alice 100 UCT, bob 100 ETH); swap deposits/payouts complete; balance deltas match exactly. See sphere-sdk#456 for the one unrelated infra blocker uncovered along the way (the @escrow-testnet nametag resolution failure — worked around with ESCROW=DIRECT://...).

Notes

  • sphere-sdk needs no companion PR — PaymentsModule.mintFungibleToken() is already on main (added in feat/migrate-state-transition-sdk → 5c8e5b6).
  • Symbol resolution accepts both legacy faucet names (unicity, bitcoin) and canonical symbols (UCT, BTC).
  • Bulk mint runs sequentially — keeps output ordered and sidesteps storage-write races on concurrent addToken() calls. ~7 inclusion-proof waits ≈ 10s in practice.

Related

  • Fixes the root cause behind sphere-sdk#455 (single-coin faucet flakiness).
  • Discovered during validation: sphere-sdk#456 (@escrow-testnet nametag does not resolve on testnet relay) — unrelated infra issue, does not affect this PR.

…P faucet

The faucet/topup/top-up handlers now call sphere.payments.mintFungibleToken()
to mint test tokens directly via the L3 aggregator. This removes the
dependency on the external https://faucet.unicity.network HTTP service —
which was the dominant cause of the soak flakiness reported in #455
(single-coin path lost Nostr events; bulk path stayed lucky because 7
parallel events raised retention odds).

Behavioral changes:
- Nametag precondition dropped — local mint goes to the wallet's own
  signing key; nothing on-chain depends on a registered nametag.
- Default coin set unchanged (UCT 100, BTC 1, ETH 42, SOL 1000,
  USDT 1000, USDC 1000, USDU 1000) — soaks/playbooks see the same
  balances after `sphere faucet`.
- Symbol resolution covers both the legacy faucet names ("unicity",
  "bitcoin", ...) and the canonical symbols ("UCT", "BTC", ...).
- Bulk mint runs sequentially to keep output ordered and sidestep
  potential storage-write races between concurrent addToken() calls.
- Help text + command listing refreshed to reflect "mint locally".

Integration test: dropped the no-nametag dispatch pin (premise gone) and
refreshed the live-mint test to match the new "Minting … locally" /
"Received …" wording. Help-shape pins still cover all three aliases.

Verified: typecheck clean; 127 unit tests pass; integration faucet suite
4/4 pass including live mint of 1 UCT against the testnet aggregator.
@vrogojin vrogojin merged commit d6ac128 into main Jun 10, 2026
2 checks passed
@vrogojin vrogojin deleted the fix/sphere-sdk-455 branch June 10, 2026 15:05
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