mirror of
https://github.com/pezkuwichain/pezkuwi-runtime-templates.git
synced 2026-06-11 17:41:02 +00:00
Merge pull request #24 from OpenZeppelin/amar-integration-sanity-tests
Start integrity tests
This commit is contained in:
Generated
+1
@@ -7401,6 +7401,7 @@ dependencies = [
|
||||
"sp-core",
|
||||
"sp-genesis-builder",
|
||||
"sp-inherents",
|
||||
"sp-io",
|
||||
"sp-offchain",
|
||||
"sp-runtime",
|
||||
"sp-session",
|
||||
|
||||
@@ -82,6 +82,9 @@ cumulus-primitives-utility = { git = "https://github.com/paritytech/polkadot-sdk
|
||||
pallet-collator-selection = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||
parachain-info = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// ExtBuilder impl for all runtime integration tests
|
||||
use frame_support::weights::Weight;
|
||||
use parachain_template_runtime::{BuildStorage, Runtime, System};
|
||||
|
||||
pub fn run_with_system_weight<F: FnMut()>(w: Weight, mut assertions: F) {
|
||||
let mut t: sp_io::TestExternalities =
|
||||
frame_system::GenesisConfig::<Runtime>::default().build_storage().unwrap().into();
|
||||
t.execute_with(|| {
|
||||
System::set_block_consumed_resources(w, 0);
|
||||
assertions()
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Integration transaction weight-fee tests
|
||||
mod common;
|
||||
use common::*;
|
||||
use frame_support::pallet_prelude::*;
|
||||
use pallet_transaction_payment::Multiplier;
|
||||
use parachain_template_runtime::{Runtime, RuntimeBlockWeights};
|
||||
use polkadot_runtime_common::MinimumMultiplier;
|
||||
use sp_runtime::{traits::Convert, Perquintill};
|
||||
|
||||
fn min_multiplier() -> Multiplier {
|
||||
MinimumMultiplier::get()
|
||||
}
|
||||
|
||||
fn target() -> Weight {
|
||||
Perquintill::from_percent(25)
|
||||
* RuntimeBlockWeights::get().get(DispatchClass::Normal).max_total.unwrap()
|
||||
}
|
||||
|
||||
fn runtime_multiplier_update(fm: Multiplier) -> Multiplier {
|
||||
<Runtime as pallet_transaction_payment::Config>::FeeMultiplierUpdate::convert(fm)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiplier_can_grow_from_zero() {
|
||||
// if the min is too small, then this will not change, and we are doomed forever.
|
||||
// the block ref time is 1/100th bigger than target.
|
||||
run_with_system_weight(target().set_ref_time(target().ref_time() * 101 / 100), || {
|
||||
let next = runtime_multiplier_update(min_multiplier());
|
||||
assert!(next > min_multiplier(), "{:?} !> {:?}", next, min_multiplier());
|
||||
});
|
||||
|
||||
// the block proof size is 1/100th bigger than target.
|
||||
run_with_system_weight(target().set_proof_size((target().proof_size() / 100) * 101), || {
|
||||
let next = runtime_multiplier_update(min_multiplier());
|
||||
assert!(next > min_multiplier(), "{:?} !> {:?}", next, min_multiplier());
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiplier_cannot_go_below_limit() {
|
||||
// will not go any further below even if block is empty.
|
||||
run_with_system_weight(Weight::zero(), || {
|
||||
let next = runtime_multiplier_update(min_multiplier());
|
||||
assert_eq!(next, min_multiplier());
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Storage indices integration checks
|
||||
use frame_support::traits::PalletInfo;
|
||||
use parachain_template_runtime::{
|
||||
Aura, AuraExt, Authorship, Balances, CollatorSelection, CumulusXcm, DmpQueue, Multisig,
|
||||
ParachainInfo, ParachainSystem, PolkadotXcm, Proxy, Runtime, Session, Sudo, System,
|
||||
TemplatePallet, Timestamp, TransactionPayment, XcmpQueue,
|
||||
};
|
||||
|
||||
fn assert_pallet_prefix<P: 'static>(name: &str) {
|
||||
assert_eq!(<Runtime as frame_system::Config>::PalletInfo::name::<P>(), Some(name));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verify_pallet_prefixes() {
|
||||
assert_pallet_prefix::<System>("System");
|
||||
assert_pallet_prefix::<ParachainSystem>("ParachainSystem");
|
||||
assert_pallet_prefix::<Timestamp>("Timestamp");
|
||||
assert_pallet_prefix::<ParachainInfo>("ParachainInfo");
|
||||
assert_pallet_prefix::<Proxy>("Proxy");
|
||||
assert_pallet_prefix::<Balances>("Balances");
|
||||
assert_pallet_prefix::<TransactionPayment>("TransactionPayment");
|
||||
assert_pallet_prefix::<Sudo>("Sudo");
|
||||
assert_pallet_prefix::<Multisig>("Multisig");
|
||||
assert_pallet_prefix::<Authorship>("Authorship");
|
||||
assert_pallet_prefix::<CollatorSelection>("CollatorSelection");
|
||||
assert_pallet_prefix::<Session>("Session");
|
||||
assert_pallet_prefix::<Aura>("Aura");
|
||||
assert_pallet_prefix::<AuraExt>("AuraExt");
|
||||
assert_pallet_prefix::<XcmpQueue>("XcmpQueue");
|
||||
assert_pallet_prefix::<PolkadotXcm>("PolkadotXcm");
|
||||
assert_pallet_prefix::<CumulusXcm>("CumulusXcm");
|
||||
assert_pallet_prefix::<DmpQueue>("DmpQueue");
|
||||
assert_pallet_prefix::<TemplatePallet>("TemplatePallet");
|
||||
}
|
||||
Reference in New Issue
Block a user