Skip to content

fix(tests): isolate fake timers and enrich signer error messages#344

Open
mehmetkr-31 wants to merge 3 commits into
base:masterfrom
mehmetkr-31:fix/test-isolation-fake-timers
Open

fix(tests): isolate fake timers and enrich signer error messages#344
mehmetkr-31 wants to merge 3 commits into
base:masterfrom
mehmetkr-31:fix/test-isolation-fake-timers

Conversation

@mehmetkr-31

Copy link
Copy Markdown

Summary

This PR addresses two independent issues in the account-sdk:

1. Test Isolation (Node v24 + Vitest compatibility)

  • Problem: createSmartAccount.test.ts's getNonce describe block used vi.useFakeTimers() inside beforeEach with a return cleanup callback. In Vitest + Node v24, this pattern leaves fake timer state polluted across parallel test runs, causing 6 tests to fail with timeouts or AbortSignal prototype mismatches.
  • Fix: Move vi.useRealTimers() to an explicit afterEach hook. This guarantees cleanup regardless of test outcome.
  • Impact: All 999 account-sdk tests now pass consistently.

2. Signer Error Detail (#213)

  • Problem: When handleAddSubAccountOwner fails, the thrown error is completely generic: failed to add sub account owner when sending request to sub account signer. Developers cannot distinguish which method, subAccount, or underlying error caused the failure.
  • Fix: Include request.method, subAccount.address, and parseErrorMessageFromAny(error) in the unauthorized error message.
  • Impact: Debugging signer failures becomes tractable.

Test Plan

  • yarn workspace @base-org/account test --run → 999/999 pass

Related Issues

Move vi.useRealTimers() cleanup from beforeEach return callback to
afterEach to ensure parallel test runs don't leave fake timer state
polluted. Resolves Node v24 + Vitest timeout and AbortSignal issues.
Enriches the generic unauthorized error thrown when handleAddSubAccountOwner
fails by adding the request method, subAccount address, and underlying
error detail to the message. This makes debugging signer failures tractable
for developers.
@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

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