test(integration): per-test TEST_DIR for 7 remaining flake-prone test files#433
Merged
Merged
Conversation
… files Follow-up to PR #432 (which fixed the same flake in `nametag-normalization.test.ts`). Surfaced on PR #326's CI: the `wallet-clear.test.ts > destroy() shuts down tokenStorageProviders > should not throw if tokenStorage shutdown fails` test failed with `Wallet already exists. Use Sphere.load() or Sphere.clear() first.` at `Sphere.create()` — exact same flake class as commit 9bf3e90 and PR #432 fixed. Root cause (mirror of 9bf3e90 + #432): seven additional integration test files use shared `path.join(__dirname, '.test-X')` directories with cleanTestDir() in beforeEach/afterEach. Under parallel-worker load, the FS race between cleanTestDir() and the next test's `Sphere.init` → `Sphere.exists` lets a partially-saved wallet.json from the FileStorageProvider's proper-lockfile path slip through — exists() returns true when it shouldn't and Sphere.create throws. Fix mirrors 9bf3e90/#432: each beforeEach now generates a fresh per-test TEST_DIR under `os.tmpdir()` with `Date.now()` + random suffix. tmpfs gives no fsync / no cross-process lock contention, and the unique path guarantees zero FS interaction between tests in the same file. afterEach still runs cleanTestDir() to keep tmpdir from growing. Files fixed: - tests/integration/wallet-clear.test.ts - tests/integration/provider-disable-sync.test.ts - tests/integration/operator-escape-hatch-bootstrap.test.ts - tests/integration/history-sync.test.ts (custom DEVICE_A/B_DIR) - tests/integration/tracked-addresses.test.ts - tests/integration/market-module.test.ts (custom cleanupTestDir) - tests/integration/nametag-overwrite-guard.test.ts Verified: - Full integration suite: 486/486 pass, 9 skipped (no regression). - Typecheck clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to PR #432. Same flake class (
Wallet already existsfromSphere.create()under parallel-worker load) was surfaced on PR #326's CI inwallet-clear.test.ts. Six other integration test files share the same shared-TEST_DIR pattern and are equally exposed — fixing them all proactively.Root cause
Mirror of commit 9bf3e90 and PR #432: shared
path.join(__dirname, '.test-X')pluscleanTestDir()in beforeEach/afterEach races with FileStorageProvider's proper-lockfile path.Sphere.exists()can see a partially-saved wallet.json from a prior test →Sphere.create()throws.Fix
Mirrors 9bf3e90/#432: each beforeEach generates a fresh per-test TEST_DIR under
os.tmpdir()withDate.now()+ random suffix. afterEach still runscleanTestDir()to keep tmpdir from growing.Files
tests/integration/wallet-clear.test.ts(the one that surfaced this)tests/integration/provider-disable-sync.test.tstests/integration/operator-escape-hatch-bootstrap.test.tstests/integration/history-sync.test.ts(custom DEVICE_A/B_DIR)tests/integration/tracked-addresses.test.tstests/integration/market-module.test.ts(custom cleanupTestDir)tests/integration/nametag-overwrite-guard.test.tsTest plan