Files
pezkuwi-runtime-templates/evm-template/runtime/tests/constants_test.rs
T

273 lines
8.8 KiB
Rust

mod constant_tests {
use evm_runtime_template::constants::currency::*;
#[test]
fn test_constants() {
assert_eq!(MICTYRENTS, 1_000_000);
assert_eq!(MILLICENTS, 1_000_000_000);
assert_eq!(CENTS, 1_000 * MILLICENTS);
assert_eq!(DOLLARS, 100 * CENTS);
#[cfg(not(feature = "runtime-benchmarks"))]
assert_eq!(EXISTENTIAL_DEPOSIT, 0);
#[cfg(feature = "runtime-benchmarks")]
assert_eq!(EXISTENTIAL_DEPOSIT, 1);
// Ensure deposit function behavior remains constant
assert_eq!(deposit(2, 3), 2 * 15 * CENTS + 3 * 6 * CENTS);
}
}
mod runtime_tests {
use evm_runtime_template::{
configs,
constants::{currency::*, *},
BlockNumber, Runtime,
};
use pezframe_support::{pezpallet_prelude::Weight, traits::TypedGet, PezpalletId};
use pezsp_runtime::{Cow, Perbill};
use pezsp_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: Cow::Borrowed("template-teyrchain"),
impl_name: Cow::Borrowed("template-teyrchain"),
authoring_version: 1,
spec_version: 1,
impl_version: 0,
apis: evm_runtime_template::RUNTIME_API_VERSIONS,
transaction_version: 1,
system_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 pezframe_system_constants() {
#[cfg(not(feature = "async-backing"))]
assert_eq!(
MAXIMUM_BLOCK_WEIGHT,
Weight::from_parts(
pezframe_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
pezcumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64
)
);
#[cfg(feature = "async-backing")]
assert_eq!(
MAXIMUM_BLOCK_WEIGHT,
Weight::from_parts(
pezframe_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
pezcumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64
)
);
assert_eq!(AVERAGE_ON_INITIALIZE_RATIO, Perbill::from_percent(5));
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!(BLOCK_PTYRESSING_VELOCITY, 1);
assert_eq!(RELAY_CHAIN_SLOT_DURATION_MILLIS, 6000);
#[cfg(not(feature = "async-backing"))]
assert_eq!(MILLISECS_PER_BLOCK, 12000);
#[cfg(feature = "async-backing")]
assert_eq!(MILLISECS_PER_BLOCK, 6000);
assert_eq!(SLOT_DURATION, MILLISECS_PER_BLOCK);
assert_eq!(MINUTES, 60_000 / (MILLISECS_PER_BLOCK as BlockNumber));
assert_eq!(HOURS, MINUTES * 60);
assert_eq!(DAYS, HOURS * 24);
assert_eq!(MAX_BLOCK_LENGTH, 5 * 1024 * 1024);
assert_eq!(<Runtime as frame_system::Config>::SS58Prefix::get(), 42);
assert_eq!(<Runtime as frame_system::Config>::MaxConsumers::get(), 16);
}
#[test]
fn proxy_constants() {
assert_eq!(<Runtime as pezpallet_proxy::Config>::MaxProxies::get(), 32);
assert_eq!(<Runtime as pezpallet_proxy::Config>::MaxPending::get(), 32);
assert_eq!(<Runtime as pezpallet_proxy::Config>::ProxyDepositBase::get(), deposit(1, 40));
assert_eq!(
<Runtime as pezpallet_proxy::Config>::AnnouncementDepositBase::get(),
deposit(1, 48)
);
assert_eq!(<Runtime as pezpallet_proxy::Config>::ProxyDepositFactor::get(), deposit(0, 33));
assert_eq!(
<Runtime as pezpallet_proxy::Config>::AnnouncementDepositFactor::get(),
deposit(0, 66)
);
}
#[test]
fn balances_constants() {
assert_eq!(<Runtime as pezpallet_balances::Config>::MaxFreezes::get(), 0);
assert_eq!(<Runtime as pezpallet_balances::Config>::MaxLocks::get(), 50);
assert_eq!(<Runtime as pezpallet_balances::Config>::MaxReserves::get(), 50);
}
#[test]
fn assets_constants() {
assert_eq!(<Runtime as pezpallet_assets::Config>::AssetDeposit::get(), 10 * CENTS);
assert_eq!(<Runtime as pezpallet_assets::Config>::AssetAccountDeposit::get(), deposit(1, 16));
assert_eq!(<Runtime as pezpallet_assets::Config>::ApprovalDeposit::get(), MILLICENTS);
assert_eq!(<Runtime as pezpallet_assets::Config>::StringLimit::get(), 50);
assert_eq!(<Runtime as pezpallet_assets::Config>::MetadataDepositBase::get(), deposit(1, 68));
assert_eq!(
<Runtime as pezpallet_assets::Config>::MetadataDepositPerByte::get(),
deposit(0, 1)
);
assert_eq!(<Runtime as pezpallet_assets::Config>::RemoveItemsLimit::get(), 1000);
}
#[test]
fn transaction_payment_constants() {
assert_eq!(configs::TransactionByteFee::get(), 10 * MICTYRENTS);
assert_eq!(
<Runtime as pezpallet_transaction_payment::Config>::OperationalFeeMultiplier::get(),
5
);
}
#[test]
fn pezcumulus_pezpallet_teyrchain_system_constants() {
assert_eq!(
<Runtime as pezcumulus_pezpallet_teyrchain_system::Config>::ReservedXcmpWeight::get(),
MAXIMUM_BLOCK_WEIGHT.saturating_div(4)
);
assert_eq!(
<Runtime as pezcumulus_pezpallet_teyrchain_system::Config>::ReservedDmpWeight::get(),
MAXIMUM_BLOCK_WEIGHT.saturating_div(4)
);
}
#[test]
fn message_queue_constants() {
assert_eq!(<Runtime as pezpallet_message_queue::Config>::HeapSize::get(), 64 * 1024);
assert_eq!(<Runtime as pezpallet_message_queue::Config>::MaxStale::get(), 8);
}
#[test]
fn pezcumulus_pezpallet_xcmp_queue_constants() {
assert_eq!(
<Runtime as pezcumulus_pezpallet_xcmp_queue::Config>::MaxInboundSuspended::get(),
1000
);
}
#[test]
fn multisig_constants() {
assert_eq!(<Runtime as pezpallet_multisig::Config>::DepositBase::get(), deposit(1, 88));
assert_eq!(<Runtime as pezpallet_multisig::Config>::DepositFactor::get(), deposit(0, 32));
assert_eq!(<Runtime as pezpallet_multisig::Config>::MaxSignatories::get(), 100);
}
#[test]
#[cfg(not(feature = "tanssi"))]
fn session_constants() {
assert_eq!(configs::Period::get(), 6 * HOURS);
assert_eq!(configs::Offset::get(), 0);
}
#[test]
#[allow(clippy::assertions_on_constants)]
#[cfg(not(feature = "tanssi"))]
fn aura_constants() {
#[cfg(not(feature = "async-backing"))]
assert!(!<Runtime as pezpallet_aura::Config>::AllowMultipleBlocksPerSlot::get());
#[cfg(feature = "async-backing")]
assert!(<Runtime as pezpallet_aura::Config>::AllowMultipleBlocksPerSlot::get());
assert_eq!(<Runtime as pezpallet_aura::Config>::MaxAuthorities::get(), 100_000);
}
#[test]
#[cfg(not(feature = "tanssi"))]
fn collator_selection_constants() {
let pezpallet_id_to_string = |id: PezpalletId| -> String {
core::str::from_utf8(&id.0).unwrap_or_default().to_string()
};
assert_eq!(
pezpallet_id_to_string(<Runtime as pezpallet_collator_selection::Config>::PotId::get()),
pezpallet_id_to_string(PezpalletId(*b"PotStake"))
);
assert_eq!(configs::SessionLength::get(), 6 * HOURS);
assert_eq!(configs::StakingAdminBodyId::get(), BodyId::Defense);
assert_eq!(<Runtime as pezpallet_collator_selection::Config>::MaxCandidates::get(), 100);
assert_eq!(<Runtime as pezpallet_collator_selection::Config>::MaxInvulnerables::get(), 20);
assert_eq!(<Runtime as pezpallet_collator_selection::Config>::MinEligibleCollators::get(), 4);
}
}
mod xcm_tests {
use evm_runtime_template::{configs, Runtime};
use pezframe_support::weights::Weight;
#[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 pezpallet_xcm_constants() {
assert_eq!(<Runtime as pezpallet_xcm::Config>::MaxLockers::get(), 8);
assert_eq!(<Runtime as pezpallet_xcm::Config>::MaxRemoteLockConsumers::get(), 0);
assert_eq!(<Runtime as pezpallet_xcm::Config>::VERSION_DISCOVERY_QUEUE_SIZE, 100);
}
}