From 26a5bcf20ede5a6f3029bd1698a220a410ecd37c Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 26 Apr 2026 13:28:15 +0000 Subject: [PATCH] fix(worker): gate test_config behind test-utils crates/worker/src/config.rs:20 - WorkerConfig::test_config() returned a struct hardcoding /tmp/test-worker.key. Without a cfg gate this scaffolding (and its insecure path string) compiled into release binaries that depend on willow-worker. Follow the willow convention from crates/network/src/mem.rs: gate behind #[cfg(any(test, feature = "test-utils"))] and add the test-utils feature to crates/worker/Cargo.toml. Verification: - cargo check -p willow-worker (default features): ok - cargo check -p willow-worker --features test-utils: ok - cargo test -p willow-worker --no-run: ok - cargo fmt -p willow-worker: clean Closes #331 https://claude.ai/code/session_01KvXynFPgSaqWTBo65iMnD9 --- crates/worker/Cargo.toml | 3 +++ crates/worker/src/config.rs | 1 + 2 files changed, 4 insertions(+) diff --git a/crates/worker/Cargo.toml b/crates/worker/Cargo.toml index 2f0a04a9..3b2eb057 100644 --- a/crates/worker/Cargo.toml +++ b/crates/worker/Cargo.toml @@ -19,6 +19,9 @@ clap = { version = "4", features = ["derive"] } anyhow = { workspace = true } uuid = { workspace = true } +[features] +test-utils = [] + [dev-dependencies] willow-network = { path = "../network", features = ["test-utils"] } async-trait = { workspace = true } diff --git a/crates/worker/src/config.rs b/crates/worker/src/config.rs index b8bef856..9a1a3305 100644 --- a/crates/worker/src/config.rs +++ b/crates/worker/src/config.rs @@ -15,6 +15,7 @@ pub struct WorkerConfig { pub allocation: AllocationStrategy, } +#[cfg(any(test, feature = "test-utils"))] impl WorkerConfig { /// Create a config for testing. pub fn test_config() -> Self {