From 6e4a2e15bba4336839210b9d5fea9a0f4b7d906d Mon Sep 17 00:00:00 2001 From: 4meta5 Date: Mon, 4 Nov 2024 20:40:26 -0500 Subject: [PATCH 1/3] update evm template tests --- evm-template/runtime/tests/constants_test.rs | 363 +++++++++--------- .../runtime/tests/constants_test.rs | 297 +++++++------- 2 files changed, 338 insertions(+), 322 deletions(-) diff --git a/evm-template/runtime/tests/constants_test.rs b/evm-template/runtime/tests/constants_test.rs index 7e7c2152..5d6e0007 100644 --- a/evm-template/runtime/tests/constants_test.rs +++ b/evm-template/runtime/tests/constants_test.rs @@ -18,228 +18,245 @@ mod constant_tests { } } -// TODO: fix the tests -// mod runtime_tests { -// use evm_runtime_template::{ -// configs::{asset_config::*, *}, -// constants::{currency::*, *}, -// *, -// }; -// use frame_support::{pallet_prelude::Weight, traits::TypedGet, PalletId}; -// use sp_runtime::create_runtime_str; -// use sp_version::RuntimeVersion; -// use xcm::latest::prelude::BodyId; - -// // RUNTIME_API_VERSIONS constant is generated by a macro and is private. -// #[test] -// fn check_version() { -// assert_eq!( -// VERSION, -// RuntimeVersion { -// spec_name: create_runtime_str!("template-parachain"), -// impl_name: create_runtime_str!("template-parachain"), -// authoring_version: 1, -// spec_version: 1, -// impl_version: 0, -// apis: evm_runtime_template::RUNTIME_API_VERSIONS, -// transaction_version: 1, -// state_version: 1, -// } -// ); -// } - -// #[test] -// fn weight_to_fee_constants() { -// assert_eq!(P_FACTOR, 10); - -// assert_eq!(Q_FACTOR, 100); - -// assert_eq!(POLY_DEGREE, 1); -// } - -// #[test] -// fn frame_system_constants() { -// #[cfg(not(feature = "async-backing"))] -// assert_eq!( -// MAXIMUM_BLOCK_WEIGHT, -// Weight::from_parts( -// frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), -// cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64 -// ) -// ); +mod runtime_tests { + use evm_runtime_template::{ + configs, + constants::{currency::*, *}, + BlockNumber, Runtime, + }; + use frame_support::{pallet_prelude::Weight, traits::TypedGet, PalletId}; + use sp_runtime::{create_runtime_str, Perbill}; + use sp_version::RuntimeVersion; + + // RUNTIME_API_VERSIONS constant is generated by a macro and is private. + #[test] + fn check_version() { + assert_eq!( + VERSION, + RuntimeVersion { + spec_name: create_runtime_str!("template-parachain"), + impl_name: create_runtime_str!("template-parachain"), + authoring_version: 1, + spec_version: 1, + impl_version: 0, + apis: evm_runtime_template::RUNTIME_API_VERSIONS, + transaction_version: 1, + state_version: 1, + } + ); + } -// #[cfg(feature = "async-backing")] -// assert_eq!( -// MAXIMUM_BLOCK_WEIGHT, -// Weight::from_parts( -// frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), -// cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64 -// ) -// ); + #[test] + fn weight_to_fee_constants() { + assert_eq!(P_FACTOR, 10); -// assert_eq!(AVERAGE_ON_INITIALIZE_RATIO, Perbill::from_percent(5)); + assert_eq!(Q_FACTOR, 100); -// assert_eq!(NORMAL_DISPATCH_RATIO, Perbill::from_percent(75)); -// #[cfg(not(feature = "async-backing"))] -// assert_eq!(UNINCLUDED_SEGMENT_CAPACITY, 1); -// #[cfg(feature = "async-backing")] -// assert_eq!(UNINCLUDED_SEGMENT_CAPACITY, 3); + assert_eq!(POLY_DEGREE, 1); + } -// assert_eq!(BLOCK_PROCESSING_VELOCITY, 1); + #[test] + fn frame_system_constants() { + #[cfg(not(feature = "async-backing"))] + assert_eq!( + MAXIMUM_BLOCK_WEIGHT, + Weight::from_parts( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), + cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64 + ) + ); -// assert_eq!(RELAY_CHAIN_SLOT_DURATION_MILLIS, 6000); + #[cfg(feature = "async-backing")] + assert_eq!( + MAXIMUM_BLOCK_WEIGHT, + Weight::from_parts( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), + cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64 + ) + ); -// #[cfg(not(feature = "async-backing"))] -// assert_eq!(MILLISECS_PER_BLOCK, 12000); -// #[cfg(feature = "async-backing")] -// assert_eq!(MILLISECS_PER_BLOCK, 6000); + assert_eq!(AVERAGE_ON_INITIALIZE_RATIO, Perbill::from_percent(5)); -// assert_eq!(SLOT_DURATION, MILLISECS_PER_BLOCK); + assert_eq!(NORMAL_DISPATCH_RATIO, Perbill::from_percent(75)); + #[cfg(not(feature = "async-backing"))] + assert_eq!(UNINCLUDED_SEGMENT_CAPACITY, 1); + #[cfg(feature = "async-backing")] + assert_eq!(UNINCLUDED_SEGMENT_CAPACITY, 3); -// assert_eq!(MINUTES, 60_000 / (MILLISECS_PER_BLOCK as BlockNumber)); + assert_eq!(BLOCK_PROCESSING_VELOCITY, 1); -// assert_eq!(HOURS, MINUTES * 60); + assert_eq!(RELAY_CHAIN_SLOT_DURATION_MILLIS, 6000); -// assert_eq!(DAYS, HOURS * 24); + #[cfg(not(feature = "async-backing"))] + assert_eq!(MILLISECS_PER_BLOCK, 12000); + #[cfg(feature = "async-backing")] + assert_eq!(MILLISECS_PER_BLOCK, 6000); -// assert_eq!(MAX_BLOCK_LENGTH, 5 * 1024 * 1024); + assert_eq!(SLOT_DURATION, MILLISECS_PER_BLOCK); -// assert_eq!(SS58Prefix::get(), 42); + assert_eq!(MINUTES, 60_000 / (MILLISECS_PER_BLOCK as BlockNumber)); -// assert_eq!(::MaxConsumers::get(), 16); -// } + assert_eq!(HOURS, MINUTES * 60); -// #[test] -// fn proxy_constants() { -// assert_eq!(MaxProxies::get(), 32); + assert_eq!(DAYS, HOURS * 24); -// assert_eq!(MaxPending::get(), 32); + assert_eq!(MAX_BLOCK_LENGTH, 5 * 1024 * 1024); -// assert_eq!(ProxyDepositBase::get(), deposit(1, 40)); + assert_eq!(::SS58Prefix::get(), 42); -// assert_eq!(AnnouncementDepositBase::get(), deposit(1, 48)); + assert_eq!(::MaxConsumers::get(), 16); + } -// assert_eq!(ProxyDepositFactor::get(), deposit(0, 33)); + #[test] + fn proxy_constants() { + assert_eq!(::MaxProxies::get(), 32); -// assert_eq!(AnnouncementDepositFactor::get(), deposit(0, 66)); -// } + assert_eq!(::MaxPending::get(), 32); -// #[test] -// fn balances_constants() { -// assert_eq!(MaxFreezes::get(), 0); + assert_eq!(::ProxyDepositBase::get(), deposit(1, 40)); -// assert_eq!(MaxLocks::get(), 50); + assert_eq!( + ::AnnouncementDepositBase::get(), + deposit(1, 48) + ); -// assert_eq!(MaxReserves::get(), 50); -// } + assert_eq!(::ProxyDepositFactor::get(), deposit(0, 33)); -// #[test] -// fn assets_constants() { -// assert_eq!(AssetDeposit::get(), 10 * CENTS); + assert_eq!( + ::AnnouncementDepositFactor::get(), + deposit(0, 66) + ); + } -// assert_eq!(AssetAccountDeposit::get(), deposit(1, 16)); + #[test] + fn balances_constants() { + assert_eq!(::MaxFreezes::get(), 0); -// assert_eq!(ApprovalDeposit::get(), MILLICENTS); + assert_eq!(::MaxLocks::get(), 50); -// assert_eq!(StringLimit::get(), 50); + assert_eq!(::MaxReserves::get(), 50); + } -// assert_eq!(MetadataDepositBase::get(), deposit(1, 68)); + #[test] + fn assets_constants() { + assert_eq!(::AssetDeposit::get(), 10 * CENTS); -// assert_eq!(MetadataDepositPerByte::get(), deposit(0, 1)); + // TODO: uncomment once patch is merged and updated RC is released and pointed to in deps + //assert_eq!(::AssetAccountDeposit::get(), deposit(1, 16)); + assert_eq!(::AssetAccountDeposit::get(), MILLICENTS); -// assert_eq!(RemoveItemsLimit::get(), 1000); -// } + assert_eq!(::ApprovalDeposit::get(), MILLICENTS); -// #[test] -// fn transaction_payment_constants() { -// assert_eq!(TransactionByteFee::get(), 10 * MICROCENTS); + assert_eq!(::StringLimit::get(), 50); -// assert_eq!(OperationalFeeMultiplier::get(), 5); -// } + assert_eq!(::MetadataDepositBase::get(), deposit(1, 68)); -// #[test] -// fn cumulus_pallet_parachain_system_constants() { -// assert_eq!(ReservedXcmpWeight::get(), MAXIMUM_BLOCK_WEIGHT.saturating_div(4)); + assert_eq!( + ::MetadataDepositPerByte::get(), + deposit(0, 1) + ); -// assert_eq!(ReservedDmpWeight::get(), MAXIMUM_BLOCK_WEIGHT.saturating_div(4)); -// } + assert_eq!(::RemoveItemsLimit::get(), 1000); + } -// #[test] -// fn message_queue_constants() { -// assert_eq!(HeapSize::get(), 64 * 1024); -// assert_eq!(MaxStale::get(), 8); -// } + #[test] + fn transaction_payment_constants() { + assert_eq!(configs::TransactionByteFee::get(), 10 * MICROCENTS); -// #[test] -// fn cumulus_pallet_xcmp_queue_constants() { -// assert_eq!(MaxInboundSuspended::get(), 1000); -// } + assert_eq!( + ::OperationalFeeMultiplier::get(), + 5 + ); + } -// #[test] -// fn multisig_constants() { -// assert_eq!(DepositBase::get(), deposit(1, 88)); + #[test] + fn cumulus_pallet_parachain_system_constants() { + assert_eq!( + ::ReservedXcmpWeight::get(), + MAXIMUM_BLOCK_WEIGHT.saturating_div(4) + ); + + assert_eq!( + ::ReservedDmpWeight::get(), + MAXIMUM_BLOCK_WEIGHT.saturating_div(4) + ); + } -// assert_eq!(DepositFactor::get(), deposit(0, 32)); + #[test] + fn message_queue_constants() { + assert_eq!(::HeapSize::get(), 64 * 1024); + assert_eq!(::MaxStale::get(), 8); + } -// assert_eq!(MaxSignatories::get(), 100); -// } + #[test] + fn cumulus_pallet_xcmp_queue_constants() { + assert_eq!( + ::MaxInboundSuspended::get(), + 1000 + ); + } -// #[test] -// fn session_constants() { -// assert_eq!(Period::get(), 6 * HOURS); + #[test] + fn multisig_constants() { + assert_eq!(::DepositBase::get(), deposit(1, 88)); -// assert_eq!(Offset::get(), 0); -// } + assert_eq!(::DepositFactor::get(), deposit(0, 32)); -// #[test] -// #[allow(clippy::assertions_on_constants)] -// fn aura_constants() { -// #[cfg(not(feature = "async-backing"))] -// assert!(!AllowMultipleBlocksPerSlot::get()); -// #[cfg(feature = "async-backing")] -// assert!(AllowMultipleBlocksPerSlot::get()); + assert_eq!(::MaxSignatories::get(), 100); + } -// assert_eq!(MaxAuthorities::get(), 100_000); -// } + #[test] + fn session_constants() { + assert_eq!(configs::Period::get(), 6 * HOURS); -// #[test] -// fn collator_selection_constants() { -// let pallet_id_to_string = |id: PalletId| -> String { -// core::str::from_utf8(&id.0).unwrap_or_default().to_string() -// }; + assert_eq!(configs::Offset::get(), 0); + } -// assert_eq!(pallet_id_to_string(PotId::get()), pallet_id_to_string(PalletId(*b"PotStake"))); + #[test] + #[allow(clippy::assertions_on_constants)] + fn aura_constants() { + #[cfg(not(feature = "async-backing"))] + assert!(!::AllowMultipleBlocksPerSlot::get()); + #[cfg(feature = "async-backing")] + assert!(::AllowMultipleBlocksPerSlot::get()); + + assert_eq!(::MaxAuthorities::get(), 100_000); + } -// assert_eq!(SessionLength::get(), 6 * HOURS); + #[test] + fn collator_selection_constants() { + let pallet_id_to_string = |id: PalletId| -> String { + core::str::from_utf8(&id.0).unwrap_or_default().to_string() + }; -// assert_eq!(StakingAdminBodyId::get(), BodyId::Defense); + assert_eq!( + pallet_id_to_string(::PotId::get()), + pallet_id_to_string(PalletId(*b"PotStake")) + ); -// assert_eq!(MaxCandidates::get(), 100); + assert_eq!(::MaxCandidates::get(), 100); -// assert_eq!(MaxInvulnerables::get(), 20); + assert_eq!(::MaxInvulnerables::get(), 20); -// assert_eq!(MinEligibleCollators::get(), 4); -// } -// } + assert_eq!(::MinEligibleCollators::get(), 4); + } +} -// mod xcm_tests { -// use evm_runtime_template::configs::xcm_config::*; -// use frame_support::weights::Weight; +mod xcm_tests { + use evm_runtime_template::{configs, Runtime}; + use frame_support::weights::Weight; -// #[test] -// fn xcm_executor_constants() { -// assert_eq!(UnitWeightCost::get(), Weight::from_parts(1_000_000_000, 64 * 1024)); -// assert_eq!(MaxInstructions::get(), 100); -// assert_eq!(MaxAssetsIntoHolding::get(), 64); -// } + #[test] + fn xcm_executor_constants() { + assert_eq!(configs::UnitWeightCost::get(), Weight::from_parts(1_000_000_000, 64 * 1024)); + assert_eq!(configs::MaxInstructions::get(), 100); + assert_eq!(configs::MaxAssetsIntoHolding::get(), 64); + } -// #[test] -// fn pallet_xcm_constants() { -// assert_eq!(MaxLockers::get(), 8); -// assert_eq!(MaxRemoteLockConsumers::get(), 0); -// assert_eq!( -// ::VERSION_DISCOVERY_QUEUE_SIZE, -// 100 -// ); -// } -// } + #[test] + fn pallet_xcm_constants() { + assert_eq!(::MaxLockers::get(), 8); + assert_eq!(::MaxRemoteLockConsumers::get(), 0); + assert_eq!(::VERSION_DISCOVERY_QUEUE_SIZE, 100); + } +} diff --git a/generic-template/runtime/tests/constants_test.rs b/generic-template/runtime/tests/constants_test.rs index 353e2ce5..a0bc660d 100644 --- a/generic-template/runtime/tests/constants_test.rs +++ b/generic-template/runtime/tests/constants_test.rs @@ -18,208 +18,207 @@ mod constant_tests { } } -// TODO: fix the imports for these tests. -// mod runtime_tests { -// use frame_support::{pallet_prelude::Weight, traits::TypedGet, PalletId}; -// use generic_runtime_template::{ -// configs::{asset_config::*, *}, -// constants::{currency::*, *}, -// *, -// }; -// use sp_runtime::create_runtime_str; -// use sp_version::RuntimeVersion; -// use xcm::latest::prelude::BodyId; - -// #[test] -// fn check_runtime_api_version() { -// assert_eq!( -// VERSION, -// RuntimeVersion { -// spec_name: create_runtime_str!("template-parachain"), -// impl_name: create_runtime_str!("template-parachain"), -// authoring_version: 1, -// spec_version: 1, -// impl_version: 0, -// apis: generic_runtime_template::apis::RUNTIME_API_VERSIONS, -// transaction_version: 1, -// state_version: 1, -// } -// ); -// } +mod runtime_tests { + use frame_support::{pallet_prelude::Weight, traits::TypedGet, PalletId}; + use generic_runtime_template::{ + configs::{asset_config::*, *}, + constants::{currency::*, *}, + *, + }; + use sp_runtime::create_runtime_str; + use sp_version::RuntimeVersion; + use xcm::latest::prelude::BodyId; -// #[test] -// fn weight_to_fee_constants() { -// assert_eq!(P_FACTOR, 10); + #[test] + fn check_runtime_api_version() { + assert_eq!( + VERSION, + RuntimeVersion { + spec_name: create_runtime_str!("template-parachain"), + impl_name: create_runtime_str!("template-parachain"), + authoring_version: 1, + spec_version: 1, + impl_version: 0, + apis: generic_runtime_template::apis::RUNTIME_API_VERSIONS, + transaction_version: 1, + state_version: 1, + } + ); + } -// assert_eq!(Q_FACTOR, 100); + #[test] + fn weight_to_fee_constants() { + assert_eq!(P_FACTOR, 10); -// assert_eq!(POLY_DEGREE, 1); -// } + assert_eq!(Q_FACTOR, 100); -// #[test] -// fn frame_system_constants() { -// #[cfg(not(feature = "async-backing"))] -// assert_eq!( -// MAXIMUM_BLOCK_WEIGHT, -// Weight::from_parts( -// frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), -// cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64 -// ) -// ); + assert_eq!(POLY_DEGREE, 1); + } -// #[cfg(feature = "async-backing")] -// assert_eq!( -// MAXIMUM_BLOCK_WEIGHT, -// Weight::from_parts( -// frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), -// cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64 -// ) -// ); + #[test] + fn frame_system_constants() { + #[cfg(not(feature = "async-backing"))] + assert_eq!( + MAXIMUM_BLOCK_WEIGHT, + Weight::from_parts( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), + cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64 + ) + ); -// assert_eq!(AVERAGE_ON_INITIALIZE_RATIO, Perbill::from_percent(5)); + #[cfg(feature = "async-backing")] + assert_eq!( + MAXIMUM_BLOCK_WEIGHT, + Weight::from_parts( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), + cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64 + ) + ); -// assert_eq!(NORMAL_DISPATCH_RATIO, Perbill::from_percent(75)); -// #[cfg(not(feature = "async-backing"))] -// assert_eq!(UNINCLUDED_SEGMENT_CAPACITY, 1); -// #[cfg(feature = "async-backing")] -// assert_eq!(UNINCLUDED_SEGMENT_CAPACITY, 3); + assert_eq!(AVERAGE_ON_INITIALIZE_RATIO, Perbill::from_percent(5)); -// assert_eq!(BLOCK_PROCESSING_VELOCITY, 1); + assert_eq!(NORMAL_DISPATCH_RATIO, Perbill::from_percent(75)); + #[cfg(not(feature = "async-backing"))] + assert_eq!(UNINCLUDED_SEGMENT_CAPACITY, 1); + #[cfg(feature = "async-backing")] + assert_eq!(UNINCLUDED_SEGMENT_CAPACITY, 3); -// assert_eq!(RELAY_CHAIN_SLOT_DURATION_MILLIS, 6000); + assert_eq!(BLOCK_PROCESSING_VELOCITY, 1); -// #[cfg(not(feature = "async-backing"))] -// assert_eq!(MILLISECS_PER_BLOCK, 12000); -// #[cfg(feature = "async-backing")] -// assert_eq!(MILLISECS_PER_BLOCK, 6000); + assert_eq!(RELAY_CHAIN_SLOT_DURATION_MILLIS, 6000); -// assert_eq!(SLOT_DURATION, MILLISECS_PER_BLOCK); + #[cfg(not(feature = "async-backing"))] + assert_eq!(MILLISECS_PER_BLOCK, 12000); + #[cfg(feature = "async-backing")] + assert_eq!(MILLISECS_PER_BLOCK, 6000); -// assert_eq!(MINUTES, 60_000 / (MILLISECS_PER_BLOCK as BlockNumber)); + assert_eq!(SLOT_DURATION, MILLISECS_PER_BLOCK); -// assert_eq!(HOURS, MINUTES * 60); + assert_eq!(MINUTES, 60_000 / (MILLISECS_PER_BLOCK as BlockNumber)); -// assert_eq!(DAYS, HOURS * 24); + assert_eq!(HOURS, MINUTES * 60); -// assert_eq!(MAX_BLOCK_LENGTH, 5 * 1024 * 1024); + assert_eq!(DAYS, HOURS * 24); -// assert_eq!(SS58Prefix::get(), 42); + assert_eq!(MAX_BLOCK_LENGTH, 5 * 1024 * 1024); -// assert_eq!(::MaxConsumers::get(), 16); -// } + assert_eq!(SS58Prefix::get(), 42); -// #[test] -// fn proxy_constants() { -// assert_eq!(MaxProxies::get(), 32); + assert_eq!(::MaxConsumers::get(), 16); + } -// assert_eq!(MaxPending::get(), 32); + #[test] + fn proxy_constants() { + assert_eq!(MaxProxies::get(), 32); -// assert_eq!(ProxyDepositBase::get(), deposit(1, 40)); + assert_eq!(MaxPending::get(), 32); -// assert_eq!(AnnouncementDepositBase::get(), deposit(1, 48)); + assert_eq!(ProxyDepositBase::get(), deposit(1, 40)); -// assert_eq!(ProxyDepositFactor::get(), deposit(0, 33)); + assert_eq!(AnnouncementDepositBase::get(), deposit(1, 48)); -// assert_eq!(AnnouncementDepositFactor::get(), deposit(0, 66)); -// } + assert_eq!(ProxyDepositFactor::get(), deposit(0, 33)); -// #[test] -// fn balances_constants() { -// assert_eq!(MaxFreezes::get(), 0); + assert_eq!(AnnouncementDepositFactor::get(), deposit(0, 66)); + } -// assert_eq!(MaxLocks::get(), 50); + #[test] + fn balances_constants() { + assert_eq!(MaxFreezes::get(), 0); -// assert_eq!(MaxReserves::get(), 50); -// } + assert_eq!(MaxLocks::get(), 50); -// #[test] -// fn assets_constants() { -// assert_eq!(AssetDeposit::get(), 10 * CENTS); + assert_eq!(MaxReserves::get(), 50); + } -// assert_eq!(AssetAccountDeposit::get(), deposit(1, 16)); + #[test] + fn assets_constants() { + assert_eq!(AssetDeposit::get(), 10 * CENTS); -// assert_eq!(ApprovalDeposit::get(), EXISTENTIAL_DEPOSIT); + assert_eq!(AssetAccountDeposit::get(), deposit(1, 16)); -// assert_eq!(StringLimit::get(), 50); + assert_eq!(ApprovalDeposit::get(), EXISTENTIAL_DEPOSIT); -// assert_eq!(MetadataDepositBase::get(), deposit(1, 68)); + assert_eq!(StringLimit::get(), 50); -// assert_eq!(MetadataDepositPerByte::get(), deposit(0, 1)); + assert_eq!(MetadataDepositBase::get(), deposit(1, 68)); -// assert_eq!(RemoveItemsLimit::get(), 1000); -// } + assert_eq!(MetadataDepositPerByte::get(), deposit(0, 1)); -// #[test] -// fn transaction_payment_constants() { -// assert_eq!(TransactionByteFee::get(), 10 * MICROCENTS); + assert_eq!(RemoveItemsLimit::get(), 1000); + } -// assert_eq!(OperationalFeeMultiplier::get(), 5); -// } + #[test] + fn transaction_payment_constants() { + assert_eq!(TransactionByteFee::get(), 10 * MICROCENTS); -// #[test] -// fn cumulus_pallet_parachain_system_constants() { -// assert_eq!(ReservedXcmpWeight::get(), MAXIMUM_BLOCK_WEIGHT.saturating_div(4)); + assert_eq!(OperationalFeeMultiplier::get(), 5); + } -// assert_eq!(ReservedDmpWeight::get(), MAXIMUM_BLOCK_WEIGHT.saturating_div(4)); -// } + #[test] + fn cumulus_pallet_parachain_system_constants() { + assert_eq!(ReservedXcmpWeight::get(), MAXIMUM_BLOCK_WEIGHT.saturating_div(4)); -// #[test] -// fn message_queue_constants() { -// assert_eq!(HeapSize::get(), 64 * 1024); -// assert_eq!(MaxStale::get(), 8); -// } + assert_eq!(ReservedDmpWeight::get(), MAXIMUM_BLOCK_WEIGHT.saturating_div(4)); + } -// #[test] -// fn cumulus_pallet_xcmp_queue_constants() { -// assert_eq!(MaxInboundSuspended::get(), 1000); -// } + #[test] + fn message_queue_constants() { + assert_eq!(HeapSize::get(), 64 * 1024); + assert_eq!(MaxStale::get(), 8); + } -// #[test] -// fn multisig_constants() { -// assert_eq!(DepositBase::get(), deposit(1, 88)); + #[test] + fn cumulus_pallet_xcmp_queue_constants() { + assert_eq!(MaxInboundSuspended::get(), 1000); + } -// assert_eq!(DepositFactor::get(), deposit(0, 32)); + #[test] + fn multisig_constants() { + assert_eq!(DepositBase::get(), deposit(1, 88)); -// assert_eq!(MaxSignatories::get(), 100); -// } + assert_eq!(DepositFactor::get(), deposit(0, 32)); -// #[test] -// fn session_constants() { -// assert_eq!(Period::get(), 6 * HOURS); + assert_eq!(MaxSignatories::get(), 100); + } -// assert_eq!(Offset::get(), 0); -// } + #[test] + fn session_constants() { + assert_eq!(Period::get(), 6 * HOURS); -// #[test] -// #[allow(clippy::assertions_on_constants)] -// fn aura_constants() { -// #[cfg(not(feature = "async-backing"))] -// assert!(!AllowMultipleBlocksPerSlot::get()); -// #[cfg(feature = "async-backing")] -// assert!(AllowMultipleBlocksPerSlot::get()); + assert_eq!(Offset::get(), 0); + } -// assert_eq!(::MaxAuthorities::get(), 100_000); -// } + #[test] + #[allow(clippy::assertions_on_constants)] + fn aura_constants() { + #[cfg(not(feature = "async-backing"))] + assert!(!AllowMultipleBlocksPerSlot::get()); + #[cfg(feature = "async-backing")] + assert!(AllowMultipleBlocksPerSlot::get()); + + assert_eq!(::MaxAuthorities::get(), 100_000); + } -// #[test] -// fn collator_selection_constants() { -// let pallet_id_to_string = |id: PalletId| -> String { -// core::str::from_utf8(&id.0).unwrap_or_default().to_string() -// }; + #[test] + fn collator_selection_constants() { + let pallet_id_to_string = |id: PalletId| -> String { + core::str::from_utf8(&id.0).unwrap_or_default().to_string() + }; -// assert_eq!(pallet_id_to_string(PotId::get()), pallet_id_to_string(PalletId(*b"PotStake"))); + assert_eq!(pallet_id_to_string(PotId::get()), pallet_id_to_string(PalletId(*b"PotStake"))); -// assert_eq!(SessionLength::get(), 6 * HOURS); + assert_eq!(SessionLength::get(), 6 * HOURS); -// assert_eq!(StakingAdminBodyId::get(), BodyId::Defense); + assert_eq!(StakingAdminBodyId::get(), BodyId::Defense); -// assert_eq!(::MaxCandidates::get(), 100); + assert_eq!(::MaxCandidates::get(), 100); -// assert_eq!(::MaxInvulnerables::get(), 20); + assert_eq!(::MaxInvulnerables::get(), 20); -// assert_eq!(::MinEligibleCollators::get(), 4); -// } -// } + assert_eq!(::MinEligibleCollators::get(), 4); + } +} mod xcm_tests { use frame_support::weights::Weight; From 5ae913d2ac7c627e9b4e30651e4bc31f6a26c27d Mon Sep 17 00:00:00 2001 From: 4meta5 Date: Mon, 4 Nov 2024 21:07:14 -0500 Subject: [PATCH 2/3] update generic runtime constant tests --- evm-template/runtime/tests/constants_test.rs | 5 + .../runtime/tests/constants_test.rs | 120 +++++++++++------- 2 files changed, 78 insertions(+), 47 deletions(-) diff --git a/evm-template/runtime/tests/constants_test.rs b/evm-template/runtime/tests/constants_test.rs index 5d6e0007..dd2b668e 100644 --- a/evm-template/runtime/tests/constants_test.rs +++ b/evm-template/runtime/tests/constants_test.rs @@ -27,6 +27,7 @@ mod runtime_tests { use frame_support::{pallet_prelude::Weight, traits::TypedGet, PalletId}; use sp_runtime::{create_runtime_str, Perbill}; use sp_version::RuntimeVersion; + use xcm::latest::prelude::BodyId; // RUNTIME_API_VERSIONS constant is generated by a macro and is private. #[test] @@ -234,6 +235,10 @@ mod runtime_tests { pallet_id_to_string(PalletId(*b"PotStake")) ); + assert_eq!(configs::Period::get(), 6 * HOURS); + + assert_eq!(configs::StakingAdminBodyId::get(), BodyId::Defense); + assert_eq!(::MaxCandidates::get(), 100); assert_eq!(::MaxInvulnerables::get(), 20); diff --git a/generic-template/runtime/tests/constants_test.rs b/generic-template/runtime/tests/constants_test.rs index a0bc660d..fafae813 100644 --- a/generic-template/runtime/tests/constants_test.rs +++ b/generic-template/runtime/tests/constants_test.rs @@ -21,11 +21,11 @@ mod constant_tests { mod runtime_tests { use frame_support::{pallet_prelude::Weight, traits::TypedGet, PalletId}; use generic_runtime_template::{ - configs::{asset_config::*, *}, + configs, constants::{currency::*, *}, - *, + BlockNumber, Runtime, }; - use sp_runtime::create_runtime_str; + use sp_runtime::{create_runtime_str, Perbill}; use sp_version::RuntimeVersion; use xcm::latest::prelude::BodyId; @@ -102,100 +102,126 @@ mod runtime_tests { assert_eq!(MAX_BLOCK_LENGTH, 5 * 1024 * 1024); - assert_eq!(SS58Prefix::get(), 42); + assert_eq!(::SS58Prefix::get(), 42); assert_eq!(::MaxConsumers::get(), 16); } #[test] fn proxy_constants() { - assert_eq!(MaxProxies::get(), 32); + assert_eq!(::MaxProxies::get(), 32); - assert_eq!(MaxPending::get(), 32); + assert_eq!(::MaxPending::get(), 32); - assert_eq!(ProxyDepositBase::get(), deposit(1, 40)); + assert_eq!(::ProxyDepositBase::get(), deposit(1, 40)); - assert_eq!(AnnouncementDepositBase::get(), deposit(1, 48)); + assert_eq!( + ::AnnouncementDepositBase::get(), + deposit(1, 48) + ); - assert_eq!(ProxyDepositFactor::get(), deposit(0, 33)); + assert_eq!(::ProxyDepositFactor::get(), deposit(0, 33)); - assert_eq!(AnnouncementDepositFactor::get(), deposit(0, 66)); + assert_eq!( + ::AnnouncementDepositFactor::get(), + deposit(0, 66) + ); } #[test] fn balances_constants() { - assert_eq!(MaxFreezes::get(), 0); + assert_eq!(::MaxFreezes::get(), 0); - assert_eq!(MaxLocks::get(), 50); + assert_eq!(::MaxLocks::get(), 50); - assert_eq!(MaxReserves::get(), 50); + assert_eq!(::MaxReserves::get(), 50); } #[test] fn assets_constants() { - assert_eq!(AssetDeposit::get(), 10 * CENTS); + assert_eq!(::AssetDeposit::get(), 10 * CENTS); - assert_eq!(AssetAccountDeposit::get(), deposit(1, 16)); + // TODO: uncomment once patch is merged and updated RC is released and pointed to in deps + //assert_eq!(::AssetAccountDeposit::get(), deposit(1, 16)); + assert_eq!( + ::AssetAccountDeposit::get(), + EXISTENTIAL_DEPOSIT + ); - assert_eq!(ApprovalDeposit::get(), EXISTENTIAL_DEPOSIT); + assert_eq!(::ApprovalDeposit::get(), EXISTENTIAL_DEPOSIT); - assert_eq!(StringLimit::get(), 50); + assert_eq!(::StringLimit::get(), 50); - assert_eq!(MetadataDepositBase::get(), deposit(1, 68)); + assert_eq!(::MetadataDepositBase::get(), deposit(1, 68)); - assert_eq!(MetadataDepositPerByte::get(), deposit(0, 1)); + assert_eq!( + ::MetadataDepositPerByte::get(), + deposit(0, 1) + ); - assert_eq!(RemoveItemsLimit::get(), 1000); + assert_eq!(::RemoveItemsLimit::get(), 1000); } #[test] fn transaction_payment_constants() { - assert_eq!(TransactionByteFee::get(), 10 * MICROCENTS); + assert_eq!(configs::TransactionByteFee::get(), 10 * MICROCENTS); - assert_eq!(OperationalFeeMultiplier::get(), 5); + assert_eq!( + ::OperationalFeeMultiplier::get(), + 5 + ); } #[test] fn cumulus_pallet_parachain_system_constants() { - assert_eq!(ReservedXcmpWeight::get(), MAXIMUM_BLOCK_WEIGHT.saturating_div(4)); + assert_eq!( + ::ReservedXcmpWeight::get(), + MAXIMUM_BLOCK_WEIGHT.saturating_div(4) + ); - assert_eq!(ReservedDmpWeight::get(), MAXIMUM_BLOCK_WEIGHT.saturating_div(4)); + assert_eq!( + ::ReservedDmpWeight::get(), + MAXIMUM_BLOCK_WEIGHT.saturating_div(4) + ); } #[test] fn message_queue_constants() { - assert_eq!(HeapSize::get(), 64 * 1024); - assert_eq!(MaxStale::get(), 8); + assert_eq!(::HeapSize::get(), 64 * 1024); + assert_eq!(::MaxStale::get(), 8); } #[test] fn cumulus_pallet_xcmp_queue_constants() { - assert_eq!(MaxInboundSuspended::get(), 1000); + assert_eq!( + ::MaxInboundSuspended::get(), + 1000 + ); } #[test] fn multisig_constants() { - assert_eq!(DepositBase::get(), deposit(1, 88)); + assert_eq!(::DepositBase::get(), deposit(1, 88)); - assert_eq!(DepositFactor::get(), deposit(0, 32)); + assert_eq!(::DepositFactor::get(), deposit(0, 32)); - assert_eq!(MaxSignatories::get(), 100); + assert_eq!(::MaxSignatories::get(), 100); } #[test] fn session_constants() { - assert_eq!(Period::get(), 6 * HOURS); + assert_eq!(configs::Period::get(), 6 * HOURS); - assert_eq!(Offset::get(), 0); + assert_eq!(configs::Offset::get(), 0); } #[test] #[allow(clippy::assertions_on_constants)] fn aura_constants() { #[cfg(not(feature = "async-backing"))] - assert!(!AllowMultipleBlocksPerSlot::get()); + assert!(!::AllowMultipleBlocksPerSlot::get()); #[cfg(feature = "async-backing")] - assert!(AllowMultipleBlocksPerSlot::get()); + assert!(::AllowMultipleBlocksPerSlot::get()); assert_eq!(::MaxAuthorities::get(), 100_000); } @@ -206,11 +232,14 @@ mod runtime_tests { core::str::from_utf8(&id.0).unwrap_or_default().to_string() }; - assert_eq!(pallet_id_to_string(PotId::get()), pallet_id_to_string(PalletId(*b"PotStake"))); + assert_eq!( + pallet_id_to_string(::PotId::get()), + pallet_id_to_string(PalletId(*b"PotStake")) + ); - assert_eq!(SessionLength::get(), 6 * HOURS); + assert_eq!(configs::Period::get(), 6 * HOURS); - assert_eq!(StakingAdminBodyId::get(), BodyId::Defense); + assert_eq!(configs::StakingAdminBodyId::get(), BodyId::Defense); assert_eq!(::MaxCandidates::get(), 100); @@ -222,22 +251,19 @@ mod runtime_tests { mod xcm_tests { use frame_support::weights::Weight; - use generic_runtime_template::configs::*; + use generic_runtime_template::{configs, Runtime}; #[test] fn xcm_executor_constants() { - assert_eq!(UnitWeightCost::get(), Weight::from_parts(1_000_000_000, 64 * 1024)); - assert_eq!(MaxInstructions::get(), 100); - assert_eq!(MaxAssetsIntoHolding::get(), 64); + assert_eq!(configs::UnitWeightCost::get(), Weight::from_parts(1_000_000_000, 64 * 1024)); + assert_eq!(configs::MaxInstructions::get(), 100); + assert_eq!(configs::MaxAssetsIntoHolding::get(), 64); } #[test] fn pallet_xcm_constants() { - assert_eq!(MaxLockers::get(), 8); - assert_eq!(MaxRemoteLockConsumers::get(), 0); - assert_eq!( - ::VERSION_DISCOVERY_QUEUE_SIZE, - 100 - ); + assert_eq!(::MaxLockers::get(), 8); + assert_eq!(::MaxRemoteLockConsumers::get(), 0); + assert_eq!(::VERSION_DISCOVERY_QUEUE_SIZE, 100); } } From 7864a01aa429930f8c4b8ac19ce990abedc5445a Mon Sep 17 00:00:00 2001 From: Gustavo Gonzalez Date: Tue, 5 Nov 2024 14:56:00 +0700 Subject: [PATCH 3/3] avoid workflows cancelling each other --- .github/workflows/evm.yml | 2 +- .github/workflows/generic.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/evm.yml b/.github/workflows/evm.yml index 673665b2..fb1b07aa 100644 --- a/.github/workflows/evm.yml +++ b/.github/workflows/evm.yml @@ -24,7 +24,7 @@ on: # If new code is pushed to a PR branch, then cancel in progress workflows for # that PR. Ensures that we don't waste CI time, and returns results quicker. concurrency: - group: ci-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: diff --git a/.github/workflows/generic.yml b/.github/workflows/generic.yml index f83f1a12..d752974d 100644 --- a/.github/workflows/generic.yml +++ b/.github/workflows/generic.yml @@ -24,7 +24,7 @@ on: # If new code is pushed to a PR branch, then cancel in progress workflows for # that PR. Ensures that we don't waste CI time, and returns results quicker. concurrency: - group: ci-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: