Skip to content

test(lib): add coverage for secondary market, portfolio, batch transa… - #975

Merged
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
AbdulSnk:test/add-unit-tests-services-batch-csrf
Aug 29, 2026
Merged

test(lib): add coverage for secondary market, portfolio, batch transa…#975
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
AbdulSnk:test/add-unit-tests-services-batch-csrf

Conversation

@AbdulSnk

Copy link
Copy Markdown
Contributor

📌 Description

This PR addresses critical missing unit test coverage across key utilities and service modules in src/lib/. It pins down core business logic, data mapping, transaction encoding, and security mechanisms ahead of pending mock migrations and refactors.

🚀 Changes Included

1. secondaryMarketService Tests (#931)

  • Added unit test suite for src/lib/secondaryMarketService.ts.
  • Tested listing filtering logic against target attributes to ensure filtering behaviors remain intact when replacing mock data (MOCK_LISTINGS).

2. portfolioService Tests (#930)

  • Added unit test suite for src/lib/portfolioService.ts.
  • Verified contract shape and output schemas for token holdings (MOCK_TOKEN_HOLDINGS) and gas-balance mappings (MOCK_GAS_BALANCES) consumed by the portfolio store and dashboard.

3. batchTransaction Tests (#932)

  • Added unit test suite for src/lib/batchTransaction.ts.
  • Verified multi-call batch encoding structures.
  • Validated revert-error decoding logic, including edge cases and the specific revert-data constant ("Insufficient balance for transfer").

4. csrf Security Utility Tests (#933)

  • Added unit test suite for src/lib/csrf.ts.
  • Covered getCsrfSessionId, getAuthStatePart, and generateTokenForSession.
  • Tested token-to-session and auth-state binding guarantees used by GET /api/security/csrf to prevent security regressions.

Closes: #930
Closes: #931
Closes: #932
Closes: #933

@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@AbdulSnk Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@nanaf6203-bit
nanaf6203-bit merged commit 31d45c1 into MettaChain:main Aug 29, 2026
2 of 4 checks passed
@github-actions

Copy link
Copy Markdown

🔒 Preview Environment Destroyed

The preview environment for this PR has been torn down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants