All checks were successful
repository checks / lockfiles, advisories, tests in CI, workflow hygiene, spec and section references, public text (push) Successful in 8m28s
Every OpenPay crate now passes clippy with -D warnings, and the openpay entry of the workspace build sets clippy: true so it stays there. Most of the findings were mechanical (clippy's own fixes, write! for push_str(&format!), let-else); where a lint is wrong for the code it is allowed at the narrowest scope with its reason: code tables keep one arm per code, units_cents amounts keep their grouping, op-fraud-graph's index casts rest on a bound upsert_entity now enforces (it used to hand every vertex past 2^32 the same id). Two findings were bugs. op-payouts capped FedNow at USD 1,000,000, the limit before November 2025; the network maximum is USD 10,000,000 and a test now sends five million. op-crypto-extra's EIP-7702 low-s bound was N - 2^255, not N/2: it refused valid low-s signatures in a band just below N/2. It is N/2 now, with tests at both edges. Co-Authored-By: Claude Opus 5.5 <[email protected]>
77 lines
2.8 KiB
Rust
77 lines
2.8 KiB
Rust
//! Integration: FedNow payout shape + cap enforcement.
|
|
|
|
#![allow(clippy::inconsistent_digit_grouping, reason = "amounts in minor units are written units_cents: 2500_00 is 2 500.00")]
|
|
use op_core::{Currency, Money};
|
|
use op_payouts::fednow::{FedNowDriver, FEDNOW_MAX_AMOUNT_USD};
|
|
use op_payouts::{
|
|
Beneficiary, BeneficiaryAccount, Error, FundingSource, Payout, PayoutMethod, PayoutRequest,
|
|
PayoutStatus,
|
|
};
|
|
|
|
fn driver() -> FedNowDriver {
|
|
FedNowDriver {
|
|
sender_aba: "021000021".to_string(),
|
|
sender_account: "0000123456".to_string(),
|
|
sender_name: "Acme Inc".to_string(),
|
|
}
|
|
}
|
|
|
|
fn req(amount: Money) -> PayoutRequest {
|
|
PayoutRequest {
|
|
idempotency_key: "33333333-3333-4333-8333-333333333333".to_string(),
|
|
method: PayoutMethod::FedNow,
|
|
amount,
|
|
beneficiary: Beneficiary {
|
|
name: "John Doe".to_string(),
|
|
address: None,
|
|
account: BeneficiaryAccount::UsBank {
|
|
aba: "121000358".to_string(),
|
|
account: "9876543210".to_string(),
|
|
account_type: "CHECKING".to_string(),
|
|
},
|
|
kyc_ref: None,
|
|
},
|
|
funding: FundingSource::Prefunded {
|
|
account_ref: "fednow-settlement".to_string(),
|
|
},
|
|
memo: None,
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn fednow_builds_pacs008_xml() {
|
|
let amount = Money::from_minor(2_500_00, Currency::USD); // $2,500
|
|
let res = driver().submit(&req(amount)).expect("offline build");
|
|
assert_eq!(res.status, PayoutStatus::PreparedOffline);
|
|
let xml = String::from_utf8(res.wire_payload.expect("payload")).expect("utf8");
|
|
assert!(xml.contains("<Cd>FDN</Cd>"));
|
|
assert!(xml.contains("Ccy=\"USD\""));
|
|
assert!(xml.contains("2500.00"));
|
|
assert!(xml.contains("<MmbId>121000358</MmbId>"));
|
|
}
|
|
|
|
#[test]
|
|
fn fednow_rejects_above_cap() {
|
|
let amount = Money::from_minor(FEDNOW_MAX_AMOUNT_USD + 1, Currency::USD);
|
|
let err = driver().submit(&req(amount)).unwrap_err();
|
|
assert!(matches!(err, Error::LimitViolation { rail: "fednow", .. }));
|
|
}
|
|
|
|
/// The network maximum is USD 10,000,000 since November 2025: a payout of
|
|
/// five million, refused under the old USD 1,000,000 cap, now goes, and the
|
|
/// maximum itself does.
|
|
#[test]
|
|
fn fednow_takes_payouts_up_to_the_network_maximum() {
|
|
assert_eq!(FEDNOW_MAX_AMOUNT_USD, 10_000_000 * 100);
|
|
for cents in [5_000_000 * 100, FEDNOW_MAX_AMOUNT_USD] {
|
|
let res = driver().submit(&req(Money::from_minor(cents, Currency::USD))).expect("within the network maximum");
|
|
assert_eq!(res.status, PayoutStatus::PreparedOffline);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn fednow_rejects_non_usd() {
|
|
let amount = Money::from_minor(2_500_00, Currency::EUR);
|
|
let err = driver().submit(&req(amount)).unwrap_err();
|
|
assert!(matches!(err, Error::LimitViolation { rail: "fednow", .. }));
|
|
}
|