Skip to content

Fix test race conditions and SQLite database locking#98

Merged
oskarszoon merged 1 commit into
bsv-blockchain:mainfrom
sugh01:fix-sqlite-tests
Nov 4, 2025
Merged

Fix test race conditions and SQLite database locking#98
oskarszoon merged 1 commit into
bsv-blockchain:mainfrom
sugh01:fix-sqlite-tests

Conversation

@sugh01

@sugh01 sugh01 commented Nov 4, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

@github-actions

github-actions Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

🤖 Claude Code Review

Status: Complete


This PR addresses race conditions in tests with good synchronization improvements. The changes correctly isolate SQLite databases per test and add proper locking for concurrent access to the Difficulty cache.

Potential Issue:

QuorumPath may not respect test-specific data directory - The DataFolder override happens at daemon/test_daemon.go:287, but QuorumPath is read at line 297 from existing settings. If QuorumPath is configured as an absolute path, it won't use the test-specific directory and could cause conflicts between parallel tests sharing the same quorum directory. Consider also overriding appSettings.SubtreeValidation.QuorumPath to filepath.Join(path, "quorum") when in test context.

What Works Well:

✅ Difficulty.go mutex implementation is correct with proper RLock/RUnlock early return pattern
✅ ErrorTestLogger shutdown mechanism prevents race detector warnings on testing.T access
✅ Unique test directory naming using test name + timestamp effectively isolates SQLite databases
✅ Logger shutdown sequencing is correct (after daemon stop, before cleanup)

@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2025

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
68.8% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@oskarszoon oskarszoon merged commit 0e3debe into bsv-blockchain:main Nov 4, 2025
9 checks passed
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