mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-10-27 07:52:03 +00:00
Replaced non-deterministic `time.sleep` calls with active polling loops or thread joins in `src/tests/` to improve test determinism and reliability. Modified `test_unlock_sync.py`, `test_nostr_sdk_workflow.py`, `test_background_relay_check.py`, `test_offline_mode_behavior.py`, and `test_nostr_index_size.py`. Generated integrity and audit reports in `reports/test-audit/`. Completed the scheduler rotation by publishing completion logic and task log file to `torch/task-logs/daily/`. Co-authored-by: PR0M3TH3AN <[email protected]>
1.6 KiB
1.6 KiB
Test Audit Report
Date: 2026-03-01 Agent: test-audit-agent
Overview
The test-audit-agent ran a static analysis of tests using run_python_static_analysis.py and discovered multiple test files that utilized time.sleep(), causing flaky behavior, non-determinism, and slowing down the overall test suite. The agent modified several tests to replace explicit sleeping with active polling or deterministic thread joins.
Changes
-
src/tests/test_unlock_sync.py- In
test_unlock_triggers_sync, replacedtime.sleep(0.05)withpm._sync_task.join(timeout=1.0).
- In
-
src/tests/test_nostr_sdk_workflow.py- Replaced
time.sleep(0.5)with a polling loop that attempts to connect usingcreate_connectionup to 40 times (with 0.05s interval), raising an exception if the fake relay doesn't start.
- Replaced
-
src/tests/test_background_relay_check.py- In both async checks, replaced
time.sleep(0.05)withpm._relay_thread.join(timeout=1.0).
- In both async checks, replaced
-
src/tests/test_offline_mode_behavior.py- Removed
time.sleep(0.05)entirely fromtest_start_background_sync_offlinebecause the early return on offline mode makes synchronization instantaneous, rendering the sleep useless.
- Removed
-
src/tests/test_nostr_index_size.py- The test was missing an assertion (reported by static analysis). Added
assert len(results) > 0to verify results collection. - Replaced
time.sleep(delay)during propagation waiting with an asynchronous polling retry logic insidefetch_with_retryloop.
- The test was missing an assertion (reported by static analysis). Added
Notes
No remaining flakiness detected in the modified files.