From 40310a38cdb1e56ae72d8798e7e8ad28c1494bdb Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 12 Jan 2024 21:10:28 +0800 Subject: [PATCH] runtime test for create asset in AH --- .../asset-hub-rococo/tests/snowbridge.rs | 41 +++++++++++++++++++ .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 10 +---- 2 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/snowbridge.rs diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/snowbridge.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/snowbridge.rs new file mode 100644 index 000000000000..dc051a15744c --- /dev/null +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/snowbridge.rs @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2023 Snowfork + +pub use asset_hub_rococo_runtime::{Runtime, RuntimeCall}; +use codec::Encode; +use frame_support::instances::Instance2; +use sp_runtime::MultiAddress; +use xcm::latest::prelude::*; + +#[test] +fn test_foreign_create_asset_call_compatibility() { + assert_eq!( + RuntimeCall::ForeignAssets(pallet_assets::Call::create { + id: MultiLocation::default(), + admin: MultiAddress::Id([0; 32].into()), + min_balance: 1, + }) + .encode(), + snowbridge_router_primitives::inbound::Call::ForeignAssets( + snowbridge_router_primitives::inbound::ForeignAssetsCall::create { + id: MultiLocation::default(), + admin: MultiAddress::Id([0; 32].into()), + min_balance: 1, + } + ) + .encode() + ); +} + +#[test] +fn check_foreign_create_asset_call_with_sane_weight() { + use pallet_assets::WeightInfo; + let actual = >::WeightInfo::create(); + let max_weight = snowbridge_router_primitives::inbound::FOREIGN_CREATE_ASSET_WEIGHT_AT_MOST; + assert!( + actual.all_lte(max_weight), + "max_weight: {:?} should be adjusted to actual {:?}", + max_weight, + actual + ); +} diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index a64d8b26ec61..6527826627cc 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -500,7 +500,6 @@ parameter_types! { } parameter_types! { - pub const CreateAssetCall: [u8;2] = [53, 0]; pub const CreateAssetDeposit: u128 = (UNITS / 10) + EXISTENTIAL_DEPOSIT; pub const InboundQueuePalletInstance: u8 = parachains_common::rococo::snowbridge::INBOUND_QUEUE_PALLET_INDEX; pub Parameters: PricingParameters = PricingParameters { @@ -560,13 +559,8 @@ impl snowbridge_pallet_inbound_queue::Config for Runtime { type GatewayAddress = EthereumGatewayAddress; #[cfg(feature = "runtime-benchmarks")] type Helper = Runtime; - type MessageConverter = MessageToXcm< - CreateAssetCall, - CreateAssetDeposit, - InboundQueuePalletInstance, - AccountId, - Balance, - >; + type MessageConverter = + MessageToXcm; type WeightToFee = WeightToFee; type LengthToFee = ConstantMultiplier; type MaxMessageSize = ConstU32<2048>;