OpenPay (1 crate, 2174 LOC, 14 tests)
op-payouts Multi-rail payout engine. Visa Direct, Mastercard Send,
ACH credits (NACHA), Fedwire + SWIFT MT103 + ISO 20022
pacs.008, SEPA SCT + SCT Inst (mod-97 IBAN), UK FPS,
FedNow, RTP, PayPal, Wise. Crypto: USDC/USDT on
ETH/Polygon/Base/Solana + BTC + Lightning with real
ERC-20 transfer(address,uint256) calldata. Offline-pure
drivers (emit wire payloads — operators transmit).
Smart Byte (1 crate, 2605 LOC, 38 tests)
smart-byte-nostr Nostr adapter. NIP-01 canonical event id + BIP-340
Schnorr sign/verify; from-scratch bech32 + NIP-19 TLV
(npub/nsec/note/nprofile/nevent/nrelay); NIP-04 legacy
AES-256-CBC DMs; NIP-44 v2 HKDF-SHA256→ChaCha20+HMAC
with bucketed padding; NIP-17 gift-wrap (kind 1059) +
seal (kind 13) + rumor (kind 14); NIP-05/11/13/26/65.
Relay client message vocabulary (REQ/EVENT/CLOSE/AUTH/
EOSE/OK/NOTICE/CLOSED) + in-memory router.
EOC (1 crate, 2024 LOC, 30 tests)
eoc-streaming Token-by-token + tool-call streaming primitives.
SSE framing (data: lines); Anthropic event mapper
(message_start/content_block_*/message_delta/stop/ping);
OpenAI delta mapper; Vercel AI SDK mapper. Bounded-channel
backpressure with watermarks; CancelToken propagation;
Last-Event-ID resumable streams; per-stream joule meter.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
41 lines
1.2 KiB
Rust
41 lines
1.2 KiB
Rust
//! End-to-end SSE encode → parse round-trip.
|
|
|
|
use eoc_streaming::sse::{SseEvent, SseParser, parse_all};
|
|
|
|
#[test]
|
|
fn encode_then_parse_recovers_event() {
|
|
let original = SseEvent {
|
|
event: "content_block_delta".into(),
|
|
data: r#"{"index":0,"delta":{"type":"text_delta","text":"hi"}}"#.into(),
|
|
id: Some("evt-7".into()),
|
|
retry_ms: Some(1500),
|
|
};
|
|
let wire = original.encode();
|
|
let parsed = parse_all(&wire).expect("parse");
|
|
assert_eq!(parsed.len(), 1);
|
|
assert_eq!(parsed[0], original);
|
|
}
|
|
|
|
#[test]
|
|
fn incremental_feed_preserves_event_boundaries() {
|
|
let wire =
|
|
"event: a\ndata: 1\n\nevent: b\ndata: 2\ndata: 3\n\n";
|
|
let mut p = SseParser::new();
|
|
for chunk in wire.as_bytes().chunks(3) {
|
|
let s = std::str::from_utf8(chunk).expect("ascii");
|
|
p.feed(s).expect("feed");
|
|
}
|
|
let evs = p.drain();
|
|
assert_eq!(evs.len(), 2);
|
|
assert_eq!(evs[0].event, "a");
|
|
assert_eq!(evs[0].data, "1");
|
|
assert_eq!(evs[1].event, "b");
|
|
assert_eq!(evs[1].data, "2\n3");
|
|
}
|
|
|
|
#[test]
|
|
fn default_event_type_is_message() {
|
|
let wire = "data: hello\n\n";
|
|
let evs = parse_all(wire).unwrap();
|
|
assert_eq!(evs[0].event, "message");
|
|
}
|