open-standards/smart-byte/smart-byte-rs/crates/smart-byte-atproto/tests/mst_basic.rs
Transaction Science 6ea90afbed ingest wave A4: 3 crates · smart-byte-atproto + op-openbanking + eoc-distributed
Smart Byte (1 crate, 2127 LOC, 35 tests)
  smart-byte-atproto    ATProto (Bluesky federation) adapter.
                        PLC + did:web resolution; XRPC client; CARv1 encode/decode
                        with CIDv1 (dag-cbor + raw, SHA-256); sketch MST with
                        order-independent BLAKE3 root; Repo + UnsignedCommit /
                        SignedCommit (Ed25519 over CBOR); firehose transport
                        trait + in-memory impl; AT URI ↔ smart-byte AID bridge
                        with SAID commitment.

OpenPay (1 crate, 2397 LOC, 44 tests)
  op-openbanking        UK OBIE R/W v3.1.10/3.1.11, Berlin Group NextGenPSD2
                        XS2A v1.3.13, STET PSD2 v1.7, Australia CDR Banking v1.31,
                        FDX v5/v6, SGFinDex shapes. AISP / PISP / PIIS / VRP
                        traits. FAPI 1.0 Advanced (PS256/ES256, mTLS, RFC 8705
                        certificate binding, JWK registration). Operators wire
                        their own JWS signer + HTTP transport — keeps the crate
                        KMS-agnostic.

EOC (1 crate, 2179 LOC, 32 tests)
  eoc-distributed       Distributed-inference scheduling. Worker trait with
                        Capability + Accelerator (CPU/GPU/TPU/NPU/Mixed) +
                        Load.busyness()/projected_micro_joules()/projected_g_co2e().
                        RoundRobin / LeastBusy / LatencyWeighted / JouleWeighted
                        (default) / CarbonWeighted routers. Work-stealing
                        scheduler. vLLM-style continuous batching with KV-block
                        budget. Ray-Serve-style auto-scaler with cooldown.
                        KV-cache-aware sticky-session routing.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-05-24 12:22:09 -04:00

50 lines
1.3 KiB
Rust

//! Basic MST insert / delete / lookup invariants.
use smart_byte_atproto::car::Cid;
use smart_byte_atproto::{Mst, MstEntry};
fn cid(b: &[u8]) -> Cid {
Cid::dag_cbor(b)
}
#[test]
fn insert_lookup_delete() {
let mut m = Mst::new();
m.insert("app.bsky.feed.post/aaa", cid(b"A"));
m.insert("app.bsky.feed.post/bbb", cid(b"B"));
m.insert("app.bsky.feed.like/ccc", cid(b"C"));
assert_eq!(m.len(), 3);
assert_eq!(m.lookup("app.bsky.feed.post/aaa"), Some(&cid(b"A")));
let prev = m.delete("app.bsky.feed.post/bbb");
assert_eq!(prev, Some(cid(b"B")));
assert_eq!(m.len(), 2);
assert!(m.lookup("app.bsky.feed.post/bbb").is_none());
}
#[test]
fn iter_is_sorted() {
let mut m = Mst::new();
m.insert("z/2", cid(b"two"));
m.insert("a/1", cid(b"one"));
m.insert("m/3", cid(b"three"));
let keys: Vec<String> =
m.iter().map(|e: MstEntry| e.key).collect();
assert_eq!(keys, vec!["a/1", "m/3", "z/2"]);
}
#[test]
fn root_hash_changes_on_update() {
let mut m = Mst::new();
m.insert("k/1", cid(b"v1"));
let h1 = m.root_hash();
m.insert("k/1", cid(b"v2"));
let h2 = m.root_hash();
assert_ne!(h1, h2);
}
#[test]
fn root_hex_is_64_chars() {
let mut m = Mst::new();
m.insert("k/1", cid(b"v"));
assert_eq!(m.root_hex().len(), 64);
}