mirror of
https://github.com/jmcorgan/fips.git
synced 2026-10-05 19:18:25 +00:00
Pin the three dormant peer-machine constants to the config defaults
The rekey and liveness constants carried bare literals with no tie to the configuration they were copied from. Each now has a test asserting it against the config default function, so a change to the default reds the build instead of leaving the constant silently stale. The constants stay compile-time values rather than expressions over the default, because that default is an ordinary Default implementation and not a const function, so it cannot appear in a const initialiser. The comments say what these are: placeholders pinned to today's defaults. Nothing reads the configuration to produce them, and wiring that up is separate work.
This commit is contained in:
+34
-3
@@ -88,10 +88,19 @@ const RESEND_BACKOFF: f64 = 2.0;
|
|||||||
const REKEY_CADENCE_INTERVAL_MS: u64 = 60_000;
|
const REKEY_CADENCE_INTERVAL_MS: u64 = 60_000;
|
||||||
const REKEY_RESEND_INTERVAL_MS: u64 = 1_000;
|
const REKEY_RESEND_INTERVAL_MS: u64 = 1_000;
|
||||||
const REKEY_MAX_RESENDS: u32 = 5;
|
const REKEY_MAX_RESENDS: u32 = 5;
|
||||||
const REKEY_AFTER_SECS: u64 = 3_600;
|
// `REKEY_AFTER_SECS`, `REKEY_AFTER_MESSAGES` and `LIVENESS_INTERVAL_MS` below
|
||||||
const REKEY_AFTER_MESSAGES: u64 = 1_000_000;
|
// are placeholders pinned to today's `RekeyConfig` and `NodeConfig` defaults.
|
||||||
|
// They are not a wiring to the config: nothing here reads a config value, so
|
||||||
|
// an operator override is not tracked. They are what the machine falls back to
|
||||||
|
// until it is wired to config. The tie to the defaults is asserted by
|
||||||
|
// `rekey_constants_match_the_rekey_config_defaults` and
|
||||||
|
// `liveness_interval_matches_the_heartbeat_config_default` rather than stated
|
||||||
|
// in these declarations, because `Default for NodeConfig` is an ordinary impl
|
||||||
|
// and cannot be called from a `const` initializer.
|
||||||
|
const REKEY_AFTER_SECS: u64 = 120;
|
||||||
|
const REKEY_AFTER_MESSAGES: u64 = 65_536;
|
||||||
const DRAIN_WINDOW_MS: u64 = 5_000;
|
const DRAIN_WINDOW_MS: u64 = 5_000;
|
||||||
const LIVENESS_INTERVAL_MS: u64 = 15_000;
|
const LIVENESS_INTERVAL_MS: u64 = 10_000;
|
||||||
const REKEY_DAMPEN_MS: u64 = 30_000;
|
const REKEY_DAMPEN_MS: u64 = 30_000;
|
||||||
const CLOSED_BACKOFF_MS: u64 = 5_000;
|
const CLOSED_BACKOFF_MS: u64 = 5_000;
|
||||||
|
|
||||||
@@ -3386,6 +3395,28 @@ mod tests {
|
|||||||
.is_err()
|
.is_err()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `LIVENESS_INTERVAL_MS` stays pinned to `NodeConfig`'s heartbeat default.
|
||||||
|
///
|
||||||
|
/// The expectation is read from the default rather than repeated as a
|
||||||
|
/// literal, so raising or lowering `heartbeat_interval_secs` without
|
||||||
|
/// re-pinning the constant reds here instead of drifting unnoticed.
|
||||||
|
#[test]
|
||||||
|
fn liveness_interval_matches_the_heartbeat_config_default() {
|
||||||
|
assert_eq!(
|
||||||
|
LIVENESS_INTERVAL_MS,
|
||||||
|
crate::config::NodeConfig::default().heartbeat_interval_secs * 1_000
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `REKEY_AFTER_SECS` and `REKEY_AFTER_MESSAGES` stay pinned to
|
||||||
|
/// `RekeyConfig`'s defaults, read from the impl for the same reason.
|
||||||
|
#[test]
|
||||||
|
fn rekey_constants_match_the_rekey_config_defaults() {
|
||||||
|
let defaults = crate::config::RekeyConfig::default();
|
||||||
|
assert_eq!(REKEY_AFTER_SECS, defaults.after_secs);
|
||||||
|
assert_eq!(REKEY_AFTER_MESSAGES, defaults.after_messages);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// T-SANSIO: the action vocabulary must stay plain, comparable data.
|
/// T-SANSIO: the action vocabulary must stay plain, comparable data.
|
||||||
|
|||||||
Reference in New Issue
Block a user