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

nordisk/monetize

crates/lake-product/tests/the_lake_names_its_kinds.rs

//! **The Lake names its own kinds, as data in its facts** (A28 H13, M23; the owner: the Lake
//! stays THIN). Its box kind is a nordisk-pairing box kind (`Kind::Box`, not elected), so the
//! Lake can pair. Its boxes run exactly the order kinds its facts name, each one of the core's
//! one list (A28 M25), and refuse any other kind BY NAME in the ack: no Lake code decides it.

use monetize_guest_lake::facts;
use monetize_product::pull;
use nordisk_pairing::seed::Kind;

#[test]
fn the_lakes_box_kind_is_a_box_kind_that_is_not_elected() {
    let f = facts();
    let named = f
        .box_kind
        .as_deref()
        .expect("the Lake's facts name its box kind");
    let kind = Kind::named(named).unwrap_or_else(|e| panic!("{named:?} is a box kind: {e}"));
    assert!(
        kind.is_box() && !kind.is_elected(),
        "{named}: a Lake box stands alone, it is never elected"
    );
    assert_eq!(
        kind.as_str(),
        named,
        "the kind is said on the wire as its own name"
    );
}

#[test]
fn the_lakes_order_kinds_are_core_kinds() {
    let f = facts();
    assert!(
        !f.order_kinds.is_empty(),
        "the Lake names the kinds its boxes run"
    );
    for k in &f.order_kinds {
        assert!(pull::is_core(k), "{k} is one of the core's kinds");
    }
}

#[test]
fn a_lake_box_acks_its_own_kinds_and_refuses_any_other_by_name() {
    for k in &facts().order_kinds {
        let a = lake_product::lake_box::ack("be", 7, k);
        assert!(a.ok && a.seq == 7, "{k}: {}", a.detail);
    }
    for k in ["recharge_from_twin", "grow_go_ahead", "join_member"] {
        let a = lake_product::lake_box::ack("be", 8, k);
        assert!(!a.ok && a.seq == 8, "{k} is not the Lake's");
        assert!(
            a.detail.starts_with("REFUSED [order-kind] ") && a.detail.contains(&format!("`{k}`")),
            "{}",
            a.detail
        );
    }
}