Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/gunnar

crates/gunnar-monetize-guest/tests/the_guardian_steps_are_shared.rs

//! **ONE set of guardian steps** (T16 / P4-REST, A28 M11): Gunnar's guest builds its plans from
//! `monetize_product::guardian::steps` (reached as `monetize_product_guest::guardian::steps`), as
//! Holger's guest does since P4a. Its own copies of `order`, `wait`, `recharge`, `restate`,
//! `heard` and the three bounds go. `the_guest_guards_its_estate.rs` keeps every finding and plan
//! as it was; this test pins the bounds and the steps a remedy names, and that no copy is left.

use gunnar_monetize_guest::guardian::{HEARD_WITHIN_MS, PAIRED_WITHIN_MS, RECHARGED_WITHIN_MS};
use monetize_product_guest::guardian::steps;

/// ★ The bounds Gunnar's guardian waits by are the shared ones (30 min, 10 min, 6 h).
#[test]
fn gunnars_bounds_are_the_shared_steps_bounds() {
    assert_eq!(
        (HEARD_WITHIN_MS, PAIRED_WITHIN_MS, RECHARGED_WITHIN_MS),
        (1_800_000, 600_000, 21_600_000)
    );
    assert_eq!(
        (HEARD_WITHIN_MS, PAIRED_WITHIN_MS, RECHARGED_WITHIN_MS),
        (
            steps::HEARD_WITHIN_MS,
            steps::PAIRED_WITHIN_MS,
            steps::RECHARGED_WITHIN_MS
        )
    );
}

/// ★ No copy is left in the guest's guardian: it calls the shared steps.
#[test]
fn the_guests_guardian_carries_no_copy_of_the_shared_steps() {
    let g = std::fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/src/guardian.rs"))
        .expect("the guest's guardian.rs");
    for gone in [
        "fn order(",
        "fn wait(",
        "fn recharge(",
        "fn restate(",
        "fn heard(",
        "fn main_word",
        "pub const HEARD_WITHIN_MS: u64",
        "pub const PAIRED_WITHIN_MS: u64",
        "pub const RECHARGED_WITHIN_MS: u64",
    ] {
        assert!(!g.contains(gone), "the guest's guardian still carries `{gone}`: it is monetize-product::guardian::steps's");
    }
    assert!(
        g.contains("monetize_product_guest::guardian::steps::"),
        "it builds its plans from the shared steps"
    );
}