open-standards/smart-byte/smart-byte-rs/crates/smart-byte-atproto/tests/car_roundtrip.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

43 lines
1.4 KiB
Rust

//! CAR file encode → decode roundtrip.
use smart_byte_atproto::{CarBlock, CarFile, Cid};
#[test]
fn empty_car_roundtrip() {
let car = CarFile::new(vec![Cid::dag_cbor(b"root")]);
let bytes = car.encode().unwrap();
let back = CarFile::decode(&bytes).unwrap();
assert_eq!(back.roots.len(), 1);
assert_eq!(back.roots[0], car.roots[0]);
assert!(back.blocks.is_empty());
}
#[test]
fn roundtrip_with_blocks() {
let payload_a = b"alpha".to_vec();
let payload_b = b"beta-block".to_vec();
let block_a = CarBlock::dag_cbor(payload_a.clone());
let block_b = CarBlock::dag_cbor(payload_b.clone());
let mut car = CarFile::new(vec![block_a.cid.clone()]);
car.push(block_a.clone());
car.push(block_b.clone());
let encoded = car.encode().unwrap();
let decoded = CarFile::decode(&encoded).unwrap();
assert_eq!(decoded.blocks.len(), 2);
assert_eq!(decoded.blocks[0].cid, block_a.cid);
assert_eq!(decoded.blocks[0].data, payload_a);
assert_eq!(decoded.blocks[1].cid, block_b.cid);
assert_eq!(decoded.blocks[1].data, payload_b);
assert_eq!(decoded.roots, vec![block_a.cid]);
}
#[test]
fn truncated_car_rejected() {
let block = CarBlock::dag_cbor(b"x".to_vec());
let mut car = CarFile::new(vec![block.cid.clone()]);
car.push(block);
let mut encoded = car.encode().unwrap();
encoded.truncate(encoded.len() - 4);
assert!(CarFile::decode(&encoded).is_err());
}