mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 07:31:02 +00:00
Final nits for bridge-hub-test-utils (#2788)
closes https://github.com/paritytech/parity-bridges-common/issues/2739
This commit is contained in:
committed by
GitHub
parent
0686cf1748
commit
b62df69592
+1
-3
@@ -18,7 +18,7 @@
|
|||||||
//! with remote GRANDPA chain.
|
//! with remote GRANDPA chain.
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
test_cases::{helpers, run_test},
|
test_cases::{bridges_prelude::*, helpers, run_test},
|
||||||
test_data,
|
test_data,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -38,8 +38,6 @@ use bridge_runtime_common::{
|
|||||||
};
|
};
|
||||||
use frame_support::traits::{Get, OnFinalize, OnInitialize};
|
use frame_support::traits::{Get, OnFinalize, OnInitialize};
|
||||||
use frame_system::pallet_prelude::BlockNumberFor;
|
use frame_system::pallet_prelude::BlockNumberFor;
|
||||||
use pallet_bridge_grandpa::{Call as BridgeGrandpaCall, Config as BridgeGrandpaConfig};
|
|
||||||
use pallet_bridge_messages::{Call as BridgeMessagesCall, Config as BridgeMessagesConfig};
|
|
||||||
use parachains_runtimes_test_utils::{
|
use parachains_runtimes_test_utils::{
|
||||||
AccountIdOf, BasicParachainRuntime, CollatorSessionKeys, RuntimeCallOf,
|
AccountIdOf, BasicParachainRuntime, CollatorSessionKeys, RuntimeCallOf,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
//! with remote parachain.
|
//! with remote parachain.
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
test_cases::{helpers, run_test},
|
test_cases::{bridges_prelude::*, helpers, run_test},
|
||||||
test_data,
|
test_data,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -39,12 +39,6 @@ use bridge_runtime_common::{
|
|||||||
};
|
};
|
||||||
use frame_support::traits::{Get, OnFinalize, OnInitialize};
|
use frame_support::traits::{Get, OnFinalize, OnInitialize};
|
||||||
use frame_system::pallet_prelude::BlockNumberFor;
|
use frame_system::pallet_prelude::BlockNumberFor;
|
||||||
use pallet_bridge_grandpa::{Call as BridgeGrandpaCall, Config as BridgeGrandpaConfig};
|
|
||||||
use pallet_bridge_messages::{Call as BridgeMessagesCall, Config as BridgeMessagesConfig};
|
|
||||||
use pallet_bridge_parachains::{
|
|
||||||
Call as BridgeParachainsCall, Config as BridgeParachainsConfig, RelayBlockHash,
|
|
||||||
RelayBlockNumber,
|
|
||||||
};
|
|
||||||
use parachains_runtimes_test_utils::{
|
use parachains_runtimes_test_utils::{
|
||||||
AccountIdOf, BasicParachainRuntime, CollatorSessionKeys, RuntimeCallOf,
|
AccountIdOf, BasicParachainRuntime, CollatorSessionKeys, RuntimeCallOf,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
//! Module contains tests code, that is shared by all types of bridges
|
//! Module contains tests code, that is shared by all types of bridges
|
||||||
|
|
||||||
use crate::test_cases::{run_test, RuntimeHelper};
|
use crate::test_cases::{bridges_prelude::*, run_test, RuntimeHelper};
|
||||||
|
|
||||||
use asset_test_utils::BasicParachainRuntime;
|
use asset_test_utils::BasicParachainRuntime;
|
||||||
use bp_messages::{LaneId, MessageNonce};
|
use bp_messages::{LaneId, MessageNonce};
|
||||||
@@ -30,13 +30,16 @@ use frame_support::{
|
|||||||
use frame_system::pallet_prelude::BlockNumberFor;
|
use frame_system::pallet_prelude::BlockNumberFor;
|
||||||
use pallet_bridge_grandpa::{BridgedBlockHash, BridgedHeader};
|
use pallet_bridge_grandpa::{BridgedBlockHash, BridgedHeader};
|
||||||
use parachains_common::AccountId;
|
use parachains_common::AccountId;
|
||||||
use parachains_runtimes_test_utils::{mock_open_hrmp_channel, AccountIdOf, CollatorSessionKeys};
|
use parachains_runtimes_test_utils::{
|
||||||
|
mock_open_hrmp_channel, AccountIdOf, CollatorSessionKeys, RuntimeCallOf,
|
||||||
|
};
|
||||||
use sp_core::Get;
|
use sp_core::Get;
|
||||||
use sp_keyring::AccountKeyring::*;
|
use sp_keyring::AccountKeyring::*;
|
||||||
use sp_runtime::{traits::TrailingZeroInput, AccountId32};
|
use sp_runtime::{traits::TrailingZeroInput, AccountId32};
|
||||||
use sp_std::marker::PhantomData;
|
use sp_std::marker::PhantomData;
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
|
|
||||||
|
/// Verify that the transaction has succeeded.
|
||||||
#[impl_trait_for_tuples::impl_for_tuples(30)]
|
#[impl_trait_for_tuples::impl_for_tuples(30)]
|
||||||
pub trait VerifyTransactionOutcome {
|
pub trait VerifyTransactionOutcome {
|
||||||
fn verify_outcome(&self);
|
fn verify_outcome(&self);
|
||||||
@@ -51,7 +54,7 @@ impl VerifyTransactionOutcome for Box<dyn VerifyTransactionOutcome> {
|
|||||||
/// Checks that the best finalized header hash in the bridge GRANDPA pallet equals to given one.
|
/// Checks that the best finalized header hash in the bridge GRANDPA pallet equals to given one.
|
||||||
pub struct VerifySubmitGrandpaFinalityProofOutcome<Runtime, GPI>
|
pub struct VerifySubmitGrandpaFinalityProofOutcome<Runtime, GPI>
|
||||||
where
|
where
|
||||||
Runtime: pallet_bridge_grandpa::Config<GPI>,
|
Runtime: BridgeGrandpaConfig<GPI>,
|
||||||
GPI: 'static,
|
GPI: 'static,
|
||||||
{
|
{
|
||||||
expected_best_hash: BridgedBlockHash<Runtime, GPI>,
|
expected_best_hash: BridgedBlockHash<Runtime, GPI>,
|
||||||
@@ -59,7 +62,7 @@ where
|
|||||||
|
|
||||||
impl<Runtime, GPI> VerifySubmitGrandpaFinalityProofOutcome<Runtime, GPI>
|
impl<Runtime, GPI> VerifySubmitGrandpaFinalityProofOutcome<Runtime, GPI>
|
||||||
where
|
where
|
||||||
Runtime: pallet_bridge_grandpa::Config<GPI>,
|
Runtime: BridgeGrandpaConfig<GPI>,
|
||||||
GPI: 'static,
|
GPI: 'static,
|
||||||
{
|
{
|
||||||
/// Expect given header hash to be the best after transaction.
|
/// Expect given header hash to be the best after transaction.
|
||||||
@@ -73,7 +76,7 @@ where
|
|||||||
impl<Runtime, GPI> VerifyTransactionOutcome
|
impl<Runtime, GPI> VerifyTransactionOutcome
|
||||||
for VerifySubmitGrandpaFinalityProofOutcome<Runtime, GPI>
|
for VerifySubmitGrandpaFinalityProofOutcome<Runtime, GPI>
|
||||||
where
|
where
|
||||||
Runtime: pallet_bridge_grandpa::Config<GPI>,
|
Runtime: BridgeGrandpaConfig<GPI>,
|
||||||
GPI: 'static,
|
GPI: 'static,
|
||||||
{
|
{
|
||||||
fn verify_outcome(&self) {
|
fn verify_outcome(&self) {
|
||||||
@@ -96,7 +99,7 @@ pub struct VerifySubmitParachainHeaderProofOutcome<Runtime, PPI> {
|
|||||||
|
|
||||||
impl<Runtime, PPI> VerifySubmitParachainHeaderProofOutcome<Runtime, PPI>
|
impl<Runtime, PPI> VerifySubmitParachainHeaderProofOutcome<Runtime, PPI>
|
||||||
where
|
where
|
||||||
Runtime: pallet_bridge_parachains::Config<PPI>,
|
Runtime: BridgeParachainsConfig<PPI>,
|
||||||
PPI: 'static,
|
PPI: 'static,
|
||||||
{
|
{
|
||||||
/// Expect given header hash to be the best after transaction.
|
/// Expect given header hash to be the best after transaction.
|
||||||
@@ -111,7 +114,7 @@ where
|
|||||||
impl<Runtime, PPI> VerifyTransactionOutcome
|
impl<Runtime, PPI> VerifyTransactionOutcome
|
||||||
for VerifySubmitParachainHeaderProofOutcome<Runtime, PPI>
|
for VerifySubmitParachainHeaderProofOutcome<Runtime, PPI>
|
||||||
where
|
where
|
||||||
Runtime: pallet_bridge_parachains::Config<PPI>,
|
Runtime: BridgeParachainsConfig<PPI>,
|
||||||
PPI: 'static,
|
PPI: 'static,
|
||||||
{
|
{
|
||||||
fn verify_outcome(&self) {
|
fn verify_outcome(&self) {
|
||||||
@@ -132,7 +135,7 @@ pub struct VerifySubmitMessagesProofOutcome<Runtime, MPI> {
|
|||||||
|
|
||||||
impl<Runtime, MPI> VerifySubmitMessagesProofOutcome<Runtime, MPI>
|
impl<Runtime, MPI> VerifySubmitMessagesProofOutcome<Runtime, MPI>
|
||||||
where
|
where
|
||||||
Runtime: pallet_bridge_messages::Config<MPI>,
|
Runtime: BridgeMessagesConfig<MPI>,
|
||||||
MPI: 'static,
|
MPI: 'static,
|
||||||
{
|
{
|
||||||
/// Expect given delivered nonce to be the latest after transaction.
|
/// Expect given delivered nonce to be the latest after transaction.
|
||||||
@@ -146,7 +149,7 @@ where
|
|||||||
|
|
||||||
impl<Runtime, MPI> VerifyTransactionOutcome for VerifySubmitMessagesProofOutcome<Runtime, MPI>
|
impl<Runtime, MPI> VerifyTransactionOutcome for VerifySubmitMessagesProofOutcome<Runtime, MPI>
|
||||||
where
|
where
|
||||||
Runtime: pallet_bridge_messages::Config<MPI>,
|
Runtime: BridgeMessagesConfig<MPI>,
|
||||||
MPI: 'static,
|
MPI: 'static,
|
||||||
{
|
{
|
||||||
fn verify_outcome(&self) {
|
fn verify_outcome(&self) {
|
||||||
@@ -194,7 +197,7 @@ where
|
|||||||
pub(crate) fn initialize_bridge_grandpa_pallet<Runtime, GPI>(
|
pub(crate) fn initialize_bridge_grandpa_pallet<Runtime, GPI>(
|
||||||
init_data: bp_header_chain::InitializationData<BridgedHeader<Runtime, GPI>>,
|
init_data: bp_header_chain::InitializationData<BridgedHeader<Runtime, GPI>>,
|
||||||
) where
|
) where
|
||||||
Runtime: pallet_bridge_grandpa::Config<GPI>,
|
Runtime: BridgeGrandpaConfig<GPI>,
|
||||||
{
|
{
|
||||||
pallet_bridge_grandpa::Pallet::<Runtime, GPI>::initialize(
|
pallet_bridge_grandpa::Pallet::<Runtime, GPI>::initialize(
|
||||||
RuntimeHelper::<Runtime>::root_origin(),
|
RuntimeHelper::<Runtime>::root_origin(),
|
||||||
@@ -205,7 +208,7 @@ pub(crate) fn initialize_bridge_grandpa_pallet<Runtime, GPI>(
|
|||||||
|
|
||||||
/// Runtime calls and their verifiers.
|
/// Runtime calls and their verifiers.
|
||||||
pub type CallsAndVerifiers<Runtime> =
|
pub type CallsAndVerifiers<Runtime> =
|
||||||
Vec<(<Runtime as frame_system::Config>::RuntimeCall, Box<dyn VerifyTransactionOutcome>)>;
|
Vec<(RuntimeCallOf<Runtime>, Box<dyn VerifyTransactionOutcome>)>;
|
||||||
|
|
||||||
/// Returns relayer id at the bridged chain.
|
/// Returns relayer id at the bridged chain.
|
||||||
pub fn relayer_id_at_bridged_chain<Runtime: pallet_bridge_messages::Config<MPI>, MPI>(
|
pub fn relayer_id_at_bridged_chain<Runtime: pallet_bridge_messages::Config<MPI>, MPI>(
|
||||||
@@ -222,7 +225,7 @@ pub fn relayed_incoming_message_works<Runtime, AllPalletsWithoutSystem, MPI>(
|
|||||||
local_relay_chain_id: NetworkId,
|
local_relay_chain_id: NetworkId,
|
||||||
construct_and_apply_extrinsic: fn(
|
construct_and_apply_extrinsic: fn(
|
||||||
sp_keyring::AccountKeyring,
|
sp_keyring::AccountKeyring,
|
||||||
<Runtime as frame_system::Config>::RuntimeCall,
|
RuntimeCallOf<Runtime>,
|
||||||
) -> sp_runtime::DispatchOutcome,
|
) -> sp_runtime::DispatchOutcome,
|
||||||
prepare_message_proof_import: impl FnOnce(
|
prepare_message_proof_import: impl FnOnce(
|
||||||
Runtime::AccountId,
|
Runtime::AccountId,
|
||||||
@@ -232,9 +235,7 @@ pub fn relayed_incoming_message_works<Runtime, AllPalletsWithoutSystem, MPI>(
|
|||||||
Xcm<()>,
|
Xcm<()>,
|
||||||
) -> CallsAndVerifiers<Runtime>,
|
) -> CallsAndVerifiers<Runtime>,
|
||||||
) where
|
) where
|
||||||
Runtime: BasicParachainRuntime
|
Runtime: BasicParachainRuntime + cumulus_pallet_xcmp_queue::Config + BridgeMessagesConfig<MPI>,
|
||||||
+ cumulus_pallet_xcmp_queue::Config
|
|
||||||
+ pallet_bridge_messages::Config<MPI>,
|
|
||||||
AllPalletsWithoutSystem:
|
AllPalletsWithoutSystem:
|
||||||
OnInitialize<BlockNumberFor<Runtime>> + OnFinalize<BlockNumberFor<Runtime>>,
|
OnInitialize<BlockNumberFor<Runtime>> + OnFinalize<BlockNumberFor<Runtime>>,
|
||||||
MPI: 'static,
|
MPI: 'static,
|
||||||
@@ -251,7 +252,12 @@ pub fn relayed_incoming_message_works<Runtime, AllPalletsWithoutSystem, MPI>(
|
|||||||
runtime_para_id,
|
runtime_para_id,
|
||||||
vec![(
|
vec![(
|
||||||
relayer_id_on_target.clone().into(),
|
relayer_id_on_target.clone().into(),
|
||||||
Runtime::ExistentialDeposit::get() * 100000u32.into(),
|
// this value should be enough to cover all transaction costs, but computing the actual
|
||||||
|
// value here is tricky - there are several transaction payment pallets and we don't
|
||||||
|
// want to introduce additional bounds and traits here just for that, so let's just
|
||||||
|
// select some presumably large value
|
||||||
|
sp_std::cmp::max::<Runtime::Balance>(Runtime::ExistentialDeposit::get(), 1u32.into()) *
|
||||||
|
100_000_000u32.into(),
|
||||||
)],
|
)],
|
||||||
|| {
|
|| {
|
||||||
let mut alice = [0u8; 32];
|
let mut alice = [0u8; 32];
|
||||||
@@ -327,7 +333,7 @@ fn execute_and_verify_calls<Runtime: frame_system::Config>(
|
|||||||
submitter: sp_keyring::AccountKeyring,
|
submitter: sp_keyring::AccountKeyring,
|
||||||
construct_and_apply_extrinsic: fn(
|
construct_and_apply_extrinsic: fn(
|
||||||
sp_keyring::AccountKeyring,
|
sp_keyring::AccountKeyring,
|
||||||
<Runtime as frame_system::Config>::RuntimeCall,
|
RuntimeCallOf<Runtime>,
|
||||||
) -> sp_runtime::DispatchOutcome,
|
) -> sp_runtime::DispatchOutcome,
|
||||||
calls_and_verifiers: CallsAndVerifiers<Runtime>,
|
calls_and_verifiers: CallsAndVerifiers<Runtime>,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ pub mod from_parachain;
|
|||||||
|
|
||||||
pub(crate) mod helpers;
|
pub(crate) mod helpers;
|
||||||
|
|
||||||
use crate::test_data;
|
use crate::{test_cases::bridges_prelude::*, test_data};
|
||||||
|
|
||||||
use asset_test_utils::BasicParachainRuntime;
|
use asset_test_utils::BasicParachainRuntime;
|
||||||
use bp_messages::{
|
use bp_messages::{
|
||||||
@@ -38,12 +38,13 @@ use bridge_runtime_common::messages_xcm_extension::{
|
|||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
assert_ok,
|
assert_ok,
|
||||||
|
dispatch::GetDispatchInfo,
|
||||||
traits::{Get, OnFinalize, OnInitialize, OriginTrait},
|
traits::{Get, OnFinalize, OnInitialize, OriginTrait},
|
||||||
};
|
};
|
||||||
use frame_system::pallet_prelude::BlockNumberFor;
|
use frame_system::pallet_prelude::BlockNumberFor;
|
||||||
use parachains_common::AccountId;
|
use parachains_common::AccountId;
|
||||||
use parachains_runtimes_test_utils::{
|
use parachains_runtimes_test_utils::{
|
||||||
mock_open_hrmp_channel, AccountIdOf, BalanceOf, CollatorSessionKeys, ExtBuilder, ValidatorIdOf,
|
mock_open_hrmp_channel, AccountIdOf, BalanceOf, CollatorSessionKeys, ExtBuilder, RuntimeCallOf,
|
||||||
XcmReceivedFrom,
|
XcmReceivedFrom,
|
||||||
};
|
};
|
||||||
use sp_runtime::{traits::Zero, AccountId32};
|
use sp_runtime::{traits::Zero, AccountId32};
|
||||||
@@ -54,6 +55,16 @@ use xcm_executor::{
|
|||||||
XcmExecutor,
|
XcmExecutor,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Common bridges exports.
|
||||||
|
pub(crate) mod bridges_prelude {
|
||||||
|
pub use pallet_bridge_grandpa::{Call as BridgeGrandpaCall, Config as BridgeGrandpaConfig};
|
||||||
|
pub use pallet_bridge_messages::{Call as BridgeMessagesCall, Config as BridgeMessagesConfig};
|
||||||
|
pub use pallet_bridge_parachains::{
|
||||||
|
Call as BridgeParachainsCall, Config as BridgeParachainsConfig, RelayBlockHash,
|
||||||
|
RelayBlockNumber,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Re-export test_case from assets
|
// Re-export test_case from assets
|
||||||
pub use asset_test_utils::include_teleports_for_native_asset_works;
|
pub use asset_test_utils::include_teleports_for_native_asset_works;
|
||||||
|
|
||||||
@@ -89,11 +100,10 @@ pub fn initialize_bridge_by_governance_works<Runtime, GrandpaPalletInstance>(
|
|||||||
collator_session_key: CollatorSessionKeys<Runtime>,
|
collator_session_key: CollatorSessionKeys<Runtime>,
|
||||||
runtime_para_id: u32,
|
runtime_para_id: u32,
|
||||||
) where
|
) where
|
||||||
Runtime: BasicParachainRuntime + pallet_bridge_grandpa::Config<GrandpaPalletInstance>,
|
Runtime: BasicParachainRuntime + BridgeGrandpaConfig<GrandpaPalletInstance>,
|
||||||
GrandpaPalletInstance: 'static,
|
GrandpaPalletInstance: 'static,
|
||||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
RuntimeCallOf<Runtime>:
|
||||||
<Runtime as frame_system::Config>::RuntimeCall:
|
GetDispatchInfo + From<BridgeGrandpaCall<Runtime, GrandpaPalletInstance>>,
|
||||||
From<pallet_bridge_grandpa::Call<Runtime, GrandpaPalletInstance>>,
|
|
||||||
{
|
{
|
||||||
run_test::<Runtime, _>(collator_session_key, runtime_para_id, vec![], || {
|
run_test::<Runtime, _>(collator_session_key, runtime_para_id, vec![], || {
|
||||||
// check mode before
|
// check mode before
|
||||||
@@ -102,24 +112,18 @@ pub fn initialize_bridge_by_governance_works<Runtime, GrandpaPalletInstance>(
|
|||||||
Err(())
|
Err(())
|
||||||
);
|
);
|
||||||
|
|
||||||
// encode `initialize` call
|
// prepare the `initialize` call
|
||||||
let initialize_call =
|
let initialize_call = RuntimeCallOf::<Runtime>::from(BridgeGrandpaCall::<
|
||||||
<Runtime as frame_system::Config>::RuntimeCall::from(pallet_bridge_grandpa::Call::<
|
|
||||||
Runtime,
|
Runtime,
|
||||||
GrandpaPalletInstance,
|
GrandpaPalletInstance,
|
||||||
>::initialize {
|
>::initialize {
|
||||||
init_data: test_data::initialization_data::<Runtime, GrandpaPalletInstance>(12345),
|
init_data: test_data::initialization_data::<Runtime, GrandpaPalletInstance>(12345),
|
||||||
})
|
});
|
||||||
.encode();
|
|
||||||
|
|
||||||
// overestimate - check weight for `pallet_bridge_grandpa::Pallet::initialize()` call
|
|
||||||
let require_weight_at_most =
|
|
||||||
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(7, 7);
|
|
||||||
|
|
||||||
// execute XCM with Transacts to `initialize bridge` as governance does
|
// execute XCM with Transacts to `initialize bridge` as governance does
|
||||||
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
|
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
|
||||||
initialize_call,
|
initialize_call.encode(),
|
||||||
require_weight_at_most
|
initialize_call.get_dispatch_info().weight,
|
||||||
)
|
)
|
||||||
.ensure_complete());
|
.ensure_complete());
|
||||||
|
|
||||||
@@ -137,11 +141,10 @@ pub fn change_bridge_grandpa_pallet_mode_by_governance_works<Runtime, GrandpaPal
|
|||||||
collator_session_key: CollatorSessionKeys<Runtime>,
|
collator_session_key: CollatorSessionKeys<Runtime>,
|
||||||
runtime_para_id: u32,
|
runtime_para_id: u32,
|
||||||
) where
|
) where
|
||||||
Runtime: BasicParachainRuntime + pallet_bridge_grandpa::Config<GrandpaPalletInstance>,
|
Runtime: BasicParachainRuntime + BridgeGrandpaConfig<GrandpaPalletInstance>,
|
||||||
GrandpaPalletInstance: 'static,
|
GrandpaPalletInstance: 'static,
|
||||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
RuntimeCallOf<Runtime>:
|
||||||
<Runtime as frame_system::Config>::RuntimeCall:
|
GetDispatchInfo + From<BridgeGrandpaCall<Runtime, GrandpaPalletInstance>>,
|
||||||
From<pallet_bridge_grandpa::Call<Runtime, GrandpaPalletInstance>>,
|
|
||||||
{
|
{
|
||||||
run_test::<Runtime, _>(collator_session_key, runtime_para_id, vec![], || {
|
run_test::<Runtime, _>(collator_session_key, runtime_para_id, vec![], || {
|
||||||
let dispatch_set_operating_mode_call = |old_mode, new_mode| {
|
let dispatch_set_operating_mode_call = |old_mode, new_mode| {
|
||||||
@@ -151,23 +154,17 @@ pub fn change_bridge_grandpa_pallet_mode_by_governance_works<Runtime, GrandpaPal
|
|||||||
old_mode,
|
old_mode,
|
||||||
);
|
);
|
||||||
|
|
||||||
// overestimate - check weight for `pallet_bridge_grandpa::Pallet::set_operating_mode()`
|
// prepare the `set_operating_mode` call
|
||||||
// call
|
|
||||||
let require_weight_at_most =
|
|
||||||
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(7, 7);
|
|
||||||
|
|
||||||
// encode `set_operating_mode` call
|
|
||||||
let set_operating_mode_call = <Runtime as frame_system::Config>::RuntimeCall::from(
|
let set_operating_mode_call = <Runtime as frame_system::Config>::RuntimeCall::from(
|
||||||
pallet_bridge_grandpa::Call::<Runtime, GrandpaPalletInstance>::set_operating_mode {
|
pallet_bridge_grandpa::Call::<Runtime, GrandpaPalletInstance>::set_operating_mode {
|
||||||
operating_mode: new_mode,
|
operating_mode: new_mode,
|
||||||
},
|
},
|
||||||
)
|
);
|
||||||
.encode();
|
|
||||||
|
|
||||||
// execute XCM with Transacts to `initialize bridge` as governance does
|
// execute XCM with Transacts to `initialize bridge` as governance does
|
||||||
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
|
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
|
||||||
set_operating_mode_call,
|
set_operating_mode_call.encode(),
|
||||||
require_weight_at_most
|
set_operating_mode_call.get_dispatch_info().weight,
|
||||||
)
|
)
|
||||||
.ensure_complete());
|
.ensure_complete());
|
||||||
|
|
||||||
@@ -195,11 +192,10 @@ pub fn change_bridge_parachains_pallet_mode_by_governance_works<Runtime, Paracha
|
|||||||
collator_session_key: CollatorSessionKeys<Runtime>,
|
collator_session_key: CollatorSessionKeys<Runtime>,
|
||||||
runtime_para_id: u32,
|
runtime_para_id: u32,
|
||||||
) where
|
) where
|
||||||
Runtime: BasicParachainRuntime + pallet_bridge_parachains::Config<ParachainsPalletInstance>,
|
Runtime: BasicParachainRuntime + BridgeParachainsConfig<ParachainsPalletInstance>,
|
||||||
ParachainsPalletInstance: 'static,
|
ParachainsPalletInstance: 'static,
|
||||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
RuntimeCallOf<Runtime>:
|
||||||
<Runtime as frame_system::Config>::RuntimeCall:
|
GetDispatchInfo + From<BridgeParachainsCall<Runtime, ParachainsPalletInstance>>,
|
||||||
From<pallet_bridge_parachains::Call<Runtime, ParachainsPalletInstance>>,
|
|
||||||
{
|
{
|
||||||
run_test::<Runtime, _>(collator_session_key, runtime_para_id, vec![], || {
|
run_test::<Runtime, _>(collator_session_key, runtime_para_id, vec![], || {
|
||||||
let dispatch_set_operating_mode_call = |old_mode, new_mode| {
|
let dispatch_set_operating_mode_call = |old_mode, new_mode| {
|
||||||
@@ -209,23 +205,19 @@ pub fn change_bridge_parachains_pallet_mode_by_governance_works<Runtime, Paracha
|
|||||||
old_mode,
|
old_mode,
|
||||||
);
|
);
|
||||||
|
|
||||||
// overestimate - check weight for
|
// prepare the `set_operating_mode` call
|
||||||
// `pallet_bridge_parachains::Pallet::set_operating_mode()` call
|
let set_operating_mode_call =
|
||||||
let require_weight_at_most =
|
RuntimeCallOf::<Runtime>::from(pallet_bridge_parachains::Call::<
|
||||||
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(7, 7);
|
|
||||||
|
|
||||||
// encode `set_operating_mode` call
|
|
||||||
let set_operating_mode_call = <Runtime as frame_system::Config>::RuntimeCall::from(pallet_bridge_parachains::Call::<
|
|
||||||
Runtime,
|
Runtime,
|
||||||
ParachainsPalletInstance,
|
ParachainsPalletInstance,
|
||||||
>::set_operating_mode {
|
>::set_operating_mode {
|
||||||
operating_mode: new_mode,
|
operating_mode: new_mode,
|
||||||
}).encode();
|
});
|
||||||
|
|
||||||
// execute XCM with Transacts to `initialize bridge` as governance does
|
// execute XCM with Transacts to `initialize bridge` as governance does
|
||||||
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
|
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
|
||||||
set_operating_mode_call,
|
set_operating_mode_call.encode(),
|
||||||
require_weight_at_most
|
set_operating_mode_call.get_dispatch_info().weight,
|
||||||
)
|
)
|
||||||
.ensure_complete());
|
.ensure_complete());
|
||||||
|
|
||||||
@@ -253,11 +245,10 @@ pub fn change_bridge_messages_pallet_mode_by_governance_works<Runtime, MessagesP
|
|||||||
collator_session_key: CollatorSessionKeys<Runtime>,
|
collator_session_key: CollatorSessionKeys<Runtime>,
|
||||||
runtime_para_id: u32,
|
runtime_para_id: u32,
|
||||||
) where
|
) where
|
||||||
Runtime: BasicParachainRuntime + pallet_bridge_messages::Config<MessagesPalletInstance>,
|
Runtime: BasicParachainRuntime + BridgeMessagesConfig<MessagesPalletInstance>,
|
||||||
MessagesPalletInstance: 'static,
|
MessagesPalletInstance: 'static,
|
||||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
RuntimeCallOf<Runtime>:
|
||||||
<Runtime as frame_system::Config>::RuntimeCall:
|
GetDispatchInfo + From<BridgeMessagesCall<Runtime, MessagesPalletInstance>>,
|
||||||
From<pallet_bridge_messages::Call<Runtime, MessagesPalletInstance>>,
|
|
||||||
{
|
{
|
||||||
run_test::<Runtime, _>(collator_session_key, runtime_para_id, vec![], || {
|
run_test::<Runtime, _>(collator_session_key, runtime_para_id, vec![], || {
|
||||||
let dispatch_set_operating_mode_call = |old_mode, new_mode| {
|
let dispatch_set_operating_mode_call = |old_mode, new_mode| {
|
||||||
@@ -268,23 +259,18 @@ pub fn change_bridge_messages_pallet_mode_by_governance_works<Runtime, MessagesP
|
|||||||
old_mode,
|
old_mode,
|
||||||
);
|
);
|
||||||
|
|
||||||
// overestimate - check weight for
|
|
||||||
// `pallet_bridge_messages::Pallet::set_operating_mode()` call
|
|
||||||
let require_weight_at_most =
|
|
||||||
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(7, 7);
|
|
||||||
|
|
||||||
// encode `set_operating_mode` call
|
// encode `set_operating_mode` call
|
||||||
let set_operating_mode_call = <Runtime as frame_system::Config>::RuntimeCall::from(pallet_bridge_messages::Call::<
|
let set_operating_mode_call = RuntimeCallOf::<Runtime>::from(BridgeMessagesCall::<
|
||||||
Runtime,
|
Runtime,
|
||||||
MessagesPalletInstance,
|
MessagesPalletInstance,
|
||||||
>::set_operating_mode {
|
>::set_operating_mode {
|
||||||
operating_mode: new_mode,
|
operating_mode: new_mode,
|
||||||
}).encode();
|
});
|
||||||
|
|
||||||
// execute XCM with Transacts to `initialize bridge` as governance does
|
// execute XCM with Transacts to `initialize bridge` as governance does
|
||||||
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
|
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
|
||||||
set_operating_mode_call,
|
set_operating_mode_call.encode(),
|
||||||
require_weight_at_most
|
set_operating_mode_call.get_dispatch_info().weight,
|
||||||
)
|
)
|
||||||
.ensure_complete());
|
.ensure_complete());
|
||||||
|
|
||||||
@@ -337,10 +323,9 @@ pub fn handle_export_message_from_system_parachain_to_outbound_queue_works<
|
|||||||
maybe_paid_export_message: Option<MultiAsset>,
|
maybe_paid_export_message: Option<MultiAsset>,
|
||||||
prepare_configuration: impl Fn(),
|
prepare_configuration: impl Fn(),
|
||||||
) where
|
) where
|
||||||
Runtime: BasicParachainRuntime + pallet_bridge_messages::Config<MessagesPalletInstance>,
|
Runtime: BasicParachainRuntime + BridgeMessagesConfig<MessagesPalletInstance>,
|
||||||
XcmConfig: xcm_executor::Config,
|
XcmConfig: xcm_executor::Config,
|
||||||
MessagesPalletInstance: 'static,
|
MessagesPalletInstance: 'static,
|
||||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
|
||||||
{
|
{
|
||||||
assert_ne!(runtime_para_id, sibling_parachain_id);
|
assert_ne!(runtime_para_id, sibling_parachain_id);
|
||||||
let sibling_parachain_location = MultiLocation::new(1, Parachain(sibling_parachain_id));
|
let sibling_parachain_location = MultiLocation::new(1, Parachain(sibling_parachain_id));
|
||||||
@@ -446,15 +431,13 @@ pub fn message_dispatch_routing_works<
|
|||||||
) where
|
) where
|
||||||
Runtime: BasicParachainRuntime
|
Runtime: BasicParachainRuntime
|
||||||
+ cumulus_pallet_xcmp_queue::Config
|
+ cumulus_pallet_xcmp_queue::Config
|
||||||
+ pallet_bridge_messages::Config<MessagesPalletInstance, InboundPayload = XcmAsPlainPayload>,
|
+ BridgeMessagesConfig<MessagesPalletInstance, InboundPayload = XcmAsPlainPayload>,
|
||||||
AllPalletsWithoutSystem:
|
AllPalletsWithoutSystem:
|
||||||
OnInitialize<BlockNumberFor<Runtime>> + OnFinalize<BlockNumberFor<Runtime>>,
|
OnInitialize<BlockNumberFor<Runtime>> + OnFinalize<BlockNumberFor<Runtime>>,
|
||||||
<Runtime as frame_system::Config>::AccountId:
|
AccountIdOf<Runtime>: From<AccountId32>
|
||||||
Into<<<Runtime as frame_system::Config>::RuntimeOrigin as OriginTrait>::AccountId>,
|
+ Into<<<Runtime as frame_system::Config>::RuntimeOrigin as OriginTrait>::AccountId>,
|
||||||
XcmConfig: xcm_executor::Config,
|
XcmConfig: xcm_executor::Config,
|
||||||
MessagesPalletInstance: 'static,
|
MessagesPalletInstance: 'static,
|
||||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
|
||||||
<Runtime as frame_system::Config>::AccountId: From<AccountId32>,
|
|
||||||
HrmpChannelOpener: frame_support::inherent::ProvideInherent<
|
HrmpChannelOpener: frame_support::inherent::ProvideInherent<
|
||||||
Call = cumulus_pallet_parachain_system::Call<Runtime>,
|
Call = cumulus_pallet_parachain_system::Call<Runtime>,
|
||||||
>,
|
>,
|
||||||
@@ -488,8 +471,9 @@ pub fn message_dispatch_routing_works<
|
|||||||
NetworkWithParentCount<RuntimeNetwork, NetworkDistanceAsParentCount>,
|
NetworkWithParentCount<RuntimeNetwork, NetworkDistanceAsParentCount>,
|
||||||
AlwaysLatest,
|
AlwaysLatest,
|
||||||
>((RuntimeNetwork::get(), Here));
|
>((RuntimeNetwork::get(), Here));
|
||||||
let result = <<Runtime as pallet_bridge_messages::Config<MessagesPalletInstance>>::MessageDispatch>::dispatch(
|
let result =
|
||||||
test_data::dispatch_message(expected_lane_id, 1, bridging_message)
|
<<Runtime as BridgeMessagesConfig<MessagesPalletInstance>>::MessageDispatch>::dispatch(
|
||||||
|
test_data::dispatch_message(expected_lane_id, 1, bridging_message),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{:?}", result.dispatch_level_result),
|
format!("{:?}", result.dispatch_level_result),
|
||||||
@@ -515,11 +499,11 @@ pub fn message_dispatch_routing_works<
|
|||||||
|
|
||||||
// 2.1. WITHOUT opened hrmp channel -> RoutingError
|
// 2.1. WITHOUT opened hrmp channel -> RoutingError
|
||||||
let result =
|
let result =
|
||||||
<<Runtime as pallet_bridge_messages::Config<MessagesPalletInstance>>::MessageDispatch>::dispatch(
|
<<Runtime as BridgeMessagesConfig<MessagesPalletInstance>>::MessageDispatch>::dispatch(
|
||||||
DispatchMessage {
|
DispatchMessage {
|
||||||
key: MessageKey { lane_id: expected_lane_id, nonce: 1 },
|
key: MessageKey { lane_id: expected_lane_id, nonce: 1 },
|
||||||
data: DispatchMessageData { payload: Ok(bridging_message.clone()) },
|
data: DispatchMessageData { payload: Ok(bridging_message.clone()) },
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{:?}", result.dispatch_level_result),
|
format!("{:?}", result.dispatch_level_result),
|
||||||
@@ -545,11 +529,12 @@ pub fn message_dispatch_routing_works<
|
|||||||
included_head,
|
included_head,
|
||||||
&alice,
|
&alice,
|
||||||
);
|
);
|
||||||
let result = <<Runtime as pallet_bridge_messages::Config<MessagesPalletInstance>>::MessageDispatch>::dispatch(
|
let result =
|
||||||
|
<<Runtime as BridgeMessagesConfig<MessagesPalletInstance>>::MessageDispatch>::dispatch(
|
||||||
DispatchMessage {
|
DispatchMessage {
|
||||||
key: MessageKey { lane_id: expected_lane_id, nonce: 1 },
|
key: MessageKey { lane_id: expected_lane_id, nonce: 1 },
|
||||||
data: DispatchMessageData { payload: Ok(bridging_message) },
|
data: DispatchMessageData { payload: Ok(bridging_message) },
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{:?}", result.dispatch_level_result),
|
format!("{:?}", result.dispatch_level_result),
|
||||||
|
|||||||
Reference in New Issue
Block a user