Skip to content

tests: raise wallet coverage from 77.7% to 84.4%#1

Merged
TeoSlayer merged 1 commit into
mainfrom
add-test-coverage
May 27, 2026
Merged

tests: raise wallet coverage from 77.7% to 84.4%#1
TeoSlayer merged 1 commit into
mainfrom
add-test-coverage

Conversation

@TeoSlayer
Copy link
Copy Markdown
Contributor

Summary

  • Adds targeted tests for previously-uncovered paths in pkg/wallet, pkg/walletipc, pkg/evm, and cmd/wallet.
  • Production code is unchanged — only new *_test.go files.
  • Total module coverage: 77.7% -> 84.4% (+6.7pp), clearing the 80% target.

Per-package gains

Package Before After
pkg/wallet 74.1% 85.5%
pkg/walletipc 82.1% 86.2%
pkg/evm 82.4% 84.1%
cmd/wallet 76.3% 76.3%

What's covered now

  • Wallet.HookPreSendMessage (paywall happy path + every error branch: missing peer, bad base64 data, bad spec, blank spec, no-paywall passthrough, custom method/escrow IDs).
  • Wallet.HookPostRecvMessage (no-data, bad-base64, bad-json, incomplete-envelope passthroughs + happy-path roundtrip with the sender's pre-send output).
  • Wallet.Request and Wallet.Topup validation branches (zero amount, empty asset, missing source / expiresIn).
  • sqliteStore.GetIssued and sqliteStore.IsSettled (previously 0% — only the memory store had tests).
  • walletipc dispatcher: history Since/Before time-bounds, empty-payload decode, type-mismatched JSON, ExpiresInSeconds=0 rejection.
  • evm.EVMMethod accessors (ID, ChainID, Token, Address), Client.Endpoint, NewClient(_, nil) default-http branch, and Uint128 packing.

Safety

  • All file-based tests use t.TempDir() — nothing touches ~/.pilot.
  • No t.Logf / fmt.Println of any private-key bytes (seed, signature, or otherwise) in any new test file.

Test plan

  • go test -race -count=1 -timeout 120s ./... — all pass
  • go vet ./... — clean
  • go test -coverprofile=/tmp/wallet-after.cov -count=1 ./... then go tool cover -func=... | tail -1 — confirms 84.4%

Add targeted tests for paywall send/recv hooks, sqlite issued/settled
lookups, dispatcher decode paths, EVM accessors, and validation
branches in Wallet.Request / Wallet.Topup. All tests use t.TempDir()
for file-based state and never log private key material.

Per-package coverage:
  pkg/wallet      74.1% -> 85.5%
  pkg/walletipc   82.1% -> 86.2%
  pkg/evm         82.4% -> 84.1%
  cmd/wallet      76.3% -> 76.3%
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@TeoSlayer TeoSlayer merged commit 6e34492 into main May 27, 2026
3 checks passed
@TeoSlayer TeoSlayer deleted the add-test-coverage branch May 27, 2026 23:27
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.

2 participants