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]>
79 lines
1.9 KiB
Rust
79 lines
1.9 KiB
Rust
//! ILP address grammar and prefix-matching tests.
|
|
|
|
use smart_byte_ilp::{Address, AddressScheme};
|
|
|
|
#[test]
|
|
fn accepts_all_known_schemes() {
|
|
for s in [
|
|
"g.us.bank.alice",
|
|
"private.peer.alice",
|
|
"example.test",
|
|
"peer.alpha",
|
|
"self.local",
|
|
"test.alpha",
|
|
"test1.beta",
|
|
"test2.beta",
|
|
"test3.beta",
|
|
"local.dev",
|
|
] {
|
|
assert!(Address::parse(s).is_ok(), "should parse: {s}");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn rejects_unknown_scheme() {
|
|
assert!(Address::parse("xn--bad").is_err());
|
|
assert!(Address::parse("crypto.foo").is_err());
|
|
}
|
|
|
|
#[test]
|
|
fn rejects_empty_segment() {
|
|
assert!(Address::parse("g..bank").is_err());
|
|
assert!(Address::parse(".g.bank").is_err());
|
|
}
|
|
|
|
#[test]
|
|
fn rejects_oversized_input() {
|
|
let huge = format!("g.{}", "a".repeat(1024));
|
|
assert!(Address::parse(&huge).is_err());
|
|
}
|
|
|
|
#[test]
|
|
fn rejects_oversized_segment() {
|
|
let seg = "x".repeat(129);
|
|
let addr = format!("g.us.{seg}");
|
|
assert!(Address::parse(&addr).is_err());
|
|
}
|
|
|
|
#[test]
|
|
fn segment_chars_only() {
|
|
assert!(Address::parse("g.us.with space").is_err());
|
|
assert!(Address::parse("g.us.with/slash").is_err());
|
|
}
|
|
|
|
#[test]
|
|
fn prefix_match_is_segment_aligned() {
|
|
let a = Address::parse("g.us.bank.alice").unwrap();
|
|
assert!(a.starts_with_prefix("g"));
|
|
assert!(a.starts_with_prefix("g.us"));
|
|
assert!(a.starts_with_prefix("g.us.bank"));
|
|
assert!(a.starts_with_prefix("g.us.bank.alice"));
|
|
assert!(!a.starts_with_prefix("g.us.bankhq"));
|
|
assert!(!a.starts_with_prefix("g.us.bank.al"));
|
|
}
|
|
|
|
#[test]
|
|
fn scheme_lift() {
|
|
assert_eq!(
|
|
Address::parse("g.us").unwrap().scheme(),
|
|
AddressScheme::Global
|
|
);
|
|
assert_eq!(
|
|
Address::parse("test1.foo").unwrap().scheme(),
|
|
AddressScheme::Test
|
|
);
|
|
assert_eq!(
|
|
Address::parse("self.svc").unwrap().scheme(),
|
|
AddressScheme::SelfScheme
|
|
);
|
|
}
|