Add Transaction Builder Tests & tRPC Integration Tests
Background
Two gaps exist in the current test coverage:
-
Gap 1 — Transaction building is untested. The DRep certificate wiring in registerDrep.tsx, updateDrep.tsx, and retire.tsx is inlined and cannot be exercised without a browser. The staking certificate helpers in stakingCertificates.ts are extracted but have no tests. The proxy contract methods in offchain.ts have no test coverage at all.
-
Gap 2 — The tRPC persistence path is untested. The browser persists transactions via transaction.createTransaction. A schema mismatch, DB constraint violation, wrong state value, or authorization regression in the tRPC layer is not caught today.
What We're Adding
Option B — Transaction Builder Unit Tests (Jest, no browser)
Extract shared transaction-building logic into testable functions and cover them with Jest tests that run in Node.js using a mock BlockfrostProvider.
Phase 0 — Add cbor-x dev dependency
Phase 1 — Test infrastructure (no source changes)
Phase 2 — Staking certificate tests (no source changes)
Phase 3 — DRep certificate extraction + tests
Phase 4 — Proxy transaction tests (no source changes)
Phase 5 — CI gate
Option C — tRPC createCaller Integration Tests (Jest, optional real DB)
Test tRPC procedures directly via createCaller — no HTTP server, no browser, no Playwright. No changes to production code.
Phase 1 — Test infrastructure
Phase 2 — Authorization tests (mock DB, always runs)
Phase 3 — Transaction procedure tests (real DB)
Phase 4 — Proxy procedure tests (real DB)
Phase 5 — CI integration
Sequencing
| PR |
Covers |
Source changes? |
Risk |
| 1 |
Option B Phase 0 + 1 + 2 |
package.json only |
None |
| 2 |
Option B Phase 3 |
Minor (extract inlined cert block) |
Low |
| 3 |
Option B Phase 4 |
None |
None |
| 4 |
Option C Phase 1 + 2 |
None |
None |
| 5 |
Option C Phase 3 + 4 |
None |
None |
| 6 |
CI gate (Option B Phase 5 + Option C Phase 5) |
CI workflow + jest config |
None |
PRs 1–3 and 4–5 are independent and can be merged in parallel.
Add Transaction Builder Tests & tRPC Integration Tests
Background
Two gaps exist in the current test coverage:
Gap 1 — Transaction building is untested. The DRep certificate wiring in
registerDrep.tsx,updateDrep.tsx, andretire.tsxis inlined and cannot be exercised without a browser. The staking certificate helpers instakingCertificates.tsare extracted but have no tests. The proxy contract methods inoffchain.tshave no test coverage at all.Gap 2 — The tRPC persistence path is untested. The browser persists transactions via
transaction.createTransaction. A schema mismatch, DB constraint violation, wrong state value, or authorization regression in the tRPC layer is not caught today.What We're Adding
Option B — Transaction Builder Unit Tests (Jest, no browser)
Extract shared transaction-building logic into testable functions and cover them with Jest tests that run in Node.js using a mock
BlockfrostProvider.Phase 0 — Add
cbor-xdev dependencypnpm add -D cbor-x— pure-JS CBOR decoder used in tests to inspect raw transaction structure without WASMPhase 1 — Test infrastructure (no source changes)
src/__tests__/tx-builders/fixtures.ts— synthetic UTxO fixtures, addresses, DRep/staking identifiers (factory pattern, no real preprod data)src/__tests__/tx-builders/mockProvider.ts—IFetcher+IEvaluatormock;evaluateTxreturns[]socomplete()runs offlinesrc/__tests__/tx-builders/testTxBuilder.ts—MeshTxBuilderfactory using mock providersrc/__tests__/tx-builders/cborUtils.ts—decodeTxBody(),getCerts(),getWithdrawals(),CERT_KINDconstantssrc/__tests__/tx-builders/infrastructure.test.ts— smoke test (import + construct, cbor-x round-trip)Phase 2 — Staking certificate tests (no source changes)
src/__tests__/tx-builders/stakingCert.test.tsregister,deregister,delegate,register_and_delegate,withdrawalactionstxBuilder.complete()then decode withcbor-x; assertCERT_KINDand cert countPhase 3 — DRep certificate extraction + tests
src/lib/tx-builders/buildDRepCertTx.ts— new sharedapplyDRepCert(txBuilder, params)functionregisterDrep.tsx,updateDrep.tsx,retire.tsx— replace inlined cert blocks withapplyDRepCert(...)src/__tests__/tx-builders/drepCert.test.tsregister/updatewith anchor,retirewithout anchorPhase 4 — Proxy transaction tests (no source changes)
src/__tests__/tx-builders/proxy.test.tssetupProxy: mints auth tokens, sends to proxy address, distributes UTxOsmanageProxyDrep: register/update/retire DRep certs, anchor validation, missing auth tokenvoteProxyDrep: single/multiple votes, empty array, invalid proposal IDgetAuthTokenPolicyId(),getDrepId(),setProxyAddress()Phase 5 — CI gate
pnpm jest --testPathPattern="src/__tests__/tx-builders"step to CI workflowstakingCertificates.tsandbuildDRepCertTx.tsinjest.config.mjsOption C — tRPC
createCallerIntegration Tests (Jest, optional real DB)Test tRPC procedures directly via
createCaller— no HTTP server, no browser, no Playwright. No changes to production code.Phase 1 — Test infrastructure
src/__tests__/trpc/helpers.ts—makeWalletCtx,makeSessionCtx,makeAnonymousCtxfactoriessrc/__tests__/trpc/fixtures.ts—seedWallet,seedUser,cleanupFixtureshelpersDATABASE_URLis absent (itWithDbguard)Phase 2 — Authorization tests (mock DB, always runs)
src/__tests__/trpc/transactionAuth.test.tsUNAUTHORIZED, wallet not found →NOT_FOUND, not a signer →FORBIDDEN, owner passes, signer viasessionWalletspassessrc/__tests__/trpc/proxyAuth.test.tsPhase 3 — Transaction procedure tests (real DB)
src/__tests__/trpc/createTransaction.test.tsdescription,txHash), Zod rejects emptytxCbor/txJson, FORBIDDEN for non-signer, full row shape returnedsrc/__tests__/trpc/pendingTransactions.test.tscreatedAtdesc, cross-wallet isolationPhase 4 — Proxy procedure tests (real DB)
src/__tests__/trpc/createProxy.test.tsisActivedefaults true, optionaldescription, Zod validation, FORBIDDEN cases, read-back viagetProxiesByWalletPhase 5 — CI integration
test:unitandtest:trpcscripts topackage.jsonTEST_DATABASE_URLsecret)Sequencing
package.jsononlyPRs 1–3 and 4–5 are independent and can be merged in parallel.