diff --git a/.gitignore b/.gitignore index 368d2bb..f149512 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ nimcache/ # SDS state written by nodes at runtime (e.g. the channels tests) data/ +data-*-test/ .submodules-initialized diff --git a/waku-bindings/src/node/config.rs b/waku-bindings/src/node/config.rs index 1f0f0b9..3da8dff 100644 --- a/waku-bindings/src/node/config.rs +++ b/waku-bindings/src/node/config.rs @@ -33,6 +33,11 @@ pub struct WakuNodeConfig { /// sharding, and an explicit shard on every send. #[serde(skip_serializing_if = "Option::is_none", rename = "num-shards-in-network")] pub num_shards_in_network: Option, + /// Where the node keeps local data. Note the persistency layer is a + /// process-wide singleton: a second node in the same process must use the + /// same path, or it fails to start. + #[serde(skip_serializing_if = "Option::is_none", rename = "local-storage-path")] + pub local_storage_path: Option, /// Relay protocol #[default(Some(true))] diff --git a/waku-bindings/tests/channels.rs b/waku-bindings/tests/channels.rs index 8c82490..ba25eb0 100644 --- a/waku-bindings/tests/channels.rs +++ b/waku-bindings/tests/channels.rs @@ -16,6 +16,10 @@ const OTHER_SENDER_ID: &str = "other-sender"; const CHANNEL_PAYLOAD: &[u8] = b"Hi from a reliable channel!"; const TIMEOUT: Duration = Duration::from_secs(30); const SHARDS_IN_NETWORK: usize = 8; +/// Cargo runs test binaries in parallel and serial_test only serialises within +/// one, so each binary needs its own persistency root. Every node in a binary +/// must share it: the singleton refuses to be re-targeted. +const STORAGE_PATH: &str = "./data-channels-test"; /// Body of `channel_send`, whose payload travels base64-encoded. #[derive(Serialize)] @@ -31,6 +35,7 @@ fn new_node(tcp_port: usize) -> LogosDeliveryCtx { tcp_port: Some(tcp_port), num_shards_in_network: Some(SHARDS_IN_NETWORK as u16), shards: (0..SHARDS_IN_NETWORK).collect(), + local_storage_path: Some(STORAGE_PATH.to_string()), ..Default::default() }) .expect("config should serialise"); diff --git a/waku-bindings/tests/node.rs b/waku-bindings/tests/node.rs index 6d0421d..6fb1c5a 100644 --- a/waku-bindings/tests/node.rs +++ b/waku-bindings/tests/node.rs @@ -18,7 +18,16 @@ const ECHO_MESSAGE: &str = "Hi from 🦀!"; const TEST_PUBSUBTOPIC: &str = "test"; const TIMEOUT: Duration = Duration::from_secs(30); +/// Cargo runs test binaries in parallel and serial_test only serialises within +/// one, so each binary needs its own persistency root. Every node in a binary +/// must share it: the singleton refuses to be re-targeted. +const STORAGE_PATH: &str = "./data-node-test"; + fn new_node(config: WakuNodeConfig) -> Result { + let config = WakuNodeConfig { + local_storage_path: Some(STORAGE_PATH.to_string()), + ..config + }; let config_json = serde_json::to_string(&config).map_err(|e| e.to_string())?; LogosDeliveryCtx::create(config_json, TIMEOUT) }