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

nordisk/monetize

crates/monetize-front/tests/pull_only.rs

//! ★ **OM-8: only the pull channel remains** (ONE monetize, owner 2026-10-10
//! 13:35Z; K3 removed the last estate front that ran a monetize). The legacy
//! dial-in lane — an estate's own plugin door on tcp/8475, a primary
//! self-registering its plugin (the `endpoint` monetize then DIALS), the feed
//! loop that filled a block from the estate's verdict — is gone from this
//! crate: nothing here listens for an estate, accepts a self-registration, or
//! writes an endpoint into a block. What stays is what the ONE box uses:
//! [`monetize_front::intake::apply_pull`] (its feed) and
//! [`monetize_front::attach`] (`/attach/enrol`, `/attach/token`).

use std::path::Path;

fn src(rel: &str) -> Option<String> {
    std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join(rel)).ok()
}

/// The crate's code (comments aside): every `src/**/*.rs`, the manifest.
fn code() -> Vec<(String, String)> {
    let mut out = Vec::new();
    let mut dirs = vec![Path::new(env!("CARGO_MANIFEST_DIR")).join("src")];
    while let Some(d) = dirs.pop() {
        for e in std::fs::read_dir(&d).unwrap().flatten() {
            let p = e.path();
            if p.is_dir() {
                dirs.push(p);
            } else if p.extension().is_some_and(|x| x == "rs") {
                let text = std::fs::read_to_string(&p).unwrap();
                let code: String = text.lines().filter(|l| !l.trim_start().starts_with("//")).collect::<Vec<_>>().join("\n");
                out.push((p.display().to_string(), code));
            }
        }
    }
    out
}

#[test]
fn no_estate_door_listens_and_no_self_registration_is_accepted() {
    for gone in ["src/self_register.rs", "src/door.rs", "src/door/tests.rs", "tests/self_register.rs"] {
        assert!(src(gone).is_none(), "{gone}: the legacy dial-in lane is retired (OM-8)");
    }
    let lib = src("src/lib.rs").unwrap();
    for m in ["pub mod door", "pub mod self_register", "pub struct Target", "pub type Minter"] {
        assert!(!lib.contains(m), "lib.rs still has `{m}`");
    }
    for (file, code) in code() {
        for legacy in ["8475", "self_register", "/register", "crate::Target", "crate::door", "Dial::Estate", "fill_from_target", "INSERTED_REL", "set_pending"] {
            assert!(!code.contains(legacy), "{file}: `{legacy}` — the legacy dial-in lane (OM-8)");
        }
    }
}

#[test]
fn the_feed_is_taken_in_by_the_pull_channel_only() {
    let intake = src("src/intake.rs").unwrap();
    assert!(intake.contains("pub fn apply_pull("), "the ONE box's feed");
    assert!(!intake.contains("pub fn apply("), "no estate-dialing apply beside it");
    assert!(!intake.contains("pub fn ticket("), "no appliance ticket key: monetize dials no appliance");
    assert!(!intake.contains("pub fn start("), "no feed loop re-dialling an estate's primary");
}


/// The ONE box mints an estate's enrolment token: the ask is `attach`'s.
#[test]
fn the_attach_token_ask_is_attachs() {
    let ask = monetize_front::attach::AttachTokenAsk { estate: "acme".into(), product: "gunnar".into(), ttl_secs: 0 };
    let back: monetize_front::attach::AttachTokenAsk = serde_json::from_str(&serde_json::to_string(&ask).unwrap()).unwrap();
    assert_eq!(back, ask);
}