mirror of
https://github.com/logos-messaging/logos-delivery-rust-bindings.git
synced 2026-07-29 22:43:34 +00:00
test: give each test binary its own persistency root
Cargo runs test binaries in parallel and serial_test only serialises within one, so the channels and node suites were sharing ./data — two processes over one on-disk persistency root. Nothing here proves that caused harm, but shared mutable state across concurrent processes is not worth leaving in place. local_storage_path is added to WakuNodeConfig to make this expressible. The field is worth having regardless: it was simply missing, and its docs record that the persistency singleton refuses re-targeting, so a second node in the same process must use the same path or fail to start. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
dfedf2ba15
commit
3ee17ecc4d
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,4 +6,5 @@ nimcache/
|
||||
|
||||
# SDS state written by nodes at runtime (e.g. the channels tests)
|
||||
data/
|
||||
data-*-test/
|
||||
.submodules-initialized
|
||||
|
||||
@ -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<u16>,
|
||||
/// 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<String>,
|
||||
|
||||
/// Relay protocol
|
||||
#[default(Some(true))]
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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<LogosDeliveryCtx, String> {
|
||||
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)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user