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]>
48 lines
1.6 KiB
Rust
48 lines
1.6 KiB
Rust
//! Integration test: full event sign + verify with multiple kinds and
|
|
//! tag shapes, plus tamper detection.
|
|
|
|
use smart_byte_nostr::{NostrSecretKey, UnsignedEvent};
|
|
|
|
#[test]
|
|
fn many_kinds_sign_and_verify() {
|
|
for kind in [0u32, 1, 4, 5, 1059, 10002] {
|
|
let sk = NostrSecretKey::generate();
|
|
let pk = sk.public_key();
|
|
let ev = UnsignedEvent::new(pk, kind, format!("payload for {kind}"), 1_700_000_000)
|
|
.with_tag(vec!["p".into(), pk.to_hex()])
|
|
.with_tag(vec!["t".into(), "smart-byte".into()])
|
|
.sign(&sk)
|
|
.expect("sign");
|
|
ev.verify().expect("verify");
|
|
assert_eq!(ev.kind, kind);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn tag_reorder_changes_id() {
|
|
let sk = NostrSecretKey::generate();
|
|
let pk = sk.public_key();
|
|
let a = UnsignedEvent::new(pk, 1, "hi", 1_700_000_000)
|
|
.with_tag(vec!["t".into(), "a".into()])
|
|
.with_tag(vec!["t".into(), "b".into()])
|
|
.sign(&sk)
|
|
.expect("sign");
|
|
let b = UnsignedEvent::new(pk, 1, "hi", 1_700_000_000)
|
|
.with_tag(vec!["t".into(), "b".into()])
|
|
.with_tag(vec!["t".into(), "a".into()])
|
|
.sign(&sk)
|
|
.expect("sign");
|
|
assert_ne!(a.id, b.id);
|
|
}
|
|
|
|
#[test]
|
|
fn wrong_key_fails_verify() {
|
|
let sk = NostrSecretKey::generate();
|
|
let bad_pk = NostrSecretKey::generate().public_key();
|
|
let mut ev = UnsignedEvent::new(sk.public_key(), 1, "hi", 1_700_000_000)
|
|
.sign(&sk)
|
|
.expect("sign");
|
|
// Re-point the event to a different pubkey but keep the same id/sig.
|
|
ev.pubkey = bad_pk.to_hex();
|
|
assert!(ev.verify().is_err());
|
|
}
|