6b597bebcf
- Fix pezpallet-welati EnsureOrigin implementations (3 fixes)
- Remove incorrect #[cfg(not(feature = "runtime-benchmarks"))] blocks
- Affects EnsureSerok, EnsureParlementer, EnsureDiwan
- Fix asset-hub-zagros governance origins macros (2 fixes)
- Remove non-benchmark try_successful_origin from decl_unit_ensures!
- Remove non-benchmark try_successful_origin from decl_ensure!
- Rename snowbridge -> pezsnowbridge for consistency
- Update WORKFLOW_PLAN.md with build status and package names
- Correct package names: pezkuwi-teyrchain-bin, pezstaging-node-cli
- Mark completed builds: pezkuwi, pezkuwi-teyrchain-bin,
pezstaging-node-cli, teyrchain-template-node
175 lines
4.6 KiB
Rust
175 lines
4.6 KiB
Rust
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
|
|
use super::*;
|
|
|
|
use pezframe_support::{
|
|
derive_impl, parameter_types,
|
|
traits::{Everything, Hooks},
|
|
weights::IdentityFee,
|
|
};
|
|
|
|
use pezsnowbridge_core::{
|
|
gwei, meth,
|
|
pricing::{PricingParameters, Rewards},
|
|
ParaId, PRIMARY_GOVERNANCE_CHANNEL,
|
|
};
|
|
use pezsnowbridge_outbound_queue_primitives::v1::*;
|
|
use pezsp_core::{ConstU32, ConstU8, H160, H256};
|
|
use pezsp_runtime::{
|
|
traits::{BlakeTwo256, IdentityLookup, Keccak256},
|
|
AccountId32, BuildStorage, FixedU128,
|
|
};
|
|
use pezsp_std::marker::PhantomData;
|
|
|
|
type Block = pezframe_system::mocking::MockBlock<Test>;
|
|
type AccountId = AccountId32;
|
|
|
|
pezframe_support::construct_runtime!(
|
|
pub enum Test
|
|
{
|
|
System: pezframe_system::{Pezpallet, Call, Storage, Event<T>},
|
|
MessageQueue: pezpallet_message_queue::{Pezpallet, Call, Storage, Event<T>},
|
|
OutboundQueue: crate::{Pezpallet, Storage, Event<T>},
|
|
}
|
|
);
|
|
|
|
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
|
impl pezframe_system::Config for Test {
|
|
type BaseCallFilter = Everything;
|
|
type RuntimeOrigin = RuntimeOrigin;
|
|
type RuntimeCall = RuntimeCall;
|
|
type RuntimeTask = RuntimeTask;
|
|
type Hash = H256;
|
|
type Hashing = BlakeTwo256;
|
|
type AccountId = AccountId;
|
|
type Lookup = IdentityLookup<Self::AccountId>;
|
|
type RuntimeEvent = RuntimeEvent;
|
|
type PalletInfo = PalletInfo;
|
|
type Nonce = u64;
|
|
type Block = Block;
|
|
}
|
|
|
|
parameter_types! {
|
|
pub const HeapSize: u32 = 32 * 1024;
|
|
pub const MaxStale: u32 = 32;
|
|
pub static ServiceWeight: Option<Weight> = Some(Weight::from_parts(100, 100));
|
|
}
|
|
|
|
impl pezpallet_message_queue::Config for Test {
|
|
type RuntimeEvent = RuntimeEvent;
|
|
type WeightInfo = ();
|
|
type MessageProcessor = OutboundQueue;
|
|
type Size = u32;
|
|
type QueueChangeHandler = ();
|
|
type HeapSize = HeapSize;
|
|
type MaxStale = MaxStale;
|
|
type ServiceWeight = ServiceWeight;
|
|
type IdleMaxServiceWeight = ();
|
|
type QueuePausedQuery = ();
|
|
}
|
|
|
|
parameter_types! {
|
|
pub const OwnParaId: ParaId = ParaId::new(1013);
|
|
pub Parameters: PricingParameters<u128> = PricingParameters {
|
|
exchange_rate: FixedU128::from_rational(1, 400),
|
|
fee_per_gas: gwei(20),
|
|
rewards: Rewards { local: HEZ, remote: meth(1) },
|
|
multiplier: FixedU128::from_rational(4, 3),
|
|
};
|
|
}
|
|
|
|
pub const HEZ: u128 = 10_000_000_000;
|
|
|
|
impl crate::Config for Test {
|
|
type RuntimeEvent = RuntimeEvent;
|
|
type Hashing = Keccak256;
|
|
type MessageQueue = MessageQueue;
|
|
type Decimals = ConstU8<12>;
|
|
type MaxMessagePayloadSize = ConstU32<1024>;
|
|
type MaxMessagesPerBlock = ConstU32<20>;
|
|
type GasMeter = ConstantGasMeter;
|
|
type Balance = u128;
|
|
type PricingParameters = Parameters;
|
|
type Channels = Everything;
|
|
type WeightToFee = IdentityFee<u128>;
|
|
type WeightInfo = ();
|
|
}
|
|
|
|
fn setup() {
|
|
System::set_block_number(1);
|
|
}
|
|
|
|
pub fn new_tester() -> pezsp_io::TestExternalities {
|
|
let storage = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
|
let mut ext: pezsp_io::TestExternalities = storage.into();
|
|
ext.execute_with(setup);
|
|
ext
|
|
}
|
|
|
|
pub fn run_to_end_of_next_block() {
|
|
// finish current block
|
|
MessageQueue::on_finalize(System::block_number());
|
|
OutboundQueue::on_finalize(System::block_number());
|
|
System::on_finalize(System::block_number());
|
|
// start next block
|
|
System::set_block_number(System::block_number() + 1);
|
|
System::on_initialize(System::block_number());
|
|
OutboundQueue::on_initialize(System::block_number());
|
|
MessageQueue::on_initialize(System::block_number());
|
|
// finish next block
|
|
MessageQueue::on_finalize(System::block_number());
|
|
OutboundQueue::on_finalize(System::block_number());
|
|
System::on_finalize(System::block_number());
|
|
}
|
|
|
|
pub fn mock_governance_message<T>() -> Message
|
|
where
|
|
T: Config,
|
|
{
|
|
let _marker = PhantomData::<T>; // for clippy
|
|
|
|
Message {
|
|
id: None,
|
|
channel_id: PRIMARY_GOVERNANCE_CHANNEL,
|
|
command: Command::Upgrade {
|
|
impl_address: H160::zero(),
|
|
impl_code_hash: H256::zero(),
|
|
initializer: None,
|
|
},
|
|
}
|
|
}
|
|
|
|
// Message should fail validation as it is too large
|
|
pub fn mock_invalid_governance_message<T>() -> Message
|
|
where
|
|
T: Config,
|
|
{
|
|
let _marker = PhantomData::<T>; // for clippy
|
|
|
|
Message {
|
|
id: None,
|
|
channel_id: PRIMARY_GOVERNANCE_CHANNEL,
|
|
command: Command::Upgrade {
|
|
impl_address: H160::zero(),
|
|
impl_code_hash: H256::zero(),
|
|
initializer: Some(Initializer {
|
|
params: (0..1000).map(|_| 1u8).collect::<Vec<u8>>(),
|
|
maximum_required_gas: 0,
|
|
}),
|
|
},
|
|
}
|
|
}
|
|
|
|
pub fn mock_message(sibling_para_id: u32) -> Message {
|
|
Message {
|
|
id: None,
|
|
channel_id: ParaId::from(sibling_para_id).into(),
|
|
command: Command::UnlockNativeToken {
|
|
agent_id: Default::default(),
|
|
token: Default::default(),
|
|
recipient: Default::default(),
|
|
amount: 0,
|
|
},
|
|
}
|
|
}
|