diff --git a/crates/origin-chain-runtime/src/lib.rs b/crates/origin-chain-runtime/src/lib.rs index 0414df1..21bb5e2 100644 --- a/crates/origin-chain-runtime/src/lib.rs +++ b/crates/origin-chain-runtime/src/lib.rs @@ -742,4 +742,118 @@ mod tests { assert_eq!(MILLISECS_PER_BLOCK, 6_000); assert_eq!(SLOT_DURATION, MILLISECS_PER_BLOCK); } + + // ============================================================ + // Phase 3 Slice 3.1 v0.0.40 — pallet-revive integration tests E2E + // SCAFFOLD-level: verify Config wiring + constants + AddressMapper + + // Genesis. Real PolkaVM bytecode E2E deferred a Phase 3.x maduración + // post cargo-contract v6 install + ink! v6 contract templates (Slice 3.2+). + // ============================================================ + + #[test] + fn revive_chain_id_eip155_unique_origin_metaverse() { + // OriginChainId canonical 9_120_005 — EIP-155 unique identifier + // previene cross-chain replay attacks canonical post-mainnet. + use frame_support::traits::Get; + let chain_id: u64 = <::ChainId>::get(); + assert_eq!(chain_id, 9_120_005_u64); + } + + #[test] + fn revive_native_to_eth_ratio_one_million_canonical() { + // OGC 12 decimals → ETH 18 decimals = ratio 10^6 canonical. + // Mapping balance OGC↔ETH-equivalent units para EVM compat. + use frame_support::traits::Get; + let ratio: u32 = <::NativeToEthRatio>::get(); + assert_eq!(ratio, 1_000_000_u32); + } + + #[test] + fn revive_deposit_per_byte_canonical_milli_ogc() { + // Asset Hub pattern adapted OGC tokenomics — 1 MILLI_OGC per byte canonical. + use frame_support::traits::Get; + let deposit_per_byte: Balance = + <::DepositPerByte>::get(); + assert_eq!(deposit_per_byte, MILLI_OGC); + assert_eq!(deposit_per_byte, Ogc::ONE / 1_000); + } + + #[test] + fn revive_deposit_per_item_canonical_one_ogc() { + // Storage item deposit = 1 OGC canonical (gate storage proliferation). + use frame_support::traits::Get; + let deposit_per_item: Balance = + <::DepositPerItem>::get(); + assert_eq!(deposit_per_item, Ogc::ONE); + } + + #[test] + fn revive_evm_bytecode_allowed_canonical() { + // SBS-5 ratificado: Solidity contracts deployables via revive compiler. + // AllowEVMBytecode = true canonical para opens Ethereum dev ecosystem. + use frame_support::traits::Get; + let allow_evm: bool = <::AllowEVMBytecode>::get(); + assert!(allow_evm, "EVM bytecode must be allowed per SBS-5 ratified"); + } + + #[test] + fn revive_runtime_memory_128_mb_canonical() { + // RuntimeMemory canonical 128 MB — runtime memory allocation budget. + use frame_support::traits::Get; + let runtime_memory: u32 = <::RuntimeMemory>::get(); + assert_eq!(runtime_memory, 128_u32 * 1024 * 1024); + } + + #[test] + fn revive_pvf_memory_2_gb_canonical_integrity_pass() { + // PVFMemory canonical 2 GB — required canonical para pass + // __construct_runtime_integrity_test (formula: storage_limit = + // (PVFMemory - RuntimeMemory) / 2 > max_storage_size ~650 MB). + use frame_support::traits::Get; + let pvf_memory: u32 = <::PVFMemory>::get(); + assert_eq!(pvf_memory, 2_u32 * 1024 * 1024 * 1024); + // Verify integrity formula passes canonical + let runtime_memory: u32 = <::RuntimeMemory>::get(); + let storage_limit: u32 = (pvf_memory - runtime_memory) / 2; + // ~960 MB storage limit canonical — comfortably above 650 MB max storage. + assert!( + storage_limit > 700_u32 * 1024 * 1024, + "storage_limit must exceed 700 MB para pallet-revive integrity canonical" + ); + } + + #[test] + fn revive_safety_toggles_production_safe_canonical() { + // Production canonical safety: UnsafeUnstableInterface=false. + // DebugEnabled NO disponible en pallet-revive 0.10.1 (added 0.12+). + use frame_support::traits::Get; + let unsafe_interface: bool = + <::UnsafeUnstableInterface>::get(); + assert!( + !unsafe_interface, + "Unstable interface MUST be disabled en production runtime canonical" + ); + } + + #[test] + fn revive_pallet_index_11_canonical_post_governance() { + // Pallet index canonical: Revive=11 (post Governance=10 Phase 5.1). + // Asegura orden storage migrations canonical canonical preservado. + use frame_support::traits::PalletInfoAccess; + assert_eq!(::index(), 11); + assert_eq!(::name(), "Revive"); + } + + #[test] + fn revive_address_mapper_account32_returns_h160_canonical() { + // AccountId32Mapper canonical: AccountId32 → H160 mapping deterministic. + // BLAKE2b derivation per Asset Hub canonical solochain pattern. + // Slice 3.1 SCAFFOLD: verify mapper type bound, no real address conversion + // (requires pallet runtime context). Phase 3.x maduración: real mapping tests. + use pallet_revive::AddressMapper; + type ConfiguredMapper = ::AddressMapper; + // Compile-time verification que el mapper type implements AddressMapper trait + fn _verify_implements_mapper>() {} + _verify_implements_mapper::(); + } }