Skip to content

Add test coverage for connecting a wallet while already connected in useWallet #73

Description

@Jagadeeshftw

📌 Description

useWallet (src/hooks/useWallet.ts) wraps the mock wallet connect flow, persisting the account via saveAccount/loadAccount (src/lib/wallet.ts) to localStorage per the README. It's unclear whether calling connect again while already connected is a safe no-op or silently overwrites the persisted account with a freshly generated mock address, which would be surprising if the "connect" button is clickable while already connected.

🧩 Requirements and context

  • Add a test: connect once, capture the resulting account, call connect again, and assert the account is unchanged (no-op) rather than replaced.
  • If a fresh reconnect should generate a new mock address (e.g. simulating a wallet switch), that's a valid design choice too — pick one behavior deliberately and test it, rather than leaving it as accidental.
  • Ensure ConnectButton (src/components/ConnectButton.tsx) doesn't present a confusing "Connect" affordance while already connected (should show a connected state per its existing tests).

🛠️ Suggested execution

  • Add the double-connect test to src/hooks/useWallet.test.ts.
  • Fix useWallet.ts/lib/wallet.ts if the behavior is found to be unintentional.

✅ Acceptance criteria

  • Double-connect behavior is explicit and tested.
  • ConnectButton's UI state is consistent with the decided behavior.

🔒 Security notes

No new attack surface; this is a mock wallet flow, but the same account-persistence pattern would matter for a real wallet integration later.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26testingTests and coverage

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions