Repository navigation
test: isolate filesystem tests from the real ~/.foc-devnet - #240
Merged
Merged
Conversation
Unit tests exercised production write paths (key generation, mnemonic storage, run-ID persistence) against the real home directory. Running cargo test therefore overwrote ~/.foc-devnet/keys and, worse, deleted the active ~/.foc-devnet/state/current_runid.json. Add a test-only home override in paths::foc_devnet_home, guarded by a process-wide lock so parallel tests cannot race on it, and use it in every test that touches foc-devnet paths. Also fix two tests that verified nothing: - create_latest_symlink's test reimplemented the logic with temp dirs instead of calling the function; it now calls it. - print_running_status's test only asserted is_ok() while shelling out to Docker; it is removed.
Collaborator
|
@OzzyHelper rebase fix lint |
Contributor
Author
|
❌ Permission denied. Only users with write access can trigger bot commands. |
Collaborator
|
@OzzyHelper rebase, fix the lint |
Contributor
Author
Rebase with requested adjustmentsBranch Changes applied
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
Kubuxu
approved these changes
Nov 20, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the changes that isolate filesystem tests from developers’ local state.
No open issues 🎉
What changed in this PR
This PR isolates filesystem tests from the developer’s real ~/.foc-devnet, protecting local network state and keys while improving persistence and symlink coverage. Production path resolution remains unchanged.
Changes:
- Add a test-only home override with a shared lock to serialize path-dependent tests.
- Exercise real persistence and symlink functions using temporary directories.
- Remove the Docker-dependent running-status smoke test and extend image-name parsing coverage.
| File | Description |
|---|---|
src/run_id/persistence.rs |
Isolate run-ID persistence and verify file creation and deletion. |
src/run_id/mod.rs |
Test real symlink recreation and replacement in temporary directories. |
src/paths.rs |
Add TestHome and share its lock with environment-variable tests. |
src/crypto/mnemonic.rs |
Add isolated mnemonic round-trip and missing-file tests. |
src/commands/status/running.rs |
Remove Docker smoke test and cover unprefixed image names. |
src/commands/status/disk_usage.rs |
Measure a temporary home during tests. |
src/commands/status/build_status.rs |
Restrict test binary lookups to a temporary home. |
src/commands/init/keys.rs |
Isolate key generation and verify persisted keys reload correctly. |
Review effort: Balanced
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.
What
Cargo tests no longer read or write the real
~/.foc-devnet, and two tests that asserted nothing meaningful are fixed.Why
cargo testran production persistence code against the developer's real home.test_save_and_load_run_idwrote and then deleted~/.foc-devnet/state/current_runid.json, silently breakingstop/statusfor a running devnet; the keys/mnemonic tests also overwrote~/.foc-devnet/keys.How
paths::foc_devnet_home(), guarded by a process-wideTestHomelock so parallel tests cannot race on it.TestHomein every test that touches foc-devnet paths (keys, mnemonic, run-ID persistence, latest symlink, build/disk status).create_latest_symlink's test used to re-implement the logic with temp dirs; it now calls the real function and covers broken-link recreation and existing-link replacement.test_print_running_status, which only assertedis_ok()while shelling out to Docker.Testing
The Rust toolchain is not installed in this environment, so
cargo testcould not be run here. Changes are confined to test code plus a#[cfg(test)]-only branch. Please run:FIX=0 ./scripts/lint.sh cargo test --all-targets --all-featuresSecurity note (outside this PR's scope):
generate_keyslogs the full mnemonic (src/commands/init/keys.rs:75) and every private key (:99-108) at info level. These are local devnet test keys, but logging the master mnemonic is poor hygiene; worth redacting or dropping todebug!in a follow-up.Quality Report
Changes: 8 files changed, 187 insertions(+), 73 deletions(-)
Code scan: clean
Tests: skipped
Branch hygiene: 1 issue(s)