open-standards/openpay/crates/op-crypto-extra/tests/erc4337_userop.rs
Transaction Science 68b8a2dbee ingest wave F: 3 crates · op-crypto-extra + smart-byte-acdc + eoc-memory
OpenPay (1 crate, 3751 LOC, 83 tests)
  op-crypto-extra      Extended crypto rails. Stablecoin catalog (USDC, USDT,
                       PYUSD, DAI, RLUSD, EURC, FDUSD — 26 deployments). L2
                       catalog (12 chains incl. Optimism, Arbitrum, Base,
                       zkSync Era, Polygon zkEVM, Linea, Scroll, Starknet).
                       CCTP v2 BurnMessage encode/decode + domain ids +
                       attestation. ERC-4337 UserOperation v0.7 +
                       PackedUserOperation. EIP-7702 set-EOA-code with RLP
                       signing preimage. Uniswap Permit2 single + batch
                       transfer EIP-712 hashes. EIP-2612 ERC-20 permit.
                       BOLT-11 bech32 invoices + LNURL decode. Bitcoin
                       PSBT v2 (BIP-370). Atomic-swap HTLC. Solana SPL /
                       Aleo / Aztec confidential-transfer sketches.

Smart Byte (1 crate, 2304 LOC, 30 tests)
  smart-byte-acdc      Authentic Chained Data Containers (KERI ecosystem).
                       Acdc + AcdcBuilder (targeted + untargeted) with SAID
                       derivation. JSON Schema 2020-12 validator with
                       oneOf partial-disclosure. TEL (RIP/VRT/ISS/REV)
                       with hash-chained verification. IPEX (apply/offer/
                       agree/grant/admit/spurn) chained by SAID. Edge
                       records (I2I/NI2I/DI2I) + EdgeGraph BFS traversal
                       with cycle detection. Selective disclosure with
                       full/none/subset plans + compact packing.
                       CredentialRegistry trait + InMemoryRegistry over
                       TEL. Composes with smart-byte-core + smart-byte-keri-witness.

EOC (1 crate, 1764 LOC, 16 tests)
  eoc-memory           Long-term memory primitives. Memory trait + MemoryKind +
                       EpisodeId. Episodic event log with TimeIndex range
                       queries. RDF-style Triple store with S/P/O indices.
                       Bounded attention-budget Scratchpad with
                       salience-weighted eviction. Rolling SummaryBuffer +
                       FIFO SlidingWindow. Dream-cycle consolidate()
                       (episodic → semantic). Ebbinghaus forgetting curve
                       with reinforcement. Retriever blending cosine
                       similarity + recency + saturating frequency.
                       MemGpt three-tier shape (Main/Recall/Archival).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-05-24 17:28:24 -04:00

56 lines
2.1 KiB
Rust

//! Integration: ERC-4337 v0.7 packed user-op assembly.
use op_crypto_extra::erc4337::{EntryPointVersion, UserOperation, pack_user_op};
#[test]
fn entrypoint_addresses_distinct_across_versions() {
let a = EntryPointVersion::V0_6.canonical_address();
let b = EntryPointVersion::V0_7.canonical_address();
let c = EntryPointVersion::V0_8.canonical_address();
assert_ne!(a, b);
assert_ne!(b, c);
assert!(a.starts_with("0x"));
assert!(b.starts_with("0x"));
}
#[test]
fn pack_round_trip_preserves_data_fields() {
let op = UserOperation {
sender: "0x1111111111111111111111111111111111111111".into(),
nonce: 7,
init_code: vec![0xde, 0xad],
call_data: vec![0xbe, 0xef],
call_gas_limit: 100_000,
verification_gas_limit: 60_000,
pre_verification_gas: 21_000,
max_fee_per_gas: 10_000_000_000,
max_priority_fee_per_gas: 2_000_000_000,
paymaster_and_data: vec![0xab; 20],
signature: vec![0xcd; 65],
};
op.validate_structure().expect("structure ok");
let packed = pack_user_op(&op);
assert_eq!(packed.sender, op.sender);
assert_eq!(packed.nonce, op.nonce);
assert_eq!(packed.init_code, op.init_code);
assert_eq!(packed.call_data, op.call_data);
assert_eq!(packed.pre_verification_gas, op.pre_verification_gas);
assert_eq!(packed.paymaster_and_data, op.paymaster_and_data);
assert_eq!(packed.signature, op.signature);
// account_gas_limits high half = verification_gas_limit
let high: u128 = u128::from_be_bytes(packed.account_gas_limits[..16].try_into().unwrap());
let low: u128 = u128::from_be_bytes(packed.account_gas_limits[16..].try_into().unwrap());
assert_eq!(high, 60_000);
assert_eq!(low, 100_000);
}
#[test]
fn validate_rejects_paymaster_too_short() {
let mut op = UserOperation::new("0x1111111111111111111111111111111111111111");
op.call_gas_limit = 1;
op.verification_gas_limit = 1;
op.max_fee_per_gas = 1;
op.paymaster_and_data = vec![0xab; 5]; // too short
assert!(op.validate_structure().is_err());
}