openpay/ (+3 crates)
op-bnpl/ Affirm + Klarna + Afterpay/Clearpay rails. Full lifecycle
typestate (Initiated→Approved→Captured→Settled→Refunded).
Per-provider sandbox+production base URLs, regions (NA/EU/OC
for Klarna; US/AuNz/Gb/Ca/Eu for Afterpay). HMAC-SHA256
webhook verification with constant-time compare. 61 tests.
op-batch/ NACHA ACH (94-char records, PPD/CCD/WEB/TEL/CTX, R01-R99
return codes, Same-Day ACH cutoffs); SEPA pain.001.001.09
(CT) + pain.008.001.08 (DD) with SCT-Inst flagging; Fedwire
MT103/MT202/CHIPS + pacs.008.001.12 / pacs.009.001.10 +
UETR; Bacs Standard 18. Per-rail cutoff scheduler. Exception
taxonomy unified across rails. 51 tests.
op-screening/ OFAC SDN + EU consolidated + UN consolidated + HMT UK
consolidated + Australia DFAT + Canada SEMA + Japan MOF.
Levenshtein + Jaro-Winkler + Soundex + Metaphone + token
Jaccard scoring. Unicode NFKD normalisation + Cyrillic /
Arabic transliteration. Ed25519-signed BLAKE3-chained
audit log. BSA helpers: CTR + SAR pattern detection
(structuring, round-dollar, rapid-in-out). 43 tests.
smart-byte/smart-byte-rs/ (+3 crates)
smart-byte-bbs/ BBS+ signatures (IETF draft-irtf-cfrg-bbs-signatures-08).
BLS12-381 keys, signatures, disclosure proofs with
cryptographic unlinkability. bbs-2023 Data Integrity
cryptosuite. AnonCreds-shaped link secrets +
predicate proofs. SecretKey zeroize-on-drop. 49 tests.
smart-byte-didcomm/ DIDComm v2 messaging per DIF spec. Pack-encrypted
(ECDH-1PU + ECDH-ES via X25519), pack-signed (JWS),
pack-plaintext. Aries protocols: issue-credential v3,
present-proof v3, basic-message, trust-ping, discover-
features, out-of-band, coordinate-mediation, message-
pickup. Mediator role with pluggable storage. 23 tests.
smart-byte-mdl/ ISO/IEC 18013-5 mobile driver's licence + 18013-7
online presentment. mDoc + MSO with salted-hash
selective disclosure (per item; SHA-256 digest tree).
org.iso.18013.5.1 namespace + AAMVA add-on. ES256
device-auth + issuer-auth. QR-code device-engagement
scaffolding. 28 tests.
eoc/eoc-rs/ (+3 crates)
eoc-local/ Local-inference backends behind one NeuralBackend:
llama.cpp (GGUF, Q4/Q5/Q6/Q8/F16/F32 quantisation),
MLX (Apple Silicon, feature-gated), MLC-LLM (TVM, feature-
gated marker), ONNX Runtime. GGUF file-format reader.
HuggingFace tokenizers. Greedy / top-k / top-p / temperature /
Mirostat samplers. Model registry scanning ~/.eoc/models/.
Joule attribution via eoc-meter. 39 tests.
eoc-rerank/ BM25 sparse + HNSW dense + RRF + min-max hybrid fusion.
Cohere v3.5 + Voyage v2 + bge-reranker v2-m3 + ms-marco
MiniLM + ColBERT v2 rerankers. Two-stage pipeline:
retrieve top-K hybrid → cross-encoder rerank → top-N.
KV-stage recovery shim into the cascade. 31 tests.
eoc-eval/ 15 canonical eval harnesses: MMLU, MMLU-Pro, GPQA,
HumanEval (pass@1 with python3 sandbox), BBH, IFEval (25
verifiable constraints), AlpacaEval, AGIEval, HellaSwag,
ARC (Easy + Challenge), TruthfulQA (MC1+MC2), BoolQ,
GSM8K, MATH (boxed-answer equivalence), Winogrande. Real
questions in BuiltinSamples. EvalRunner emits joules-per-
correct alongside accuracy. 49 tests.
Quality:
- cargo check across all three workspaces: clean
- cargo clippy --all-targets -- -D warnings on every new crate: clean
- 374 new tests, all passing
- #![forbid(unsafe_code)] across every new crate
- No unwrap/expect outside #[cfg(test)]
Rust 1.95.0 edition 2024 (inherited via root rust-toolchain.toml).
215 lines
7.3 KiB
Rust
215 lines
7.3 KiB
Rust
//! End-to-end tests for DIDComm v2 application protocols, using the
|
|
//! in-memory connection from `state.rs` to wire two synthetic agents
|
|
//! together.
|
|
|
|
use smart_byte_didcomm::message::DidcommMessage;
|
|
use smart_byte_didcomm::protocol::ProtocolMessage;
|
|
use smart_byte_didcomm::protocols::issue_credential::{
|
|
AckBody as IssueAck, IssueCredentialBody, IssueCredentialKind,
|
|
OfferCredentialBody, RequestCredentialBody, State as IssueState,
|
|
StateMachine as IssueStateMachine,
|
|
};
|
|
use smart_byte_didcomm::protocols::present_proof::{
|
|
AckBody as ProofAck, PresentProofKind, PresentationFormat,
|
|
RequestPresentationBody, State as ProofState,
|
|
StateMachine as ProofStateMachine, make_presentation_with_sd_jwt,
|
|
};
|
|
use smart_byte_didcomm::protocols::trust_ping::{
|
|
PingBody, TrustPingKind, respond_to,
|
|
};
|
|
use smart_byte_didcomm::state::{Connection, InMemoryConnection};
|
|
use smart_byte_did::Did;
|
|
|
|
fn alice() -> Did {
|
|
"did:example:alice".parse().unwrap()
|
|
}
|
|
fn bob() -> Did {
|
|
"did:example:bob".parse().unwrap()
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn e2e_issue_credential_v3_happy_path() {
|
|
let (issuer_side, holder_side) =
|
|
InMemoryConnection::pair(alice(), bob());
|
|
|
|
let mut issuer_sm = IssueStateMachine::new();
|
|
let mut holder_sm = IssueStateMachine::new();
|
|
|
|
// 1) Issuer sends offer.
|
|
let mut offer =
|
|
IssueCredentialKind::Offer(OfferCredentialBody::default()).to_message();
|
|
offer.from = Some(alice());
|
|
offer.to = vec![bob()];
|
|
issuer_sm.step(&offer).unwrap();
|
|
issuer_side.send(offer.clone()).await.unwrap();
|
|
|
|
let recv_offer = holder_side.receive().await.unwrap();
|
|
holder_sm.step(&recv_offer).unwrap();
|
|
assert_eq!(holder_sm.state, IssueState::Offered);
|
|
|
|
// 2) Holder sends request.
|
|
let mut req = IssueCredentialKind::Request(RequestCredentialBody::default())
|
|
.to_message();
|
|
req.from = Some(bob());
|
|
req.to = vec![alice()];
|
|
req.thid = holder_sm.thid.clone();
|
|
holder_sm.step(&req).unwrap();
|
|
holder_side.send(req).await.unwrap();
|
|
|
|
let recv_req = issuer_side.receive().await.unwrap();
|
|
issuer_sm.step(&recv_req).unwrap();
|
|
assert_eq!(issuer_sm.state, IssueState::Requested);
|
|
|
|
// 3) Issuer sends issue-credential.
|
|
let mut issue = IssueCredentialKind::Issue(IssueCredentialBody::default())
|
|
.to_message();
|
|
issue.from = Some(alice());
|
|
issue.to = vec![bob()];
|
|
issue.thid = issuer_sm.thid.clone();
|
|
issuer_sm.step(&issue).unwrap();
|
|
issuer_side.send(issue).await.unwrap();
|
|
|
|
let recv_issue = holder_side.receive().await.unwrap();
|
|
holder_sm.step(&recv_issue).unwrap();
|
|
assert_eq!(holder_sm.state, IssueState::Issued);
|
|
|
|
// 4) Holder acks.
|
|
let mut ack = IssueCredentialKind::Ack(IssueAck { status: "OK".into() })
|
|
.to_message();
|
|
ack.from = Some(bob());
|
|
ack.to = vec![alice()];
|
|
ack.thid = holder_sm.thid.clone();
|
|
holder_sm.step(&ack).unwrap();
|
|
holder_side.send(ack).await.unwrap();
|
|
|
|
let recv_ack = issuer_side.receive().await.unwrap();
|
|
issuer_sm.step(&recv_ack).unwrap();
|
|
assert_eq!(issuer_sm.state, IssueState::Done);
|
|
assert_eq!(holder_sm.state, IssueState::Done);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn e2e_present_proof_v3_selective_disclosure() {
|
|
let (verifier_side, holder_side) =
|
|
InMemoryConnection::pair(alice(), bob());
|
|
|
|
let mut verifier_sm = ProofStateMachine::new();
|
|
let mut holder_sm = ProofStateMachine::new();
|
|
|
|
// 1) Verifier sends request-presentation.
|
|
let mut req = PresentProofKind::Request(RequestPresentationBody {
|
|
will_confirm: true,
|
|
formats: vec![PresentationFormat {
|
|
attach_id: "req-1".into(),
|
|
format: "sd-jwt".into(),
|
|
}],
|
|
..Default::default()
|
|
})
|
|
.to_message();
|
|
req.from = Some(alice());
|
|
req.to = vec![bob()];
|
|
verifier_sm.step(&req).unwrap();
|
|
verifier_side.send(req).await.unwrap();
|
|
|
|
let recv_req = holder_side.receive().await.unwrap();
|
|
holder_sm.step(&recv_req).unwrap();
|
|
assert_eq!(holder_sm.state, ProofState::Requested);
|
|
|
|
// 2) Holder builds an SD-JWT presentation (mocked here as a string).
|
|
// The bridge to smart-byte-vc::sd_jwt would assemble disclosures
|
|
// selecting only the claims requested by the verifier. We use a
|
|
// canned token to verify the message envelope round-trips.
|
|
let mock_sd_jwt_presentation =
|
|
"eyJhbGciOiJFZERTQSJ9.eyJ2YyI6e319.SIG~disclosure-1~disclosure-2~";
|
|
let mut pres =
|
|
make_presentation_with_sd_jwt(mock_sd_jwt_presentation, "pres-1");
|
|
pres.from = Some(bob());
|
|
pres.to = vec![alice()];
|
|
pres.thid = holder_sm.thid.clone();
|
|
holder_sm.step(&pres).unwrap();
|
|
holder_side.send(pres).await.unwrap();
|
|
|
|
let recv_pres = verifier_side.receive().await.unwrap();
|
|
let kind = PresentProofKind::from_message(&recv_pres).unwrap();
|
|
match kind {
|
|
PresentProofKind::Presentation(b) => {
|
|
assert_eq!(b.formats.len(), 1);
|
|
assert_eq!(b.formats[0].format, "sd-jwt");
|
|
}
|
|
_ => panic!("expected presentation"),
|
|
}
|
|
assert!(!recv_pres.attachments.is_empty());
|
|
verifier_sm.step(&recv_pres).unwrap();
|
|
assert_eq!(verifier_sm.state, ProofState::Presented);
|
|
|
|
// 3) Verifier acks.
|
|
let mut ack = PresentProofKind::Ack(ProofAck { status: "OK".into() })
|
|
.to_message();
|
|
ack.from = Some(alice());
|
|
ack.to = vec![bob()];
|
|
ack.thid = verifier_sm.thid.clone();
|
|
verifier_sm.step(&ack).unwrap();
|
|
verifier_side.send(ack).await.unwrap();
|
|
|
|
let recv_ack = holder_side.receive().await.unwrap();
|
|
holder_sm.step(&recv_ack).unwrap();
|
|
assert_eq!(verifier_sm.state, ProofState::Done);
|
|
assert_eq!(holder_sm.state, ProofState::Done);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn e2e_trust_ping_response() {
|
|
let (a, b) = InMemoryConnection::pair(alice(), bob());
|
|
let ping = TrustPingKind::Ping(PingBody {
|
|
response_requested: true,
|
|
comment: None,
|
|
})
|
|
.to_message()
|
|
.from_did(alice())
|
|
.to_dids(vec![bob()]);
|
|
let ping_id = ping.id.clone();
|
|
a.send(ping).await.unwrap();
|
|
let recv = b.receive().await.unwrap();
|
|
let resp = respond_to(&recv);
|
|
b.send(resp).await.unwrap();
|
|
let pong = a.receive().await.unwrap();
|
|
match TrustPingKind::from_message(&pong).unwrap() {
|
|
TrustPingKind::PingResponse(_) => {}
|
|
_ => panic!("expected ping-response"),
|
|
}
|
|
assert_eq!(pong.thid.as_deref(), Some(ping_id.as_str()));
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn e2e_basic_message() {
|
|
use smart_byte_didcomm::protocols::basic_message::{
|
|
BasicMessageBody, BasicMessageKind,
|
|
};
|
|
let (a, b) = InMemoryConnection::pair(alice(), bob());
|
|
let m = BasicMessageKind::Message(BasicMessageBody {
|
|
content: "hello bob".into(),
|
|
sent_time: None,
|
|
})
|
|
.to_message()
|
|
.from_did(alice())
|
|
.to_dids(vec![bob()]);
|
|
a.send(m).await.unwrap();
|
|
let recv = b.receive().await.unwrap();
|
|
match BasicMessageKind::from_message(&recv).unwrap() {
|
|
BasicMessageKind::Message(body) => {
|
|
assert_eq!(body.content, "hello bob");
|
|
}
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn message_serialises_with_required_envelope_fields() {
|
|
let m = DidcommMessage::new("https://didcomm.org/x/1.0/y")
|
|
.from_did(alice())
|
|
.to_dids(vec![bob()]);
|
|
let j: serde_json::Value = serde_json::to_value(&m).unwrap();
|
|
assert!(j.get("id").is_some());
|
|
assert!(j.get("type").is_some());
|
|
assert!(j.get("from").is_some());
|
|
assert!(j.get("to").is_some());
|
|
}
|