You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gap 1 — Transaction building is not covered in Jest. The DRep certificate wiring in registerDrep.tsx, updateDrep.tsx, and retire.tsx should be exercised outside the browser. The staking certificate helpers in stakingCertificates.ts and the proxy contract methods in offchain.ts should also have direct coverage.
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
Extract shared transaction-building logic into testable functions where needed and cover it with Jest tests that run in Node.js. Tests should assert which Mesh builder methods are called with which arguments, without requiring a browser wallet adapter.
Test strategy: use lightweight mock builders that record method calls. Plain JS mocks are enough for targeted helpers; proxy transaction tests can use a Proxy-based mesh mock to record arbitrary builder calls while still exposing the provider fields required by the contract.
registerDrep.tsx, updateDrep.tsx, and retire.tsx — call applyDRepCert(...) instead of carrying inline certificate wiring.
src/__tests__/tx-builders/drepCert.test.ts — use createDRepBuilderMock() to record builder method calls.
Cover register/update/retire certificate method calls and anchor validation.
Cover legacy wallet behavior where drepCbor === scriptCbor skips certificateScript.
Cover SDK wallet behavior where distinct drepCbor adds certificateScript.
Confirm txIn, txInScript, and changeAddress are called as expected.
Phase 4 — Proxy transaction tests
src/__tests__/tx-builders/proxy.test.ts.
Use createMeshMock(provider), a Proxy-based universal mock that records every builder method call, exposes fetcher / evaluator, and avoids thenable behavior.
Mock getWalletInfoForTx with jest.spyOn to inject wallet UTxOs, collateral, and an auth-token UTxO derived from contract.getAuthTokenPolicyId().
Cover pure computations: getAuthTokenPolicyId(), deterministic policy ID generation, getDrepId(), and setProxyAddress().
Cover setupProxy: minting 10 auth tokens, output to proxy address, selected paramUtxo, and insufficient-balance failure.
Add Transaction Builder Tests & tRPC Integration Tests
Background
Two gaps exist in the current test coverage:
Gap 1 — Transaction building is not covered in Jest. The DRep certificate wiring in
registerDrep.tsx,updateDrep.tsx, andretire.tsxshould be exercised outside the browser. The staking certificate helpers instakingCertificates.tsand the proxy contract methods inoffchain.tsshould also have direct coverage.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
Extract shared transaction-building logic into testable functions where needed and cover it with Jest tests that run in Node.js. Tests should assert which Mesh builder methods are called with which arguments, without requiring a browser wallet adapter.
Test strategy: use lightweight mock builders that record method calls. Plain JS mocks are enough for targeted helpers; proxy transaction tests can use a
Proxy-based mesh mock to record arbitrary builder calls while still exposing the provider fields required by the contract.Phase 1 — Test infrastructure
src/__tests__/tx-builders/fixtures.ts— synthetic UTxO, address, DRep, staking, script CBOR, and stablePARAM_UTXOfixtures.src/__tests__/tx-builders/mockProvider.ts— mockIFetcher/IEvaluatorprovider;evaluateTx()returns[].src/__tests__/tx-builders/testTxBuilder.ts—MeshTxBuilderfactory backed by the mock provider.src/__tests__/tx-builders/cborUtils.ts— transaction body and certificate constants retained for possible future structural assertions.src/__tests__/tx-builders/infrastructure.test.ts— smoke coverage for constructingMeshTxBuilderwith the mock provider.Phase 2 — Staking certificate tests
src/__tests__/tx-builders/stakingCert.test.ts.createCertBuilderMock()to record calls toregisterStakeCertificate,deregisterStakeCertificate,delegateStakeCertificate, andwithdrawal.buildStakingCertificateActions()forregister,deregister,delegate, andregister_and_delegate.buildStakingActionConfigs()forwithdrawal,registerAndDelegate, and required success messaging.poolHexdoes not throw because pool validation is left to chain rules.Phase 3 — DRep certificate extraction and tests
src/lib/tx-builders/buildDRepCertTx.ts— addapplyDRepCert(txBuilder, params).registerDrep.tsx,updateDrep.tsx, andretire.tsx— callapplyDRepCert(...)instead of carrying inline certificate wiring.src/__tests__/tx-builders/drepCert.test.ts— usecreateDRepBuilderMock()to record builder method calls.drepCbor === scriptCborskipscertificateScript.drepCboraddscertificateScript.txIn,txInScript, andchangeAddressare called as expected.Phase 4 — Proxy transaction tests
src/__tests__/tx-builders/proxy.test.ts.createMeshMock(provider), aProxy-based universal mock that records every builder method call, exposesfetcher/evaluator, and avoids thenable behavior.getWalletInfoForTxwithjest.spyOnto inject wallet UTxOs, collateral, and an auth-token UTxO derived fromcontract.getAuthTokenPolicyId().getAuthTokenPolicyId(), deterministic policy ID generation,getDrepId(), andsetProxyAddress().setupProxy: minting 10 auth tokens, output to proxy address, selectedparamUtxo, and insufficient-balance failure.manageProxyDrep: register/deregister/update certificate calls, missing-anchor failures, missing-auth-token failure,certificateScript, andchangeAddress.voteProxyDrep: empty votes, single vote, multiple votes, DRep voter identity, missing auth token, and malformed proposal ID.Phase 5 — CI gate
.github/workflows/unit-tests.ymlfor PRs tomain/preprod, pushes tomain, and manual dispatch.npm run test:ci -- --testPathPatterns="src/__tests__/tx-builders"and uploadcoverage/.src/utils/stakingCertificates.tsandsrc/lib/tx-builders/buildDRepCertTx.tsinjest.config.mjs.Option B Stabilization
npm run test:ci -- --testPathPatterns="src/__tests__/tx-builders"locally and in CI.Option C — tRPC
createCallerIntegration TestsTest tRPC procedures directly via
createCaller: no HTTP server, no browser, no Playwright. Production code should not need changes for the first pass.Phase 1 — Test infrastructure
src/__tests__/trpc/helpers.ts—makeWalletCtx,makeSessionCtx, andmakeAnonymousCtxfactories.src/__tests__/trpc/fixtures.ts—seedWallet,seedUser, andcleanupFixtureshelpers.DATABASE_URL/TEST_DATABASE_URLis absent via anitWithDbguard.Phase 2 — Authorization tests, mock DB, always runs
src/__tests__/trpc/transactionAuth.test.ts.sessionWalletsallowed.src/__tests__/trpc/proxyAuth.test.ts.Phase 3 — Transaction procedure tests, real DB
src/__tests__/trpc/createTransaction.test.ts.description/txHash, Zod validation for emptytxCbor/txJson, forbidden non-signer access, and returned row shape.src/__tests__/trpc/pendingTransactions.test.ts.createdAtdescending order, and cross-wallet isolation.Phase 4 — Proxy procedure tests, real DB
src/__tests__/trpc/createProxy.test.ts.isActivedefaulting true, optionaldescription, Zod validation, forbidden cases, and read-back viagetProxiesByWallet.Phase 5 — CI integration
test:unitandtest:trpctopackage.json.TEST_DATABASE_URL.Updated Sequencing
Option B and Option C remain independently mergeable. Progress should be tracked by ticking the checkboxes above as each task lands.