From 83650f28dac594ca7f8d6a994995e03a86cdeb80 Mon Sep 17 00:00:00 2001 From: Alistair Singh Date: Mon, 18 Dec 2023 21:57:20 +0200 Subject: [PATCH] fix runtime tests --- parachain/pallets/system/src/lib.rs | 19 ++++++++----------- parachain/runtime/tests/src/lib.rs | 17 +---------------- parachain/runtime/tests/src/test_cases.rs | 13 +++++++++++-- polkadot-sdk | 2 +- 4 files changed, 21 insertions(+), 30 deletions(-) diff --git a/parachain/pallets/system/src/lib.rs b/parachain/pallets/system/src/lib.rs index 94256ee27e..f6b23d5a8b 100644 --- a/parachain/pallets/system/src/lib.rs +++ b/parachain/pallets/system/src/lib.rs @@ -618,18 +618,8 @@ pub mod pallet { Ok(()) } - /// Checks if the pallet has been initialized. - pub(crate) fn is_initialized() -> bool { - let primary_exists = Channels::::contains_key(PRIMARY_GOVERNANCE_CHANNEL); - let secondary_exists = Channels::::contains_key(SECONDARY_GOVERNANCE_CHANNEL); - primary_exists && secondary_exists - } - /// Initializes agents and channels. - pub(crate) fn initialize( - para_id: ParaId, - asset_hub_para_id: ParaId, - ) -> Result<(), DispatchError> { + pub fn initialize(para_id: ParaId, asset_hub_para_id: ParaId) -> Result<(), DispatchError> { // Asset Hub let asset_hub_location: MultiLocation = ParentThen(X1(Parachain(asset_hub_para_id.into()))).into(); @@ -660,6 +650,13 @@ pub mod pallet { Ok(()) } + + /// Checks if the pallet has been initialized. + pub(crate) fn is_initialized() -> bool { + let primary_exists = Channels::::contains_key(PRIMARY_GOVERNANCE_CHANNEL); + let secondary_exists = Channels::::contains_key(SECONDARY_GOVERNANCE_CHANNEL); + primary_exists && secondary_exists + } } impl StaticLookup for Pallet { diff --git a/parachain/runtime/tests/src/lib.rs b/parachain/runtime/tests/src/lib.rs index c2811f7ab8..91103cb3a7 100644 --- a/parachain/runtime/tests/src/lib.rs +++ b/parachain/runtime/tests/src/lib.rs @@ -8,7 +8,7 @@ mod test_cases; use asset_hub_rococo_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee; use bridge_hub_rococo_runtime::{xcm_config::XcmConfig, Runtime, RuntimeEvent, SessionKeys}; use codec::Decode; -use cumulus_primitives_core::XcmError::{FailedToTransactAsset, NotHoldingFees, Unroutable}; +use cumulus_primitives_core::XcmError::{FailedToTransactAsset, NotHoldingFees}; use parachains_common::{AccountId, AuraId}; use sp_core::H160; use sp_keyring::AccountKeyring::Alice; @@ -39,21 +39,6 @@ pub fn transfer_token_to_ethereum_works() { ) } -#[test] -pub fn transfer_token_from_non_assethub_to_ethereum_unroutable() { - test_cases::send_transfer_token_message_failure::( - collator_session_keys(), - 1013, - 1001, - DefaultBridgeHubEthereumBaseFee::get() + 1_000_000_000, - H160::random(), - H160::random(), - // fee not enough - 1_000_000_000, - Unroutable, - ) -} - #[test] pub fn unpaid_transfer_token_to_ethereum_fails_with_barrier() { test_cases::send_unpaid_transfer_token_message::( diff --git a/parachain/runtime/tests/src/test_cases.rs b/parachain/runtime/tests/src/test_cases.rs index 0c921787aa..ec9aa2de4a 100644 --- a/parachain/runtime/tests/src/test_cases.rs +++ b/parachain/runtime/tests/src/test_cases.rs @@ -4,6 +4,7 @@ //! Module contains predefined test-case scenarios for `Runtime` with bridging capabilities. use asset_hub_rococo_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee; +use bridge_hub_rococo_runtime::EthereumSystem; use codec::Encode; use frame_support::{assert_err, assert_ok, traits::fungible::Mutate}; use parachains_runtimes_test_utils::{ @@ -119,7 +120,8 @@ pub fn send_transfer_token_message_success( + parachain_info::Config + pallet_collator_selection::Config + cumulus_pallet_parachain_system::Config - + snowbridge_outbound_queue::Config, + + snowbridge_outbound_queue::Config + + snowbridge_system::Config, XcmConfig: xcm_executor::Config, ValidatorIdOf: From>, { @@ -130,6 +132,9 @@ pub fn send_transfer_token_message_success( .with_tracing() .build() .execute_with(|| { + EthereumSystem::initialize(runtime_para_id.into(), assethub_parachain_id.into()) + .unwrap(); + // fund asset hub sovereign account enough so it can pay fees initial_fund::( assethub_parachain_id, @@ -257,7 +262,8 @@ pub fn send_transfer_token_message_failure( + parachain_info::Config + pallet_collator_selection::Config + cumulus_pallet_parachain_system::Config - + snowbridge_outbound_queue::Config, + + snowbridge_outbound_queue::Config + + snowbridge_system::Config, XcmConfig: xcm_executor::Config, ValidatorIdOf: From>, { @@ -268,6 +274,9 @@ pub fn send_transfer_token_message_failure( .with_tracing() .build() .execute_with(|| { + EthereumSystem::initialize(runtime_para_id.into(), assethub_parachain_id.into()) + .unwrap(); + // fund asset hub sovereign account enough so it can pay fees initial_fund::(assethub_parachain_id, initial_amount); diff --git a/polkadot-sdk b/polkadot-sdk index 7c7cd74edb..4e35a92314 160000 --- a/polkadot-sdk +++ b/polkadot-sdk @@ -1 +1 @@ -Subproject commit 7c7cd74edb300aa76b283fb7f42f5f9df85434a3 +Subproject commit 4e35a92314f288280564af1699a2d12d727b680a