Skip to content

test(wallet): add full useStellarWallet hook coverage (#68) - #1

Closed
benzy018 wants to merge 1 commit into
mainfrom
test/useStellarWallet-hook-coverage
Closed

test(wallet): add full useStellarWallet hook coverage (#68)#1
benzy018 wants to merge 1 commit into
mainfrom
test/useStellarWallet-hook-coverage

Conversation

@benzy018

Copy link
Copy Markdown
Owner

Description

Closes ecotask-network#68

Adds comprehensive test coverage for src/hooks/useStellarWallet.ts, the primary interface between the app and the Stellar blockchain (Freighter connection, Lobstr deep-link, in-app wallet creation, import, balance refresh, and disconnection).

Extends the existing src/__tests__/useStellarWallet.test.tsx (which covered connect-rollback on balance-fetch failure) with the remaining acceptance criteria:

  • connectFreighter: success, extension not detected, extension not unlocked
  • connectLobstr: success (public key extracted from signed challenge), not installed, signing cancelled
  • createInAppWallet: success + network failure (already covered)
  • importWallet: valid key (trims + persists to vault), invalid key (rejected, nothing persisted)
  • disconnectWallet: clears the vault entry and resets the store
  • refreshBalance / refreshEcoBalance / refreshUsdcBalance: success updates balances, failures keep last known balance

Mocks used: stellar.ts (getBalance, getTokenBalance, createTestnetAccount, isValidSecretKey, getPublicKeyFromSecret, Keypair, TransactionBuilder), lobstr.ts (isLobstrInstalled, openLobstrForSigning), walletVault.ts (via mocked MMKV), and the Zustand useWalletStore.

Type of Change

  • Chore (deps, tooling, refactoring)

How Has This Been Tested?

  • Unit tests added / updated

Verified: npm test (42 suites, 373 tests pass), npm run typecheck, npx eslint src/__tests__/useStellarWallet.test.tsx — all green.

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my own code
  • I have commented on complex or non-obvious code
  • I have updated the documentation where needed
  • My changes generate no new warnings or lint errors
  • All existing and new tests pass

Extend the useStellarWallet tests to cover every acceptance criterion
from ecotask-network#68: Freighter connect (success, extension missing, not unlocked),
Lobstr connect (success, not installed, signing cancelled), import
(valid and invalid secret keys), disconnectWallet clearing the vault,
and balance/token refresh success and failure paths.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>

Copy link
Copy Markdown
Owner Author

Superseded by ecotask-network#118 (this repo is a fork; CI runs on the upstream and the issue ecotask-network#68 lives there).

@benzy018 benzy018 closed this Aug 24, 2026
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.

[Testing] Zero test coverage for useStellarWallet hook — wallet creation, import, and balance refresh

1 participant