OpenPay (1 crate, 2487 LOC, 33 tests)
op-fraud-graph Graph-based fraud detection. EntityKind (card/email/
device/IP/address/phone/BIN+last4/account) with
canonicalization + hashed EntityKey + billing↔shipping
mismatch detection. Adjacency-list FraudGraph with
idempotent upsert + edge-merge. Double-hashing Bloom
filter (capacity+FPR-sized). Union-find connected
components. PageRank with dangling-sink handling.
Louvain community detection. Shared-instrument hub
rings. Sliding ring-buffer velocity counters. Synthetic
identity heuristics (freshness + heavy-use + mail-drop).
Structuring / smurfing / mule-chain DFS. EntityRisk +
TransactionRisk + RiskBand combiner.
Smart Byte (1 crate, ~1844 LOC, 44 tests)
smart-byte-ilp Interledger Protocol v4. OER codec (length-determinant,
var-octet-string, BE u32/u64). Prepare/Fulfill/Reject
packet roundtrip with all 19 IL-RFC-27 reject codes.
SHA-256 Condition + Fulfillment with constant-time
verify. ILP address validator (7 schemes, 1-128 char
segments, 1023-byte cap, segment-aligned prefix match).
STREAM (15 frame types). BTP. SPSP payment-pointer
resolver. Open Payments API. Longest-prefix routing
Connector with fixed-point quote conversion + balance +
rate-limit checks.
EOC (1 crate, 1921 LOC, 36 tests)
eoc-quantize Quantization primitives. int8 (symmetric/asymmetric
with zero-inclusion fix), int4 (GPTQ + AWQ group quant),
int2 (BitNet), fp8 (E4M3/E5M2), nf4 (QLoRA). GGUF v3
header parse. safetensors read sketch. Calibration
datasets + per-channel scales. KV-cache quant. Energy
tradeoff curves (joules-per-token across schemes).
Co-Authored-By: Claude Opus 4.7 <[email protected]>
53 lines
1.6 KiB
Rust
53 lines
1.6 KiB
Rust
//! STREAM frame multiplex tests.
|
|
|
|
use smart_byte_ilp::{Frame, FrameType, Result, StreamPacket};
|
|
|
|
#[test]
|
|
fn multiplexed_money_plus_data_round_trip() -> Result<()> {
|
|
let pkt = StreamPacket {
|
|
version: 1,
|
|
ilp_packet_type: 12,
|
|
sequence: 42,
|
|
prepare_amount: 1_000,
|
|
frames: vec![
|
|
Frame::stream_money(1, 500),
|
|
Frame::stream_money(2, 500),
|
|
Frame::stream_data(1, 0, b"first chunk"),
|
|
Frame::stream_data(2, 0, b"second chunk"),
|
|
],
|
|
};
|
|
let wire = pkt.encode();
|
|
let back = StreamPacket::decode(&wire)?;
|
|
assert_eq!(pkt, back);
|
|
assert_eq!(back.frames.len(), 4);
|
|
assert_eq!(back.frames[0].frame_type, FrameType::StreamMoney);
|
|
assert_eq!(back.frames[3].frame_type, FrameType::StreamData);
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn empty_frame_list_decodes() -> Result<()> {
|
|
let pkt = StreamPacket {
|
|
version: 1,
|
|
ilp_packet_type: 13,
|
|
sequence: 0,
|
|
prepare_amount: 0,
|
|
frames: vec![],
|
|
};
|
|
let wire = pkt.encode();
|
|
let back = StreamPacket::decode(&wire)?;
|
|
assert_eq!(back.frames.len(), 0);
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn unknown_frame_type_errors() {
|
|
// Build a one-frame packet with a forbidden frame-type byte.
|
|
let mut wire = vec![1u8, 12]; // version + ilp packet type
|
|
wire.extend_from_slice(&0u64.to_be_bytes()); // sequence
|
|
wire.extend_from_slice(&0u64.to_be_bytes()); // prepare amount
|
|
wire.push(1); // n_frames == 1 (short form)
|
|
wire.push(0xff); // frame_type byte
|
|
wire.push(0); // empty payload
|
|
assert!(StreamPacket::decode(&wire).is_err());
|
|
}
|