//! # Mock runtime canonical para integration tests v0.0.26 //! //! Pattern v0.0.18 (Provenance) + v0.0.22 (Fees) mirror — construct_runtime! + //! derive_impl + new_test_ext + helpers canonical. #![cfg(test)] use crate as origin_chain_agent_identity; use frame_support::derive_impl; use sp_core::{ed25519, Pair}; use sp_runtime::BuildStorage; /// Mock block type canonical para tests. type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( pub enum Test { System: frame_system, AgentIdentity: origin_chain_agent_identity, } ); #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for Test { type Block = Block; type AccountId = sp_runtime::AccountId32; type Lookup = sp_runtime::traits::IdentityLookup; } impl origin_chain_agent_identity::Config for Test { type RuntimeEvent = RuntimeEvent; } /// Test externalities builder canonical (pattern v0.0.18/v0.0.22 mirror). pub fn new_test_ext() -> sp_io::TestExternalities { let mut ext: sp_io::TestExternalities = frame_system::GenesisConfig::::default() .build_storage() .expect("genesis canonical builds") .into(); ext.execute_with(|| { System::set_block_number(1); }); ext } /// Test origin canonical ALICE. pub fn alice_origin() -> RuntimeOrigin { RuntimeOrigin::signed(sp_runtime::AccountId32::new([1u8; 32])) } /// Test account canonical ALICE (AccountId32 value para storage assertions). pub fn alice_account() -> sp_runtime::AccountId32 { sp_runtime::AccountId32::new([1u8; 32]) } /// Test origin canonical BOB. pub fn bob_origin() -> RuntimeOrigin { RuntimeOrigin::signed(sp_runtime::AccountId32::new([2u8; 32])) } /// Test account canonical BOB. pub fn bob_account() -> sp_runtime::AccountId32 { sp_runtime::AccountId32::new([2u8; 32]) } // ─── Ed25519 keypairs canonical (FIX-3 V3-H1 DID binding) ────────────── // Pairs reales desde seeds → pubkeys reales + firmas verificables. Reemplaza // los pubkeys-bytes-arbitrarios previos (sin private key, incapaces de firmar el // binding del registro). /// Ed25519 pair canonical ALICE (agent identity key). pub fn alice_pair() -> ed25519::Pair { ed25519::Pair::from_seed(&[0x11u8; 32]) } /// Ed25519 pair canonical BOB. pub fn bob_pair() -> ed25519::Pair { ed25519::Pair::from_seed(&[0x22u8; 32]) } /// Ed25519 pair canonical CHARLIE (Hybrid co-author lineage). pub fn charlie_pair() -> ed25519::Pair { ed25519::Pair::from_seed(&[0x33u8; 32]) } /// Public key bytes canonical ALICE (derivado del pair real). pub fn alice_pubkey() -> [u8; 32] { alice_pair().public().0 } /// Public key bytes canonical BOB. pub fn bob_pubkey() -> [u8; 32] { bob_pair().public().0 } /// Public key bytes canonical CHARLIE. pub fn charlie_pubkey() -> [u8; 32] { charlie_pair().public().0 } /// Firma de binding canonical (FIX-3 (b)): el holder de `pair` firma el mensaje /// de registro `AGENT_DID_REGISTER_DOMAIN || who.encode()` → prueba control de la /// key. Usa el MISMO builder de mensaje que el pallet (una fuente de verdad). pub fn sign_registration(pair: &ed25519::Pair, who: &sp_runtime::AccountId32) -> [u8; 64] { use parity_scale_codec::Encode; let msg = origin_chain_agent_identity::agent_did_register_message(&who.encode()); pair.sign(&msg).0 }