From 3d7e24a3535c5f893b3f8e0679bfded43e51dfb6 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Tue, 20 Aug 2024 16:26:36 +0200 Subject: [PATCH 001/151] feat(xcm): add PayFees instruction --- .../xcm/procedural/src/builder_pattern.rs | 98 ++++++----- polkadot/xcm/src/v4/mod.rs | 1 + polkadot/xcm/src/v5/mod.rs | 10 ++ polkadot/xcm/xcm-executor/src/lib.rs | 15 ++ polkadot/xcm/xcm-executor/src/tests/mod.rs | 23 +++ .../xcm/xcm-executor/src/tests/pay_fees.rs | 156 ++++++++++++++++++ 6 files changed, 265 insertions(+), 38 deletions(-) create mode 100644 polkadot/xcm/xcm-executor/src/tests/mod.rs create mode 100644 polkadot/xcm/xcm-executor/src/tests/pay_fees.rs diff --git a/polkadot/xcm/procedural/src/builder_pattern.rs b/polkadot/xcm/procedural/src/builder_pattern.rs index 09ead1389d19..000b80cf7cf0 100644 --- a/polkadot/xcm/procedural/src/builder_pattern.rs +++ b/polkadot/xcm/procedural/src/builder_pattern.rs @@ -160,13 +160,13 @@ fn generate_builder_impl(name: &Ident, data_enum: &DataEnum) -> Result>>()?; @@ -260,50 +260,72 @@ fn generate_builder_impl(name: &Ident, data_enum: &DataEnum) -> Result, _>>()?; // Then we require fees to be paid - let buy_execution_method = data_enum + let pay_fees_variants = data_enum .variants .iter() - .find(|variant| variant.ident == "BuyExecution") - .map_or( - Err(Error::new_spanned(&data_enum.variants, "No BuyExecution instruction")), - |variant| { - let variant_name = &variant.ident; - let method_name_string = &variant_name.to_string().to_snake_case(); - let method_name = syn::Ident::new(method_name_string, variant_name.span()); - let docs = get_doc_comments(variant); - let fields = match &variant.fields { - Fields::Named(fields) => { - let arg_names: Vec<_> = - fields.named.iter().map(|field| &field.ident).collect(); - let arg_types: Vec<_> = - fields.named.iter().map(|field| &field.ty).collect(); - quote! { - #(#docs)* - pub fn #method_name(self, #(#arg_names: impl Into<#arg_types>),*) -> XcmBuilder { - let mut new_instructions = self.instructions; - #(let #arg_names = #arg_names.into();)* - new_instructions.push(#name::::#variant_name { #(#arg_names),* }); - XcmBuilder { - instructions: new_instructions, - state: core::marker::PhantomData, - } + .map(|variant| { + let maybe_builder_attr = variant.attrs.iter().find(|attr| match attr.meta { + Meta::List(ref list) => list.path.is_ident("builder"), + _ => false, + }); + let builder_attr = match maybe_builder_attr { + Some(builder) => builder.clone(), + None => return Ok(None), /* It's not going to be an instruction that pays fees */ + }; + let Meta::List(ref list) = builder_attr.meta else { unreachable!("We checked before") }; + let inner_ident: Ident = syn::parse2(list.tokens.clone()).map_err(|_| { + Error::new_spanned(&builder_attr, "Expected `builder(loads_holding)` or `builder(pays_fees)`") + })?; + let ident_to_match: Ident = syn::parse_quote!(pays_fees); + if inner_ident == ident_to_match { + Ok(Some(variant)) + } else { + Ok(None) // Must have been `loads_holding` instead. + } + }) + .collect::>>()?; + + let pay_fees_methods = pay_fees_variants + .into_iter() + .flatten() + .map(|variant| { + let variant_name = &variant.ident; + let method_name_string = &variant_name.to_string().to_snake_case(); + let method_name = syn::Ident::new(method_name_string, variant_name.span()); + let docs = get_doc_comments(variant); + let fields = match &variant.fields { + Fields::Named(fields) => { + let arg_names: Vec<_> = + fields.named.iter().map(|field| &field.ident).collect(); + let arg_types: Vec<_> = + fields.named.iter().map(|field| &field.ty).collect(); + quote! { + #(#docs)* + pub fn #method_name(self, #(#arg_names: impl Into<#arg_types>),*) -> XcmBuilder { + let mut new_instructions = self.instructions; + #(let #arg_names = #arg_names.into();)* + new_instructions.push(#name::::#variant_name { #(#arg_names),* }); + XcmBuilder { + instructions: new_instructions, + state: core::marker::PhantomData, } } - }, - _ => - return Err(Error::new_spanned( - variant, - "BuyExecution should have named fields", - )), - }; - Ok(fields) - }, - )?; + } + }, + _ => + return Err(Error::new_spanned( + variant, + "Both BuyExecution and PayFees have named fields", + )), + }; + Ok(fields) + }) + .collect::>>()?; let second_impl = quote! { impl XcmBuilder { #(#allowed_after_load_holding_methods)* - #buy_execution_method + #(#pay_fees_methods)* } }; diff --git a/polkadot/xcm/src/v4/mod.rs b/polkadot/xcm/src/v4/mod.rs index 778c02f3a735..68060ed5bf11 100644 --- a/polkadot/xcm/src/v4/mod.rs +++ b/polkadot/xcm/src/v4/mod.rs @@ -1411,6 +1411,7 @@ impl TryFrom> for Instruction { weight_limit, check_origin: check_origin.map(|origin| origin.try_into()).transpose()?, }, + PayFees { asset } => Self::BuyExecution { fees: asset.try_into()?, weight_limit: WeightLimit::Unlimited }, }) } } diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index 4a23507709f5..0fcaa1784392 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -689,6 +689,7 @@ pub enum Instruction { /// Kind: *Command* /// /// Errors: + #[builder(pays_fees)] BuyExecution { fees: Asset, weight_limit: WeightLimit }, /// Refund any surplus weight previously bought with `BuyExecution`. @@ -1037,6 +1038,13 @@ pub enum Instruction { /// /// Errors: If the given origin is `Some` and not equal to the current Origin register. UnpaidExecution { weight_limit: WeightLimit, check_origin: Option }, + + /// Pay Fees. + /// + /// Successor to `BuyExecution`. + /// Defined in fellowship RFC 105. + #[builder(pays_fees)] + PayFees { asset: Asset }, } impl Xcm { @@ -1114,6 +1122,7 @@ impl Instruction { AliasOrigin(location) => AliasOrigin(location), UnpaidExecution { weight_limit, check_origin } => UnpaidExecution { weight_limit, check_origin }, + PayFees { asset } => PayFees { asset }, } } } @@ -1183,6 +1192,7 @@ impl> GetWeight for Instruction { AliasOrigin(location) => W::alias_origin(location), UnpaidExecution { weight_limit, check_origin } => W::unpaid_execution(weight_limit, check_origin), + PayFees { asset } => W::pay_fees(asset), } } } diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 74561e931e7e..c6c591df0e62 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -47,6 +47,9 @@ pub use assets::AssetsInHolding; mod config; pub use config::Config; +#[cfg(test)] +mod tests; + /// A struct to specify how fees are being paid. #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct FeesMode { @@ -83,6 +86,7 @@ pub struct XcmExecutor { appendix_weight: Weight, transact_status: MaybeErrorCode, fees_mode: FeesMode, + fees: AssetsInHolding, _config: PhantomData, } @@ -172,6 +176,12 @@ impl XcmExecutor { pub fn set_fees_mode(&mut self, v: FeesMode) { self.fees_mode = v } + pub fn fees(&self) -> &AssetsInHolding { + self.fees + } + pub fn set_fees(&self, value: AssetsInHolding) { + self.fees = value; + } pub fn topic(&self) -> &Option<[u8; 32]> { &self.context.topic } @@ -319,6 +329,7 @@ impl XcmExecutor { appendix_weight: Weight::zero(), transact_status: Default::default(), fees_mode: FeesMode { jit_withdraw: false }, + fees: AssetsInHolding::new(), _config: PhantomData, } } @@ -982,6 +993,10 @@ impl XcmExecutor { } result }, + PayFees { asset } => { + tracing::trace!(target: "xcm::process_instruction::pay_fees", "PayFees was encountered"); + Ok(()) + }, RefundSurplus => self.refund_surplus(), SetErrorHandler(mut handler) => { let handler_weight = Config::Weigher::weight(&mut handler) diff --git a/polkadot/xcm/xcm-executor/src/tests/mod.rs b/polkadot/xcm/xcm-executor/src/tests/mod.rs new file mode 100644 index 000000000000..0f994d9fcc54 --- /dev/null +++ b/polkadot/xcm/xcm-executor/src/tests/mod.rs @@ -0,0 +1,23 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +//! Unit tests for the XCM executor. +//! +//! These exclude any cross-chain functionality. For those, look at the +//! `xcm-emulator` based tests in the cumulus folder. +//! These tests deal with internal state changes of the XCVM. + +mod pay_fees; diff --git a/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs new file mode 100644 index 000000000000..03d229878771 --- /dev/null +++ b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs @@ -0,0 +1,156 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +//! Unit tests related to the `fees` register and `PayFees` instruction. +//! +//! See [Fellowship RFC 105](https://github.com/polkadot-fellows/rfCs/pull/105) +//! and the [specification](https://github.com/polkadot-fellows/xcm-format) for more information. + +use alloc::collections::btree_map::BTreeMap; +use codec::{Encode, Decode}; +use core::cell::RefCell; +use frame_support::{parameter_types, traits::{Everything, Nothing}, weights::Weight, dispatch::{DispatchResultWithPostInfo, PostDispatchInfo, GetDispatchInfo, DispatchInfo}}; +use sp_runtime::traits::Dispatchable; +use xcm::prelude::*; + +use crate::{AssetsInHolding, traits::{TransactAsset, WeightBounds}, XcmExecutor}; + +#[test] +fn works_for_execution_fees() { + let xcm = Xcm::::builder() + .withdraw_asset((Here, 100u128)) + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .deposit_asset(All, [1; 32]) + .build(); + + let who = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + + let result = XcmExecutor::::prepare_and_execute(who, xcm.clone(), &mut xcm.using_encoded(sp_io::hashing::blake2_256), Weight::MAX, Weight::zero()); + + dbg!(&result); +} + +parameter_types! { + pub const MaxAssetsIntoHolding: u32 = 10; + pub const BaseXcmWeight: Weight = Weight::from_parts(1, 1); + pub const MaxInstructions: u32 = 10; + pub UniversalLocation: InteriorLocation = GlobalConsensus(ByGenesis([0; 32])).into(); +} + +/// Dummy origin. +#[derive(Debug)] +pub struct TestOrigin; + +/// Dummy call. +/// +/// Doesn't dispatch anything, has an empty implementation of [`Dispatchable`] that +/// just returns `Ok` with an empty [`PostDispatchInfo`]. +#[derive(Debug, Encode, Decode, Eq, PartialEq, Clone, Copy, scale_info::TypeInfo)] +pub struct TestCall; +impl Dispatchable for TestCall { + type RuntimeOrigin = TestOrigin; + type Config = (); + type Info = (); + type PostInfo = PostDispatchInfo; + + fn dispatch(self, _origin: Self::RuntimeOrigin) -> DispatchResultWithPostInfo { + Ok(PostDispatchInfo::default()) + } +} +impl GetDispatchInfo for TestCall { + fn get_dispatch_info(&self) -> DispatchInfo { + DispatchInfo::default() + } +} + +pub struct TestWeigher; +impl WeightBounds for TestWeigher { + fn weight(_message: &mut Xcm) -> Result { + Ok(Weight::from_parts(1, 1)) + } + + fn instr_weight(_instruction: &Instruction) -> Result { + Ok(Weight::from_parts(1, 1)) + } +} + +thread_local! { + pub static ASSETS: RefCell> = RefCell::new(BTreeMap::new()); +} + +pub struct TestAssetTransactor; +impl TransactAsset for TestAssetTransactor { + fn deposit_asset( + what: &Asset, + who: &Location, + _context: Option<&XcmContext>, + ) -> Result<(), XcmError> { + ASSETS.with(|a| { + a.borrow_mut() + .entry(who.clone().into()) + .or_insert(AssetsInHolding::new()) + .subsume(what.clone().into()) + }); + Ok(()) + } + + fn withdraw_asset( + what: &Asset, + who: &Location, + _context: Option<&XcmContext>, + ) -> Result { + ASSETS.with(|a| { + a.borrow_mut() + .get_mut(who) + .ok_or(XcmError::NotWithdrawable)? + .try_take(what.clone().into()) + .map_err(|_| XcmError::NotWithdrawable) + }) + } +} + +pub struct XcmConfig; +impl crate::Config for XcmConfig { + type RuntimeCall = TestCall; + type XcmSender = (); + type AssetTransactor = TestAssetTransactor; + type OriginConverter = (); + type IsReserve = (); + type IsTeleporter = (); + type UniversalLocation = UniversalLocation; + type Barrier = (); + type Weigher = TestWeigher; + type Trader = (); + type ResponseHandler = (); + type AssetTrap = (); + type AssetLocker = (); + type AssetExchanger = (); + type AssetClaims = (); + type SubscriptionService = (); + type PalletInstancesInfo = (); + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; + type CallDispatcher = Self::RuntimeCall; + type SafeCallFilter = Everything; + type Aliasers = Nothing; + type TransactionalProcessor = (); + type HrmpNewChannelOpenRequestHandler = (); + type HrmpChannelAcceptedHandler = (); + type HrmpChannelClosingHandler = (); + type XcmRecorder = (); +} From 0a88320a96a1234eac55a2fd8565504649dd380a Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Wed, 21 Aug 2024 18:20:13 +0200 Subject: [PATCH 002/151] chore(xcm-executor): clean up executor unit test and move everything to mock --- .../xcm/procedural/src/builder_pattern.rs | 10 +- polkadot/xcm/src/v4/mod.rs | 3 +- polkadot/xcm/xcm-executor/src/lib.rs | 32 ++- polkadot/xcm/xcm-executor/src/tests/mock.rs | 238 ++++++++++++++++++ polkadot/xcm/xcm-executor/src/tests/mod.rs | 1 + .../xcm/xcm-executor/src/tests/pay_fees.rs | 161 +++--------- 6 files changed, 307 insertions(+), 138 deletions(-) create mode 100644 polkadot/xcm/xcm-executor/src/tests/mock.rs diff --git a/polkadot/xcm/procedural/src/builder_pattern.rs b/polkadot/xcm/procedural/src/builder_pattern.rs index 000b80cf7cf0..b65290332af9 100644 --- a/polkadot/xcm/procedural/src/builder_pattern.rs +++ b/polkadot/xcm/procedural/src/builder_pattern.rs @@ -160,7 +160,10 @@ fn generate_builder_impl(name: &Ident, data_enum: &DataEnum) -> Result Result TryFrom> for Instruction { weight_limit, check_origin: check_origin.map(|origin| origin.try_into()).transpose()?, }, - PayFees { asset } => Self::BuyExecution { fees: asset.try_into()?, weight_limit: WeightLimit::Unlimited }, + PayFees { asset } => + Self::BuyExecution { fees: asset.try_into()?, weight_limit: WeightLimit::Unlimited }, }) } } diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index c6c591df0e62..7daaa3a12664 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -87,10 +87,12 @@ pub struct XcmExecutor { transact_status: MaybeErrorCode, fees_mode: FeesMode, fees: AssetsInHolding, + /// Stores the current message's weight. + message_weight: Weight, _config: PhantomData, } -#[cfg(feature = "runtime-benchmarks")] +#[cfg(any(test, feature = "runtime-benchmarks"))] impl XcmExecutor { pub fn holding(&self) -> &AssetsInHolding { &self.holding @@ -177,9 +179,9 @@ impl XcmExecutor { self.fees_mode = v } pub fn fees(&self) -> &AssetsInHolding { - self.fees + &self.fees } - pub fn set_fees(&self, value: AssetsInHolding) { + pub fn set_fees(&mut self, value: AssetsInHolding) { self.fees = value; } pub fn topic(&self) -> &Option<[u8; 32]> { @@ -256,6 +258,7 @@ impl ExecuteXcm for XcmExecutor XcmExecutor { transact_status: Default::default(), fees_mode: FeesMode { jit_withdraw: false }, fees: AssetsInHolding::new(), + message_weight: Weight::zero(), _config: PhantomData, } } @@ -560,7 +564,7 @@ impl XcmExecutor { assets.into_assets_iter().collect::>().into() } - #[cfg(feature = "runtime-benchmarks")] + #[cfg(any(test, feature = "runtime-benchmarks"))] pub fn bench_process(&mut self, xcm: Xcm) -> Result<(), ExecutorError> { self.process(xcm) } @@ -994,8 +998,24 @@ impl XcmExecutor { result }, PayFees { asset } => { - tracing::trace!(target: "xcm::process_instruction::pay_fees", "PayFees was encountered"); - Ok(()) + // Record old holding in case we need to rollback. + let old_holding = self.holding.clone(); + // The max we're willing to pay for fees is decided by the `asset` operand. + let max_fee = + self.holding.try_take(asset.into()).map_err(|_| XcmError::NotHoldingFees)?; + // Pay for execution fees. + let result = || -> Result<(), XcmError> { + let unspent = + self.trader.buy_weight(self.message_weight, max_fee, &self.context)?; + // Move unspent to the `fees` register. + self.fees.subsume_assets(unspent); + Ok(()) + }(); + if result.is_err() { + // Rollback. + self.holding = old_holding; + } + result }, RefundSurplus => self.refund_surplus(), SetErrorHandler(mut handler) => { diff --git a/polkadot/xcm/xcm-executor/src/tests/mock.rs b/polkadot/xcm/xcm-executor/src/tests/mock.rs new file mode 100644 index 000000000000..1db4feb47d12 --- /dev/null +++ b/polkadot/xcm/xcm-executor/src/tests/mock.rs @@ -0,0 +1,238 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +//! Mock types and XcmConfig for all executor unit tests. + +use alloc::collections::btree_map::BTreeMap; +use codec::{Decode, Encode}; +use core::cell::RefCell; +use frame_support::{ + dispatch::{DispatchInfo, DispatchResultWithPostInfo, GetDispatchInfo, PostDispatchInfo}, + parameter_types, + traits::{Everything, Nothing, ProcessMessageError}, + weights::Weight, +}; +use sp_runtime::traits::Dispatchable; +use xcm::prelude::*; + +use crate::{ + traits::{DropAssets, Properties, ShouldExecute, TransactAsset, WeightBounds, WeightTrader}, + AssetsInHolding, +}; + +parameter_types! { + pub const MaxAssetsIntoHolding: u32 = 10; + pub const BaseXcmWeight: Weight = Weight::from_parts(1, 1); + pub const MaxInstructions: u32 = 10; + pub UniversalLocation: InteriorLocation = GlobalConsensus(ByGenesis([0; 32])).into(); +} + +/// Test origin. +#[derive(Debug)] +pub struct TestOrigin; + +/// Test call. +/// +/// Doesn't dispatch anything, has an empty implementation of [`Dispatchable`] that +/// just returns `Ok` with an empty [`PostDispatchInfo`]. +#[derive(Debug, Encode, Decode, Eq, PartialEq, Clone, Copy, scale_info::TypeInfo)] +pub struct TestCall; +impl Dispatchable for TestCall { + type RuntimeOrigin = TestOrigin; + type Config = (); + type Info = (); + type PostInfo = PostDispatchInfo; + + fn dispatch(self, _origin: Self::RuntimeOrigin) -> DispatchResultWithPostInfo { + Ok(PostDispatchInfo::default()) + } +} +impl GetDispatchInfo for TestCall { + fn get_dispatch_info(&self) -> DispatchInfo { + DispatchInfo::default() + } +} + +/// Test weigher that just returns a fixed weight for every program. +pub struct TestWeigher; +impl WeightBounds for TestWeigher { + fn weight(_message: &mut Xcm) -> Result { + Ok(Weight::from_parts(2, 2)) + } + + fn instr_weight(_instruction: &Instruction) -> Result { + Ok(Weight::from_parts(2, 2)) + } +} + +thread_local! { + pub static ASSETS: RefCell> = RefCell::new(BTreeMap::new()); +} + +pub fn add_asset(who: impl Into, what: impl Into) { + ASSETS.with(|a| { + a.borrow_mut() + .entry(who.into()) + .or_insert(AssetsInHolding::new()) + .subsume(what.into()) + }); +} + +pub fn asset_list(who: impl Into) -> Vec { + Assets::from(assets(who)).into_inner() +} + +pub fn assets(who: impl Into) -> AssetsInHolding { + ASSETS.with(|a| a.borrow().get(&who.into()).cloned()).unwrap_or_default() +} + +pub fn get_first_fungible(assets: &AssetsInHolding) -> Option { + assets.fungible_assets_iter().next() +} + +/// Test asset transactor that withdraws from and deposits to a thread local assets storage. +pub struct TestAssetTransactor; +impl TransactAsset for TestAssetTransactor { + fn deposit_asset( + what: &Asset, + who: &Location, + _context: Option<&XcmContext>, + ) -> Result<(), XcmError> { + add_asset(who.clone(), what.clone()); + Ok(()) + } + + fn withdraw_asset( + what: &Asset, + who: &Location, + _context: Option<&XcmContext>, + ) -> Result { + ASSETS.with(|a| { + a.borrow_mut() + .get_mut(who) + .ok_or(XcmError::NotWithdrawable)? + .try_take(what.clone().into()) + .map_err(|_| XcmError::NotWithdrawable) + }) + } +} + +/// Test barrier that just lets everything through. +pub struct TestBarrier; +impl ShouldExecute for TestBarrier { + fn should_execute( + _origin: &Location, + _instructions: &mut [Instruction], + _max_weight: Weight, + _properties: &mut Properties, + ) -> Result<(), ProcessMessageError> { + Ok(()) + } +} + +/// Test weight to fee that just multiplies `Weight.ref_time` and `Weight.proof_size`. +pub struct WeightToFee; +impl WeightToFee { + pub fn weight_to_fee(weight: &Weight) -> u128 { + weight.ref_time() as u128 * weight.proof_size() as u128 + } +} + +/// Test weight trader that just buys weight with the native asset (`Here`) and +/// uses the test `WeightToFee`. +pub struct TestTrader { + weight_bought_so_far: Weight, +} +impl WeightTrader for TestTrader { + fn new() -> Self { + Self { weight_bought_so_far: Weight::zero() } + } + + fn buy_weight( + &mut self, + weight: Weight, + payment: AssetsInHolding, + _context: &XcmContext, + ) -> Result { + let amount = WeightToFee::weight_to_fee(&weight); + let required: Asset = (Here, amount).into(); + let unused = payment.checked_sub(required).map_err(|_| XcmError::TooExpensive)?; + self.weight_bought_so_far.saturating_add(weight); + Ok(unused) + } + + fn refund_weight(&mut self, weight: Weight, _context: &XcmContext) -> Option { + let weight = weight.min(self.weight_bought_so_far); + let amount = WeightToFee::weight_to_fee(&weight); + self.weight_bought_so_far -= weight; + if amount > 0 { + Some((Here, amount).into()) + } else { + None + } + } +} + +/// Account where all dropped assets are deposited. +pub const VOID_ACCOUNT: [u8; 32] = [255; 32]; + +/// Test asset trap that moves all dropped assets to the `VOID_ACCOUNT` account. +pub struct TestAssetTrap; +impl DropAssets for TestAssetTrap { + fn drop_assets(_origin: &Location, assets: AssetsInHolding, _context: &XcmContext) -> Weight { + ASSETS.with(|a| { + a.borrow_mut() + .entry(VOID_ACCOUNT.into()) + .or_insert(AssetsInHolding::new()) + .subsume_assets(assets) + }); + Weight::zero() + } +} + +/// Test XcmConfig that uses all the test implementations in this file. +pub struct XcmConfig; +impl crate::Config for XcmConfig { + type RuntimeCall = TestCall; + type XcmSender = (); + type AssetTransactor = TestAssetTransactor; + type OriginConverter = (); + type IsReserve = (); + type IsTeleporter = (); + type UniversalLocation = UniversalLocation; + type Barrier = TestBarrier; + type Weigher = TestWeigher; + type Trader = TestTrader; + type ResponseHandler = (); + type AssetTrap = TestAssetTrap; + type AssetLocker = (); + type AssetExchanger = (); + type AssetClaims = (); + type SubscriptionService = (); + type PalletInstancesInfo = (); + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; + type CallDispatcher = Self::RuntimeCall; + type SafeCallFilter = Everything; + type Aliasers = Nothing; + type TransactionalProcessor = (); + type HrmpNewChannelOpenRequestHandler = (); + type HrmpChannelAcceptedHandler = (); + type HrmpChannelClosingHandler = (); + type XcmRecorder = (); +} diff --git a/polkadot/xcm/xcm-executor/src/tests/mod.rs b/polkadot/xcm/xcm-executor/src/tests/mod.rs index 0f994d9fcc54..9892a0277127 100644 --- a/polkadot/xcm/xcm-executor/src/tests/mod.rs +++ b/polkadot/xcm/xcm-executor/src/tests/mod.rs @@ -20,4 +20,5 @@ //! `xcm-emulator` based tests in the cumulus folder. //! These tests deal with internal state changes of the XCVM. +mod mock; mod pay_fees; diff --git a/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs index 03d229878771..c95a436044c3 100644 --- a/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs +++ b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs @@ -19,138 +19,41 @@ //! See [Fellowship RFC 105](https://github.com/polkadot-fellows/rfCs/pull/105) //! and the [specification](https://github.com/polkadot-fellows/xcm-format) for more information. -use alloc::collections::btree_map::BTreeMap; -use codec::{Encode, Decode}; -use core::cell::RefCell; -use frame_support::{parameter_types, traits::{Everything, Nothing}, weights::Weight, dispatch::{DispatchResultWithPostInfo, PostDispatchInfo, GetDispatchInfo, DispatchInfo}}; -use sp_runtime::traits::Dispatchable; +use codec::Encode; use xcm::prelude::*; -use crate::{AssetsInHolding, traits::{TransactAsset, WeightBounds}, XcmExecutor}; +use super::mock::*; +use crate::XcmExecutor; #[test] fn works_for_execution_fees() { - let xcm = Xcm::::builder() - .withdraw_asset((Here, 100u128)) - .pay_fees((Here, 10u128)) // 10% destined for fees, not more. - .deposit_asset(All, [1; 32]) - .build(); - - let who = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); - - let result = XcmExecutor::::prepare_and_execute(who, xcm.clone(), &mut xcm.using_encoded(sp_io::hashing::blake2_256), Weight::MAX, Weight::zero()); - - dbg!(&result); -} - -parameter_types! { - pub const MaxAssetsIntoHolding: u32 = 10; - pub const BaseXcmWeight: Weight = Weight::from_parts(1, 1); - pub const MaxInstructions: u32 = 10; - pub UniversalLocation: InteriorLocation = GlobalConsensus(ByGenesis([0; 32])).into(); -} - -/// Dummy origin. -#[derive(Debug)] -pub struct TestOrigin; - -/// Dummy call. -/// -/// Doesn't dispatch anything, has an empty implementation of [`Dispatchable`] that -/// just returns `Ok` with an empty [`PostDispatchInfo`]. -#[derive(Debug, Encode, Decode, Eq, PartialEq, Clone, Copy, scale_info::TypeInfo)] -pub struct TestCall; -impl Dispatchable for TestCall { - type RuntimeOrigin = TestOrigin; - type Config = (); - type Info = (); - type PostInfo = PostDispatchInfo; - - fn dispatch(self, _origin: Self::RuntimeOrigin) -> DispatchResultWithPostInfo { - Ok(PostDispatchInfo::default()) - } -} -impl GetDispatchInfo for TestCall { - fn get_dispatch_info(&self) -> DispatchInfo { - DispatchInfo::default() - } -} - -pub struct TestWeigher; -impl WeightBounds for TestWeigher { - fn weight(_message: &mut Xcm) -> Result { - Ok(Weight::from_parts(1, 1)) - } - - fn instr_weight(_instruction: &Instruction) -> Result { - Ok(Weight::from_parts(1, 1)) - } -} - -thread_local! { - pub static ASSETS: RefCell> = RefCell::new(BTreeMap::new()); -} - -pub struct TestAssetTransactor; -impl TransactAsset for TestAssetTransactor { - fn deposit_asset( - what: &Asset, - who: &Location, - _context: Option<&XcmContext>, - ) -> Result<(), XcmError> { - ASSETS.with(|a| { - a.borrow_mut() - .entry(who.clone().into()) - .or_insert(AssetsInHolding::new()) - .subsume(what.clone().into()) - }); - Ok(()) - } - - fn withdraw_asset( - what: &Asset, - who: &Location, - _context: Option<&XcmContext>, - ) -> Result { - ASSETS.with(|a| { - a.borrow_mut() - .get_mut(who) - .ok_or(XcmError::NotWithdrawable)? - .try_take(what.clone().into()) - .map_err(|_| XcmError::NotWithdrawable) - }) - } -} - -pub struct XcmConfig; -impl crate::Config for XcmConfig { - type RuntimeCall = TestCall; - type XcmSender = (); - type AssetTransactor = TestAssetTransactor; - type OriginConverter = (); - type IsReserve = (); - type IsTeleporter = (); - type UniversalLocation = UniversalLocation; - type Barrier = (); - type Weigher = TestWeigher; - type Trader = (); - type ResponseHandler = (); - type AssetTrap = (); - type AssetLocker = (); - type AssetExchanger = (); - type AssetClaims = (); - type SubscriptionService = (); - type PalletInstancesInfo = (); - type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type FeeManager = (); - type MessageExporter = (); - type UniversalAliases = Nothing; - type CallDispatcher = Self::RuntimeCall; - type SafeCallFilter = Everything; - type Aliasers = Nothing; - type TransactionalProcessor = (); - type HrmpNewChannelOpenRequestHandler = (); - type HrmpChannelAcceptedHandler = (); - type HrmpChannelClosingHandler = (); - type XcmRecorder = (); + let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + let recipient = Location::new(0, [AccountId32 { id: [1; 32], network: None }]); + + // Make sure the user has enough funds to withdraw. + add_asset(sender.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder() + .withdraw_asset((Here, 100u128)) + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .deposit_asset(All, recipient.clone()) + .build(); + + // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we + // can inspect its fields. + let mut vm = + XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + + let result = vm.bench_process(xcm); + assert!(result.is_ok()); + + assert_eq!(get_first_fungible(vm.holding()), None); + // Execution fees were 4, so we still have 6 left in the `fees` register. + assert_eq!(get_first_fungible(vm.fees()).unwrap(), (Here, 6u128).into()); + + // The recipient received all the assets in the holding register, so `100` that + // were withdrawn minus the `10` that were destinated for fee payment. + assert_eq!(asset_list(recipient), [(Here, 90u128).into()]); } From 2393087c881f59fb15e5bfeaa4e333c3229c46b2 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Wed, 21 Aug 2024 19:35:47 +0200 Subject: [PATCH 003/151] feat(xcm-executor): tests for delivery fees and old BuyExecution --- polkadot/xcm/xcm-executor/src/lib.rs | 10 +- polkadot/xcm/xcm-executor/src/tests/mock.rs | 39 ++++++- .../xcm/xcm-executor/src/tests/pay_fees.rs | 102 +++++++++++++++--- 3 files changed, 130 insertions(+), 21 deletions(-) diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 7daaa3a12664..4397e201330a 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -503,7 +503,15 @@ impl XcmExecutor { } fee } else { - self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?.into() + // This condition exists to support `BuyExecution` while the ecosystem + // transitions to `PayFees`. + if self.fees.is_empty() { + // Means `BuyExecution` was used, we'll find the fees in the `holding` register. + self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?.into() + } else { + // Means `PayFees` was used, we'll find the fees in the `fees` register. + self.fees.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?.into() + } }; Config::FeeManager::handle_fee(paid, Some(&self.context), reason); Ok(()) diff --git a/polkadot/xcm/xcm-executor/src/tests/mock.rs b/polkadot/xcm/xcm-executor/src/tests/mock.rs index 1db4feb47d12..1ea6147aa717 100644 --- a/polkadot/xcm/xcm-executor/src/tests/mock.rs +++ b/polkadot/xcm/xcm-executor/src/tests/mock.rs @@ -30,9 +30,21 @@ use xcm::prelude::*; use crate::{ traits::{DropAssets, Properties, ShouldExecute, TransactAsset, WeightBounds, WeightTrader}, - AssetsInHolding, + AssetsInHolding, Config, XcmExecutor, }; +/// We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we +/// can inspect its fields. +pub fn instantiate_executor( + origin: impl Into, + message: Xcm<::RuntimeCall>, +) -> XcmExecutor { + let mut vm = + XcmExecutor::::new(origin, message.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(message.clone()).unwrap().weight_of(); + vm +} + parameter_types! { pub const MaxAssetsIntoHolding: u32 = 10; pub const BaseXcmWeight: Weight = Weight::from_parts(1, 1); @@ -203,11 +215,32 @@ impl DropAssets for TestAssetTrap { } } +/// Test sender that always succeeds but doesn't actually send anything. +/// +/// It does charge `1` for the delivery fee. +pub struct TestSender; +impl SendXcm for TestSender { + type Ticket = (); + + fn validate( + _destination: &mut Option, + _message: &mut Option>, + ) -> SendResult { + let ticket = (); + let delivery_fee: Asset = (Here, 1u128).into(); + Ok((ticket, delivery_fee.into())) + } + + fn deliver(_ticket: Self::Ticket) -> Result { + Ok([0; 32]) + } +} + /// Test XcmConfig that uses all the test implementations in this file. pub struct XcmConfig; -impl crate::Config for XcmConfig { +impl Config for XcmConfig { type RuntimeCall = TestCall; - type XcmSender = (); + type XcmSender = TestSender; type AssetTransactor = TestAssetTransactor; type OriginConverter = (); type IsReserve = (); diff --git a/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs index c95a436044c3..b2f43018c610 100644 --- a/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs +++ b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs @@ -19,41 +19,109 @@ //! See [Fellowship RFC 105](https://github.com/polkadot-fellows/rfCs/pull/105) //! and the [specification](https://github.com/polkadot-fellows/xcm-format) for more information. -use codec::Encode; use xcm::prelude::*; use super::mock::*; -use crate::XcmExecutor; +// The sender and recipient we use across these tests. +const SENDER: [u8; 32] = [0; 32]; +const RECIPIENT: [u8; 32] = [1; 32]; + +// This is a sort of backwards compatibility test. +// Since `PayFees` is a replacement for `BuyExecution`, we need to make sure it at least +// manages to do the same thing, paying for execution fees. #[test] fn works_for_execution_fees() { - let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); - let recipient = Location::new(0, [AccountId32 { id: [1; 32], network: None }]); - - // Make sure the user has enough funds to withdraw. - add_asset(sender.clone(), (Here, 100u128)); + // Make sure the sender has enough funds to withdraw. + add_asset(SENDER.clone(), (Here, 100u128)); // Build xcm. let xcm = Xcm::::builder() .withdraw_asset((Here, 100u128)) .pay_fees((Here, 10u128)) // 10% destined for fees, not more. - .deposit_asset(All, recipient.clone()) + .deposit_asset(All, RECIPIENT.clone()) .build(); - // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we - // can inspect its fields. - let mut vm = - XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); - vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + let mut vm = instantiate_executor(SENDER, xcm.clone()); - let result = vm.bench_process(xcm); - assert!(result.is_ok()); + // Program runs successfully. + assert!(vm.bench_process(xcm).is_ok()); + // Nothing is left in the `holding` register. assert_eq!(get_first_fungible(vm.holding()), None); // Execution fees were 4, so we still have 6 left in the `fees` register. assert_eq!(get_first_fungible(vm.fees()).unwrap(), (Here, 6u128).into()); // The recipient received all the assets in the holding register, so `100` that - // were withdrawn minus the `10` that were destinated for fee payment. - assert_eq!(asset_list(recipient), [(Here, 90u128).into()]); + // were withdrawn, minus the `10` that were destinated for fee payment. + assert_eq!(asset_list(RECIPIENT), [(Here, 90u128).into()]); +} + +// This tests the new functionality provided by `PayFees`, being able to pay for +// delivery fees from the `fees` register. +#[test] +fn works_for_delivery_fees() { + // Make sure the sender has enough funds to withdraw. + add_asset(SENDER.clone(), (Here, 100u128)); + + // Information to send messages. + // We don't care about the specifics since we're not actually sending them. + let query_response_info = + QueryResponseInfo { destination: Parent.into(), query_id: 0, max_weight: Weight::zero() }; + + // Build xcm. + let xcm = Xcm::::builder() + .withdraw_asset((Here, 100u128)) + .pay_fees((Here, 10u128)) + // Send a bunch of messages, each charging delivery fees. + .report_error(query_response_info.clone()) + .report_error(query_response_info.clone()) + .report_error(query_response_info) + .deposit_asset(All, RECIPIENT.clone()) + .build(); + + let mut vm = instantiate_executor(SENDER, xcm.clone()); + + // Program runs successfully. + assert!(vm.bench_process(xcm).is_ok()); + + // Nothing is left in the `holding` register. + assert_eq!(get_first_fungible(vm.holding()), None); + // Execution fees were 4, delivery were 3, so we are left with only 3 in the `fees` register. + assert_eq!(get_first_fungible(vm.fees()).unwrap(), (Here, 3u128).into()); + + // The recipient received all the assets in the holding register, so `100` that + // were withdrawn, minus the `10` that were destinated for fee payment. + assert_eq!(asset_list(RECIPIENT), [(Here, 90u128).into()]); +} + +// Tests the support for `BuyExecution` while the ecosystem transitions to `PayFees`. +#[test] +fn buy_execution_works_as_before() { + // Make sure the sender has enough funds to withdraw. + add_asset(SENDER.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder() + .withdraw_asset((Here, 100u128)) + // We can put everything here, since excess will be returned to holding. + // We have to specify `Limited` here to actually work, it's normally + // set in the `AllowTopLevelPaidExecutionFrom` barrier. + .buy_execution((Here, 100u128), Limited(Weight::from_parts(2, 2))) + .deposit_asset(All, RECIPIENT.clone()) + .build(); + + let mut vm = instantiate_executor(SENDER, xcm.clone()); + + // Program runs successfully. + assert!(vm.bench_process(xcm).is_ok()); + + // Nothing is left in the `holding` register. + assert_eq!(get_first_fungible(vm.holding()), None); + // `BuyExecution` does not interact with the `fees` register. + assert_eq!(get_first_fungible(vm.fees()), None); + + // The recipient received all the assets in the holding register, so `100` that + // were withdrawn, minus the `4` from paying the execution fees. + assert_eq!(asset_list(RECIPIENT), [(Here, 96u128).into()]); } From b9ca9e0314878b94623f02f242395f23ffdf283d Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Wed, 21 Aug 2024 19:44:35 +0200 Subject: [PATCH 004/151] feat(xcm-executor): interaction between PayFees and RefundSurplus --- polkadot/xcm/xcm-executor/src/lib.rs | 5 +++ .../xcm/xcm-executor/src/tests/pay_fees.rs | 35 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 4397e201330a..2f84662e6bc5 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -477,6 +477,11 @@ impl XcmExecutor { self.holding.subsume_assets(w.into()); } } + // If there are any leftover `fees`, merge them with `holding`. + if !self.fees.is_empty() { + let leftover_fees = self.fees.saturating_take(Wild(All)); + self.holding.subsume_assets(leftover_fees); + } tracing::trace!( target: "xcm::refund_surplus", total_refunded = ?self.total_refunded, diff --git a/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs index b2f43018c610..3c73badf7de1 100644 --- a/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs +++ b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs @@ -27,6 +27,8 @@ use super::mock::*; const SENDER: [u8; 32] = [0; 32]; const RECIPIENT: [u8; 32] = [1; 32]; +// ===== Happy path ===== + // This is a sort of backwards compatibility test. // Since `PayFees` is a replacement for `BuyExecution`, we need to make sure it at least // manages to do the same thing, paying for execution fees. @@ -125,3 +127,36 @@ fn buy_execution_works_as_before() { // were withdrawn, minus the `4` from paying the execution fees. assert_eq!(asset_list(RECIPIENT), [(Here, 96u128).into()]); } + +// Tests the interaction between `PayFees` and `RefundSurplus`. +#[test] +fn fees_can_be_refunded() { + // Make sure the sender has enough funds to withdraw. + add_asset(SENDER.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder() + .withdraw_asset((Here, 100u128)) + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .deposit_asset(All, RECIPIENT.clone()) + .refund_surplus() + .deposit_asset(All, SENDER.clone()) + .build(); + + let mut vm = instantiate_executor(SENDER.clone(), xcm.clone()); + + // Program runs successfully. + assert!(vm.bench_process(xcm).is_ok()); + + // Nothing is left in the `holding` register. + assert_eq!(get_first_fungible(vm.holding()), None); + // Nothing was left in the `fees` register since it was refunded. + assert_eq!(get_first_fungible(vm.fees()), None); + + // The recipient received all the assets in the holding register, so `100` that + // were withdrawn, minus the `10` that were destinated for fee payment. + assert_eq!(asset_list(RECIPIENT), [(Here, 90u128).into()]); + + // The sender got back `6` from unused assets. + assert_eq!(asset_list(SENDER), [(Here, 6u128).into()]); +} From 22efce593c727e76f492c0d107e28621ce389863 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Wed, 21 Aug 2024 19:46:57 +0200 Subject: [PATCH 005/151] fix(xcm): add builder(pays_fees) to old xcm versions --- polkadot/xcm/src/v3/mod.rs | 1 + polkadot/xcm/src/v4/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/polkadot/xcm/src/v3/mod.rs b/polkadot/xcm/src/v3/mod.rs index b6b21846e5e5..576ec8accb68 100644 --- a/polkadot/xcm/src/v3/mod.rs +++ b/polkadot/xcm/src/v3/mod.rs @@ -792,6 +792,7 @@ pub enum Instruction { /// Kind: *Command* /// /// Errors: + #[builder(pays_fees)] BuyExecution { fees: MultiAsset, weight_limit: WeightLimit }, /// Refund any surplus weight previously bought with `BuyExecution`. diff --git a/polkadot/xcm/src/v4/mod.rs b/polkadot/xcm/src/v4/mod.rs index 8152567b9d26..43629d8f5951 100644 --- a/polkadot/xcm/src/v4/mod.rs +++ b/polkadot/xcm/src/v4/mod.rs @@ -750,6 +750,7 @@ pub enum Instruction { /// Kind: *Command* /// /// Errors: + #[builder(pays_fees)] BuyExecution { fees: Asset, weight_limit: WeightLimit }, /// Refund any surplus weight previously bought with `BuyExecution`. From 49f63a4f48d11cc8b496052d91086377c932f464 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Wed, 21 Aug 2024 20:26:49 +0200 Subject: [PATCH 006/151] chore(xcm-executor): unhappy tests for PayFees --- polkadot/xcm/xcm-executor/src/tests/mock.rs | 21 ++-- .../xcm/xcm-executor/src/tests/pay_fees.rs | 96 ++++++++++++++++++- 2 files changed, 109 insertions(+), 8 deletions(-) diff --git a/polkadot/xcm/xcm-executor/src/tests/mock.rs b/polkadot/xcm/xcm-executor/src/tests/mock.rs index 1ea6147aa717..a777541ac5ae 100644 --- a/polkadot/xcm/xcm-executor/src/tests/mock.rs +++ b/polkadot/xcm/xcm-executor/src/tests/mock.rs @@ -92,6 +92,7 @@ impl WeightBounds for TestWeigher { thread_local! { pub static ASSETS: RefCell> = RefCell::new(BTreeMap::new()); + pub static SENT_XCM: RefCell)>> = RefCell::new(Vec::new()); } pub fn add_asset(who: impl Into, what: impl Into) { @@ -215,27 +216,33 @@ impl DropAssets for TestAssetTrap { } } -/// Test sender that always succeeds but doesn't actually send anything. +/// Test sender that always succeeds and puts messages in a dummy queue. /// -/// It does charge `1` for the delivery fee. +/// It charges `1` for the delivery fee. pub struct TestSender; impl SendXcm for TestSender { - type Ticket = (); + type Ticket = (Location, Xcm<()>); fn validate( - _destination: &mut Option, - _message: &mut Option>, + destination: &mut Option, + message: &mut Option>, ) -> SendResult { - let ticket = (); + let ticket = (destination.take().unwrap(), message.take().unwrap()); let delivery_fee: Asset = (Here, 1u128).into(); Ok((ticket, delivery_fee.into())) } - fn deliver(_ticket: Self::Ticket) -> Result { + fn deliver(ticket: Self::Ticket) -> Result { + SENT_XCM.with(|q| q.borrow_mut().push(ticket)); Ok([0; 32]) } } +/// Gets queued test messages. +pub fn sent_xcm() -> Vec<(Location, Xcm<()>)> { + SENT_XCM.with(|q| (*q.borrow()).clone()) +} + /// Test XcmConfig that uses all the test implementations in this file. pub struct XcmConfig; impl Config for XcmConfig { diff --git a/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs index 3c73badf7de1..e8e83191ff86 100644 --- a/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs +++ b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs @@ -82,7 +82,7 @@ fn works_for_delivery_fees() { .deposit_asset(All, RECIPIENT.clone()) .build(); - let mut vm = instantiate_executor(SENDER, xcm.clone()); + let mut vm = instantiate_executor(SENDER.clone(), xcm.clone()); // Program runs successfully. assert!(vm.bench_process(xcm).is_ok()); @@ -95,6 +95,28 @@ fn works_for_delivery_fees() { // The recipient received all the assets in the holding register, so `100` that // were withdrawn, minus the `10` that were destinated for fee payment. assert_eq!(asset_list(RECIPIENT), [(Here, 90u128).into()]); + + let querier: Location = ( + UniversalLocation::get().take_first().unwrap(), + AccountId32 { id: SENDER.into(), network: None }, + ) + .into(); + let sent_message = Xcm(vec![QueryResponse { + query_id: 0, + response: Response::ExecutionResult(None), + max_weight: Weight::zero(), + querier: Some(querier), + }]); + + // The messages were "sent" successfully. + assert_eq!( + sent_xcm(), + vec![ + (Parent.into(), sent_message.clone()), + (Parent.into(), sent_message.clone()), + (Parent.into(), sent_message.clone()) + ] + ); } // Tests the support for `BuyExecution` while the ecosystem transitions to `PayFees`. @@ -160,3 +182,75 @@ fn fees_can_be_refunded() { // The sender got back `6` from unused assets. assert_eq!(asset_list(SENDER), [(Here, 6u128).into()]); } + +// ===== Unhappy path ===== + +#[test] +fn putting_all_assets_in_pay_fees() { + // Make sure the sender has enough funds to withdraw. + add_asset(SENDER.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder() + .withdraw_asset((Here, 100u128)) + .pay_fees((Here, 100u128)) // 100% destined for fees, this is not going to end well... + .deposit_asset(All, RECIPIENT.clone()) + .build(); + + let mut vm = instantiate_executor(SENDER.clone(), xcm.clone()); + + // Program runs successfully. + assert!(vm.bench_process(xcm).is_ok()); + + // Nothing is left in the `holding` register. + assert_eq!(get_first_fungible(vm.holding()), None); + // We destined `100` for fee payment, after `4` for execution fees, we are left with `96`. + assert_eq!(get_first_fungible(vm.fees()).unwrap(), (Here, 96u128).into()); + + // The recipient received no assets since they were all destined for fee payment. + assert_eq!(asset_list(RECIPIENT), []); +} + +#[test] +fn refunding_too_early() { + // Make sure the sender has enough funds to withdraw. + add_asset(SENDER.clone(), (Here, 100u128)); + + // Information to send messages. + // We don't care about the specifics since we're not actually sending them. + let query_response_info = + QueryResponseInfo { destination: Parent.into(), query_id: 0, max_weight: Weight::zero() }; + + // Build xcm. + let xcm = Xcm::::builder() + .withdraw_asset((Here, 100u128)) + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .deposit_asset(All, RECIPIENT.clone()) + .refund_surplus() + .deposit_asset(All, SENDER.clone()) + // `refund_surplus` cleared the `fees` register. + // `holding` is used as a fallback, but we also cleared that. + // The instruction will error and the message won't be sent :(. + .report_error(query_response_info) + .build(); + + let mut vm = instantiate_executor(SENDER.clone(), xcm.clone()); + + // Program fails to run. + assert!(vm.bench_process(xcm).is_err()); + + // Nothing is left in the `holding` register. + assert_eq!(get_first_fungible(vm.holding()), None); + // Nothing was left in the `fees` register since it was refunded. + assert_eq!(get_first_fungible(vm.fees()), None); + + // The recipient received all the assets in the holding register, so `100` that + // were withdrawn, minus the `10` that were destinated for fee payment. + assert_eq!(asset_list(RECIPIENT), [(Here, 90u128).into()]); + + // The sender got back `6` from unused assets. + assert_eq!(asset_list(SENDER), [(Here, 6u128).into()]); + + // No messages were "sent". + assert_eq!(sent_xcm(), Vec::new()); +} From 50b06d652aefd22b628c20d3019b0167c0240091 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Fri, 23 Aug 2024 17:09:27 +0200 Subject: [PATCH 007/151] chore(xcm-executor): test that leftover fees are also trapped --- polkadot/xcm/xcm-executor/src/lib.rs | 5 +++++ polkadot/xcm/xcm-executor/src/tests/mock.rs | 13 +++++++------ polkadot/xcm/xcm-executor/src/tests/pay_fees.rs | 16 ++++++++++------ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 2f84662e6bc5..f3acca51a713 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -582,6 +582,11 @@ impl XcmExecutor { self.process(xcm) } + #[cfg(any(test, feature = "runtime-benchmarks"))] + pub fn bench_post_process(self, xcm_weight: Weight) -> Outcome { + self.post_process(xcm_weight) + } + fn process(&mut self, xcm: Xcm) -> Result<(), ExecutorError> { tracing::trace!( target: "xcm::process", diff --git a/polkadot/xcm/xcm-executor/src/tests/mock.rs b/polkadot/xcm/xcm-executor/src/tests/mock.rs index a777541ac5ae..cd612879d205 100644 --- a/polkadot/xcm/xcm-executor/src/tests/mock.rs +++ b/polkadot/xcm/xcm-executor/src/tests/mock.rs @@ -38,11 +38,12 @@ use crate::{ pub fn instantiate_executor( origin: impl Into, message: Xcm<::RuntimeCall>, -) -> XcmExecutor { +) -> (XcmExecutor, Weight) { let mut vm = XcmExecutor::::new(origin, message.using_encoded(sp_io::hashing::blake2_256)); - vm.message_weight = XcmExecutor::::prepare(message.clone()).unwrap().weight_of(); - vm + let weight = XcmExecutor::::prepare(message.clone()).unwrap().weight_of(); + vm.message_weight = weight; + (vm, weight) } parameter_types! { @@ -200,15 +201,15 @@ impl WeightTrader for TestTrader { } /// Account where all dropped assets are deposited. -pub const VOID_ACCOUNT: [u8; 32] = [255; 32]; +pub const TRAPPED_ASSETS: [u8; 32] = [255; 32]; -/// Test asset trap that moves all dropped assets to the `VOID_ACCOUNT` account. +/// Test asset trap that moves all dropped assets to the `TRAPPED_ASSETS` account. pub struct TestAssetTrap; impl DropAssets for TestAssetTrap { fn drop_assets(_origin: &Location, assets: AssetsInHolding, _context: &XcmContext) -> Weight { ASSETS.with(|a| { a.borrow_mut() - .entry(VOID_ACCOUNT.into()) + .entry(TRAPPED_ASSETS.into()) .or_insert(AssetsInHolding::new()) .subsume_assets(assets) }); diff --git a/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs index e8e83191ff86..96ec5b43d0c8 100644 --- a/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs +++ b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs @@ -44,7 +44,7 @@ fn works_for_execution_fees() { .deposit_asset(All, RECIPIENT.clone()) .build(); - let mut vm = instantiate_executor(SENDER, xcm.clone()); + let (mut vm, weight) = instantiate_executor(SENDER, xcm.clone()); // Program runs successfully. assert!(vm.bench_process(xcm).is_ok()); @@ -57,6 +57,10 @@ fn works_for_execution_fees() { // The recipient received all the assets in the holding register, so `100` that // were withdrawn, minus the `10` that were destinated for fee payment. assert_eq!(asset_list(RECIPIENT), [(Here, 90u128).into()]); + + // Leftover fees get trapped. + assert!(vm.bench_post_process(weight).ensure_complete().is_ok()); + assert_eq!(asset_list(TRAPPED_ASSETS), [(Here, 6u128).into()]) } // This tests the new functionality provided by `PayFees`, being able to pay for @@ -82,7 +86,7 @@ fn works_for_delivery_fees() { .deposit_asset(All, RECIPIENT.clone()) .build(); - let mut vm = instantiate_executor(SENDER.clone(), xcm.clone()); + let (mut vm, _) = instantiate_executor(SENDER.clone(), xcm.clone()); // Program runs successfully. assert!(vm.bench_process(xcm).is_ok()); @@ -135,7 +139,7 @@ fn buy_execution_works_as_before() { .deposit_asset(All, RECIPIENT.clone()) .build(); - let mut vm = instantiate_executor(SENDER, xcm.clone()); + let (mut vm, _) = instantiate_executor(SENDER, xcm.clone()); // Program runs successfully. assert!(vm.bench_process(xcm).is_ok()); @@ -165,7 +169,7 @@ fn fees_can_be_refunded() { .deposit_asset(All, SENDER.clone()) .build(); - let mut vm = instantiate_executor(SENDER.clone(), xcm.clone()); + let (mut vm, _) = instantiate_executor(SENDER.clone(), xcm.clone()); // Program runs successfully. assert!(vm.bench_process(xcm).is_ok()); @@ -197,7 +201,7 @@ fn putting_all_assets_in_pay_fees() { .deposit_asset(All, RECIPIENT.clone()) .build(); - let mut vm = instantiate_executor(SENDER.clone(), xcm.clone()); + let (mut vm, _) = instantiate_executor(SENDER.clone(), xcm.clone()); // Program runs successfully. assert!(vm.bench_process(xcm).is_ok()); @@ -234,7 +238,7 @@ fn refunding_too_early() { .report_error(query_response_info) .build(); - let mut vm = instantiate_executor(SENDER.clone(), xcm.clone()); + let (mut vm, _) = instantiate_executor(SENDER.clone(), xcm.clone()); // Program fails to run. assert!(vm.bench_process(xcm).is_err()); From 738a8c182d0661ff79a7a88e4e5f3aefdeb578a3 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Mon, 26 Aug 2024 19:48:17 +0200 Subject: [PATCH 008/151] chore: add made-up benchmarks to all runtimes --- .../assets/asset-hub-rococo/src/weights/xcm/mod.rs | 3 +++ .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../assets/asset-hub-westend/src/weights/xcm/mod.rs | 3 +++ .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs | 3 +++ .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs | 3 +++ .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../coretime/coretime-rococo/src/weights/xcm/mod.rs | 3 +++ .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../coretime/coretime-westend/src/weights/xcm/mod.rs | 3 +++ .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../runtimes/people/people-rococo/src/weights/xcm/mod.rs | 3 +++ .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../runtimes/people/people-westend/src/weights/xcm/mod.rs | 3 +++ .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ polkadot/runtime/rococo/src/weights/xcm/mod.rs | 3 +++ .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ polkadot/runtime/westend/src/weights/xcm/mod.rs | 3 +++ .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ 20 files changed, 100 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index 8c52ecd9f1b1..19a10ba370bb 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -138,6 +138,9 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight { XcmGeneric::::buy_execution() } + fn pay_fees(_asset: &Asset) -> Weight { + XcmGeneric::::pay_fees() + } fn refund_surplus() -> Weight { XcmGeneric::::refund_surplus() } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index bee6bcdf21cf..cd113c69a72a 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -80,6 +80,13 @@ impl WeightInfo { // Minimum execution time: 3_313_000 picoseconds. Weight::from_parts(3_422_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index d39052c5c03b..478113359a7e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -138,6 +138,9 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight { XcmGeneric::::buy_execution() } + fn pay_fees(_asset: &Asset) -> Weight { + XcmGeneric::::pay_fees() + } fn refund_surplus() -> Weight { XcmGeneric::::refund_surplus() } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 127bc173c103..18517cf38822 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -79,6 +79,13 @@ impl WeightInfo { // Minimum execution time: 3_193_000 picoseconds. Weight::from_parts(3_620_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_193_000 picoseconds. + Weight::from_parts(27_000_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs index b40cbfeeb8f2..bc1c9980e140 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs @@ -139,6 +139,9 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight { fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight { XcmGeneric::::buy_execution() } + fn pay_fees(_asset: &Asset) -> Weight { + XcmGeneric::::pay_fees() + } fn refund_surplus() -> Weight { XcmGeneric::::refund_surplus() } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 9c58072d402c..b837fe961fa6 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -80,6 +80,13 @@ impl WeightInfo { // Minimum execution time: 998_000 picoseconds. Weight::from_parts(1_038_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index 3961cc6d5cdd..35abce1083d9 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -140,6 +140,9 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight { XcmGeneric::::buy_execution() } + fn pay_fees(_asset: &Asset) -> Weight { + XcmGeneric::::pay_fees() + } fn refund_surplus() -> Weight { XcmGeneric::::refund_surplus() } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index ba434ff29629..8bd6719bda8e 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -80,6 +80,13 @@ impl WeightInfo { // Minimum execution time: 510_000 picoseconds. Weight::from_parts(569_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 510_000 picoseconds. + Weight::from_parts(27_000_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs index b8db473f1066..9983aaf4c0ed 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs @@ -138,6 +138,9 @@ impl XcmWeightInfo for CoretimeRococoXcmWeight { fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight { XcmGeneric::::buy_execution() } + fn pay_fees(_asset: &Asset) -> Weight { + XcmGeneric::::pay_fees() + } fn refund_surplus() -> Weight { XcmGeneric::::refund_surplus() } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 676048f92ad9..bd857e114d1b 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -76,6 +76,13 @@ impl WeightInfo { // Minimum execution time: 522_000 picoseconds. Weight::from_parts(546_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs index f35f7bfc188d..24787079e4c0 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs @@ -138,6 +138,9 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight { XcmGeneric::::buy_execution() } + fn pay_fees(_asset: &Asset) -> Weight { + XcmGeneric::::pay_fees() + } fn refund_surplus() -> Weight { XcmGeneric::::refund_surplus() } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 7390f35e3974..6ac74f7316ec 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -76,6 +76,13 @@ impl WeightInfo { // Minimum execution time: 569_000 picoseconds. Weight::from_parts(619_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 569_000 picoseconds. + Weight::from_parts(27_000_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs index 58007173ae1d..09e3b3732206 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs @@ -137,6 +137,9 @@ impl XcmWeightInfo for PeopleRococoXcmWeight { fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight { XcmGeneric::::buy_execution() } + fn pay_fees(_asset: &Asset) -> Weight { + XcmGeneric::::pay_fees() + } fn refund_surplus() -> Weight { XcmGeneric::::refund_surplus() } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 729a32117041..587035c6a705 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -76,6 +76,13 @@ impl WeightInfo { // Minimum execution time: 607_000 picoseconds. Weight::from_parts(672_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs index b44e8d4b61b8..3f0bda0f4f57 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs @@ -137,6 +137,9 @@ impl XcmWeightInfo for PeopleWestendXcmWeight { fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight { XcmGeneric::::buy_execution() } + fn pay_fees(_asset: &Asset) -> Weight { + XcmGeneric::::pay_fees() + } fn refund_surplus() -> Weight { XcmGeneric::::refund_surplus() } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 1377d31f2db7..37a111652bf4 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -76,6 +76,13 @@ impl WeightInfo { // Minimum execution time: 683_000 picoseconds. Weight::from_parts(738_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 683_000 picoseconds. + Weight::from_parts(27_000_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/polkadot/runtime/rococo/src/weights/xcm/mod.rs b/polkadot/runtime/rococo/src/weights/xcm/mod.rs index bd2b0fbb8c06..0c4b7e7c1596 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/mod.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/mod.rs @@ -169,6 +169,9 @@ impl XcmWeightInfo for RococoXcmWeight { fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight { XcmGeneric::::buy_execution() } + fn pay_fees(_asset: &Asset) -> Weight { + XcmGeneric::::pay_fees() + } fn refund_surplus() -> Weight { XcmGeneric::::refund_surplus() } diff --git a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index df2f9b2d0e8d..754b074d55dc 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -82,6 +82,13 @@ impl WeightInfo { // Minimum execution time: 2_831_000 picoseconds. Weight::from_parts(2_904_000, 0) } + pub(crate) fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_831_000 picoseconds. + Weight::from_parts(27_000_000, 0) + } /// Storage: XcmPallet Queries (r:1 w:0) /// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured) pub(crate) fn query_response() -> Weight { diff --git a/polkadot/runtime/westend/src/weights/xcm/mod.rs b/polkadot/runtime/westend/src/weights/xcm/mod.rs index cb5894ea51e3..8035439e8892 100644 --- a/polkadot/runtime/westend/src/weights/xcm/mod.rs +++ b/polkadot/runtime/westend/src/weights/xcm/mod.rs @@ -172,6 +172,9 @@ impl XcmWeightInfo for WestendXcmWeight { fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight { XcmGeneric::::buy_execution() } + fn pay_fees(_asset: &Asset) -> Weight { + XcmGeneric::::pay_fees() + } fn refund_surplus() -> Weight { XcmGeneric::::refund_surplus() } diff --git a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 49beb85c2784..dc071ebaff0a 100644 --- a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -79,6 +79,13 @@ impl WeightInfo { // Minimum execution time: 2_741_000 picoseconds. Weight::from_parts(2_823_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_193_000 picoseconds. + Weight::from_parts(27_000_000, 0) + } /// Storage: XcmPallet Queries (r:1 w:0) /// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured) pub(crate) fn query_response() -> Weight { From 995cc09daa28e9939975bb3e43142a6028dbe511 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Mon, 26 Aug 2024 19:49:20 +0200 Subject: [PATCH 009/151] feat(xcm-builder): allow PayFees in AllowTopLevelPaidExecutionFrom barrier --- polkadot/xcm/xcm-builder/src/barriers.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/polkadot/xcm/xcm-builder/src/barriers.rs b/polkadot/xcm/xcm-builder/src/barriers.rs index 5d95005eb663..ea83820f6203 100644 --- a/polkadot/xcm/xcm-builder/src/barriers.rs +++ b/polkadot/xcm/xcm-builder/src/barriers.rs @@ -104,6 +104,7 @@ impl> ShouldExecute for AllowTopLevelPaidExecutionFrom *weight_limit = Limited(max_weight); Ok(()) }, + PayFees { .. } => Ok(()), _ => Err(ProcessMessageError::Overweight(max_weight)), })?; Ok(()) From 679c3c7543a8229c12d02c9394234efbb8a9b95e Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Mon, 26 Aug 2024 19:50:06 +0200 Subject: [PATCH 010/151] feat(xcm-executor): use fees register in DepositReserveAsset --- polkadot/xcm/xcm-executor/src/lib.rs | 37 ++++++++++++++++------------ 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index f3acca51a713..613daf885c14 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -901,20 +901,23 @@ impl XcmExecutor { DepositReserveAsset { assets, dest, xcm } => { let old_holding = self.holding.clone(); let result = Config::TransactionalProcessor::process(|| { - // we need to do this take/put cycle to solve wildcards and get exact assets to - // be weighed - let to_weigh = self.holding.saturating_take(assets.clone()); - self.holding.subsume_assets(to_weigh.clone()); - let to_weigh_reanchored = Self::reanchored(to_weigh, &dest, None); - let mut message_to_weigh = - vec![ReserveAssetDeposited(to_weigh_reanchored), ClearOrigin]; - message_to_weigh.extend(xcm.0.clone().into_iter()); - let (_, fee) = - validate_send::(dest.clone(), Xcm(message_to_weigh))?; - // set aside fee to be charged by XcmSender - let transport_fee = self.holding.saturating_take(fee.into()); - - // now take assets to deposit (excluding transport_fee) + let maybe_parked_fee = if self.fees.is_empty() { + // we need to do this take/put cycle to solve wildcards and get exact assets to + // be weighed + let to_weigh = self.holding.saturating_take(assets.clone()); + self.holding.subsume_assets(to_weigh.clone()); + let to_weigh_reanchored = Self::reanchored(to_weigh, &dest, None); + let mut message_to_weigh = + vec![ReserveAssetDeposited(to_weigh_reanchored), ClearOrigin]; + message_to_weigh.extend(xcm.0.clone().into_iter()); + let (_, fee) = + validate_send::(dest.clone(), Xcm(message_to_weigh))?; + // set aside fee to be charged by XcmSender + let delivery_fee = self.holding.saturating_take(fee.into()); + Some(delivery_fee) + } else { None }; + + // now take assets to deposit (possibly excluding delivery_fee) let deposited = self.holding.saturating_take(assets); self.deposit_assets_with_retry(&deposited, &dest)?; // Note that we pass `None` as `maybe_failed_bin` and drop any assets which @@ -923,8 +926,10 @@ impl XcmExecutor { let assets = Self::reanchored(deposited, &dest, None); let mut message = vec![ReserveAssetDeposited(assets), ClearOrigin]; message.extend(xcm.0.into_iter()); - // put back transport_fee in holding register to be charged by XcmSender - self.holding.subsume_assets(transport_fee); + if let Some(delivery_fee) = maybe_parked_fee { + // Put back delivery_fee in holding register to be charged by XcmSender. + self.holding.subsume_assets(delivery_fee); + } self.send(dest, Xcm(message), FeeReason::DepositReserveAsset)?; Ok(()) }); From d934c648a48be966239c1cd39bf07c9621bfb1ba Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Mon, 26 Aug 2024 20:20:05 +0200 Subject: [PATCH 011/151] feat(xcm-emulator): add set_call method for dispatching calls --- cumulus/xcm/xcm-emulator/src/lib.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/cumulus/xcm/xcm-emulator/src/lib.rs b/cumulus/xcm/xcm-emulator/src/lib.rs index 8de3660c2236..b32a41220514 100644 --- a/cumulus/xcm/xcm-emulator/src/lib.rs +++ b/cumulus/xcm/xcm-emulator/src/lib.rs @@ -31,7 +31,7 @@ pub use core::{cell::RefCell, fmt::Debug}; pub use cumulus_primitives_core::AggregateMessageOrigin as CumulusAggregateMessageOrigin; pub use frame_support::{ assert_ok, - sp_runtime::{traits::Header as HeaderT, DispatchResult}, + sp_runtime::{traits::{Header as HeaderT, Dispatchable}, DispatchResult}, traits::{ EnqueueMessage, ExecuteOverweightError, Get, Hooks, OnInitialize, OriginTrait, ProcessMessage, ProcessMessageError, ServiceQueues, @@ -214,7 +214,7 @@ pub trait Network { pub trait Chain: TestExt { type Network: Network; type Runtime: SystemConfig; - type RuntimeCall; + type RuntimeCall: Clone + Dispatchable; type RuntimeOrigin; type RuntimeEvent; type System; @@ -1203,7 +1203,7 @@ macro_rules! __impl_check_assertion { Args: Clone, { fn check_assertion(test: $crate::Test) { - use $crate::TestExt; + use $crate::{TestExt, Dispatchable}; let chain_name = std::any::type_name::<$chain<$network>>(); @@ -1211,6 +1211,13 @@ macro_rules! __impl_check_assertion { if let Some(dispatchable) = test.hops_dispatchable.get(chain_name) { $crate::assert_ok!(dispatchable(test.clone())); } + if let Some(call) = test.hops_calls.get(chain_name) { + $crate::assert_ok!(match call.clone().dispatch(test.signed_origin.clone()) { + // We get rid of `post_info`. + Ok(_) => Ok(()), + Err(error_with_post_info) => Err(error_with_post_info.error), + }); + } if let Some(assertion) = test.hops_assertion.get(chain_name) { assertion(test); } @@ -1512,11 +1519,12 @@ where pub root_origin: Origin::RuntimeOrigin, pub hops_assertion: HashMap, pub hops_dispatchable: HashMap DispatchResult>, + pub hops_calls: HashMap, pub args: Args, _marker: PhantomData<(Destination, Hops)>, } -/// `Test` implementation +/// `Test` implementation. impl Test where Args: Clone, @@ -1526,7 +1534,7 @@ where Destination::RuntimeOrigin: OriginTrait> + Clone, Hops: Clone + CheckAssertion, { - /// Creates a new `Test` instance + /// Creates a new `Test` instance. pub fn new(test_args: TestContext) -> Self { Test { sender: TestAccount { @@ -1541,6 +1549,7 @@ where root_origin: ::RuntimeOrigin::root(), hops_assertion: Default::default(), hops_dispatchable: Default::default(), + hops_calls: Default::default(), args: test_args.args, _marker: Default::default(), } @@ -1555,6 +1564,11 @@ where let chain_name = std::any::type_name::(); self.hops_dispatchable.insert(chain_name.to_string(), dispatchable); } + /// Stores a call in a particular Chain, this will later be dispatched. + pub fn set_call(&mut self, call: Origin::RuntimeCall) { + let chain_name = std::any::type_name::(); + self.hops_calls.insert(chain_name.to_string(), call); + } /// Executes all dispatchables and assertions in order from `Origin` to `Destination` pub fn assert(&mut self) { Origin::check_assertion(self.clone()); From 52f3ba1323de449d68f7b0b97607448dd84f2fdf Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Mon, 26 Aug 2024 20:22:52 +0200 Subject: [PATCH 012/151] test(asset-hub-westend-integration-tests): add xcm estimation test with PayFees --- .../src/tests/xcm_fee_estimation.rs | 228 +++++++++++++++++- 1 file changed, 226 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs index 84689a454f39..66fc7e358573 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs @@ -92,7 +92,7 @@ fn transfer_assets_para_to_para_through_ah_call( ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; - let asset_hub_location: Location = PenpalB::sibling_location_of(AssetHubWestend::para_id()); + let asset_hub_location: Location = PenpalA::sibling_location_of(AssetHubWestend::para_id()); let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset { assets: Wild(AllCounted(test.args.assets.len() as u32)), beneficiary: test.args.beneficiary, @@ -101,7 +101,7 @@ fn transfer_assets_para_to_para_through_ah_call( dest: bx!(test.args.dest.into()), assets: bx!(test.args.assets.clone().into()), assets_transfer_type: bx!(TransferType::RemoteReserve(asset_hub_location.clone().into())), - remote_fees_id: bx!(VersionedAssetId::V5(AssetId(Location::new(1, [])))), + remote_fees_id: bx!(VersionedAssetId::V5(AssetId(Location::parent()))), fees_transfer_type: bx!(TransferType::RemoteReserve(asset_hub_location.into())), custom_xcm_on_dest: bx!(VersionedXcm::from(custom_xcm_on_dest)), weight_limit: test.args.weight_limit, @@ -286,3 +286,227 @@ fn multi_hop_works() { final_execution_fees ); } + +#[test] +fn multi_hop_pay_fees_works() { + let destination = PenpalA::sibling_location_of(PenpalB::para_id()); + let sender = PenpalASender::get(); + let amount_to_send = 1_000_000_000_000; + let asset_owner = PenpalAssetOwner::get(); + let assets: Assets = (Parent, amount_to_send).into(); + let relay_native_asset_location = Location::parent(); + let sender_as_seen_by_ah = AssetHubWestend::sibling_location_of(PenpalA::para_id()); + let sov_of_sender_on_ah = + AssetHubWestend::sovereign_account_id_of(sender_as_seen_by_ah.clone()); + + // fund Parachain's sender account + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner.clone()), + relay_native_asset_location.clone(), + sender.clone(), + amount_to_send * 2, + ); + + // fund the Parachain Origin's SA on AssetHub with the native tokens held in reserve. + AssetHubWestend::fund_accounts(vec![(sov_of_sender_on_ah.clone(), amount_to_send * 2)]); + + // Init values for Parachain Destination + let beneficiary_id = PenpalBReceiver::get(); + + let test_args = TestContext { + sender: PenpalASender::get(), // Bob in PenpalB. + receiver: PenpalBReceiver::get(), // Alice. + args: TestArgs::new_para( + destination, + beneficiary_id.clone(), + amount_to_send, + assets, + None, + 0, + ), + }; + let mut test = ParaToParaThroughAHTest::new(test_args); + + // We get them from the PenpalA closure. + let mut local_execution_fees = 0; + let mut delivery_fees_amount = 0; + let mut remote_message = VersionedXcm::V5(Xcm(Vec::new())); + ::execute_with(|| { + type Runtime = ::Runtime; + type OriginCaller = ::OriginCaller; + + let call = transfer_assets_para_to_para_through_ah_pay_fees_call( + test.clone(), + (Parent, 100_000_000_000u128), + (Parent, 100_000_000_000u128), + (Parent, 100_000_000_000u128), + ); + let origin = OriginCaller::system(RawOrigin::Signed(sender.clone())); + let result = Runtime::dry_run_call(origin, call).unwrap(); + let local_xcm = result.local_xcm.unwrap().clone(); + let local_xcm_weight = Runtime::query_xcm_weight(local_xcm).unwrap(); + local_execution_fees = Runtime::query_weight_to_asset_fee( + local_xcm_weight, + VersionedAssetId::V5(Location::parent().into()), + ).unwrap(); + // We filter the result to get only the messages we are interested in. + let (destination_to_query, messages_to_query) = &result + .forwarded_xcms + .iter() + .find(|(destination, _)| { + *destination == VersionedLocation::V5(Location::new(1, [Parachain(1000)])) + }) + .unwrap(); + assert_eq!(messages_to_query.len(), 1); + remote_message = messages_to_query[0].clone(); + let delivery_fees = + Runtime::query_delivery_fees(destination_to_query.clone(), remote_message.clone()) + .unwrap(); + delivery_fees_amount = get_amount_from_versioned_assets(delivery_fees); + }); + + // These are set in the AssetHub closure. + let mut intermediate_execution_fees = 0; + let mut intermediate_delivery_fees_amount = 0; + let mut intermediate_remote_message = VersionedXcm::V5(Xcm::<()>(Vec::new())); + ::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + + // First we get the execution fees. + let weight = Runtime::query_xcm_weight(remote_message.clone()).unwrap(); + intermediate_execution_fees = Runtime::query_weight_to_asset_fee( + weight, + VersionedAssetId::V5(Location::parent().into()), + ) + .unwrap(); + + // We have to do this to turn `VersionedXcm<()>` into `VersionedXcm`. + let xcm_program = + VersionedXcm::V5(Xcm::::from(remote_message.clone().try_into().unwrap())); + + // Now we get the delivery fees to the final destination. + let result = + Runtime::dry_run_xcm(sender_as_seen_by_ah.clone().into(), xcm_program).unwrap(); + let (destination_to_query, messages_to_query) = &result + .forwarded_xcms + .iter() + .find(|(destination, _)| { + *destination == VersionedLocation::V5(Location::new(1, [Parachain(2001)])) + }) + .unwrap(); + // There's actually two messages here. + // One created when the message we sent from PenpalA arrived and was executed. + // The second one when we dry-run the xcm. + // We could've gotten the message from the queue without having to dry-run, but + // offchain applications would have to dry-run, so we do it here as well. + intermediate_remote_message = messages_to_query[0].clone(); + let delivery_fees = Runtime::query_delivery_fees( + destination_to_query.clone(), + intermediate_remote_message.clone(), + ) + .unwrap(); + intermediate_delivery_fees_amount = get_amount_from_versioned_assets(delivery_fees); + }); + + // Get the final execution fees in the destination. + let mut final_execution_fees = 0; + ::execute_with(|| { + type Runtime = ::Runtime; + + let weight = Runtime::query_xcm_weight(intermediate_remote_message.clone()).unwrap(); + final_execution_fees = + Runtime::query_weight_to_asset_fee(weight, VersionedAssetId::V5(Parent.into())) + .unwrap(); + }); + + // Dry-running is done. + PenpalA::reset_ext(); + AssetHubWestend::reset_ext(); + PenpalB::reset_ext(); + + // Fund accounts again. + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner), + relay_native_asset_location.clone(), + sender.clone(), + amount_to_send * 2, + ); + AssetHubWestend::fund_accounts(vec![(sov_of_sender_on_ah, amount_to_send * 2)]); + + // Actually run the extrinsic. + let sender_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &sender) + }); + let receiver_assets_before = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &beneficiary_id) + }); + + test.set_assertion::(sender_assertions); + test.set_assertion::(hop_assertions); + test.set_assertion::(receiver_assertions); + let call = transfer_assets_para_to_para_through_ah_pay_fees_call( + test.clone(), + (Parent, local_execution_fees + delivery_fees_amount), + (Parent, intermediate_execution_fees + intermediate_delivery_fees_amount), + (Parent, final_execution_fees) + ); + test.set_call(call); + test.assert(); + + let sender_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &sender) + }); + let receiver_assets_after = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location, &beneficiary_id) + }); + + // We know the exact fees on every hop. + assert_eq!( + sender_assets_after, + sender_assets_before - amount_to_send + ); + assert_eq!( + receiver_assets_after, + receiver_assets_before + amount_to_send - + local_execution_fees - + delivery_fees_amount - + intermediate_execution_fees - + intermediate_delivery_fees_amount - + final_execution_fees + ); +} + +fn transfer_assets_para_to_para_through_ah_pay_fees_call( + test: ParaToParaThroughAHTest, + estimated_local_fees: impl Into, + estimated_intermediate_fees: impl Into, + estimated_remote_fees: impl Into, +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; + + let xcm_in_destination = Xcm::<()>::builder_unsafe() + .pay_fees(estimated_remote_fees) + .deposit_asset(AllCounted(test.args.assets.len() as u32), test.args.beneficiary) + .build(); + let ah_to_penpal_b = AssetHubWestend::sibling_location_of(PenpalB::para_id()); + let xcm_in_reserve = Xcm::<()>::builder_unsafe() + .pay_fees(estimated_intermediate_fees) + .deposit_reserve_asset(AllCounted(test.args.assets.len() as u32), ah_to_penpal_b, xcm_in_destination) + .build(); + let penpal_a_to_ah = PenpalA::sibling_location_of(AssetHubWestend::para_id()); + let local_xcm = Xcm::::builder() + .withdraw_asset(test.args.assets.clone()) + .pay_fees(estimated_local_fees) + .initiate_reserve_withdraw(All, penpal_a_to_ah, xcm_in_reserve) + .build(); + + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(3_000_000_000, 200_000), + }) +} From 900bb4676c3946272ff8ba0830a068f4ad734ce1 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Mon, 26 Aug 2024 20:23:23 +0200 Subject: [PATCH 013/151] fix: fmt --- .../src/tests/xcm_fee_estimation.rs | 16 +++++++++------- cumulus/xcm/xcm-emulator/src/lib.rs | 19 ++++++++++++------- polkadot/xcm/xcm-executor/src/lib.rs | 14 +++++++++----- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs index 66fc7e358573..505a8165f0df 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs @@ -348,7 +348,8 @@ fn multi_hop_pay_fees_works() { local_execution_fees = Runtime::query_weight_to_asset_fee( local_xcm_weight, VersionedAssetId::V5(Location::parent().into()), - ).unwrap(); + ) + .unwrap(); // We filter the result to get only the messages we are interested in. let (destination_to_query, messages_to_query) = &result .forwarded_xcms @@ -451,7 +452,7 @@ fn multi_hop_pay_fees_works() { test.clone(), (Parent, local_execution_fees + delivery_fees_amount), (Parent, intermediate_execution_fees + intermediate_delivery_fees_amount), - (Parent, final_execution_fees) + (Parent, final_execution_fees), ); test.set_call(call); test.assert(); @@ -466,10 +467,7 @@ fn multi_hop_pay_fees_works() { }); // We know the exact fees on every hop. - assert_eq!( - sender_assets_after, - sender_assets_before - amount_to_send - ); + assert_eq!(sender_assets_after, sender_assets_before - amount_to_send); assert_eq!( receiver_assets_after, receiver_assets_before + amount_to_send - @@ -496,7 +494,11 @@ fn transfer_assets_para_to_para_through_ah_pay_fees_call( let ah_to_penpal_b = AssetHubWestend::sibling_location_of(PenpalB::para_id()); let xcm_in_reserve = Xcm::<()>::builder_unsafe() .pay_fees(estimated_intermediate_fees) - .deposit_reserve_asset(AllCounted(test.args.assets.len() as u32), ah_to_penpal_b, xcm_in_destination) + .deposit_reserve_asset( + AllCounted(test.args.assets.len() as u32), + ah_to_penpal_b, + xcm_in_destination, + ) .build(); let penpal_a_to_ah = PenpalA::sibling_location_of(AssetHubWestend::para_id()); let local_xcm = Xcm::::builder() diff --git a/cumulus/xcm/xcm-emulator/src/lib.rs b/cumulus/xcm/xcm-emulator/src/lib.rs index b32a41220514..8cd694e30276 100644 --- a/cumulus/xcm/xcm-emulator/src/lib.rs +++ b/cumulus/xcm/xcm-emulator/src/lib.rs @@ -31,7 +31,10 @@ pub use core::{cell::RefCell, fmt::Debug}; pub use cumulus_primitives_core::AggregateMessageOrigin as CumulusAggregateMessageOrigin; pub use frame_support::{ assert_ok, - sp_runtime::{traits::{Header as HeaderT, Dispatchable}, DispatchResult}, + sp_runtime::{ + traits::{Dispatchable, Header as HeaderT}, + DispatchResult, + }, traits::{ EnqueueMessage, ExecuteOverweightError, Get, Hooks, OnInitialize, OriginTrait, ProcessMessage, ProcessMessageError, ServiceQueues, @@ -1203,7 +1206,7 @@ macro_rules! __impl_check_assertion { Args: Clone, { fn check_assertion(test: $crate::Test) { - use $crate::{TestExt, Dispatchable}; + use $crate::{Dispatchable, TestExt}; let chain_name = std::any::type_name::<$chain<$network>>(); @@ -1212,11 +1215,13 @@ macro_rules! __impl_check_assertion { $crate::assert_ok!(dispatchable(test.clone())); } if let Some(call) = test.hops_calls.get(chain_name) { - $crate::assert_ok!(match call.clone().dispatch(test.signed_origin.clone()) { - // We get rid of `post_info`. - Ok(_) => Ok(()), - Err(error_with_post_info) => Err(error_with_post_info.error), - }); + $crate::assert_ok!( + match call.clone().dispatch(test.signed_origin.clone()) { + // We get rid of `post_info`. + Ok(_) => Ok(()), + Err(error_with_post_info) => Err(error_with_post_info.error), + } + ); } if let Some(assertion) = test.hops_assertion.get(chain_name) { assertion(test); diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 613daf885c14..9e2a5e918bc8 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -902,20 +902,24 @@ impl XcmExecutor { let old_holding = self.holding.clone(); let result = Config::TransactionalProcessor::process(|| { let maybe_parked_fee = if self.fees.is_empty() { - // we need to do this take/put cycle to solve wildcards and get exact assets to - // be weighed + // we need to do this take/put cycle to solve wildcards and get exact assets + // to be weighed let to_weigh = self.holding.saturating_take(assets.clone()); self.holding.subsume_assets(to_weigh.clone()); let to_weigh_reanchored = Self::reanchored(to_weigh, &dest, None); let mut message_to_weigh = vec![ReserveAssetDeposited(to_weigh_reanchored), ClearOrigin]; message_to_weigh.extend(xcm.0.clone().into_iter()); - let (_, fee) = - validate_send::(dest.clone(), Xcm(message_to_weigh))?; + let (_, fee) = validate_send::( + dest.clone(), + Xcm(message_to_weigh), + )?; // set aside fee to be charged by XcmSender let delivery_fee = self.holding.saturating_take(fee.into()); Some(delivery_fee) - } else { None }; + } else { + None + }; // now take assets to deposit (possibly excluding delivery_fee) let deposited = self.holding.saturating_take(assets); From 56bcd4d15afcdce16727103a7c05b9e777fbb394 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Tue, 27 Aug 2024 11:49:32 +0200 Subject: [PATCH 014/151] fix(xcm-executor): remove unnecessary clones --- .../xcm/xcm-executor/src/tests/pay_fees.rs | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs index 96ec5b43d0c8..192cc319c287 100644 --- a/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs +++ b/polkadot/xcm/xcm-executor/src/tests/pay_fees.rs @@ -35,13 +35,13 @@ const RECIPIENT: [u8; 32] = [1; 32]; #[test] fn works_for_execution_fees() { // Make sure the sender has enough funds to withdraw. - add_asset(SENDER.clone(), (Here, 100u128)); + add_asset(SENDER, (Here, 100u128)); // Build xcm. let xcm = Xcm::::builder() .withdraw_asset((Here, 100u128)) .pay_fees((Here, 10u128)) // 10% destined for fees, not more. - .deposit_asset(All, RECIPIENT.clone()) + .deposit_asset(All, RECIPIENT) .build(); let (mut vm, weight) = instantiate_executor(SENDER, xcm.clone()); @@ -68,7 +68,7 @@ fn works_for_execution_fees() { #[test] fn works_for_delivery_fees() { // Make sure the sender has enough funds to withdraw. - add_asset(SENDER.clone(), (Here, 100u128)); + add_asset(SENDER, (Here, 100u128)); // Information to send messages. // We don't care about the specifics since we're not actually sending them. @@ -83,10 +83,10 @@ fn works_for_delivery_fees() { .report_error(query_response_info.clone()) .report_error(query_response_info.clone()) .report_error(query_response_info) - .deposit_asset(All, RECIPIENT.clone()) + .deposit_asset(All, RECIPIENT) .build(); - let (mut vm, _) = instantiate_executor(SENDER.clone(), xcm.clone()); + let (mut vm, _) = instantiate_executor(SENDER, xcm.clone()); // Program runs successfully. assert!(vm.bench_process(xcm).is_ok()); @@ -127,7 +127,7 @@ fn works_for_delivery_fees() { #[test] fn buy_execution_works_as_before() { // Make sure the sender has enough funds to withdraw. - add_asset(SENDER.clone(), (Here, 100u128)); + add_asset(SENDER, (Here, 100u128)); // Build xcm. let xcm = Xcm::::builder() @@ -136,7 +136,7 @@ fn buy_execution_works_as_before() { // We have to specify `Limited` here to actually work, it's normally // set in the `AllowTopLevelPaidExecutionFrom` barrier. .buy_execution((Here, 100u128), Limited(Weight::from_parts(2, 2))) - .deposit_asset(All, RECIPIENT.clone()) + .deposit_asset(All, RECIPIENT) .build(); let (mut vm, _) = instantiate_executor(SENDER, xcm.clone()); @@ -158,18 +158,18 @@ fn buy_execution_works_as_before() { #[test] fn fees_can_be_refunded() { // Make sure the sender has enough funds to withdraw. - add_asset(SENDER.clone(), (Here, 100u128)); + add_asset(SENDER, (Here, 100u128)); // Build xcm. let xcm = Xcm::::builder() .withdraw_asset((Here, 100u128)) .pay_fees((Here, 10u128)) // 10% destined for fees, not more. - .deposit_asset(All, RECIPIENT.clone()) + .deposit_asset(All, RECIPIENT) .refund_surplus() - .deposit_asset(All, SENDER.clone()) + .deposit_asset(All, SENDER) .build(); - let (mut vm, _) = instantiate_executor(SENDER.clone(), xcm.clone()); + let (mut vm, _) = instantiate_executor(SENDER, xcm.clone()); // Program runs successfully. assert!(vm.bench_process(xcm).is_ok()); @@ -192,16 +192,16 @@ fn fees_can_be_refunded() { #[test] fn putting_all_assets_in_pay_fees() { // Make sure the sender has enough funds to withdraw. - add_asset(SENDER.clone(), (Here, 100u128)); + add_asset(SENDER, (Here, 100u128)); // Build xcm. let xcm = Xcm::::builder() .withdraw_asset((Here, 100u128)) .pay_fees((Here, 100u128)) // 100% destined for fees, this is not going to end well... - .deposit_asset(All, RECIPIENT.clone()) + .deposit_asset(All, RECIPIENT) .build(); - let (mut vm, _) = instantiate_executor(SENDER.clone(), xcm.clone()); + let (mut vm, _) = instantiate_executor(SENDER, xcm.clone()); // Program runs successfully. assert!(vm.bench_process(xcm).is_ok()); @@ -218,7 +218,7 @@ fn putting_all_assets_in_pay_fees() { #[test] fn refunding_too_early() { // Make sure the sender has enough funds to withdraw. - add_asset(SENDER.clone(), (Here, 100u128)); + add_asset(SENDER, (Here, 100u128)); // Information to send messages. // We don't care about the specifics since we're not actually sending them. @@ -229,16 +229,16 @@ fn refunding_too_early() { let xcm = Xcm::::builder() .withdraw_asset((Here, 100u128)) .pay_fees((Here, 10u128)) // 10% destined for fees, not more. - .deposit_asset(All, RECIPIENT.clone()) + .deposit_asset(All, RECIPIENT) .refund_surplus() - .deposit_asset(All, SENDER.clone()) + .deposit_asset(All, SENDER) // `refund_surplus` cleared the `fees` register. // `holding` is used as a fallback, but we also cleared that. // The instruction will error and the message won't be sent :(. .report_error(query_response_info) .build(); - let (mut vm, _) = instantiate_executor(SENDER.clone(), xcm.clone()); + let (mut vm, _) = instantiate_executor(SENDER, xcm.clone()); // Program fails to run. assert!(vm.bench_process(xcm).is_err()); From c062c0caf4c4172f641929db1168023fa9684e0b Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Tue, 27 Aug 2024 12:06:01 +0200 Subject: [PATCH 015/151] chore(asset-hub-westend-integration-tests): refactor test to decl macro --- .../emulated/common/src/macros.rs | 224 +++++++++++++++++ .../src/tests/xcm_fee_estimation.rs | 237 +----------------- 2 files changed, 228 insertions(+), 233 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/common/src/macros.rs b/cumulus/parachains/integration-tests/emulated/common/src/macros.rs index 578bca84ce5a..f3acbee85054 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/macros.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/macros.rs @@ -403,3 +403,227 @@ macro_rules! test_chain_can_claim_assets { } }; } + +#[macro_export] +macro_rules! test_can_estimate_and_pay_exact_fees { + ( $sender_para:ty, $asset_hub:ty, $receiver_para:ty, ($asset_id:expr, $amount:expr), $owner_prefix:ty ) => { + $crate::macros::paste::paste! { + // We first define the call we'll use throughout the test. + fn get_call( + estimated_local_fees: impl Into, + estimated_intermediate_fees: impl Into, + estimated_remote_fees: impl Into, + ) -> <$sender_para as Chain>::RuntimeCall { + type RuntimeCall = <$sender_para as Chain>::RuntimeCall; + + let beneficiary = [<$receiver_para Receiver>]::get(); + let xcm_in_destination = Xcm::<()>::builder_unsafe() + .pay_fees(estimated_remote_fees) + .deposit_asset(AllCounted(1), beneficiary) + .build(); + let ah_to_receiver = $asset_hub::sibling_location_of($receiver_para::para_id()); + let xcm_in_reserve = Xcm::<()>::builder_unsafe() + .pay_fees(estimated_intermediate_fees) + .deposit_reserve_asset( + AllCounted(1), + ah_to_receiver, + xcm_in_destination, + ) + .build(); + let sender_to_ah = $sender_para::sibling_location_of($asset_hub::para_id()); + let local_xcm = Xcm::<<$sender_para as Chain>::RuntimeCall>::builder() + .withdraw_asset(($asset_id, $amount)) + .pay_fees(estimated_local_fees) + .initiate_reserve_withdraw(AllCounted(1), sender_to_ah, xcm_in_reserve) + .build(); + + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(10_000_000_000, 500_000), + }) + } + + let destination = $sender_para::sibling_location_of($receiver_para::para_id()); + let sender = [<$sender_para Sender>]::get(); + let sender_as_seen_by_ah = $asset_hub::sibling_location_of($sender_para::para_id()); + let sov_of_sender_on_ah = $asset_hub::sovereign_account_id_of(sender_as_seen_by_ah.clone()); + let asset_owner = [<$owner_prefix AssetOwner>]::get(); + + // Fund parachain's sender account. + $sender_para::mint_foreign_asset( + <$sender_para as Chain>::RuntimeOrigin::signed(asset_owner.clone()), + $asset_id.clone().into(), + sender.clone(), + $amount * 2, + ); + + // Fund the parachain origin's SA on Asset Hub with the native tokens. + $asset_hub::fund_accounts(vec![(sov_of_sender_on_ah.clone(), $amount * 2)]); + + let beneficiary_id = [<$receiver_para Receiver>]::get(); + + let test_args = TestContext { + sender: sender.clone(), + receiver: beneficiary_id.clone(), + args: TestArgs::new_para( + destination, + beneficiary_id.clone(), + $amount, + ($asset_id, $amount).into(), + None, + 0, + ), + }; + let mut test = ParaToParaThroughAHTest::new(test_args); + + // We get these from the closure. + let mut local_execution_fees = 0; + let mut local_delivery_fees = 0; + let mut remote_message = VersionedXcm::from(Xcm::<()>(Vec::new())); + <$sender_para as TestExt>::execute_with(|| { + type Runtime = <$sender_para as Chain>::Runtime; + type OriginCaller = <$sender_para as Chain>::OriginCaller; + + let call = get_call( + (Parent, 100_000_000_000u128), + (Parent, 100_000_000_000u128), + (Parent, 100_000_000_000u128), + ); + let origin = OriginCaller::system(RawOrigin::Signed(sender.clone())); + let result = Runtime::dry_run_call(origin, call).unwrap(); + let local_xcm = result.local_xcm.unwrap().clone(); + let local_xcm_weight = Runtime::query_xcm_weight(local_xcm).unwrap(); + local_execution_fees = Runtime::query_weight_to_asset_fee( + local_xcm_weight, + VersionedAssetId::V5(Location::parent().into()), + ) + .unwrap(); + // We filter the result to get only the messages we are interested in. + let (destination_to_query, messages_to_query) = &result + .forwarded_xcms + .iter() + .find(|(destination, _)| { + *destination == VersionedLocation::V5(Location::new(1, [Parachain(1000)])) + }) + .unwrap(); + assert_eq!(messages_to_query.len(), 1); + remote_message = messages_to_query[0].clone(); + let delivery_fees = + Runtime::query_delivery_fees(destination_to_query.clone(), remote_message.clone()) + .unwrap(); + local_delivery_fees = $crate::xcm_helpers::get_amount_from_versioned_assets(delivery_fees); + }); + + // These are set in the AssetHub closure. + let mut intermediate_execution_fees = 0; + let mut intermediate_delivery_fees = 0; + let mut intermediate_remote_message = VersionedXcm::V5(Xcm::<()>(Vec::new())); + <$asset_hub as TestExt>::execute_with(|| { + type Runtime = <$asset_hub as Chain>::Runtime; + type RuntimeCall = <$asset_hub as Chain>::RuntimeCall; + + // First we get the execution fees. + let weight = Runtime::query_xcm_weight(remote_message.clone()).unwrap(); + intermediate_execution_fees = Runtime::query_weight_to_asset_fee( + weight, + VersionedAssetId::V5(Location::new(1, []).into()), + ) + .unwrap(); + + // We have to do this to turn `VersionedXcm<()>` into `VersionedXcm`. + let xcm_program = + VersionedXcm::V5(Xcm::::from(remote_message.clone().try_into().unwrap())); + + // Now we get the delivery fees to the final destination. + let result = + Runtime::dry_run_xcm(sender_as_seen_by_ah.clone().into(), xcm_program).unwrap(); + let (destination_to_query, messages_to_query) = &result + .forwarded_xcms + .iter() + .find(|(destination, _)| { + *destination == VersionedLocation::V5(Location::new(1, [Parachain(2001)])) + }) + .unwrap(); + // There's actually two messages here. + // One created when the message we sent from `$sender_para` arrived and was executed. + // The second one when we dry-run the xcm. + // We could've gotten the message from the queue without having to dry-run, but + // offchain applications would have to dry-run, so we do it here as well. + intermediate_remote_message = messages_to_query[0].clone(); + let delivery_fees = Runtime::query_delivery_fees( + destination_to_query.clone(), + intermediate_remote_message.clone(), + ) + .unwrap(); + intermediate_delivery_fees = $crate::xcm_helpers::get_amount_from_versioned_assets(delivery_fees); + }); + + // Get the final execution fees in the destination. + let mut final_execution_fees = 0; + <$receiver_para as TestExt>::execute_with(|| { + type Runtime = <$sender_para as Chain>::Runtime; + + let weight = Runtime::query_xcm_weight(intermediate_remote_message.clone()).unwrap(); + final_execution_fees = + Runtime::query_weight_to_asset_fee(weight, VersionedAssetId::V5(Parent.into())) + .unwrap(); + }); + + // Dry-running is done. + $sender_para::reset_ext(); + $asset_hub::reset_ext(); + $receiver_para::reset_ext(); + + // Fund accounts again. + $sender_para::mint_foreign_asset( + <$sender_para as Chain>::RuntimeOrigin::signed(asset_owner), + $asset_id.clone().into(), + sender.clone(), + $amount * 2, + ); + $asset_hub::fund_accounts(vec![(sov_of_sender_on_ah, $amount * 2)]); + + // Actually run the extrinsic. + let sender_assets_before = $sender_para::execute_with(|| { + type ForeignAssets = <$sender_para as [<$sender_para Pallet>]>::ForeignAssets; + >::balance($asset_id.clone().into(), &sender) + }); + let receiver_assets_before = $receiver_para::execute_with(|| { + type ForeignAssets = <$receiver_para as [<$receiver_para Pallet>]>::ForeignAssets; + >::balance($asset_id.clone().into(), &beneficiary_id) + }); + + test.set_assertion::<$sender_para>(sender_assertions); + test.set_assertion::<$asset_hub>(hop_assertions); + test.set_assertion::<$receiver_para>(receiver_assertions); + let call = get_call( + (Parent, local_execution_fees + local_delivery_fees), + (Parent, intermediate_execution_fees + intermediate_delivery_fees), + (Parent, final_execution_fees), + ); + test.set_call(call); + test.assert(); + + let sender_assets_after = $sender_para::execute_with(|| { + type ForeignAssets = <$sender_para as [<$sender_para Pallet>]>::ForeignAssets; + >::balance($asset_id.clone().into(), &sender) + }); + let receiver_assets_after = $receiver_para::execute_with(|| { + type ForeignAssets = <$receiver_para as [<$receiver_para Pallet>]>::ForeignAssets; + >::balance($asset_id.into(), &beneficiary_id) + }); + + // We know the exact fees on every hop. + assert_eq!(sender_assets_after, sender_assets_before - $amount); + assert_eq!( + receiver_assets_after, + receiver_assets_before + $amount - + local_execution_fees - + local_delivery_fees - + intermediate_execution_fees - + intermediate_delivery_fees - + final_execution_fees + ); + } + }; +} diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs index 505a8165f0df..5a5b8ee30f64 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs @@ -17,6 +17,7 @@ use crate::imports::*; +use emulated_integration_tests_common::test_can_estimate_and_pay_exact_fees; use frame_support::{ dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, @@ -77,16 +78,6 @@ fn receiver_assertions(test: ParaToParaThroughAHTest) { ); } -fn transfer_assets_para_to_para_through_ah_dispatchable( - test: ParaToParaThroughAHTest, -) -> DispatchResult { - let call = transfer_assets_para_to_para_through_ah_call(test.clone()); - match call.dispatch(test.signed_origin) { - Ok(_) => Ok(()), - Err(error_with_post_info) => Err(error_with_post_info.error), - } -} - fn transfer_assets_para_to_para_through_ah_call( test: ParaToParaThroughAHTest, ) -> ::RuntimeCall { @@ -259,7 +250,8 @@ fn multi_hop_works() { test.set_assertion::(sender_assertions); test.set_assertion::(hop_assertions); test.set_assertion::(receiver_assertions); - test.set_dispatchable::(transfer_assets_para_to_para_through_ah_dispatchable); + let call = transfer_assets_para_to_para_through_ah_call(test.clone()); + test.set_call(call); test.assert(); let sender_assets_after = PenpalA::execute_with(|| { @@ -289,226 +281,5 @@ fn multi_hop_works() { #[test] fn multi_hop_pay_fees_works() { - let destination = PenpalA::sibling_location_of(PenpalB::para_id()); - let sender = PenpalASender::get(); - let amount_to_send = 1_000_000_000_000; - let asset_owner = PenpalAssetOwner::get(); - let assets: Assets = (Parent, amount_to_send).into(); - let relay_native_asset_location = Location::parent(); - let sender_as_seen_by_ah = AssetHubWestend::sibling_location_of(PenpalA::para_id()); - let sov_of_sender_on_ah = - AssetHubWestend::sovereign_account_id_of(sender_as_seen_by_ah.clone()); - - // fund Parachain's sender account - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner.clone()), - relay_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); - - // fund the Parachain Origin's SA on AssetHub with the native tokens held in reserve. - AssetHubWestend::fund_accounts(vec![(sov_of_sender_on_ah.clone(), amount_to_send * 2)]); - - // Init values for Parachain Destination - let beneficiary_id = PenpalBReceiver::get(); - - let test_args = TestContext { - sender: PenpalASender::get(), // Bob in PenpalB. - receiver: PenpalBReceiver::get(), // Alice. - args: TestArgs::new_para( - destination, - beneficiary_id.clone(), - amount_to_send, - assets, - None, - 0, - ), - }; - let mut test = ParaToParaThroughAHTest::new(test_args); - - // We get them from the PenpalA closure. - let mut local_execution_fees = 0; - let mut delivery_fees_amount = 0; - let mut remote_message = VersionedXcm::V5(Xcm(Vec::new())); - ::execute_with(|| { - type Runtime = ::Runtime; - type OriginCaller = ::OriginCaller; - - let call = transfer_assets_para_to_para_through_ah_pay_fees_call( - test.clone(), - (Parent, 100_000_000_000u128), - (Parent, 100_000_000_000u128), - (Parent, 100_000_000_000u128), - ); - let origin = OriginCaller::system(RawOrigin::Signed(sender.clone())); - let result = Runtime::dry_run_call(origin, call).unwrap(); - let local_xcm = result.local_xcm.unwrap().clone(); - let local_xcm_weight = Runtime::query_xcm_weight(local_xcm).unwrap(); - local_execution_fees = Runtime::query_weight_to_asset_fee( - local_xcm_weight, - VersionedAssetId::V5(Location::parent().into()), - ) - .unwrap(); - // We filter the result to get only the messages we are interested in. - let (destination_to_query, messages_to_query) = &result - .forwarded_xcms - .iter() - .find(|(destination, _)| { - *destination == VersionedLocation::V5(Location::new(1, [Parachain(1000)])) - }) - .unwrap(); - assert_eq!(messages_to_query.len(), 1); - remote_message = messages_to_query[0].clone(); - let delivery_fees = - Runtime::query_delivery_fees(destination_to_query.clone(), remote_message.clone()) - .unwrap(); - delivery_fees_amount = get_amount_from_versioned_assets(delivery_fees); - }); - - // These are set in the AssetHub closure. - let mut intermediate_execution_fees = 0; - let mut intermediate_delivery_fees_amount = 0; - let mut intermediate_remote_message = VersionedXcm::V5(Xcm::<()>(Vec::new())); - ::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - - // First we get the execution fees. - let weight = Runtime::query_xcm_weight(remote_message.clone()).unwrap(); - intermediate_execution_fees = Runtime::query_weight_to_asset_fee( - weight, - VersionedAssetId::V5(Location::parent().into()), - ) - .unwrap(); - - // We have to do this to turn `VersionedXcm<()>` into `VersionedXcm`. - let xcm_program = - VersionedXcm::V5(Xcm::::from(remote_message.clone().try_into().unwrap())); - - // Now we get the delivery fees to the final destination. - let result = - Runtime::dry_run_xcm(sender_as_seen_by_ah.clone().into(), xcm_program).unwrap(); - let (destination_to_query, messages_to_query) = &result - .forwarded_xcms - .iter() - .find(|(destination, _)| { - *destination == VersionedLocation::V5(Location::new(1, [Parachain(2001)])) - }) - .unwrap(); - // There's actually two messages here. - // One created when the message we sent from PenpalA arrived and was executed. - // The second one when we dry-run the xcm. - // We could've gotten the message from the queue without having to dry-run, but - // offchain applications would have to dry-run, so we do it here as well. - intermediate_remote_message = messages_to_query[0].clone(); - let delivery_fees = Runtime::query_delivery_fees( - destination_to_query.clone(), - intermediate_remote_message.clone(), - ) - .unwrap(); - intermediate_delivery_fees_amount = get_amount_from_versioned_assets(delivery_fees); - }); - - // Get the final execution fees in the destination. - let mut final_execution_fees = 0; - ::execute_with(|| { - type Runtime = ::Runtime; - - let weight = Runtime::query_xcm_weight(intermediate_remote_message.clone()).unwrap(); - final_execution_fees = - Runtime::query_weight_to_asset_fee(weight, VersionedAssetId::V5(Parent.into())) - .unwrap(); - }); - - // Dry-running is done. - PenpalA::reset_ext(); - AssetHubWestend::reset_ext(); - PenpalB::reset_ext(); - - // Fund accounts again. - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - relay_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); - AssetHubWestend::fund_accounts(vec![(sov_of_sender_on_ah, amount_to_send * 2)]); - - // Actually run the extrinsic. - let sender_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &sender) - }); - let receiver_assets_before = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &beneficiary_id) - }); - - test.set_assertion::(sender_assertions); - test.set_assertion::(hop_assertions); - test.set_assertion::(receiver_assertions); - let call = transfer_assets_para_to_para_through_ah_pay_fees_call( - test.clone(), - (Parent, local_execution_fees + delivery_fees_amount), - (Parent, intermediate_execution_fees + intermediate_delivery_fees_amount), - (Parent, final_execution_fees), - ); - test.set_call(call); - test.assert(); - - let sender_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &sender) - }); - let receiver_assets_after = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location, &beneficiary_id) - }); - - // We know the exact fees on every hop. - assert_eq!(sender_assets_after, sender_assets_before - amount_to_send); - assert_eq!( - receiver_assets_after, - receiver_assets_before + amount_to_send - - local_execution_fees - - delivery_fees_amount - - intermediate_execution_fees - - intermediate_delivery_fees_amount - - final_execution_fees - ); -} - -fn transfer_assets_para_to_para_through_ah_pay_fees_call( - test: ParaToParaThroughAHTest, - estimated_local_fees: impl Into, - estimated_intermediate_fees: impl Into, - estimated_remote_fees: impl Into, -) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; - - let xcm_in_destination = Xcm::<()>::builder_unsafe() - .pay_fees(estimated_remote_fees) - .deposit_asset(AllCounted(test.args.assets.len() as u32), test.args.beneficiary) - .build(); - let ah_to_penpal_b = AssetHubWestend::sibling_location_of(PenpalB::para_id()); - let xcm_in_reserve = Xcm::<()>::builder_unsafe() - .pay_fees(estimated_intermediate_fees) - .deposit_reserve_asset( - AllCounted(test.args.assets.len() as u32), - ah_to_penpal_b, - xcm_in_destination, - ) - .build(); - let penpal_a_to_ah = PenpalA::sibling_location_of(AssetHubWestend::para_id()); - let local_xcm = Xcm::::builder() - .withdraw_asset(test.args.assets.clone()) - .pay_fees(estimated_local_fees) - .initiate_reserve_withdraw(All, penpal_a_to_ah, xcm_in_reserve) - .build(); - - RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(local_xcm)), - max_weight: Weight::from_parts(3_000_000_000, 200_000), - }) + test_can_estimate_and_pay_exact_fees!(PenpalA, AssetHubWestend, PenpalB, (Parent, 1_000_000_000_000u128), Penpal); } From 94f831fdbb92338bf0332288e33f7c9b1d158da3 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Tue, 27 Aug 2024 12:06:42 +0200 Subject: [PATCH 016/151] feat(asset-hub-rococo-integration-tests): add PayFees test --- .../src/tests/xcm_fee_estimation.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/xcm_fee_estimation.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/xcm_fee_estimation.rs index 0add25d4eb2c..b2d221565bf9 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/xcm_fee_estimation.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/xcm_fee_estimation.rs @@ -16,6 +16,7 @@ //! Tests for XCM fee estimation in the runtime. use crate::imports::*; +use emulated_integration_tests_common::test_can_estimate_and_pay_exact_fees; use frame_support::{ dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, @@ -76,16 +77,6 @@ fn receiver_assertions(test: ParaToParaThroughAHTest) { ); } -fn transfer_assets_para_to_para_through_ah_dispatchable( - test: ParaToParaThroughAHTest, -) -> DispatchResult { - let call = transfer_assets_para_to_para_through_ah_call(test.clone()); - match call.dispatch(test.signed_origin) { - Ok(_) => Ok(()), - Err(error_with_post_info) => Err(error_with_post_info.error), - } -} - fn transfer_assets_para_to_para_through_ah_call( test: ParaToParaThroughAHTest, ) -> ::RuntimeCall { @@ -257,7 +248,8 @@ fn multi_hop_works() { test.set_assertion::(sender_assertions); test.set_assertion::(hop_assertions); test.set_assertion::(receiver_assertions); - test.set_dispatchable::(transfer_assets_para_to_para_through_ah_dispatchable); + let call = transfer_assets_para_to_para_through_ah_call(test.clone()); + test.set_call(call); test.assert(); let sender_assets_after = PenpalA::execute_with(|| { @@ -284,3 +276,8 @@ fn multi_hop_works() { final_execution_fees ); } + +#[test] +fn multi_hop_pay_fees_works() { + test_can_estimate_and_pay_exact_fees!(PenpalA, AssetHubRococo, PenpalB, (Parent, 1_000_000_000_000u128), Penpal); +} From 31989500602772f206817a8f90322a9f33646011 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Tue, 27 Aug 2024 12:07:06 +0200 Subject: [PATCH 017/151] fix: fmt --- .../asset-hub-rococo/src/tests/xcm_fee_estimation.rs | 8 +++++++- .../asset-hub-westend/src/tests/xcm_fee_estimation.rs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/xcm_fee_estimation.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/xcm_fee_estimation.rs index b2d221565bf9..ccf3dc3f5d4c 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/xcm_fee_estimation.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/xcm_fee_estimation.rs @@ -279,5 +279,11 @@ fn multi_hop_works() { #[test] fn multi_hop_pay_fees_works() { - test_can_estimate_and_pay_exact_fees!(PenpalA, AssetHubRococo, PenpalB, (Parent, 1_000_000_000_000u128), Penpal); + test_can_estimate_and_pay_exact_fees!( + PenpalA, + AssetHubRococo, + PenpalB, + (Parent, 1_000_000_000_000u128), + Penpal + ); } diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs index 5a5b8ee30f64..db26bc87f00f 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs @@ -281,5 +281,11 @@ fn multi_hop_works() { #[test] fn multi_hop_pay_fees_works() { - test_can_estimate_and_pay_exact_fees!(PenpalA, AssetHubWestend, PenpalB, (Parent, 1_000_000_000_000u128), Penpal); + test_can_estimate_and_pay_exact_fees!( + PenpalA, + AssetHubWestend, + PenpalB, + (Parent, 1_000_000_000_000u128), + Penpal + ); } From 6bf562b5bc7ad438b5ce20623a1e49a5d98d76b4 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 10:53:23 +0000 Subject: [PATCH 018/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=rococo --target_dir=polkadot --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 330 ++++++++---------- 1 file changed, 145 insertions(+), 185 deletions(-) diff --git a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 754b074d55dc..3c5cdaa60bfd 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -16,28 +16,27 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot +// target/production/polkadot // benchmark // pallet // --steps=50 // --repeat=20 // --extrinsic=* -// --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json // --pallet=pallet_xcm_benchmarks::generic // --chain=rococo-dev -// --header=./file_header.txt -// --template=./xcm/pallet-xcm-benchmarks/template.hbs -// --output=./runtime/rococo/src/weights/xcm/ +// --header=./polkadot/file_header.txt +// --template=./polkadot/xcm/pallet-xcm-benchmarks/template.hbs +// --output=./polkadot/runtime/rococo/src/weights/xcm/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -50,137 +49,118 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm_benchmarks::generic`. pub struct WeightInfo(PhantomData); impl WeightInfo { - /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Storage: Configuration ActiveConfig (r:1 w:0) - /// Proof Skipped: Configuration ActiveConfig (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DeliveryFeeFactor (r:1 w:0) - /// Proof Skipped: Dmp DeliveryFeeFactor (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet SupportedVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) - /// Proof Skipped: XcmPallet VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: XcmPallet SafeXcmVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueues (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueues (max_values: None, max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn report_holding() -> Weight { // Proof Size summary in bytes: - // Measured: `565` - // Estimated: `4030` - // Minimum execution time: 36_305_000 picoseconds. - Weight::from_parts(37_096_000, 4030) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `281` + // Estimated: `3746` + // Minimum execution time: 62_606_000 picoseconds. + Weight::from_parts(64_541_000, 3746) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } pub(crate) fn buy_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_831_000 picoseconds. - Weight::from_parts(2_904_000, 0) + // Minimum execution time: 655_000 picoseconds. + Weight::from_parts(728_000, 0) } - pub(crate) fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_831_000 picoseconds. - Weight::from_parts(27_000_000, 0) - } - /// Storage: XcmPallet Queries (r:1 w:0) - /// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured) + /// Storage: `XcmPallet::Queries` (r:1 w:0) + /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn query_response() -> Weight { // Proof Size summary in bytes: - // Measured: `169` - // Estimated: `3634` - // Minimum execution time: 11_769_000 picoseconds. - Weight::from_parts(12_122_000, 3634) + // Measured: `0` + // Estimated: `3465` + // Minimum execution time: 5_560_000 picoseconds. + Weight::from_parts(5_771_000, 3465) .saturating_add(T::DbWeight::get().reads(1)) } pub(crate) fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_293_000 picoseconds. - Weight::from_parts(12_522_000, 0) + // Minimum execution time: 7_303_000 picoseconds. + Weight::from_parts(7_543_000, 0) } pub(crate) fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_858_000 picoseconds. - Weight::from_parts(2_965_000, 0) + // Minimum execution time: 1_184_000 picoseconds. + Weight::from_parts(1_267_000, 0) } pub(crate) fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_623_000 picoseconds. - Weight::from_parts(2_774_000, 0) + // Minimum execution time: 711_000 picoseconds. + Weight::from_parts(761_000, 0) } pub(crate) fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_664_000 picoseconds. - Weight::from_parts(2_752_000, 0) + // Minimum execution time: 719_000 picoseconds. + Weight::from_parts(755_000, 0) } pub(crate) fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_646_000 picoseconds. - Weight::from_parts(2_709_000, 0) + // Minimum execution time: 688_000 picoseconds. + Weight::from_parts(733_000, 0) } pub(crate) fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_602_000 picoseconds. - Weight::from_parts(3_669_000, 0) + // Minimum execution time: 730_000 picoseconds. + Weight::from_parts(766_000, 0) } pub(crate) fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_609_000 picoseconds. - Weight::from_parts(2_721_000, 0) + // Minimum execution time: 697_000 picoseconds. + Weight::from_parts(740_000, 0) } - /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Storage: Configuration ActiveConfig (r:1 w:0) - /// Proof Skipped: Configuration ActiveConfig (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DeliveryFeeFactor (r:1 w:0) - /// Proof Skipped: Dmp DeliveryFeeFactor (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet SupportedVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) - /// Proof Skipped: XcmPallet VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: XcmPallet SafeXcmVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueues (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueues (max_values: None, max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn report_error() -> Weight { // Proof Size summary in bytes: - // Measured: `565` - // Estimated: `4030` - // Minimum execution time: 31_776_000 picoseconds. - Weight::from_parts(32_354_000, 4030) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `281` + // Estimated: `3746` + // Minimum execution time: 60_995_000 picoseconds. + Weight::from_parts(62_523_000, 3746) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: XcmPallet AssetTraps (r:1 w:1) - /// Proof Skipped: XcmPallet AssetTraps (max_values: None, max_size: None, mode: Measured) + /// Storage: `XcmPallet::AssetTraps` (r:1 w:1) + /// Proof: `XcmPallet::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn claim_asset() -> Weight { // Proof Size summary in bytes: - // Measured: `226` - // Estimated: `3691` - // Minimum execution time: 15_912_000 picoseconds. - Weight::from_parts(16_219_000, 3691) + // Measured: `23` + // Estimated: `3488` + // Minimum execution time: 8_814_000 picoseconds. + Weight::from_parts(9_124_000, 3488) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -188,171 +168,151 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_704_000 picoseconds. - Weight::from_parts(2_777_000, 0) + // Minimum execution time: 678_000 picoseconds. + Weight::from_parts(724_000, 0) } - /// Storage: XcmPallet VersionNotifyTargets (r:1 w:1) - /// Proof Skipped: XcmPallet VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) - /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Storage: Configuration ActiveConfig (r:1 w:0) - /// Proof Skipped: Configuration ActiveConfig (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DeliveryFeeFactor (r:1 w:0) - /// Proof Skipped: Dmp DeliveryFeeFactor (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet SupportedVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) - /// Proof Skipped: XcmPallet VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: XcmPallet SafeXcmVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueues (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueues (max_values: None, max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured) + /// Storage: `XcmPallet::VersionNotifyTargets` (r:1 w:1) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn subscribe_version() -> Weight { // Proof Size summary in bytes: - // Measured: `565` - // Estimated: `4030` - // Minimum execution time: 38_690_000 picoseconds. - Weight::from_parts(39_157_000, 4030) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(5)) + // Measured: `180` + // Estimated: `3645` + // Minimum execution time: 30_673_000 picoseconds. + Weight::from_parts(31_367_000, 3645) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: XcmPallet VersionNotifyTargets (r:0 w:1) - /// Proof Skipped: XcmPallet VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) + /// Storage: `XcmPallet::VersionNotifyTargets` (r:0 w:1) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn unsubscribe_version() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_943_000 picoseconds. - Weight::from_parts(5_128_000, 0) + // Minimum execution time: 2_983_000 picoseconds. + Weight::from_parts(3_081_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub(crate) fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_438_000 picoseconds. - Weight::from_parts(6_500_000, 0) + // Minimum execution time: 1_088_000 picoseconds. + Weight::from_parts(1_144_000, 0) } pub(crate) fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_773_000 picoseconds. - Weight::from_parts(4_840_000, 0) + // Minimum execution time: 763_000 picoseconds. + Weight::from_parts(836_000, 0) } pub(crate) fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_818_000 picoseconds. - Weight::from_parts(2_893_000, 0) + // Minimum execution time: 670_000 picoseconds. + Weight::from_parts(724_000, 0) } pub(crate) fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_611_000 picoseconds. - Weight::from_parts(2_708_000, 0) + // Minimum execution time: 691_000 picoseconds. + Weight::from_parts(735_000, 0) } pub(crate) fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_870_000 picoseconds. - Weight::from_parts(2_958_000, 0) + // Minimum execution time: 865_000 picoseconds. + Weight::from_parts(927_000, 0) } - /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Storage: Configuration ActiveConfig (r:1 w:0) - /// Proof Skipped: Configuration ActiveConfig (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DeliveryFeeFactor (r:1 w:0) - /// Proof Skipped: Dmp DeliveryFeeFactor (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet SupportedVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) - /// Proof Skipped: XcmPallet VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: XcmPallet SafeXcmVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueues (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueues (max_values: None, max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn query_pallet() -> Weight { // Proof Size summary in bytes: - // Measured: `565` - // Estimated: `4030` - // Minimum execution time: 40_735_000 picoseconds. - Weight::from_parts(66_023_000, 4030) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `281` + // Estimated: `3746` + // Minimum execution time: 71_529_000 picoseconds. + Weight::from_parts(72_723_000, 3746) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } pub(crate) fn expect_pallet() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_293_000 picoseconds. - Weight::from_parts(18_088_000, 0) + // Minimum execution time: 8_349_000 picoseconds. + Weight::from_parts(8_556_000, 0) } - /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Storage: Configuration ActiveConfig (r:1 w:0) - /// Proof Skipped: Configuration ActiveConfig (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DeliveryFeeFactor (r:1 w:0) - /// Proof Skipped: Dmp DeliveryFeeFactor (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet SupportedVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) - /// Proof Skipped: XcmPallet VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: XcmPallet SafeXcmVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueues (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueues (max_values: None, max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn report_transact_status() -> Weight { // Proof Size summary in bytes: - // Measured: `565` - // Estimated: `4030` - // Minimum execution time: 31_438_000 picoseconds. - Weight::from_parts(32_086_000, 4030) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `281` + // Estimated: `3746` + // Minimum execution time: 62_084_000 picoseconds. + Weight::from_parts(63_113_000, 3746) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } pub(crate) fn clear_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_676_000 picoseconds. - Weight::from_parts(2_746_000, 0) + // Minimum execution time: 714_000 picoseconds. + Weight::from_parts(778_000, 0) } pub(crate) fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_629_000 picoseconds. - Weight::from_parts(2_724_000, 0) + // Minimum execution time: 672_000 picoseconds. + Weight::from_parts(724_000, 0) } pub(crate) fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_602_000 picoseconds. - Weight::from_parts(2_671_000, 0) + // Minimum execution time: 639_000 picoseconds. + Weight::from_parts(703_000, 0) } pub(crate) fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_681_000 picoseconds. - Weight::from_parts(2_768_000, 0) + // Minimum execution time: 640_000 picoseconds. + Weight::from_parts(718_000, 0) } pub(crate) fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_764_000 picoseconds. - Weight::from_parts(2_865_000, 0) + // Minimum execution time: 720_000 picoseconds. + Weight::from_parts(768_000, 0) } } From 15a533341dac17da692c1bd48a5c2a24fc7624a3 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 10:53:45 +0000 Subject: [PATCH 019/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=westend --target_dir=polkadot --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 309 ++++++++---------- 1 file changed, 140 insertions(+), 169 deletions(-) diff --git a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index dc071ebaff0a..d4d4b7470904 100644 --- a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -16,11 +16,11 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: // target/production/polkadot @@ -29,14 +29,14 @@ // --steps=50 // --repeat=20 // --extrinsic=* -// --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json // --pallet=pallet_xcm_benchmarks::generic // --chain=westend-dev -// --header=./file_header.txt -// --template=./xcm/pallet-xcm-benchmarks/template.hbs -// --output=./runtime/westend/src/weights/xcm/ +// --header=./polkadot/file_header.txt +// --template=./polkadot/xcm/pallet-xcm-benchmarks/template.hbs +// --output=./polkadot/runtime/westend/src/weights/xcm/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -49,133 +49,118 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm_benchmarks::generic`. pub struct WeightInfo(PhantomData); impl WeightInfo { - /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Storage: Dmp DeliveryFeeFactor (r:1 w:0) - /// Proof Skipped: Dmp DeliveryFeeFactor (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet SupportedVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) - /// Proof Skipped: XcmPallet VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: XcmPallet SafeXcmVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueues (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueues (max_values: None, max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn report_holding() -> Weight { // Proof Size summary in bytes: - // Measured: `169` - // Estimated: `3634` - // Minimum execution time: 30_790_000 picoseconds. - Weight::from_parts(31_265_000, 3634) - .saturating_add(T::DbWeight::get().reads(7)) + // Measured: `351` + // Estimated: `6196` + // Minimum execution time: 67_452_000 picoseconds. + Weight::from_parts(69_450_000, 6196) + .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } pub(crate) fn buy_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_741_000 picoseconds. - Weight::from_parts(2_823_000, 0) + // Minimum execution time: 710_000 picoseconds. + Weight::from_parts(764_000, 0) } - pub fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_193_000 picoseconds. - Weight::from_parts(27_000_000, 0) - } - /// Storage: XcmPallet Queries (r:1 w:0) - /// Proof Skipped: XcmPallet Queries (max_values: None, max_size: None, mode: Measured) + /// Storage: `XcmPallet::Queries` (r:1 w:0) + /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn query_response() -> Weight { // Proof Size summary in bytes: - // Measured: `169` - // Estimated: `3634` - // Minimum execution time: 10_848_000 picoseconds. - Weight::from_parts(11_183_000, 3634) + // Measured: `0` + // Estimated: `3465` + // Minimum execution time: 6_607_000 picoseconds. + Weight::from_parts(6_840_000, 3465) .saturating_add(T::DbWeight::get().reads(1)) } pub(crate) fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_145_000 picoseconds. - Weight::from_parts(12_366_000, 0) + // Minimum execution time: 7_091_000 picoseconds. + Weight::from_parts(7_479_000, 0) } pub(crate) fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_837_000 picoseconds. - Weight::from_parts(2_939_000, 0) + // Minimum execution time: 1_265_000 picoseconds. + Weight::from_parts(1_350_000, 0) } pub(crate) fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_526_000 picoseconds. - Weight::from_parts(2_622_000, 0) + // Minimum execution time: 727_000 picoseconds. + Weight::from_parts(773_000, 0) } pub(crate) fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_603_000 picoseconds. - Weight::from_parts(2_642_000, 0) + // Minimum execution time: 744_000 picoseconds. + Weight::from_parts(792_000, 0) } pub(crate) fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_500_000 picoseconds. - Weight::from_parts(2_573_000, 0) + // Minimum execution time: 676_000 picoseconds. + Weight::from_parts(743_000, 0) } pub(crate) fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_323_000 picoseconds. - Weight::from_parts(3_401_000, 0) + // Minimum execution time: 721_000 picoseconds. + Weight::from_parts(795_000, 0) } pub(crate) fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_557_000 picoseconds. - Weight::from_parts(2_620_000, 0) + // Minimum execution time: 703_000 picoseconds. + Weight::from_parts(761_000, 0) } - /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Storage: Dmp DeliveryFeeFactor (r:1 w:0) - /// Proof Skipped: Dmp DeliveryFeeFactor (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet SupportedVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) - /// Proof Skipped: XcmPallet VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: XcmPallet SafeXcmVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueues (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueues (max_values: None, max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn report_error() -> Weight { // Proof Size summary in bytes: - // Measured: `169` - // Estimated: `3634` - // Minimum execution time: 25_828_000 picoseconds. - Weight::from_parts(26_318_000, 3634) - .saturating_add(T::DbWeight::get().reads(7)) + // Measured: `351` + // Estimated: `6196` + // Minimum execution time: 65_242_000 picoseconds. + Weight::from_parts(67_004_000, 6196) + .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: XcmPallet AssetTraps (r:1 w:1) - /// Proof Skipped: XcmPallet AssetTraps (max_values: None, max_size: None, mode: Measured) + /// Storage: `XcmPallet::AssetTraps` (r:1 w:1) + /// Proof: `XcmPallet::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn claim_asset() -> Weight { // Proof Size summary in bytes: - // Measured: `226` - // Estimated: `3691` - // Minimum execution time: 14_794_000 picoseconds. - Weight::from_parts(15_306_000, 3691) + // Measured: `23` + // Estimated: `3488` + // Minimum execution time: 9_865_000 picoseconds. + Weight::from_parts(10_128_000, 3488) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -183,165 +168,151 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_534_000 picoseconds. - Weight::from_parts(2_574_000, 0) + // Minimum execution time: 693_000 picoseconds. + Weight::from_parts(766_000, 0) } - /// Storage: XcmPallet VersionNotifyTargets (r:1 w:1) - /// Proof Skipped: XcmPallet VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) - /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Storage: Dmp DeliveryFeeFactor (r:1 w:0) - /// Proof Skipped: Dmp DeliveryFeeFactor (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet SupportedVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) - /// Proof Skipped: XcmPallet VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: XcmPallet SafeXcmVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueues (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueues (max_values: None, max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured) + /// Storage: `XcmPallet::VersionNotifyTargets` (r:1 w:1) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn subscribe_version() -> Weight { // Proof Size summary in bytes: - // Measured: `169` - // Estimated: `3634` - // Minimum execution time: 32_218_000 picoseconds. - Weight::from_parts(32_945_000, 3634) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(5)) + // Measured: `147` + // Estimated: `3612` + // Minimum execution time: 31_295_000 picoseconds. + Weight::from_parts(31_680_000, 3612) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: XcmPallet VersionNotifyTargets (r:0 w:1) - /// Proof Skipped: XcmPallet VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) + /// Storage: `XcmPallet::VersionNotifyTargets` (r:0 w:1) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn unsubscribe_version() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_983_000 picoseconds. - Weight::from_parts(5_132_000, 0) + // Minimum execution time: 2_745_000 picoseconds. + Weight::from_parts(2_991_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub(crate) fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_101_000 picoseconds. - Weight::from_parts(4_228_000, 0) + // Minimum execution time: 1_100_000 picoseconds. + Weight::from_parts(1_154_000, 0) } pub(crate) fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_740_000 picoseconds. - Weight::from_parts(2_814_000, 0) + // Minimum execution time: 809_000 picoseconds. + Weight::from_parts(865_000, 0) } pub(crate) fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_716_000 picoseconds. - Weight::from_parts(2_795_000, 0) + // Minimum execution time: 740_000 picoseconds. + Weight::from_parts(770_000, 0) } pub(crate) fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_550_000 picoseconds. - Weight::from_parts(2_601_000, 0) + // Minimum execution time: 726_000 picoseconds. + Weight::from_parts(767_000, 0) } pub(crate) fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_762_000 picoseconds. - Weight::from_parts(2_849_000, 0) + // Minimum execution time: 883_000 picoseconds. + Weight::from_parts(955_000, 0) } - /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Storage: Dmp DeliveryFeeFactor (r:1 w:0) - /// Proof Skipped: Dmp DeliveryFeeFactor (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet SupportedVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) - /// Proof Skipped: XcmPallet VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: XcmPallet SafeXcmVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueues (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueues (max_values: None, max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn query_pallet() -> Weight { // Proof Size summary in bytes: - // Measured: `169` - // Estimated: `3634` - // Minimum execution time: 31_709_000 picoseconds. - Weight::from_parts(32_288_000, 3634) - .saturating_add(T::DbWeight::get().reads(7)) + // Measured: `351` + // Estimated: `6196` + // Minimum execution time: 74_854_000 picoseconds. + Weight::from_parts(76_335_000, 6196) + .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } pub(crate) fn expect_pallet() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_209_000 picoseconds. - Weight::from_parts(7_332_000, 0) + // Minimum execution time: 7_449_000 picoseconds. + Weight::from_parts(7_794_000, 0) } - /// Storage: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Proof Skipped: unknown `0x3a696e747261626c6f636b5f656e74726f7079` (r:1 w:1) - /// Storage: Dmp DeliveryFeeFactor (r:1 w:0) - /// Proof Skipped: Dmp DeliveryFeeFactor (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet SupportedVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SupportedVersion (max_values: None, max_size: None, mode: Measured) - /// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) - /// Proof Skipped: XcmPallet VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: XcmPallet SafeXcmVersion (r:1 w:0) - /// Proof Skipped: XcmPallet SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueues (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueues (max_values: None, max_size: None, mode: Measured) - /// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) - /// Proof Skipped: Dmp DownwardMessageQueueHeads (max_values: None, max_size: None, mode: Measured) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn report_transact_status() -> Weight { // Proof Size summary in bytes: - // Measured: `169` - // Estimated: `3634` - // Minimum execution time: 26_161_000 picoseconds. - Weight::from_parts(26_605_000, 3634) - .saturating_add(T::DbWeight::get().reads(7)) + // Measured: `351` + // Estimated: `6196` + // Minimum execution time: 65_264_000 picoseconds. + Weight::from_parts(67_864_000, 6196) + .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } pub(crate) fn clear_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_539_000 picoseconds. - Weight::from_parts(2_647_000, 0) + // Minimum execution time: 770_000 picoseconds. + Weight::from_parts(828_000, 0) } pub(crate) fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_494_000 picoseconds. - Weight::from_parts(2_588_000, 0) + // Minimum execution time: 717_000 picoseconds. + Weight::from_parts(756_000, 0) } pub(crate) fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_510_000 picoseconds. - Weight::from_parts(2_590_000, 0) + // Minimum execution time: 677_000 picoseconds. + Weight::from_parts(740_000, 0) } pub(crate) fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_491_000 picoseconds. - Weight::from_parts(2_546_000, 0) + // Minimum execution time: 708_000 picoseconds. + Weight::from_parts(753_000, 0) } pub(crate) fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_696_000 picoseconds. - Weight::from_parts(2_816_000, 0) + // Minimum execution time: 727_000 picoseconds. + Weight::from_parts(791_000, 0) } } From fb79e696ee5e9be43d7d569a54a7356ca4ea3a7e Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 11:21:39 +0000 Subject: [PATCH 020/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=coretime-westend --runtime_dir=coretime --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 123 +++++++++--------- 1 file changed, 58 insertions(+), 65 deletions(-) diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 6ac74f7316ec..bf2bf32af4af 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-05-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-unxyhko3-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: Some("coretime-westend-dev"), DB CACHE: 1024 // Executed Command: @@ -64,8 +64,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 23_688_000 picoseconds. - Weight::from_parts(24_845_000, 3571) + // Minimum execution time: 29_342_000 picoseconds. + Weight::from_parts(30_494_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,15 +73,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 569_000 picoseconds. - Weight::from_parts(619_000, 0) - } - pub fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 569_000 picoseconds. - Weight::from_parts(27_000_000, 0) + // Minimum execution time: 636_000 picoseconds. + Weight::from_parts(705_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -89,58 +82,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 5_851_000 picoseconds. - Weight::from_parts(6_061_000, 3497) + // Minimum execution time: 7_325_000 picoseconds. + Weight::from_parts(7_771_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_770_000 picoseconds. - Weight::from_parts(5_916_000, 0) + // Minimum execution time: 7_108_000 picoseconds. + Weight::from_parts(7_366_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_155_000 picoseconds. - Weight::from_parts(1_270_000, 0) + // Minimum execution time: 1_275_000 picoseconds. + Weight::from_parts(1_369_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 558_000 picoseconds. - Weight::from_parts(628_000, 0) + // Minimum execution time: 645_000 picoseconds. + Weight::from_parts(711_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 603_000 picoseconds. - Weight::from_parts(630_000, 0) + // Minimum execution time: 669_000 picoseconds. + Weight::from_parts(712_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 533_000 picoseconds. - Weight::from_parts(563_000, 0) + // Minimum execution time: 625_000 picoseconds. + Weight::from_parts(667_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 597_000 picoseconds. - Weight::from_parts(644_000, 0) + // Minimum execution time: 611_000 picoseconds. + Weight::from_parts(695_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 536_000 picoseconds. - Weight::from_parts(588_000, 0) + // Minimum execution time: 607_000 picoseconds. + Weight::from_parts(677_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -158,8 +151,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 21_146_000 picoseconds. - Weight::from_parts(21_771_000, 3571) + // Minimum execution time: 26_390_000 picoseconds. + Weight::from_parts(27_093_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -169,8 +162,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 8_446_000 picoseconds. - Weight::from_parts(8_660_000, 3555) + // Minimum execution time: 10_759_000 picoseconds. + Weight::from_parts(10_992_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -178,8 +171,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 561_000 picoseconds. - Weight::from_parts(594_000, 0) + // Minimum execution time: 638_000 picoseconds. + Weight::from_parts(706_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -197,8 +190,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `74` // Estimated: `3539` - // Minimum execution time: 19_953_000 picoseconds. - Weight::from_parts(20_608_000, 3539) + // Minimum execution time: 24_150_000 picoseconds. + Weight::from_parts(24_912_000, 3539) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -208,44 +201,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_290_000 picoseconds. - Weight::from_parts(2_370_000, 0) + // Minimum execution time: 2_600_000 picoseconds. + Weight::from_parts(2_721_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 943_000 picoseconds. - Weight::from_parts(987_000, 0) + // Minimum execution time: 987_000 picoseconds. + Weight::from_parts(1_065_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 635_000 picoseconds. - Weight::from_parts(699_000, 0) + // Minimum execution time: 693_000 picoseconds. + Weight::from_parts(766_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 553_000 picoseconds. - Weight::from_parts(609_000, 0) + // Minimum execution time: 630_000 picoseconds. + Weight::from_parts(706_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 547_000 picoseconds. - Weight::from_parts(581_000, 0) + // Minimum execution time: 621_000 picoseconds. + Weight::from_parts(700_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 700_000 picoseconds. - Weight::from_parts(757_000, 0) + // Minimum execution time: 812_000 picoseconds. + Weight::from_parts(865_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -263,8 +256,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 24_953_000 picoseconds. - Weight::from_parts(25_516_000, 3571) + // Minimum execution time: 30_319_000 picoseconds. + Weight::from_parts(31_182_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -272,8 +265,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_746_000 picoseconds. - Weight::from_parts(2_944_000, 0) + // Minimum execution time: 2_969_000 picoseconds. + Weight::from_parts(3_064_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -291,8 +284,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 21_325_000 picoseconds. - Weight::from_parts(21_942_000, 3571) + // Minimum execution time: 27_001_000 picoseconds. + Weight::from_parts(27_659_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -300,35 +293,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 600_000 picoseconds. - Weight::from_parts(631_000, 0) + // Minimum execution time: 680_000 picoseconds. + Weight::from_parts(717_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 534_000 picoseconds. - Weight::from_parts(566_000, 0) + // Minimum execution time: 616_000 picoseconds. + Weight::from_parts(670_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 540_000 picoseconds. - Weight::from_parts(565_000, 0) + // Minimum execution time: 637_000 picoseconds. + Weight::from_parts(671_000, 0) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 542_000 picoseconds. - Weight::from_parts(581_000, 0) + // Minimum execution time: 612_000 picoseconds. + Weight::from_parts(669_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 568_000 picoseconds. - Weight::from_parts(597_000, 0) + // Minimum execution time: 624_000 picoseconds. + Weight::from_parts(693_000, 0) } } From 4c9dddc842fbed2fbbd95749274e6c8614912677 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 11:22:15 +0000 Subject: [PATCH 021/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=asset-hub-rococo --runtime_dir=assets --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 129 +++++++++--------- 1 file changed, 61 insertions(+), 68 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index cd113c69a72a..692811c61799 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -16,10 +16,10 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-11-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-yprdrvc7-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -68,8 +68,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 440_298_000 picoseconds. - Weight::from_parts(446_508_000, 6196) + // Minimum execution time: 98_846_000 picoseconds. + Weight::from_parts(101_170_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -77,15 +77,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) - } - pub fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) + // Minimum execution time: 714_000 picoseconds. + Weight::from_parts(761_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -93,58 +86,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3568` - // Minimum execution time: 9_691_000 picoseconds. - Weight::from_parts(9_948_000, 3568) + // Minimum execution time: 9_482_000 picoseconds. + Weight::from_parts(9_796_000, 3568) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 10_384_000 picoseconds. - Weight::from_parts(11_085_000, 0) + // Minimum execution time: 7_038_000 picoseconds. + Weight::from_parts(7_378_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_438_000 picoseconds. - Weight::from_parts(3_577_000, 0) + // Minimum execution time: 2_731_000 picoseconds. + Weight::from_parts(2_874_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_126_000 picoseconds. - Weight::from_parts(2_243_000, 0) + // Minimum execution time: 719_000 picoseconds. + Weight::from_parts(770_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_126_000 picoseconds. - Weight::from_parts(2_207_000, 0) + // Minimum execution time: 720_000 picoseconds. + Weight::from_parts(760_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_105_000 picoseconds. - Weight::from_parts(2_193_000, 0) + // Minimum execution time: 680_000 picoseconds. + Weight::from_parts(733_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_999_000 picoseconds. - Weight::from_parts(3_056_000, 0) + // Minimum execution time: 750_000 picoseconds. + Weight::from_parts(815_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_091_000 picoseconds. - Weight::from_parts(2_176_000, 0) + // Minimum execution time: 680_000 picoseconds. + Weight::from_parts(747_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -166,8 +159,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 55_728_000 picoseconds. - Weight::from_parts(56_704_000, 6196) + // Minimum execution time: 65_772_000 picoseconds. + Weight::from_parts(67_940_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -177,8 +170,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `160` // Estimated: `3625` - // Minimum execution time: 12_839_000 picoseconds. - Weight::from_parts(13_457_000, 3625) + // Minimum execution time: 12_922_000 picoseconds. + Weight::from_parts(13_187_000, 3625) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -186,8 +179,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_116_000 picoseconds. - Weight::from_parts(2_219_000, 0) + // Minimum execution time: 674_000 picoseconds. + Weight::from_parts(738_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -207,8 +200,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `145` // Estimated: `3610` - // Minimum execution time: 24_891_000 picoseconds. - Weight::from_parts(25_583_000, 3610) + // Minimum execution time: 28_310_000 picoseconds. + Weight::from_parts(29_029_000, 3610) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -218,44 +211,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_968_000 picoseconds. - Weight::from_parts(4_122_000, 0) + // Minimum execution time: 2_723_000 picoseconds. + Weight::from_parts(2_808_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 136_220_000 picoseconds. - Weight::from_parts(137_194_000, 0) + // Minimum execution time: 22_277_000 picoseconds. + Weight::from_parts(22_898_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_343_000 picoseconds. - Weight::from_parts(12_635_000, 0) + // Minimum execution time: 6_165_000 picoseconds. + Weight::from_parts(6_328_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_237_000 picoseconds. - Weight::from_parts(2_315_000, 0) + // Minimum execution time: 700_000 picoseconds. + Weight::from_parts(742_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_094_000 picoseconds. - Weight::from_parts(2_231_000, 0) + // Minimum execution time: 676_000 picoseconds. + Weight::from_parts(731_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_379_000 picoseconds. - Weight::from_parts(2_455_000, 0) + // Minimum execution time: 840_000 picoseconds. + Weight::from_parts(894_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -277,8 +270,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 60_734_000 picoseconds. - Weight::from_parts(61_964_000, 6196) + // Minimum execution time: 70_914_000 picoseconds. + Weight::from_parts(72_252_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -286,8 +279,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_500_000 picoseconds. - Weight::from_parts(5_720_000, 0) + // Minimum execution time: 4_482_000 picoseconds. + Weight::from_parts(4_606_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -309,8 +302,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 55_767_000 picoseconds. - Weight::from_parts(56_790_000, 6196) + // Minimum execution time: 65_617_000 picoseconds. + Weight::from_parts(67_713_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -318,22 +311,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_201_000 picoseconds. - Weight::from_parts(2_291_000, 0) + // Minimum execution time: 695_000 picoseconds. + Weight::from_parts(755_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_164_000 picoseconds. - Weight::from_parts(2_241_000, 0) + // Minimum execution time: 682_000 picoseconds. + Weight::from_parts(726_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_127_000 picoseconds. - Weight::from_parts(2_236_000, 0) + // Minimum execution time: 678_000 picoseconds. + Weight::from_parts(710_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -341,22 +334,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1489` - // Minimum execution time: 4_275_000 picoseconds. - Weight::from_parts(4_381_000, 1489) + // Minimum execution time: 2_630_000 picoseconds. + Weight::from_parts(2_700_000, 1489) .saturating_add(T::DbWeight::get().reads(1)) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_132_000 picoseconds. - Weight::from_parts(2_216_000, 0) + // Minimum execution time: 675_000 picoseconds. + Weight::from_parts(718_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_265_000 picoseconds. - Weight::from_parts(2_332_000, 0) + // Minimum execution time: 700_000 picoseconds. + Weight::from_parts(757_000, 0) } } From a8d5d1db3a675625cb248f7edb43bb45a5e8864e Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 11:22:21 +0000 Subject: [PATCH 022/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=asset-hub-westend --runtime_dir=assets --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 154 +++++++++--------- 1 file changed, 74 insertions(+), 80 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 18517cf38822..b989f733b8aa 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -1,24 +1,25 @@ // Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// This file is part of Cumulus. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-10-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-vmdtonbz-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: @@ -67,8 +68,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 415_033_000 picoseconds. - Weight::from_parts(429_573_000, 6196) + // Minimum execution time: 99_623_000 picoseconds. + Weight::from_parts(102_135_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -76,15 +77,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_193_000 picoseconds. - Weight::from_parts(3_620_000, 0) - } - pub fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_193_000 picoseconds. - Weight::from_parts(27_000_000, 0) + // Minimum execution time: 682_000 picoseconds. + Weight::from_parts(741_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -92,58 +86,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3568` - // Minimum execution time: 8_045_000 picoseconds. - Weight::from_parts(8_402_000, 3568) + // Minimum execution time: 8_193_000 picoseconds. + Weight::from_parts(8_456_000, 3568) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_827_000 picoseconds. - Weight::from_parts(10_454_000, 0) + // Minimum execution time: 7_079_000 picoseconds. + Weight::from_parts(7_300_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_330_000 picoseconds. - Weight::from_parts(3_677_000, 0) + // Minimum execution time: 2_688_000 picoseconds. + Weight::from_parts(2_840_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_947_000 picoseconds. - Weight::from_parts(2_083_000, 0) + // Minimum execution time: 702_000 picoseconds. + Weight::from_parts(758_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_915_000 picoseconds. - Weight::from_parts(1_993_000, 0) + // Minimum execution time: 702_000 picoseconds. + Weight::from_parts(767_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_918_000 picoseconds. - Weight::from_parts(2_048_000, 0) + // Minimum execution time: 686_000 picoseconds. + Weight::from_parts(734_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_683_000 picoseconds. - Weight::from_parts(3_064_000, 0) + // Minimum execution time: 724_000 picoseconds. + Weight::from_parts(769_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_893_000 picoseconds. - Weight::from_parts(2_159_000, 0) + // Minimum execution time: 680_000 picoseconds. + Weight::from_parts(744_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -165,8 +159,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 53_116_000 picoseconds. - Weight::from_parts(54_154_000, 6196) + // Minimum execution time: 67_334_000 picoseconds. + Weight::from_parts(69_168_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -176,8 +170,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `160` // Estimated: `3625` - // Minimum execution time: 12_381_000 picoseconds. - Weight::from_parts(12_693_000, 3625) + // Minimum execution time: 12_827_000 picoseconds. + Weight::from_parts(13_247_000, 3625) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -185,8 +179,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_933_000 picoseconds. - Weight::from_parts(1_983_000, 0) + // Minimum execution time: 666_000 picoseconds. + Weight::from_parts(705_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -206,8 +200,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `145` // Estimated: `3610` - // Minimum execution time: 24_251_000 picoseconds. - Weight::from_parts(24_890_000, 3610) + // Minimum execution time: 27_849_000 picoseconds. + Weight::from_parts(28_522_000, 3610) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -217,44 +211,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_850_000 picoseconds. - Weight::from_parts(4_082_000, 0) + // Minimum execution time: 2_600_000 picoseconds. + Weight::from_parts(2_741_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 112_248_000 picoseconds. - Weight::from_parts(124_454_000, 0) + // Minimum execution time: 22_267_000 picoseconds. + Weight::from_parts(22_859_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_457_000 picoseconds. - Weight::from_parts(12_060_000, 0) + // Minimum execution time: 6_365_000 picoseconds. + Weight::from_parts(6_519_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_959_000 picoseconds. - Weight::from_parts(2_076_000, 0) + // Minimum execution time: 694_000 picoseconds. + Weight::from_parts(742_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_920_000 picoseconds. - Weight::from_parts(1_994_000, 0) + // Minimum execution time: 673_000 picoseconds. + Weight::from_parts(729_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_149_000 picoseconds. - Weight::from_parts(2_394_000, 0) + // Minimum execution time: 822_000 picoseconds. + Weight::from_parts(916_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -276,8 +270,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 58_011_000 picoseconds. - Weight::from_parts(59_306_000, 6196) + // Minimum execution time: 72_037_000 picoseconds. + Weight::from_parts(73_974_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -285,8 +279,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_031_000 picoseconds. - Weight::from_parts(5_243_000, 0) + // Minimum execution time: 4_349_000 picoseconds. + Weight::from_parts(4_523_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -308,8 +302,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 53_078_000 picoseconds. - Weight::from_parts(54_345_000, 6196) + // Minimum execution time: 67_524_000 picoseconds. + Weight::from_parts(68_886_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -317,22 +311,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_936_000 picoseconds. - Weight::from_parts(2_002_000, 0) + // Minimum execution time: 723_000 picoseconds. + Weight::from_parts(794_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_855_000 picoseconds. - Weight::from_parts(1_950_000, 0) + // Minimum execution time: 688_000 picoseconds. + Weight::from_parts(725_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_882_000 picoseconds. - Weight::from_parts(1_977_000, 0) + // Minimum execution time: 682_000 picoseconds. + Weight::from_parts(752_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -340,22 +334,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1489` - // Minimum execution time: 3_912_000 picoseconds. - Weight::from_parts(4_167_000, 1489) + // Minimum execution time: 2_634_000 picoseconds. + Weight::from_parts(2_764_000, 1489) .saturating_add(T::DbWeight::get().reads(1)) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_911_000 picoseconds. - Weight::from_parts(1_971_000, 0) + // Minimum execution time: 646_000 picoseconds. + Weight::from_parts(706_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_990_000 picoseconds. - Weight::from_parts(2_076_000, 0) + // Minimum execution time: 730_000 picoseconds. + Weight::from_parts(762_000, 0) } } From c1c95dca8a5b50903efd9cb3d877eed58d411412 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 11:22:41 +0000 Subject: [PATCH 023/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=coretime-rococo --runtime_dir=coretime --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 123 +++++++++--------- 1 file changed, 58 insertions(+), 65 deletions(-) diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index bd857e114d1b..afad2ea0e538 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-05-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-unxyhko3-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: Some("coretime-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -64,8 +64,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 23_760_000 picoseconds. - Weight::from_parts(24_411_000, 3571) + // Minimum execution time: 28_989_000 picoseconds. + Weight::from_parts(30_034_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,15 +73,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 522_000 picoseconds. - Weight::from_parts(546_000, 0) - } - pub fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) + // Minimum execution time: 598_000 picoseconds. + Weight::from_parts(645_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -89,58 +82,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 5_830_000 picoseconds. - Weight::from_parts(6_069_000, 3497) + // Minimum execution time: 7_377_000 picoseconds. + Weight::from_parts(7_684_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_508_000 picoseconds. - Weight::from_parts(5_801_000, 0) + // Minimum execution time: 6_777_000 picoseconds. + Weight::from_parts(6_999_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_130_000 picoseconds. - Weight::from_parts(1_239_000, 0) + // Minimum execution time: 1_386_000 picoseconds. + Weight::from_parts(1_443_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 541_000 picoseconds. - Weight::from_parts(567_000, 0) + // Minimum execution time: 648_000 picoseconds. + Weight::from_parts(707_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 560_000 picoseconds. - Weight::from_parts(591_000, 0) + // Minimum execution time: 634_000 picoseconds. + Weight::from_parts(692_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 505_000 picoseconds. - Weight::from_parts(547_000, 0) + // Minimum execution time: 620_000 picoseconds. + Weight::from_parts(666_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 538_000 picoseconds. - Weight::from_parts(565_000, 0) + // Minimum execution time: 634_000 picoseconds. + Weight::from_parts(672_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 514_000 picoseconds. - Weight::from_parts(541_000, 0) + // Minimum execution time: 617_000 picoseconds. + Weight::from_parts(664_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -158,8 +151,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 20_920_000 picoseconds. - Weight::from_parts(21_437_000, 3571) + // Minimum execution time: 26_036_000 picoseconds. + Weight::from_parts(26_763_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -169,8 +162,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 8_549_000 picoseconds. - Weight::from_parts(8_821_000, 3555) + // Minimum execution time: 10_728_000 picoseconds. + Weight::from_parts(11_009_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -178,8 +171,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 525_000 picoseconds. - Weight::from_parts(544_000, 0) + // Minimum execution time: 617_000 picoseconds. + Weight::from_parts(677_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -197,8 +190,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `74` // Estimated: `3539` - // Minimum execution time: 19_645_000 picoseconds. - Weight::from_parts(20_104_000, 3539) + // Minimum execution time: 24_296_000 picoseconds. + Weight::from_parts(24_914_000, 3539) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -208,44 +201,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_232_000 picoseconds. - Weight::from_parts(2_334_000, 0) + // Minimum execution time: 2_427_000 picoseconds. + Weight::from_parts(2_635_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 883_000 picoseconds. - Weight::from_parts(945_000, 0) + // Minimum execution time: 1_058_000 picoseconds. + Weight::from_parts(1_097_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 600_000 picoseconds. - Weight::from_parts(645_000, 0) + // Minimum execution time: 694_000 picoseconds. + Weight::from_parts(758_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 527_000 picoseconds. - Weight::from_parts(552_000, 0) + // Minimum execution time: 600_000 picoseconds. + Weight::from_parts(660_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 527_000 picoseconds. - Weight::from_parts(550_000, 0) + // Minimum execution time: 617_000 picoseconds. + Weight::from_parts(677_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 657_000 picoseconds. - Weight::from_parts(703_000, 0) + // Minimum execution time: 783_000 picoseconds. + Weight::from_parts(856_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -263,8 +256,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 24_999_000 picoseconds. - Weight::from_parts(25_671_000, 3571) + // Minimum execution time: 29_616_000 picoseconds. + Weight::from_parts(30_997_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -272,8 +265,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_159_000 picoseconds. - Weight::from_parts(3_296_000, 0) + // Minimum execution time: 3_034_000 picoseconds. + Weight::from_parts(3_208_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -291,8 +284,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 21_052_000 picoseconds. - Weight::from_parts(22_153_000, 3571) + // Minimum execution time: 26_488_000 picoseconds. + Weight::from_parts(27_218_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -300,35 +293,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 547_000 picoseconds. - Weight::from_parts(584_000, 0) + // Minimum execution time: 639_000 picoseconds. + Weight::from_parts(688_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 506_000 picoseconds. - Weight::from_parts(551_000, 0) + // Minimum execution time: 650_000 picoseconds. + Weight::from_parts(678_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 508_000 picoseconds. - Weight::from_parts(527_000, 0) + // Minimum execution time: 621_000 picoseconds. + Weight::from_parts(650_000, 0) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 527_000 picoseconds. - Weight::from_parts(558_000, 0) + // Minimum execution time: 587_000 picoseconds. + Weight::from_parts(660_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 514_000 picoseconds. - Weight::from_parts(553_000, 0) + // Minimum execution time: 628_000 picoseconds. + Weight::from_parts(664_000, 0) } } From 0c5afe316d25284ec7fc0ebd80655d3c38dee751 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 11:23:33 +0000 Subject: [PATCH 024/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=bridge-hub-rococo --runtime_dir=bridge-hubs --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 131 +++++++++--------- 1 file changed, 62 insertions(+), 69 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index b837fe961fa6..d4f819963f63 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-07-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-7wrmsoux-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -68,8 +68,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `171` // Estimated: `6196` - // Minimum execution time: 60_119_000 picoseconds. - Weight::from_parts(61_871_000, 6196) + // Minimum execution time: 69_768_000 picoseconds. + Weight::from_parts(71_375_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -77,15 +77,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 998_000 picoseconds. - Weight::from_parts(1_038_000, 0) - } - pub fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) + // Minimum execution time: 1_074_000 picoseconds. + Weight::from_parts(1_141_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -93,58 +86,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 6_327_000 picoseconds. - Weight::from_parts(6_520_000, 3497) + // Minimum execution time: 7_797_000 picoseconds. + Weight::from_parts(7_982_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_783_000 picoseconds. - Weight::from_parts(7_117_000, 0) + // Minimum execution time: 7_824_000 picoseconds. + Weight::from_parts(8_101_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_589_000 picoseconds. - Weight::from_parts(1_655_000, 0) + // Minimum execution time: 1_778_000 picoseconds. + Weight::from_parts(1_840_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_013_000 picoseconds. - Weight::from_parts(1_045_000, 0) + // Minimum execution time: 1_081_000 picoseconds. + Weight::from_parts(1_139_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_005_000 picoseconds. - Weight::from_parts(1_044_000, 0) + // Minimum execution time: 1_096_000 picoseconds. + Weight::from_parts(1_163_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 964_000 picoseconds. - Weight::from_parts(1_011_000, 0) + // Minimum execution time: 1_034_000 picoseconds. + Weight::from_parts(1_126_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_005_000 picoseconds. - Weight::from_parts(1_027_000, 0) + // Minimum execution time: 1_108_000 picoseconds. + Weight::from_parts(1_191_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 980_000 picoseconds. - Weight::from_parts(1_009_000, 0) + // Minimum execution time: 1_095_000 picoseconds. + Weight::from_parts(1_128_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -166,8 +159,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `171` // Estimated: `6196` - // Minimum execution time: 56_726_000 picoseconds. - Weight::from_parts(59_300_000, 6196) + // Minimum execution time: 66_920_000 picoseconds. + Weight::from_parts(68_038_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -177,8 +170,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 8_962_000 picoseconds. - Weight::from_parts(9_519_000, 3555) + // Minimum execution time: 11_065_000 picoseconds. + Weight::from_parts(11_493_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -186,8 +179,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 999_000 picoseconds. - Weight::from_parts(1_035_000, 0) + // Minimum execution time: 1_100_000 picoseconds. + Weight::from_parts(1_146_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -207,8 +200,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `38` // Estimated: `3503` - // Minimum execution time: 20_313_000 picoseconds. - Weight::from_parts(21_000_000, 3503) + // Minimum execution time: 25_386_000 picoseconds. + Weight::from_parts(26_181_000, 3503) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -218,44 +211,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_820_000 picoseconds. - Weight::from_parts(2_949_000, 0) + // Minimum execution time: 2_902_000 picoseconds. + Weight::from_parts(3_055_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_293_000 picoseconds. - Weight::from_parts(1_354_000, 0) + // Minimum execution time: 1_480_000 picoseconds. + Weight::from_parts(1_570_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_076_000 picoseconds. - Weight::from_parts(1_114_000, 0) + // Minimum execution time: 1_187_000 picoseconds. + Weight::from_parts(1_243_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_014_000 picoseconds. - Weight::from_parts(1_055_000, 0) + // Minimum execution time: 1_108_000 picoseconds. + Weight::from_parts(1_179_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 979_000 picoseconds. - Weight::from_parts(1_019_000, 0) + // Minimum execution time: 1_099_000 picoseconds. + Weight::from_parts(1_160_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_161_000 picoseconds. - Weight::from_parts(1_208_000, 0) + // Minimum execution time: 1_242_000 picoseconds. + Weight::from_parts(1_321_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -277,8 +270,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `171` // Estimated: `6196` - // Minimum execution time: 62_250_000 picoseconds. - Weight::from_parts(64_477_000, 6196) + // Minimum execution time: 71_619_000 picoseconds. + Weight::from_parts(73_697_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -286,8 +279,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_286_000 picoseconds. - Weight::from_parts(4_476_000, 0) + // Minimum execution time: 4_461_000 picoseconds. + Weight::from_parts(4_664_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -309,8 +302,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `171` // Estimated: `6196` - // Minimum execution time: 58_253_000 picoseconds. - Weight::from_parts(59_360_000, 6196) + // Minimum execution time: 67_467_000 picoseconds. + Weight::from_parts(69_149_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -318,22 +311,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_026_000 picoseconds. - Weight::from_parts(1_065_000, 0) + // Minimum execution time: 1_098_000 picoseconds. + Weight::from_parts(1_191_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 993_000 picoseconds. - Weight::from_parts(1_015_000, 0) + // Minimum execution time: 1_070_000 picoseconds. + Weight::from_parts(1_150_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 966_000 picoseconds. - Weight::from_parts(999_000, 0) + // Minimum execution time: 1_079_000 picoseconds. + Weight::from_parts(1_144_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -352,10 +345,10 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `190` // Estimated: `6130` - // Minimum execution time: 37_014_000 picoseconds. - Weight::from_parts(38_096_655, 6130) - // Standard Error: 61 - .saturating_add(Weight::from_parts(45_146, 0).saturating_mul(x.into())) + // Minimum execution time: 42_708_000 picoseconds. + Weight::from_parts(43_821_835, 6130) + // Standard Error: 90 + .saturating_add(Weight::from_parts(45_150, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -363,14 +356,14 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 996_000 picoseconds. - Weight::from_parts(1_025_000, 0) + // Minimum execution time: 1_095_000 picoseconds. + Weight::from_parts(1_124_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_001_000 picoseconds. - Weight::from_parts(1_044_000, 0) + // Minimum execution time: 1_086_000 picoseconds. + Weight::from_parts(1_133_000, 0) } } From 338d8deafb7c7e9ab7d82358a701b8865f81ef94 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 11:24:30 +0000 Subject: [PATCH 025/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=bridge-hub-westend --runtime_dir=bridge-hubs --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 131 +++++++++--------- 1 file changed, 62 insertions(+), 69 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 8bd6719bda8e..a0e30f16dd23 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-07-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-7wrmsoux-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-westend-dev"), DB CACHE: 1024 // Executed Command: @@ -68,8 +68,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `208` // Estimated: `6196` - // Minimum execution time: 58_505_000 picoseconds. - Weight::from_parts(60_437_000, 6196) + // Minimum execution time: 70_164_000 picoseconds. + Weight::from_parts(71_831_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -77,15 +77,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 510_000 picoseconds. - Weight::from_parts(569_000, 0) - } - pub fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 510_000 picoseconds. - Weight::from_parts(27_000_000, 0) + // Minimum execution time: 1_062_000 picoseconds. + Weight::from_parts(1_142_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -93,58 +86,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 5_597_000 picoseconds. - Weight::from_parts(5_884_000, 3497) + // Minimum execution time: 7_942_000 picoseconds. + Weight::from_parts(8_094_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_320_000 picoseconds. - Weight::from_parts(5_594_000, 0) + // Minimum execution time: 7_908_000 picoseconds. + Weight::from_parts(8_270_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_164_000 picoseconds. - Weight::from_parts(1_227_000, 0) + // Minimum execution time: 1_793_000 picoseconds. + Weight::from_parts(1_855_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 528_000 picoseconds. - Weight::from_parts(586_000, 0) + // Minimum execution time: 1_134_000 picoseconds. + Weight::from_parts(1_160_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 509_000 picoseconds. - Weight::from_parts(571_000, 0) + // Minimum execution time: 1_117_000 picoseconds. + Weight::from_parts(1_144_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 511_000 picoseconds. - Weight::from_parts(546_000, 0) + // Minimum execution time: 1_088_000 picoseconds. + Weight::from_parts(1_122_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 560_000 picoseconds. - Weight::from_parts(600_000, 0) + // Minimum execution time: 1_123_000 picoseconds. + Weight::from_parts(1_178_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 514_000 picoseconds. - Weight::from_parts(558_000, 0) + // Minimum execution time: 1_115_000 picoseconds. + Weight::from_parts(1_152_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -166,8 +159,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `208` // Estimated: `6196` - // Minimum execution time: 55_871_000 picoseconds. - Weight::from_parts(57_172_000, 6196) + // Minimum execution time: 67_318_000 picoseconds. + Weight::from_parts(68_367_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -177,8 +170,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 8_487_000 picoseconds. - Weight::from_parts(8_800_000, 3555) + // Minimum execution time: 11_141_000 picoseconds. + Weight::from_parts(11_631_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -186,8 +179,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 528_000 picoseconds. - Weight::from_parts(569_000, 0) + // Minimum execution time: 1_068_000 picoseconds. + Weight::from_parts(1_128_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -207,8 +200,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `38` // Estimated: `3503` - // Minimum execution time: 19_803_000 picoseconds. - Weight::from_parts(20_368_000, 3503) + // Minimum execution time: 25_253_000 picoseconds. + Weight::from_parts(26_092_000, 3503) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -218,44 +211,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_185_000 picoseconds. - Weight::from_parts(2_332_000, 0) + // Minimum execution time: 3_129_000 picoseconds. + Weight::from_parts(3_237_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 822_000 picoseconds. - Weight::from_parts(928_000, 0) + // Minimum execution time: 1_466_000 picoseconds. + Weight::from_parts(1_549_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 603_000 picoseconds. - Weight::from_parts(643_000, 0) + // Minimum execution time: 1_215_000 picoseconds. + Weight::from_parts(1_272_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 503_000 picoseconds. - Weight::from_parts(580_000, 0) + // Minimum execution time: 1_141_000 picoseconds. + Weight::from_parts(1_195_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 534_000 picoseconds. - Weight::from_parts(577_000, 0) + // Minimum execution time: 1_088_000 picoseconds. + Weight::from_parts(1_134_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 694_000 picoseconds. - Weight::from_parts(745_000, 0) + // Minimum execution time: 1_267_000 picoseconds. + Weight::from_parts(1_337_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -277,8 +270,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `208` // Estimated: `6196` - // Minimum execution time: 61_083_000 picoseconds. - Weight::from_parts(62_214_000, 6196) + // Minimum execution time: 71_358_000 picoseconds. + Weight::from_parts(73_042_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -286,8 +279,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_261_000 picoseconds. - Weight::from_parts(3_483_000, 0) + // Minimum execution time: 4_230_000 picoseconds. + Weight::from_parts(4_400_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -309,8 +302,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `208` // Estimated: `6196` - // Minimum execution time: 56_270_000 picoseconds. - Weight::from_parts(57_443_000, 6196) + // Minimum execution time: 67_219_000 picoseconds. + Weight::from_parts(68_845_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -318,22 +311,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 565_000 picoseconds. - Weight::from_parts(628_000, 0) + // Minimum execution time: 1_142_000 picoseconds. + Weight::from_parts(1_191_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 496_000 picoseconds. - Weight::from_parts(563_000, 0) + // Minimum execution time: 1_050_000 picoseconds. + Weight::from_parts(1_138_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 518_000 picoseconds. - Weight::from_parts(557_000, 0) + // Minimum execution time: 1_036_000 picoseconds. + Weight::from_parts(1_128_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -352,10 +345,10 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `225` // Estimated: `6165` - // Minimum execution time: 36_288_000 picoseconds. - Weight::from_parts(37_707_751, 6165) - // Standard Error: 124 - .saturating_add(Weight::from_parts(51_290, 0).saturating_mul(x.into())) + // Minimum execution time: 43_070_000 picoseconds. + Weight::from_parts(44_862_050, 6165) + // Standard Error: 156 + .saturating_add(Weight::from_parts(46_495, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -363,14 +356,14 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 485_000 picoseconds. - Weight::from_parts(540_000, 0) + // Minimum execution time: 1_063_000 picoseconds. + Weight::from_parts(1_139_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 542_000 picoseconds. - Weight::from_parts(586_000, 0) + // Minimum execution time: 1_116_000 picoseconds. + Weight::from_parts(1_171_000, 0) } } From 12164f812fa9a849f03845ff76d39aca175a9ecf Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 11:25:34 +0000 Subject: [PATCH 026/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=people-westend --runtime_dir=people --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 121 +++++++++--------- 1 file changed, 57 insertions(+), 64 deletions(-) diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 37a111652bf4..4c0da2a90e84 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-08-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-696hpswk-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: Some("people-westend-dev"), DB CACHE: 1024 // Executed Command: @@ -64,8 +64,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `70` // Estimated: `3535` - // Minimum execution time: 29_537_000 picoseconds. - Weight::from_parts(30_513_000, 3535) + // Minimum execution time: 28_774_000 picoseconds. + Weight::from_parts(29_235_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,15 +73,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 683_000 picoseconds. - Weight::from_parts(738_000, 0) - } - pub fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 683_000 picoseconds. - Weight::from_parts(27_000_000, 0) + // Minimum execution time: 615_000 picoseconds. + Weight::from_parts(701_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -89,58 +82,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 7_498_000 picoseconds. - Weight::from_parts(7_904_000, 3497) + // Minimum execution time: 7_372_000 picoseconds. + Weight::from_parts(7_587_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_029_000 picoseconds. - Weight::from_parts(7_325_000, 0) + // Minimum execution time: 6_820_000 picoseconds. + Weight::from_parts(7_044_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_343_000 picoseconds. - Weight::from_parts(1_410_000, 0) + // Minimum execution time: 1_260_000 picoseconds. + Weight::from_parts(1_345_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 696_000 picoseconds. - Weight::from_parts(734_000, 0) + // Minimum execution time: 671_000 picoseconds. + Weight::from_parts(721_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 690_000 picoseconds. + // Minimum execution time: 711_000 picoseconds. Weight::from_parts(740_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 667_000 picoseconds. - Weight::from_parts(697_000, 0) + // Minimum execution time: 631_000 picoseconds. + Weight::from_parts(678_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 692_000 picoseconds. - Weight::from_parts(743_000, 0) + // Minimum execution time: 684_000 picoseconds. + Weight::from_parts(725_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 670_000 picoseconds. - Weight::from_parts(712_000, 0) + // Minimum execution time: 634_000 picoseconds. + Weight::from_parts(688_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -158,8 +151,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `70` // Estimated: `3535` - // Minimum execution time: 26_405_000 picoseconds. - Weight::from_parts(26_877_000, 3535) + // Minimum execution time: 25_697_000 picoseconds. + Weight::from_parts(26_374_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -169,8 +162,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 10_953_000 picoseconds. - Weight::from_parts(11_345_000, 3555) + // Minimum execution time: 10_636_000 picoseconds. + Weight::from_parts(10_929_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -178,8 +171,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 644_000 picoseconds. - Weight::from_parts(693_000, 0) + // Minimum execution time: 652_000 picoseconds. + Weight::from_parts(698_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -197,8 +190,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `38` // Estimated: `3503` - // Minimum execution time: 24_157_000 picoseconds. - Weight::from_parts(24_980_000, 3503) + // Minimum execution time: 23_730_000 picoseconds. + Weight::from_parts(24_449_000, 3503) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -208,44 +201,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_767_000 picoseconds. - Weight::from_parts(2_844_000, 0) + // Minimum execution time: 2_471_000 picoseconds. + Weight::from_parts(2_621_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_079_000 picoseconds. - Weight::from_parts(1_141_000, 0) + // Minimum execution time: 1_003_000 picoseconds. + Weight::from_parts(1_049_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 776_000 picoseconds. - Weight::from_parts(829_000, 0) + // Minimum execution time: 730_000 picoseconds. + Weight::from_parts(784_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 696_000 picoseconds. - Weight::from_parts(740_000, 0) + // Minimum execution time: 653_000 picoseconds. + Weight::from_parts(722_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 655_000 picoseconds. - Weight::from_parts(684_000, 0) + // Minimum execution time: 643_000 picoseconds. + Weight::from_parts(707_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 825_000 picoseconds. - Weight::from_parts(853_000, 0) + // Minimum execution time: 828_000 picoseconds. + Weight::from_parts(887_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -263,8 +256,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `70` // Estimated: `3535` - // Minimum execution time: 30_222_000 picoseconds. - Weight::from_parts(31_110_000, 3535) + // Minimum execution time: 29_084_000 picoseconds. + Weight::from_parts(29_956_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -272,8 +265,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_108_000 picoseconds. - Weight::from_parts(3_325_000, 0) + // Minimum execution time: 3_215_000 picoseconds. + Weight::from_parts(3_344_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -291,8 +284,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `70` // Estimated: `3535` - // Minimum execution time: 26_548_000 picoseconds. - Weight::from_parts(26_911_000, 3535) + // Minimum execution time: 25_740_000 picoseconds. + Weight::from_parts(26_975_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -300,35 +293,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 684_000 picoseconds. - Weight::from_parts(726_000, 0) + // Minimum execution time: 720_000 picoseconds. + Weight::from_parts(775_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 649_000 picoseconds. - Weight::from_parts(700_000, 0) + // Minimum execution time: 642_000 picoseconds. + Weight::from_parts(701_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 650_000 picoseconds. - Weight::from_parts(686_000, 0) + // Minimum execution time: 636_000 picoseconds. + Weight::from_parts(682_000, 0) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 652_000 picoseconds. - Weight::from_parts(703_000, 0) + // Minimum execution time: 641_000 picoseconds. + Weight::from_parts(696_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 673_000 picoseconds. - Weight::from_parts(742_000, 0) + // Minimum execution time: 676_000 picoseconds. + Weight::from_parts(730_000, 0) } } From c3b6bd0bad9c9e9409557397758b6b823a8e490f Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Tue, 27 Aug 2024 15:18:53 +0200 Subject: [PATCH 027/151] chore: add missing benchmark and made up benchmarks for all runtimes --- .../weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 +++++++ .../src/generic/benchmarking.rs | 15 +++++++++++++++ 11 files changed, 85 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 692811c61799..839c3b524b79 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -80,6 +80,13 @@ impl WeightInfo { // Minimum execution time: 714_000 picoseconds. Weight::from_parts(761_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index b989f733b8aa..ae133b6ba044 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -80,6 +80,13 @@ impl WeightInfo { // Minimum execution time: 682_000 picoseconds. Weight::from_parts(741_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index d4f819963f63..a052814f2648 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -80,6 +80,13 @@ impl WeightInfo { // Minimum execution time: 1_074_000 picoseconds. Weight::from_parts(1_141_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index a0e30f16dd23..75f60c42caa5 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -80,6 +80,13 @@ impl WeightInfo { // Minimum execution time: 1_062_000 picoseconds. Weight::from_parts(1_142_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index afad2ea0e538..1a5ecf466daa 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -76,6 +76,13 @@ impl WeightInfo { // Minimum execution time: 598_000 picoseconds. Weight::from_parts(645_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index bf2bf32af4af..c5dd552f7d4b 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -76,6 +76,13 @@ impl WeightInfo { // Minimum execution time: 636_000 picoseconds. Weight::from_parts(705_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 587035c6a705..0486c05d68f3 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -83,6 +83,13 @@ impl WeightInfo { // Minimum execution time: 3_313_000 picoseconds. Weight::from_parts(3_422_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 4c0da2a90e84..8a9ba7a5bc5a 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -76,6 +76,13 @@ impl WeightInfo { // Minimum execution time: 615_000 picoseconds. Weight::from_parts(701_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { diff --git a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 3c5cdaa60bfd..860824805156 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -75,6 +75,13 @@ impl WeightInfo { // Minimum execution time: 655_000 picoseconds. Weight::from_parts(728_000, 0) } + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } /// Storage: `XcmPallet::Queries` (r:1 w:0) /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn query_response() -> Weight { diff --git a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index d4d4b7470904..26513ef42987 100644 --- a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -75,6 +75,13 @@ impl WeightInfo { // Minimum execution time: 710_000 picoseconds. Weight::from_parts(764_000, 0) } + pub(crate) fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_313_000 picoseconds. + Weight::from_parts(3_422_000, 0) + } /// Storage: `XcmPallet::Queries` (r:1 w:0) /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub(crate) fn query_response() -> Weight { diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 40a7da58a687..cf2312b61c25 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -98,6 +98,21 @@ benchmarks! { } + pay_fees { + let holding = T::worst_case_holding(0).into(); + + let mut executor = new_executor::(Default::default()); + executor.set_holding(holding); + + let fee_asset = T::fee_asset().unwrap(); + + let instruction = Instruction::>::PayFees { asset: fee_asset }; + + let xcm = Xcm(vec![instruction]); + } : { + executor.bench_process(xcm)?; + } verify {} + query_response { let mut executor = new_executor::(Default::default()); let (query_id, response) = T::worst_case_response(); From e2c620e845f415f34e51eaf247ad334bcdd6afb1 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Tue, 27 Aug 2024 15:26:20 +0200 Subject: [PATCH 028/151] fix: remove duplicated weight --- .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 0486c05d68f3..587035c6a705 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -83,13 +83,6 @@ impl WeightInfo { // Minimum execution time: 3_313_000 picoseconds. Weight::from_parts(3_422_000, 0) } - pub fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) - } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn query_response() -> Weight { From 86b151c6f189d426ebfbedb86ab5ee75ba86b405 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Tue, 27 Aug 2024 15:32:47 +0200 Subject: [PATCH 029/151] fix: remove unused imports --- .../assets/asset-hub-rococo/src/tests/xcm_fee_estimation.rs | 5 +---- .../assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/xcm_fee_estimation.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/xcm_fee_estimation.rs index ccf3dc3f5d4c..c87dd5cdbbb0 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/xcm_fee_estimation.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/xcm_fee_estimation.rs @@ -17,10 +17,7 @@ use crate::imports::*; use emulated_integration_tests_common::test_can_estimate_and_pay_exact_fees; -use frame_support::{ - dispatch::RawOrigin, - sp_runtime::{traits::Dispatchable, DispatchResult}, -}; +use frame_support::dispatch::RawOrigin; use xcm_runtime_apis::{ dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs index db26bc87f00f..de22d15a5021 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs @@ -18,10 +18,7 @@ use crate::imports::*; use emulated_integration_tests_common::test_can_estimate_and_pay_exact_fees; -use frame_support::{ - dispatch::RawOrigin, - sp_runtime::{traits::Dispatchable, DispatchResult}, -}; +use frame_support::dispatch::RawOrigin; use xcm_runtime_apis::{ dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, From 0eaa9fb98eb3fcf211b455ae4b6746b92f9559bb Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 15:21:16 +0000 Subject: [PATCH 030/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=westend --target_dir=polkadot --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 114 +++++++++--------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 26513ef42987..4cc979959483 100644 --- a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -63,8 +63,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6196` - // Minimum execution time: 67_452_000 picoseconds. - Weight::from_parts(69_450_000, 6196) + // Minimum execution time: 68_015_000 picoseconds. + Weight::from_parts(69_575_000, 6196) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -72,15 +72,15 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 710_000 picoseconds. - Weight::from_parts(764_000, 0) + // Minimum execution time: 738_000 picoseconds. + Weight::from_parts(780_000, 0) } pub(crate) fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) + // Minimum execution time: 1_621_000 picoseconds. + Weight::from_parts(1_750_000, 0) } /// Storage: `XcmPallet::Queries` (r:1 w:0) /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -88,58 +88,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3465` - // Minimum execution time: 6_607_000 picoseconds. - Weight::from_parts(6_840_000, 3465) + // Minimum execution time: 6_548_000 picoseconds. + Weight::from_parts(6_765_000, 3465) .saturating_add(T::DbWeight::get().reads(1)) } pub(crate) fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_091_000 picoseconds. - Weight::from_parts(7_479_000, 0) + // Minimum execution time: 7_049_000 picoseconds. + Weight::from_parts(7_267_000, 0) } pub(crate) fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_265_000 picoseconds. - Weight::from_parts(1_350_000, 0) + // Minimum execution time: 1_300_000 picoseconds. + Weight::from_parts(1_408_000, 0) } pub(crate) fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 727_000 picoseconds. - Weight::from_parts(773_000, 0) + // Minimum execution time: 738_000 picoseconds. + Weight::from_parts(810_000, 0) } pub(crate) fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 744_000 picoseconds. - Weight::from_parts(792_000, 0) + // Minimum execution time: 759_000 picoseconds. + Weight::from_parts(796_000, 0) } pub(crate) fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 676_000 picoseconds. - Weight::from_parts(743_000, 0) + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(780_000, 0) } pub(crate) fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 721_000 picoseconds. - Weight::from_parts(795_000, 0) + // Minimum execution time: 749_000 picoseconds. + Weight::from_parts(835_000, 0) } pub(crate) fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 703_000 picoseconds. - Weight::from_parts(761_000, 0) + // Minimum execution time: 751_000 picoseconds. + Weight::from_parts(799_000, 0) } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -155,8 +155,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6196` - // Minimum execution time: 65_242_000 picoseconds. - Weight::from_parts(67_004_000, 6196) + // Minimum execution time: 65_464_000 picoseconds. + Weight::from_parts(67_406_000, 6196) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -166,8 +166,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `23` // Estimated: `3488` - // Minimum execution time: 9_865_000 picoseconds. - Weight::from_parts(10_128_000, 3488) + // Minimum execution time: 9_887_000 picoseconds. + Weight::from_parts(10_310_000, 3488) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -175,8 +175,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 693_000 picoseconds. - Weight::from_parts(766_000, 0) + // Minimum execution time: 737_000 picoseconds. + Weight::from_parts(792_000, 0) } /// Storage: `XcmPallet::VersionNotifyTargets` (r:1 w:1) /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -192,8 +192,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `147` // Estimated: `3612` - // Minimum execution time: 31_295_000 picoseconds. - Weight::from_parts(31_680_000, 3612) + // Minimum execution time: 30_726_000 picoseconds. + Weight::from_parts(31_268_000, 3612) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -203,44 +203,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_745_000 picoseconds. - Weight::from_parts(2_991_000, 0) + // Minimum execution time: 3_051_000 picoseconds. + Weight::from_parts(3_154_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub(crate) fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_100_000 picoseconds. - Weight::from_parts(1_154_000, 0) + // Minimum execution time: 1_146_000 picoseconds. + Weight::from_parts(1_223_000, 0) } pub(crate) fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 809_000 picoseconds. - Weight::from_parts(865_000, 0) + // Minimum execution time: 821_000 picoseconds. + Weight::from_parts(901_000, 0) } pub(crate) fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 740_000 picoseconds. - Weight::from_parts(770_000, 0) + // Minimum execution time: 762_000 picoseconds. + Weight::from_parts(808_000, 0) } pub(crate) fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 726_000 picoseconds. - Weight::from_parts(767_000, 0) + // Minimum execution time: 727_000 picoseconds. + Weight::from_parts(789_000, 0) } pub(crate) fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 883_000 picoseconds. - Weight::from_parts(955_000, 0) + // Minimum execution time: 867_000 picoseconds. + Weight::from_parts(933_000, 0) } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -256,8 +256,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6196` - // Minimum execution time: 74_854_000 picoseconds. - Weight::from_parts(76_335_000, 6196) + // Minimum execution time: 74_949_000 picoseconds. + Weight::from_parts(76_124_000, 6196) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -265,8 +265,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_449_000 picoseconds. - Weight::from_parts(7_794_000, 0) + // Minimum execution time: 7_553_000 picoseconds. + Weight::from_parts(7_889_000, 0) } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -282,8 +282,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6196` - // Minimum execution time: 65_264_000 picoseconds. - Weight::from_parts(67_864_000, 6196) + // Minimum execution time: 65_953_000 picoseconds. + Weight::from_parts(67_221_000, 6196) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -292,34 +292,34 @@ impl WeightInfo { // Measured: `0` // Estimated: `0` // Minimum execution time: 770_000 picoseconds. - Weight::from_parts(828_000, 0) + Weight::from_parts(848_000, 0) } pub(crate) fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 717_000 picoseconds. - Weight::from_parts(756_000, 0) + // Minimum execution time: 685_000 picoseconds. + Weight::from_parts(766_000, 0) } pub(crate) fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 677_000 picoseconds. - Weight::from_parts(740_000, 0) + // Minimum execution time: 693_000 picoseconds. + Weight::from_parts(759_000, 0) } pub(crate) fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 708_000 picoseconds. - Weight::from_parts(753_000, 0) + // Minimum execution time: 739_000 picoseconds. + Weight::from_parts(791_000, 0) } pub(crate) fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 727_000 picoseconds. - Weight::from_parts(791_000, 0) + // Minimum execution time: 735_000 picoseconds. + Weight::from_parts(811_000, 0) } } From 39cf7b18b6777625217a2a6e78b7beebd6f575a8 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 16:05:08 +0000 Subject: [PATCH 031/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=rococo --target_dir=polkadot --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 860824805156..53d42a0e5c47 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -63,8 +63,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `281` // Estimated: `3746` - // Minimum execution time: 62_606_000 picoseconds. - Weight::from_parts(64_541_000, 3746) + // Minimum execution time: 64_284_000 picoseconds. + Weight::from_parts(65_590_000, 3746) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -72,15 +72,15 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 655_000 picoseconds. - Weight::from_parts(728_000, 0) + // Minimum execution time: 777_000 picoseconds. + Weight::from_parts(825_000, 0) } - pub fn pay_fees() -> Weight { + pub(crate) fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) + // Minimum execution time: 1_543_000 picoseconds. + Weight::from_parts(1_627_000, 0) } /// Storage: `XcmPallet::Queries` (r:1 w:0) /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -88,58 +88,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3465` - // Minimum execution time: 5_560_000 picoseconds. - Weight::from_parts(5_771_000, 3465) + // Minimum execution time: 5_995_000 picoseconds. + Weight::from_parts(6_151_000, 3465) .saturating_add(T::DbWeight::get().reads(1)) } pub(crate) fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_303_000 picoseconds. - Weight::from_parts(7_543_000, 0) + // Minimum execution time: 7_567_000 picoseconds. + Weight::from_parts(7_779_000, 0) } pub(crate) fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_184_000 picoseconds. - Weight::from_parts(1_267_000, 0) + // Minimum execution time: 1_226_000 picoseconds. + Weight::from_parts(1_322_000, 0) } pub(crate) fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 711_000 picoseconds. - Weight::from_parts(761_000, 0) + // Minimum execution time: 768_000 picoseconds. + Weight::from_parts(828_000, 0) } pub(crate) fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 719_000 picoseconds. - Weight::from_parts(755_000, 0) + // Minimum execution time: 765_000 picoseconds. + Weight::from_parts(814_000, 0) } pub(crate) fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 688_000 picoseconds. - Weight::from_parts(733_000, 0) + // Minimum execution time: 739_000 picoseconds. + Weight::from_parts(820_000, 0) } pub(crate) fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 730_000 picoseconds. - Weight::from_parts(766_000, 0) + // Minimum execution time: 806_000 picoseconds. + Weight::from_parts(849_000, 0) } pub(crate) fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 697_000 picoseconds. - Weight::from_parts(740_000, 0) + // Minimum execution time: 782_000 picoseconds. + Weight::from_parts(820_000, 0) } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -155,8 +155,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `281` // Estimated: `3746` - // Minimum execution time: 60_995_000 picoseconds. - Weight::from_parts(62_523_000, 3746) + // Minimum execution time: 61_410_000 picoseconds. + Weight::from_parts(62_813_000, 3746) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -166,8 +166,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `23` // Estimated: `3488` - // Minimum execution time: 8_814_000 picoseconds. - Weight::from_parts(9_124_000, 3488) + // Minimum execution time: 9_315_000 picoseconds. + Weight::from_parts(9_575_000, 3488) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -175,8 +175,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 678_000 picoseconds. - Weight::from_parts(724_000, 0) + // Minimum execution time: 733_000 picoseconds. + Weight::from_parts(813_000, 0) } /// Storage: `XcmPallet::VersionNotifyTargets` (r:1 w:1) /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -192,8 +192,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `180` // Estimated: `3645` - // Minimum execution time: 30_673_000 picoseconds. - Weight::from_parts(31_367_000, 3645) + // Minimum execution time: 30_641_000 picoseconds. + Weight::from_parts(31_822_000, 3645) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -203,44 +203,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_983_000 picoseconds. - Weight::from_parts(3_081_000, 0) + // Minimum execution time: 2_978_000 picoseconds. + Weight::from_parts(3_260_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub(crate) fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_088_000 picoseconds. - Weight::from_parts(1_144_000, 0) + // Minimum execution time: 1_139_000 picoseconds. + Weight::from_parts(1_272_000, 0) } pub(crate) fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 763_000 picoseconds. - Weight::from_parts(836_000, 0) + // Minimum execution time: 850_000 picoseconds. + Weight::from_parts(879_000, 0) } pub(crate) fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 670_000 picoseconds. - Weight::from_parts(724_000, 0) + // Minimum execution time: 770_000 picoseconds. + Weight::from_parts(834_000, 0) } pub(crate) fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 691_000 picoseconds. - Weight::from_parts(735_000, 0) + // Minimum execution time: 756_000 picoseconds. + Weight::from_parts(797_000, 0) } pub(crate) fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 865_000 picoseconds. - Weight::from_parts(927_000, 0) + // Minimum execution time: 888_000 picoseconds. + Weight::from_parts(1_000_000, 0) } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -256,8 +256,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `281` // Estimated: `3746` - // Minimum execution time: 71_529_000 picoseconds. - Weight::from_parts(72_723_000, 3746) + // Minimum execution time: 72_138_000 picoseconds. + Weight::from_parts(73_728_000, 3746) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -265,8 +265,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_349_000 picoseconds. - Weight::from_parts(8_556_000, 0) + // Minimum execution time: 8_482_000 picoseconds. + Weight::from_parts(8_667_000, 0) } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -282,8 +282,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `281` // Estimated: `3746` - // Minimum execution time: 62_084_000 picoseconds. - Weight::from_parts(63_113_000, 3746) + // Minimum execution time: 61_580_000 picoseconds. + Weight::from_parts(62_928_000, 3746) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -291,35 +291,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 714_000 picoseconds. - Weight::from_parts(778_000, 0) + // Minimum execution time: 807_000 picoseconds. + Weight::from_parts(844_000, 0) } pub(crate) fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 672_000 picoseconds. - Weight::from_parts(724_000, 0) + // Minimum execution time: 757_000 picoseconds. + Weight::from_parts(808_000, 0) } pub(crate) fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 639_000 picoseconds. - Weight::from_parts(703_000, 0) + // Minimum execution time: 740_000 picoseconds. + Weight::from_parts(810_000, 0) } pub(crate) fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 640_000 picoseconds. - Weight::from_parts(718_000, 0) + // Minimum execution time: 752_000 picoseconds. + Weight::from_parts(786_000, 0) } pub(crate) fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 720_000 picoseconds. - Weight::from_parts(768_000, 0) + // Minimum execution time: 798_000 picoseconds. + Weight::from_parts(845_000, 0) } } From abe36c3d840c6cc995d2da5cd39448926c35a5cd Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 16:36:04 +0000 Subject: [PATCH 032/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=coretime-westend --runtime_dir=coretime --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 114 +++++++++--------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index c5dd552f7d4b..c8ba2d8b4ce7 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -64,8 +64,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 29_342_000 picoseconds. - Weight::from_parts(30_494_000, 3571) + // Minimum execution time: 29_463_000 picoseconds. + Weight::from_parts(30_178_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,15 +73,15 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 636_000 picoseconds. - Weight::from_parts(705_000, 0) + // Minimum execution time: 568_000 picoseconds. + Weight::from_parts(608_000, 0) } pub fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) + // Minimum execution time: 1_530_000 picoseconds. + Weight::from_parts(1_585_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -89,58 +89,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 7_325_000 picoseconds. - Weight::from_parts(7_771_000, 3497) + // Minimum execution time: 7_400_000 picoseconds. + Weight::from_parts(7_572_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_108_000 picoseconds. - Weight::from_parts(7_366_000, 0) + // Minimum execution time: 6_951_000 picoseconds. + Weight::from_parts(7_173_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_275_000 picoseconds. - Weight::from_parts(1_369_000, 0) + // Minimum execution time: 1_245_000 picoseconds. + Weight::from_parts(1_342_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 645_000 picoseconds. - Weight::from_parts(711_000, 0) + // Minimum execution time: 613_000 picoseconds. + Weight::from_parts(657_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 669_000 picoseconds. - Weight::from_parts(712_000, 0) + // Minimum execution time: 613_000 picoseconds. + Weight::from_parts(656_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 625_000 picoseconds. - Weight::from_parts(667_000, 0) + // Minimum execution time: 570_000 picoseconds. + Weight::from_parts(608_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 611_000 picoseconds. - Weight::from_parts(695_000, 0) + // Minimum execution time: 557_000 picoseconds. + Weight::from_parts(607_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 607_000 picoseconds. - Weight::from_parts(677_000, 0) + // Minimum execution time: 557_000 picoseconds. + Weight::from_parts(578_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -158,8 +158,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 26_390_000 picoseconds. - Weight::from_parts(27_093_000, 3571) + // Minimum execution time: 26_179_000 picoseconds. + Weight::from_parts(27_089_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -169,8 +169,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 10_759_000 picoseconds. - Weight::from_parts(10_992_000, 3555) + // Minimum execution time: 10_724_000 picoseconds. + Weight::from_parts(10_896_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -178,8 +178,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 638_000 picoseconds. - Weight::from_parts(706_000, 0) + // Minimum execution time: 567_000 picoseconds. + Weight::from_parts(623_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -197,8 +197,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `74` // Estimated: `3539` - // Minimum execution time: 24_150_000 picoseconds. - Weight::from_parts(24_912_000, 3539) + // Minimum execution time: 24_367_000 picoseconds. + Weight::from_parts(25_072_000, 3539) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -208,44 +208,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_600_000 picoseconds. - Weight::from_parts(2_721_000, 0) + // Minimum execution time: 2_554_000 picoseconds. + Weight::from_parts(2_757_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 987_000 picoseconds. - Weight::from_parts(1_065_000, 0) + // Minimum execution time: 922_000 picoseconds. + Weight::from_parts(992_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 693_000 picoseconds. - Weight::from_parts(766_000, 0) + // Minimum execution time: 688_000 picoseconds. + Weight::from_parts(723_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 630_000 picoseconds. - Weight::from_parts(706_000, 0) + // Minimum execution time: 607_000 picoseconds. + Weight::from_parts(647_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 621_000 picoseconds. - Weight::from_parts(700_000, 0) + // Minimum execution time: 591_000 picoseconds. + Weight::from_parts(620_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 812_000 picoseconds. - Weight::from_parts(865_000, 0) + // Minimum execution time: 735_000 picoseconds. + Weight::from_parts(802_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -263,8 +263,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 30_319_000 picoseconds. - Weight::from_parts(31_182_000, 3571) + // Minimum execution time: 29_923_000 picoseconds. + Weight::from_parts(30_770_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -272,8 +272,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_969_000 picoseconds. - Weight::from_parts(3_064_000, 0) + // Minimum execution time: 2_884_000 picoseconds. + Weight::from_parts(3_088_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -291,8 +291,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 27_001_000 picoseconds. - Weight::from_parts(27_659_000, 3571) + // Minimum execution time: 26_632_000 picoseconds. + Weight::from_parts(27_228_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -300,35 +300,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 680_000 picoseconds. - Weight::from_parts(717_000, 0) + // Minimum execution time: 599_000 picoseconds. + Weight::from_parts(655_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 616_000 picoseconds. - Weight::from_parts(670_000, 0) + // Minimum execution time: 587_000 picoseconds. + Weight::from_parts(628_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 637_000 picoseconds. - Weight::from_parts(671_000, 0) + // Minimum execution time: 572_000 picoseconds. + Weight::from_parts(631_000, 0) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 612_000 picoseconds. - Weight::from_parts(669_000, 0) + // Minimum execution time: 570_000 picoseconds. + Weight::from_parts(615_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` // Minimum execution time: 624_000 picoseconds. - Weight::from_parts(693_000, 0) + Weight::from_parts(659_000, 0) } } From a60172c81ceec1b494229062793089bfa957088e Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 16:36:07 +0000 Subject: [PATCH 033/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=asset-hub-westend --runtime_dir=assets --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 120 +++++++++--------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index ae133b6ba044..6a960e1a073e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -68,8 +68,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 99_623_000 picoseconds. - Weight::from_parts(102_135_000, 6196) + // Minimum execution time: 97_854_000 picoseconds. + Weight::from_parts(100_164_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -77,15 +77,15 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 682_000 picoseconds. - Weight::from_parts(741_000, 0) + // Minimum execution time: 723_000 picoseconds. + Weight::from_parts(769_000, 0) } pub fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) + // Minimum execution time: 3_933_000 picoseconds. + Weight::from_parts(4_168_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -93,58 +93,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3568` - // Minimum execution time: 8_193_000 picoseconds. - Weight::from_parts(8_456_000, 3568) + // Minimum execution time: 8_228_000 picoseconds. + Weight::from_parts(8_428_000, 3568) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_079_000 picoseconds. - Weight::from_parts(7_300_000, 0) + // Minimum execution time: 7_123_000 picoseconds. + Weight::from_parts(7_371_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_688_000 picoseconds. - Weight::from_parts(2_840_000, 0) + // Minimum execution time: 2_718_000 picoseconds. + Weight::from_parts(2_877_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 702_000 picoseconds. - Weight::from_parts(758_000, 0) + // Minimum execution time: 737_000 picoseconds. + Weight::from_parts(769_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 702_000 picoseconds. - Weight::from_parts(767_000, 0) + // Minimum execution time: 705_000 picoseconds. + Weight::from_parts(766_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 686_000 picoseconds. - Weight::from_parts(734_000, 0) + // Minimum execution time: 688_000 picoseconds. + Weight::from_parts(742_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 724_000 picoseconds. - Weight::from_parts(769_000, 0) + // Minimum execution time: 736_000 picoseconds. + Weight::from_parts(800_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 680_000 picoseconds. - Weight::from_parts(744_000, 0) + // Minimum execution time: 698_000 picoseconds. + Weight::from_parts(730_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -166,8 +166,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 67_334_000 picoseconds. - Weight::from_parts(69_168_000, 6196) + // Minimum execution time: 65_608_000 picoseconds. + Weight::from_parts(67_828_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -177,8 +177,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `160` // Estimated: `3625` - // Minimum execution time: 12_827_000 picoseconds. - Weight::from_parts(13_247_000, 3625) + // Minimum execution time: 12_895_000 picoseconds. + Weight::from_parts(13_134_000, 3625) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -186,8 +186,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 666_000 picoseconds. - Weight::from_parts(705_000, 0) + // Minimum execution time: 705_000 picoseconds. + Weight::from_parts(741_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -207,8 +207,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `145` // Estimated: `3610` - // Minimum execution time: 27_849_000 picoseconds. - Weight::from_parts(28_522_000, 3610) + // Minimum execution time: 27_604_000 picoseconds. + Weight::from_parts(28_364_000, 3610) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -218,44 +218,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_600_000 picoseconds. - Weight::from_parts(2_741_000, 0) + // Minimum execution time: 2_584_000 picoseconds. + Weight::from_parts(2_706_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 22_267_000 picoseconds. - Weight::from_parts(22_859_000, 0) + // Minimum execution time: 22_537_000 picoseconds. + Weight::from_parts(22_881_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_365_000 picoseconds. - Weight::from_parts(6_519_000, 0) + // Minimum execution time: 6_248_000 picoseconds. + Weight::from_parts(6_464_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 694_000 picoseconds. - Weight::from_parts(742_000, 0) + // Minimum execution time: 734_000 picoseconds. + Weight::from_parts(780_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 673_000 picoseconds. - Weight::from_parts(729_000, 0) + // Minimum execution time: 684_000 picoseconds. + Weight::from_parts(741_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 822_000 picoseconds. - Weight::from_parts(916_000, 0) + // Minimum execution time: 863_000 picoseconds. + Weight::from_parts(930_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -277,8 +277,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 72_037_000 picoseconds. - Weight::from_parts(73_974_000, 6196) + // Minimum execution time: 71_041_000 picoseconds. + Weight::from_parts(72_948_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -286,8 +286,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_349_000 picoseconds. - Weight::from_parts(4_523_000, 0) + // Minimum execution time: 4_267_000 picoseconds. + Weight::from_parts(4_557_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -309,8 +309,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 67_524_000 picoseconds. - Weight::from_parts(68_886_000, 6196) + // Minimum execution time: 65_605_000 picoseconds. + Weight::from_parts(67_382_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -318,22 +318,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 723_000 picoseconds. - Weight::from_parts(794_000, 0) + // Minimum execution time: 743_000 picoseconds. + Weight::from_parts(791_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 688_000 picoseconds. - Weight::from_parts(725_000, 0) + // Minimum execution time: 711_000 picoseconds. + Weight::from_parts(751_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 682_000 picoseconds. - Weight::from_parts(752_000, 0) + // Minimum execution time: 722_000 picoseconds. + Weight::from_parts(753_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -341,22 +341,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1489` - // Minimum execution time: 2_634_000 picoseconds. - Weight::from_parts(2_764_000, 1489) + // Minimum execution time: 2_653_000 picoseconds. + Weight::from_parts(2_720_000, 1489) .saturating_add(T::DbWeight::get().reads(1)) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 646_000 picoseconds. - Weight::from_parts(706_000, 0) + // Minimum execution time: 668_000 picoseconds. + Weight::from_parts(695_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 730_000 picoseconds. - Weight::from_parts(762_000, 0) + // Minimum execution time: 742_000 picoseconds. + Weight::from_parts(773_000, 0) } } From 8470fca5e8ab05954d5a8203380c41cfd7680f4e Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 16:36:09 +0000 Subject: [PATCH 034/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=asset-hub-rococo --runtime_dir=assets --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 120 +++++++++--------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 839c3b524b79..48918767561b 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -68,8 +68,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 98_846_000 picoseconds. - Weight::from_parts(101_170_000, 6196) + // Minimum execution time: 99_561_000 picoseconds. + Weight::from_parts(101_317_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -77,15 +77,15 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 714_000 picoseconds. - Weight::from_parts(761_000, 0) + // Minimum execution time: 733_000 picoseconds. + Weight::from_parts(786_000, 0) } pub fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) + // Minimum execution time: 3_938_000 picoseconds. + Weight::from_parts(4_178_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -93,58 +93,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3568` - // Minimum execution time: 9_482_000 picoseconds. - Weight::from_parts(9_796_000, 3568) + // Minimum execution time: 9_503_000 picoseconds. + Weight::from_parts(10_067_000, 3568) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_038_000 picoseconds. - Weight::from_parts(7_378_000, 0) + // Minimum execution time: 7_143_000 picoseconds. + Weight::from_parts(7_363_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_731_000 picoseconds. - Weight::from_parts(2_874_000, 0) + // Minimum execution time: 2_808_000 picoseconds. + Weight::from_parts(2_916_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 719_000 picoseconds. - Weight::from_parts(770_000, 0) + // Minimum execution time: 758_000 picoseconds. + Weight::from_parts(817_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 720_000 picoseconds. - Weight::from_parts(760_000, 0) + // Minimum execution time: 749_000 picoseconds. + Weight::from_parts(777_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 680_000 picoseconds. - Weight::from_parts(733_000, 0) + // Minimum execution time: 726_000 picoseconds. + Weight::from_parts(770_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 750_000 picoseconds. - Weight::from_parts(815_000, 0) + // Minimum execution time: 763_000 picoseconds. + Weight::from_parts(824_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 680_000 picoseconds. - Weight::from_parts(747_000, 0) + // Minimum execution time: 727_000 picoseconds. + Weight::from_parts(780_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -166,8 +166,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 65_772_000 picoseconds. - Weight::from_parts(67_940_000, 6196) + // Minimum execution time: 65_926_000 picoseconds. + Weight::from_parts(67_107_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -177,8 +177,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `160` // Estimated: `3625` - // Minimum execution time: 12_922_000 picoseconds. - Weight::from_parts(13_187_000, 3625) + // Minimum execution time: 12_879_000 picoseconds. + Weight::from_parts(13_214_000, 3625) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -186,8 +186,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 674_000 picoseconds. - Weight::from_parts(738_000, 0) + // Minimum execution time: 684_000 picoseconds. + Weight::from_parts(746_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -207,8 +207,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `145` // Estimated: `3610` - // Minimum execution time: 28_310_000 picoseconds. - Weight::from_parts(29_029_000, 3610) + // Minimum execution time: 27_664_000 picoseconds. + Weight::from_parts(28_321_000, 3610) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -218,44 +218,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_723_000 picoseconds. - Weight::from_parts(2_808_000, 0) + // Minimum execution time: 2_644_000 picoseconds. + Weight::from_parts(2_714_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 22_277_000 picoseconds. - Weight::from_parts(22_898_000, 0) + // Minimum execution time: 22_472_000 picoseconds. + Weight::from_parts(23_159_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_165_000 picoseconds. - Weight::from_parts(6_328_000, 0) + // Minimum execution time: 6_297_000 picoseconds. + Weight::from_parts(6_480_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 700_000 picoseconds. - Weight::from_parts(742_000, 0) + // Minimum execution time: 712_000 picoseconds. + Weight::from_parts(763_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 676_000 picoseconds. - Weight::from_parts(731_000, 0) + // Minimum execution time: 738_000 picoseconds. + Weight::from_parts(783_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 840_000 picoseconds. - Weight::from_parts(894_000, 0) + // Minimum execution time: 856_000 picoseconds. + Weight::from_parts(919_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -277,8 +277,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 70_914_000 picoseconds. - Weight::from_parts(72_252_000, 6196) + // Minimum execution time: 71_036_000 picoseconds. + Weight::from_parts(72_631_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -286,8 +286,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_482_000 picoseconds. - Weight::from_parts(4_606_000, 0) + // Minimum execution time: 4_518_000 picoseconds. + Weight::from_parts(4_737_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -309,8 +309,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `246` // Estimated: `6196` - // Minimum execution time: 65_617_000 picoseconds. - Weight::from_parts(67_713_000, 6196) + // Minimum execution time: 66_855_000 picoseconds. + Weight::from_parts(68_087_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -318,22 +318,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 695_000 picoseconds. - Weight::from_parts(755_000, 0) + // Minimum execution time: 742_000 picoseconds. + Weight::from_parts(816_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 682_000 picoseconds. - Weight::from_parts(726_000, 0) + // Minimum execution time: 713_000 picoseconds. + Weight::from_parts(786_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 678_000 picoseconds. - Weight::from_parts(710_000, 0) + // Minimum execution time: 689_000 picoseconds. + Weight::from_parts(744_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -341,22 +341,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1489` - // Minimum execution time: 2_630_000 picoseconds. - Weight::from_parts(2_700_000, 1489) + // Minimum execution time: 2_654_000 picoseconds. + Weight::from_parts(2_809_000, 1489) .saturating_add(T::DbWeight::get().reads(1)) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 675_000 picoseconds. - Weight::from_parts(718_000, 0) + // Minimum execution time: 698_000 picoseconds. + Weight::from_parts(758_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 700_000 picoseconds. - Weight::from_parts(757_000, 0) + // Minimum execution time: 757_000 picoseconds. + Weight::from_parts(800_000, 0) } } From 6a59c1d3859d511cc0c9cfe77008e347fe7a4e5c Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 16:36:38 +0000 Subject: [PATCH 035/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=bridge-hub-westend --runtime_dir=bridge-hubs --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 75f60c42caa5..8d5861fe763b 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -68,8 +68,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `208` // Estimated: `6196` - // Minimum execution time: 70_164_000 picoseconds. - Weight::from_parts(71_831_000, 6196) + // Minimum execution time: 70_353_000 picoseconds. + Weight::from_parts(72_257_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -77,15 +77,15 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_062_000 picoseconds. - Weight::from_parts(1_142_000, 0) + // Minimum execution time: 996_000 picoseconds. + Weight::from_parts(1_027_000, 0) } pub fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) + // Minimum execution time: 1_926_000 picoseconds. + Weight::from_parts(2_033_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -93,58 +93,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 7_942_000 picoseconds. - Weight::from_parts(8_094_000, 3497) + // Minimum execution time: 7_961_000 picoseconds. + Weight::from_parts(8_256_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_908_000 picoseconds. - Weight::from_parts(8_270_000, 0) + // Minimum execution time: 7_589_000 picoseconds. + Weight::from_parts(7_867_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_793_000 picoseconds. - Weight::from_parts(1_855_000, 0) + // Minimum execution time: 1_602_000 picoseconds. + Weight::from_parts(1_660_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_134_000 picoseconds. - Weight::from_parts(1_160_000, 0) + // Minimum execution time: 1_056_000 picoseconds. + Weight::from_parts(1_096_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_117_000 picoseconds. - Weight::from_parts(1_144_000, 0) + // Minimum execution time: 1_014_000 picoseconds. + Weight::from_parts(1_075_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_088_000 picoseconds. - Weight::from_parts(1_122_000, 0) + // Minimum execution time: 986_000 picoseconds. + Weight::from_parts(1_031_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_123_000 picoseconds. - Weight::from_parts(1_178_000, 0) + // Minimum execution time: 1_015_000 picoseconds. + Weight::from_parts(1_069_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_115_000 picoseconds. - Weight::from_parts(1_152_000, 0) + // Minimum execution time: 993_000 picoseconds. + Weight::from_parts(1_063_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -166,8 +166,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `208` // Estimated: `6196` - // Minimum execution time: 67_318_000 picoseconds. - Weight::from_parts(68_367_000, 6196) + // Minimum execution time: 66_350_000 picoseconds. + Weight::from_parts(68_248_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -177,8 +177,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 11_141_000 picoseconds. - Weight::from_parts(11_631_000, 3555) + // Minimum execution time: 11_247_000 picoseconds. + Weight::from_parts(11_468_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -186,8 +186,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_068_000 picoseconds. - Weight::from_parts(1_128_000, 0) + // Minimum execution time: 1_060_000 picoseconds. + Weight::from_parts(1_103_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -207,8 +207,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `38` // Estimated: `3503` - // Minimum execution time: 25_253_000 picoseconds. - Weight::from_parts(26_092_000, 3503) + // Minimum execution time: 25_599_000 picoseconds. + Weight::from_parts(26_336_000, 3503) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -218,44 +218,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_129_000 picoseconds. - Weight::from_parts(3_237_000, 0) + // Minimum execution time: 2_863_000 picoseconds. + Weight::from_parts(3_090_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_466_000 picoseconds. - Weight::from_parts(1_549_000, 0) + // Minimum execution time: 1_385_000 picoseconds. + Weight::from_parts(1_468_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_215_000 picoseconds. - Weight::from_parts(1_272_000, 0) + // Minimum execution time: 1_087_000 picoseconds. + Weight::from_parts(1_164_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_141_000 picoseconds. - Weight::from_parts(1_195_000, 0) + // Minimum execution time: 1_022_000 picoseconds. + Weight::from_parts(1_066_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_088_000 picoseconds. - Weight::from_parts(1_134_000, 0) + // Minimum execution time: 1_015_000 picoseconds. + Weight::from_parts(1_070_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_267_000 picoseconds. - Weight::from_parts(1_337_000, 0) + // Minimum execution time: 1_203_000 picoseconds. + Weight::from_parts(1_241_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -277,8 +277,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `208` // Estimated: `6196` - // Minimum execution time: 71_358_000 picoseconds. - Weight::from_parts(73_042_000, 6196) + // Minimum execution time: 70_773_000 picoseconds. + Weight::from_parts(72_730_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -286,8 +286,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_230_000 picoseconds. - Weight::from_parts(4_400_000, 0) + // Minimum execution time: 4_173_000 picoseconds. + Weight::from_parts(4_445_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -309,8 +309,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `208` // Estimated: `6196` - // Minimum execution time: 67_219_000 picoseconds. - Weight::from_parts(68_845_000, 6196) + // Minimum execution time: 66_471_000 picoseconds. + Weight::from_parts(68_362_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -318,22 +318,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_142_000 picoseconds. - Weight::from_parts(1_191_000, 0) + // Minimum execution time: 1_067_000 picoseconds. + Weight::from_parts(1_108_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_050_000 picoseconds. - Weight::from_parts(1_138_000, 0) + // Minimum execution time: 997_000 picoseconds. + Weight::from_parts(1_043_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_036_000 picoseconds. - Weight::from_parts(1_128_000, 0) + // Minimum execution time: 1_000_000 picoseconds. + Weight::from_parts(1_056_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -352,10 +352,10 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `225` // Estimated: `6165` - // Minimum execution time: 43_070_000 picoseconds. - Weight::from_parts(44_862_050, 6165) - // Standard Error: 156 - .saturating_add(Weight::from_parts(46_495, 0).saturating_mul(x.into())) + // Minimum execution time: 43_316_000 picoseconds. + Weight::from_parts(45_220_843, 6165) + // Standard Error: 169 + .saturating_add(Weight::from_parts(44_459, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -363,14 +363,14 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_063_000 picoseconds. - Weight::from_parts(1_139_000, 0) + // Minimum execution time: 998_000 picoseconds. + Weight::from_parts(1_054_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_116_000 picoseconds. - Weight::from_parts(1_171_000, 0) + // Minimum execution time: 995_000 picoseconds. + Weight::from_parts(1_060_000, 0) } } From bdae9ec42d4f40dfc1799dacd43c012251fe22c6 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 16:37:09 +0000 Subject: [PATCH 036/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=coretime-rococo --runtime_dir=coretime --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 114 +++++++++--------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 1a5ecf466daa..3a93c80766de 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -64,8 +64,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 28_989_000 picoseconds. - Weight::from_parts(30_034_000, 3571) + // Minimum execution time: 29_263_000 picoseconds. + Weight::from_parts(30_387_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,15 +73,15 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 598_000 picoseconds. - Weight::from_parts(645_000, 0) + // Minimum execution time: 603_000 picoseconds. + Weight::from_parts(664_000, 0) } pub fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) + // Minimum execution time: 1_530_000 picoseconds. + Weight::from_parts(1_662_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -89,58 +89,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 7_377_000 picoseconds. - Weight::from_parts(7_684_000, 3497) + // Minimum execution time: 7_290_000 picoseconds. + Weight::from_parts(7_493_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_777_000 picoseconds. - Weight::from_parts(6_999_000, 0) + // Minimum execution time: 6_785_000 picoseconds. + Weight::from_parts(7_012_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_386_000 picoseconds. - Weight::from_parts(1_443_000, 0) + // Minimum execution time: 1_299_000 picoseconds. + Weight::from_parts(1_380_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 648_000 picoseconds. - Weight::from_parts(707_000, 0) + // Minimum execution time: 655_000 picoseconds. + Weight::from_parts(681_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 634_000 picoseconds. - Weight::from_parts(692_000, 0) + // Minimum execution time: 625_000 picoseconds. + Weight::from_parts(669_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 620_000 picoseconds. - Weight::from_parts(666_000, 0) + // Minimum execution time: 607_000 picoseconds. + Weight::from_parts(650_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 634_000 picoseconds. - Weight::from_parts(672_000, 0) + // Minimum execution time: 655_000 picoseconds. + Weight::from_parts(688_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 617_000 picoseconds. - Weight::from_parts(664_000, 0) + // Minimum execution time: 602_000 picoseconds. + Weight::from_parts(650_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -158,8 +158,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 26_036_000 picoseconds. - Weight::from_parts(26_763_000, 3571) + // Minimum execution time: 26_176_000 picoseconds. + Weight::from_parts(26_870_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -169,8 +169,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 10_728_000 picoseconds. - Weight::from_parts(11_009_000, 3555) + // Minimum execution time: 10_674_000 picoseconds. + Weight::from_parts(10_918_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -178,8 +178,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 617_000 picoseconds. - Weight::from_parts(677_000, 0) + // Minimum execution time: 601_000 picoseconds. + Weight::from_parts(639_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -197,8 +197,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `74` // Estimated: `3539` - // Minimum execution time: 24_296_000 picoseconds. - Weight::from_parts(24_914_000, 3539) + // Minimum execution time: 24_220_000 picoseconds. + Weight::from_parts(24_910_000, 3539) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -208,44 +208,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_427_000 picoseconds. - Weight::from_parts(2_635_000, 0) + // Minimum execution time: 2_464_000 picoseconds. + Weight::from_parts(2_618_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_058_000 picoseconds. - Weight::from_parts(1_097_000, 0) + // Minimum execution time: 984_000 picoseconds. + Weight::from_parts(1_041_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 694_000 picoseconds. - Weight::from_parts(758_000, 0) + // Minimum execution time: 730_000 picoseconds. + Weight::from_parts(769_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 600_000 picoseconds. - Weight::from_parts(660_000, 0) + // Minimum execution time: 615_000 picoseconds. + Weight::from_parts(658_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 617_000 picoseconds. - Weight::from_parts(677_000, 0) + // Minimum execution time: 607_000 picoseconds. + Weight::from_parts(637_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 783_000 picoseconds. - Weight::from_parts(856_000, 0) + // Minimum execution time: 791_000 picoseconds. + Weight::from_parts(838_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -263,8 +263,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 29_616_000 picoseconds. - Weight::from_parts(30_997_000, 3571) + // Minimum execution time: 30_210_000 picoseconds. + Weight::from_parts(30_973_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -272,8 +272,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_034_000 picoseconds. - Weight::from_parts(3_208_000, 0) + // Minimum execution time: 3_097_000 picoseconds. + Weight::from_parts(3_277_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -291,8 +291,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3571` - // Minimum execution time: 26_488_000 picoseconds. - Weight::from_parts(27_218_000, 3571) + // Minimum execution time: 26_487_000 picoseconds. + Weight::from_parts(27_445_000, 3571) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -300,35 +300,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 639_000 picoseconds. - Weight::from_parts(688_000, 0) + // Minimum execution time: 655_000 picoseconds. + Weight::from_parts(689_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 650_000 picoseconds. - Weight::from_parts(678_000, 0) + // Minimum execution time: 627_000 picoseconds. + Weight::from_parts(659_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 621_000 picoseconds. + // Minimum execution time: 603_000 picoseconds. Weight::from_parts(650_000, 0) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 587_000 picoseconds. - Weight::from_parts(660_000, 0) + // Minimum execution time: 594_000 picoseconds. + Weight::from_parts(645_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 628_000 picoseconds. - Weight::from_parts(664_000, 0) + // Minimum execution time: 650_000 picoseconds. + Weight::from_parts(673_000, 0) } } From 6b339a010762134324fdc44b25e3bebce82fc5d5 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 16:37:19 +0000 Subject: [PATCH 037/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=bridge-hub-rococo --runtime_dir=bridge-hubs --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index a052814f2648..5d6ce1ff0e87 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -68,8 +68,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `171` // Estimated: `6196` - // Minimum execution time: 69_768_000 picoseconds. - Weight::from_parts(71_375_000, 6196) + // Minimum execution time: 69_010_000 picoseconds. + Weight::from_parts(70_067_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -77,15 +77,15 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_074_000 picoseconds. - Weight::from_parts(1_141_000, 0) + // Minimum execution time: 1_069_000 picoseconds. + Weight::from_parts(1_116_000, 0) } pub fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) + // Minimum execution time: 2_011_000 picoseconds. + Weight::from_parts(2_095_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -93,58 +93,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 7_797_000 picoseconds. - Weight::from_parts(7_982_000, 3497) + // Minimum execution time: 7_630_000 picoseconds. + Weight::from_parts(7_992_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_824_000 picoseconds. - Weight::from_parts(8_101_000, 0) + // Minimum execution time: 7_909_000 picoseconds. + Weight::from_parts(8_100_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_778_000 picoseconds. - Weight::from_parts(1_840_000, 0) + // Minimum execution time: 1_749_000 picoseconds. + Weight::from_parts(1_841_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_081_000 picoseconds. - Weight::from_parts(1_139_000, 0) + // Minimum execution time: 1_109_000 picoseconds. + Weight::from_parts(1_156_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_096_000 picoseconds. - Weight::from_parts(1_163_000, 0) + // Minimum execution time: 1_073_000 picoseconds. + Weight::from_parts(1_143_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_034_000 picoseconds. - Weight::from_parts(1_126_000, 0) + // Minimum execution time: 1_050_000 picoseconds. + Weight::from_parts(1_084_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_108_000 picoseconds. - Weight::from_parts(1_191_000, 0) + // Minimum execution time: 1_060_000 picoseconds. + Weight::from_parts(1_114_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_095_000 picoseconds. - Weight::from_parts(1_128_000, 0) + // Minimum execution time: 1_065_000 picoseconds. + Weight::from_parts(1_112_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -166,8 +166,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `171` // Estimated: `6196` - // Minimum execution time: 66_920_000 picoseconds. - Weight::from_parts(68_038_000, 6196) + // Minimum execution time: 65_538_000 picoseconds. + Weight::from_parts(66_943_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -177,8 +177,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 11_065_000 picoseconds. - Weight::from_parts(11_493_000, 3555) + // Minimum execution time: 10_898_000 picoseconds. + Weight::from_parts(11_262_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -186,8 +186,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_100_000 picoseconds. - Weight::from_parts(1_146_000, 0) + // Minimum execution time: 1_026_000 picoseconds. + Weight::from_parts(1_104_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -207,8 +207,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `38` // Estimated: `3503` - // Minimum execution time: 25_386_000 picoseconds. - Weight::from_parts(26_181_000, 3503) + // Minimum execution time: 25_133_000 picoseconds. + Weight::from_parts(25_526_000, 3503) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -218,44 +218,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_902_000 picoseconds. - Weight::from_parts(3_055_000, 0) + // Minimum execution time: 2_946_000 picoseconds. + Weight::from_parts(3_074_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_480_000 picoseconds. - Weight::from_parts(1_570_000, 0) + // Minimum execution time: 1_428_000 picoseconds. + Weight::from_parts(1_490_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_187_000 picoseconds. - Weight::from_parts(1_243_000, 0) + // Minimum execution time: 1_158_000 picoseconds. + Weight::from_parts(1_222_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_108_000 picoseconds. - Weight::from_parts(1_179_000, 0) + // Minimum execution time: 1_056_000 picoseconds. + Weight::from_parts(1_117_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_099_000 picoseconds. - Weight::from_parts(1_160_000, 0) + // Minimum execution time: 1_045_000 picoseconds. + Weight::from_parts(1_084_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_242_000 picoseconds. - Weight::from_parts(1_321_000, 0) + // Minimum execution time: 1_224_000 picoseconds. + Weight::from_parts(1_268_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -277,8 +277,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `171` // Estimated: `6196` - // Minimum execution time: 71_619_000 picoseconds. - Weight::from_parts(73_697_000, 6196) + // Minimum execution time: 70_789_000 picoseconds. + Weight::from_parts(72_321_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -286,8 +286,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_461_000 picoseconds. - Weight::from_parts(4_664_000, 0) + // Minimum execution time: 4_521_000 picoseconds. + Weight::from_parts(4_649_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -309,8 +309,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `171` // Estimated: `6196` - // Minimum execution time: 67_467_000 picoseconds. - Weight::from_parts(69_149_000, 6196) + // Minimum execution time: 66_129_000 picoseconds. + Weight::from_parts(68_089_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -318,22 +318,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_098_000 picoseconds. - Weight::from_parts(1_191_000, 0) + // Minimum execution time: 1_094_000 picoseconds. + Weight::from_parts(1_157_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_070_000 picoseconds. - Weight::from_parts(1_150_000, 0) + // Minimum execution time: 1_059_000 picoseconds. + Weight::from_parts(1_109_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_079_000 picoseconds. - Weight::from_parts(1_144_000, 0) + // Minimum execution time: 1_053_000 picoseconds. + Weight::from_parts(1_080_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -352,10 +352,10 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `190` // Estimated: `6130` - // Minimum execution time: 42_708_000 picoseconds. - Weight::from_parts(43_821_835, 6130) - // Standard Error: 90 - .saturating_add(Weight::from_parts(45_150, 0).saturating_mul(x.into())) + // Minimum execution time: 42_081_000 picoseconds. + Weight::from_parts(42_977_658, 6130) + // Standard Error: 77 + .saturating_add(Weight::from_parts(44_912, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -363,14 +363,14 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_095_000 picoseconds. - Weight::from_parts(1_124_000, 0) + // Minimum execution time: 1_041_000 picoseconds. + Weight::from_parts(1_084_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_086_000 picoseconds. - Weight::from_parts(1_133_000, 0) + // Minimum execution time: 1_085_000 picoseconds. + Weight::from_parts(1_161_000, 0) } } From 02b0fbb9b904dec1857e4768700f4f5cc52e3d49 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 16:38:00 +0000 Subject: [PATCH 038/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=people-westend --runtime_dir=people --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 116 +++++++++--------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 8a9ba7a5bc5a..818c2e23a2e9 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -64,8 +64,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `70` // Estimated: `3535` - // Minimum execution time: 28_774_000 picoseconds. - Weight::from_parts(29_235_000, 3535) + // Minimum execution time: 29_015_000 picoseconds. + Weight::from_parts(30_359_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,15 +73,15 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 615_000 picoseconds. - Weight::from_parts(701_000, 0) + // Minimum execution time: 572_000 picoseconds. + Weight::from_parts(637_000, 0) } pub fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) + // Minimum execution time: 1_550_000 picoseconds. + Weight::from_parts(1_604_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -89,58 +89,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 7_372_000 picoseconds. - Weight::from_parts(7_587_000, 3497) + // Minimum execution time: 7_354_000 picoseconds. + Weight::from_parts(7_808_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_820_000 picoseconds. - Weight::from_parts(7_044_000, 0) + // Minimum execution time: 6_716_000 picoseconds. + Weight::from_parts(7_067_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_260_000 picoseconds. - Weight::from_parts(1_345_000, 0) + // Minimum execution time: 1_280_000 picoseconds. + Weight::from_parts(1_355_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 671_000 picoseconds. - Weight::from_parts(721_000, 0) + // Minimum execution time: 587_000 picoseconds. + Weight::from_parts(645_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 711_000 picoseconds. - Weight::from_parts(740_000, 0) + // Minimum execution time: 629_000 picoseconds. + Weight::from_parts(662_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 631_000 picoseconds. - Weight::from_parts(678_000, 0) + // Minimum execution time: 590_000 picoseconds. + Weight::from_parts(639_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 684_000 picoseconds. - Weight::from_parts(725_000, 0) + // Minimum execution time: 651_000 picoseconds. + Weight::from_parts(688_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 634_000 picoseconds. - Weight::from_parts(688_000, 0) + // Minimum execution time: 601_000 picoseconds. + Weight::from_parts(630_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -158,8 +158,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `70` // Estimated: `3535` - // Minimum execution time: 25_697_000 picoseconds. - Weight::from_parts(26_374_000, 3535) + // Minimum execution time: 25_650_000 picoseconds. + Weight::from_parts(26_440_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -169,8 +169,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 10_636_000 picoseconds. - Weight::from_parts(10_929_000, 3555) + // Minimum execution time: 10_492_000 picoseconds. + Weight::from_parts(10_875_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -178,8 +178,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 652_000 picoseconds. - Weight::from_parts(698_000, 0) + // Minimum execution time: 597_000 picoseconds. + Weight::from_parts(647_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -197,8 +197,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `38` // Estimated: `3503` - // Minimum execution time: 23_730_000 picoseconds. - Weight::from_parts(24_449_000, 3503) + // Minimum execution time: 23_732_000 picoseconds. + Weight::from_parts(24_290_000, 3503) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -208,44 +208,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_471_000 picoseconds. - Weight::from_parts(2_621_000, 0) + // Minimum execution time: 2_446_000 picoseconds. + Weight::from_parts(2_613_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_003_000 picoseconds. - Weight::from_parts(1_049_000, 0) + // Minimum execution time: 960_000 picoseconds. + Weight::from_parts(1_045_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 730_000 picoseconds. - Weight::from_parts(784_000, 0) + // Minimum execution time: 703_000 picoseconds. + Weight::from_parts(739_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 653_000 picoseconds. - Weight::from_parts(722_000, 0) + // Minimum execution time: 616_000 picoseconds. + Weight::from_parts(651_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 643_000 picoseconds. - Weight::from_parts(707_000, 0) + // Minimum execution time: 621_000 picoseconds. + Weight::from_parts(660_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 828_000 picoseconds. - Weight::from_parts(887_000, 0) + // Minimum execution time: 794_000 picoseconds. + Weight::from_parts(831_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -263,8 +263,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `70` // Estimated: `3535` - // Minimum execution time: 29_084_000 picoseconds. - Weight::from_parts(29_956_000, 3535) + // Minimum execution time: 29_527_000 picoseconds. + Weight::from_parts(30_614_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -272,8 +272,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_215_000 picoseconds. - Weight::from_parts(3_344_000, 0) + // Minimum execution time: 3_189_000 picoseconds. + Weight::from_parts(3_296_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -291,8 +291,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `70` // Estimated: `3535` - // Minimum execution time: 25_740_000 picoseconds. - Weight::from_parts(26_975_000, 3535) + // Minimum execution time: 25_965_000 picoseconds. + Weight::from_parts(26_468_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -300,35 +300,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 720_000 picoseconds. - Weight::from_parts(775_000, 0) + // Minimum execution time: 618_000 picoseconds. + Weight::from_parts(659_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 642_000 picoseconds. - Weight::from_parts(701_000, 0) + // Minimum execution time: 593_000 picoseconds. + Weight::from_parts(618_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 636_000 picoseconds. - Weight::from_parts(682_000, 0) + // Minimum execution time: 603_000 picoseconds. + Weight::from_parts(634_000, 0) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 641_000 picoseconds. - Weight::from_parts(696_000, 0) + // Minimum execution time: 568_000 picoseconds. + Weight::from_parts(629_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 676_000 picoseconds. - Weight::from_parts(730_000, 0) + // Minimum execution time: 598_000 picoseconds. + Weight::from_parts(655_000, 0) } } From ec92154c365aea3729fce7caf76f9506b9945295 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 27 Aug 2024 16:40:45 +0000 Subject: [PATCH 039/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=people-rococo --runtime_dir=people --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 587035c6a705..e4f103e25370 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-08-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-696hpswk-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: Some("people-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -64,8 +64,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `70` // Estimated: `3535` - // Minimum execution time: 29_430_000 picoseconds. - Weight::from_parts(30_111_000, 3535) + // Minimum execution time: 28_898_000 picoseconds. + Weight::from_parts(29_717_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,15 +73,15 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 607_000 picoseconds. - Weight::from_parts(672_000, 0) + // Minimum execution time: 690_000 picoseconds. + Weight::from_parts(759_000, 0) } pub fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_313_000 picoseconds. - Weight::from_parts(3_422_000, 0) + // Minimum execution time: 1_695_000 picoseconds. + Weight::from_parts(1_799_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -89,58 +89,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 7_445_000 picoseconds. - Weight::from_parts(7_623_000, 3497) + // Minimum execution time: 7_441_000 picoseconds. + Weight::from_parts(7_746_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_749_000 picoseconds. - Weight::from_parts(7_073_000, 0) + // Minimum execution time: 6_881_000 picoseconds. + Weight::from_parts(7_219_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_275_000 picoseconds. - Weight::from_parts(1_409_000, 0) + // Minimum execution time: 1_390_000 picoseconds. + Weight::from_parts(1_471_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 670_000 picoseconds. - Weight::from_parts(709_000, 0) + // Minimum execution time: 698_000 picoseconds. + Weight::from_parts(743_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 635_000 picoseconds. - Weight::from_parts(723_000, 0) + // Minimum execution time: 695_000 picoseconds. + Weight::from_parts(746_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 650_000 picoseconds. + // Minimum execution time: 664_000 picoseconds. Weight::from_parts(699_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 678_000 picoseconds. - Weight::from_parts(728_000, 0) + // Minimum execution time: 698_000 picoseconds. + Weight::from_parts(748_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 657_000 picoseconds. - Weight::from_parts(703_000, 0) + // Minimum execution time: 669_000 picoseconds. + Weight::from_parts(726_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -158,8 +158,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `70` // Estimated: `3535` - // Minimum execution time: 25_795_000 picoseconds. - Weight::from_parts(26_415_000, 3535) + // Minimum execution time: 25_991_000 picoseconds. + Weight::from_parts(26_602_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -169,8 +169,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 10_792_000 picoseconds. - Weight::from_parts(11_061_000, 3555) + // Minimum execution time: 10_561_000 picoseconds. + Weight::from_parts(10_913_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -178,8 +178,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 624_000 picoseconds. - Weight::from_parts(682_000, 0) + // Minimum execution time: 654_000 picoseconds. + Weight::from_parts(707_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -197,8 +197,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `38` // Estimated: `3503` - // Minimum execution time: 23_906_000 picoseconds. - Weight::from_parts(24_740_000, 3503) + // Minimum execution time: 23_813_000 picoseconds. + Weight::from_parts(24_352_000, 3503) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -208,44 +208,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_621_000 picoseconds. - Weight::from_parts(2_788_000, 0) + // Minimum execution time: 2_499_000 picoseconds. + Weight::from_parts(2_655_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 954_000 picoseconds. - Weight::from_parts(1_046_000, 0) + // Minimum execution time: 1_065_000 picoseconds. + Weight::from_parts(1_108_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 742_000 picoseconds. - Weight::from_parts(790_000, 0) + // Minimum execution time: 747_000 picoseconds. + Weight::from_parts(807_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 664_000 picoseconds. - Weight::from_parts(722_000, 0) + // Minimum execution time: 685_000 picoseconds. + Weight::from_parts(750_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 619_000 picoseconds. - Weight::from_parts(672_000, 0) + // Minimum execution time: 664_000 picoseconds. + Weight::from_parts(711_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 798_000 picoseconds. - Weight::from_parts(851_000, 0) + // Minimum execution time: 830_000 picoseconds. + Weight::from_parts(880_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -263,8 +263,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `70` // Estimated: `3535` - // Minimum execution time: 29_580_000 picoseconds. - Weight::from_parts(31_100_000, 3535) + // Minimum execution time: 30_051_000 picoseconds. + Weight::from_parts(30_720_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -272,8 +272,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_150_000 picoseconds. - Weight::from_parts(3_326_000, 0) + // Minimum execution time: 3_136_000 picoseconds. + Weight::from_parts(3_265_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -291,8 +291,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `70` // Estimated: `3535` - // Minimum execution time: 26_152_000 picoseconds. - Weight::from_parts(26_635_000, 3535) + // Minimum execution time: 25_980_000 picoseconds. + Weight::from_parts(26_868_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -300,35 +300,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 693_000 picoseconds. - Weight::from_parts(724_000, 0) + // Minimum execution time: 708_000 picoseconds. + Weight::from_parts(755_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 632_000 picoseconds. - Weight::from_parts(678_000, 0) + // Minimum execution time: 667_000 picoseconds. + Weight::from_parts(702_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 646_000 picoseconds. - Weight::from_parts(694_000, 0) + // Minimum execution time: 660_000 picoseconds. + Weight::from_parts(695_000, 0) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 622_000 picoseconds. - Weight::from_parts(656_000, 0) + // Minimum execution time: 669_000 picoseconds. + Weight::from_parts(707_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 639_000 picoseconds. - Weight::from_parts(679_000, 0) + // Minimum execution time: 685_000 picoseconds. + Weight::from_parts(757_000, 0) } } From 1091ac7d9c2f060603ce5967cfb976beb55f64a5 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Fri, 30 Aug 2024 13:56:33 +0200 Subject: [PATCH 040/151] doc: add prdoc --- prdoc/pr_5420.prdoc | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 prdoc/pr_5420.prdoc diff --git a/prdoc/pr_5420.prdoc b/prdoc/pr_5420.prdoc new file mode 100644 index 000000000000..43fc1632cea6 --- /dev/null +++ b/prdoc/pr_5420.prdoc @@ -0,0 +1,54 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: [XCMv5] Better fee mechanism + +doc: + - audience: [Runtime User, Runtime Dev] + description: | + In XCMv5, there's a new instruction, `PayFees`, which is meant to be a replacement for `BuyExecution`. + This instruction takes only one parameter, the `asset` that you are willing to use for fee payment. + There's no parameter for limiting the weight, the amount of the `asset` you put in is the limit of + how much you're willing to pay. + This instruction works much better with delivery fees. + `BuyExecution` will still be around to ensure backwards-compatibility, however, the benefits of the new + instruction are a good incentive to switch. + The proposed workflow is to estimate fees using the `XcmPaymentApi` and `DryRunApi`, then to put those + values in `PayFees` and watch your message go knowing you covered all the necessary fees. + You can add a little bit more just in case if you want. + `RefundSurplus` now gets back all of the assets that were destined for fee payment so you can deposit + them somewhere. + BEWARE, make sure you're not sending any other message after you call `RefundSurplus`, if not, it will + error. + +crates: + - name: staging-xcm-executor + bump: minor + - name: staging-xcm-builder + bump: minor + - name: staging-xcm + bump: minor + - name: rococo-runtime + bump: minor + - name: westend-runtime + bump: minor + - name: xcm-emulator + bump: major + - name: people-westend-runtime + bump: minor + - name: people-rococo-runtime + bump: minor + - name: coretime-rococo-runtime + bump: minor + - name: coretime-westend-runtime + bump: minor + - name: bridge-hub-westend-runtime + bump: minor + - name: bridge-hub-rococo-runtime + bump: minor + - name: asset-hub-westend-runtime + bump: minor + - name: asset-hub-rococo-runtime + bump: minor + - name: emulated-integration-tests-common + bump: minor From f0f1aaccc631d37055915719203299d37198bb3c Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Fri, 30 Aug 2024 14:01:32 +0200 Subject: [PATCH 041/151] fix: prdoc --- prdoc/pr_5420.prdoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/prdoc/pr_5420.prdoc b/prdoc/pr_5420.prdoc index 43fc1632cea6..99eff3f25281 100644 --- a/prdoc/pr_5420.prdoc +++ b/prdoc/pr_5420.prdoc @@ -1,10 +1,12 @@ # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json -title: [XCMv5] Better fee mechanism +title: XCMv5 - Better fee mechanism doc: - - audience: [Runtime User, Runtime Dev] + - audience: + - Runtime User + - Runtime Dev description: | In XCMv5, there's a new instruction, `PayFees`, which is meant to be a replacement for `BuyExecution`. This instruction takes only one parameter, the `asset` that you are willing to use for fee payment. From b1e850e91392d71a88ff87f122c70235b6bf66cd Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 15:00:20 +0300 Subject: [PATCH 042/151] Added SetAssetClaimer instruction --- polkadot/xcm/src/v5/mod.rs | 9 +++++++++ polkadot/xcm/xcm-executor/src/lib.rs | 13 +++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index 0fcaa1784392..f6d5b8f0f47d 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -738,6 +738,15 @@ pub enum Instruction { /// Errors: None. ClearError, + /// Set asset claimer for all the trapped assets during the execution. + /// + /// - `location`: The claimer of the assets; it might be an arbitrary location, not necessarily the caller or origin. + /// + /// Kind: *Command* + /// + /// Errors: None. + SetAssetClaimer {location: Location}, + /// Create some assets which are being held on behalf of the origin. /// /// - `assets`: The assets which are to be claimed. This must match exactly with the assets diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 9e2a5e918bc8..79c953bd8b83 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -29,7 +29,7 @@ use frame_support::{ use sp_core::defer; use sp_io::hashing::blake2_128; use sp_weights::Weight; -use xcm::latest::prelude::*; +use xcm::{latest::prelude::*, v3::MultiLocation}; pub mod traits; use traits::{ @@ -90,6 +90,7 @@ pub struct XcmExecutor { /// Stores the current message's weight. message_weight: Weight, _config: PhantomData, + assetClaimer: Option, } #[cfg(any(test, feature = "runtime-benchmarks"))] @@ -357,7 +358,11 @@ impl XcmExecutor { original_origin = ?self.original_origin, "Trapping assets in holding register", ); - let effective_origin = self.context.origin.as_ref().unwrap_or(&self.original_origin); + let effective_orgin = if let Some(assetClaimer) = self.assetClaimer { + assetClaimer.as_ref().unwrap_or(&self.original_origin) + } else { + self.context.origin.as_ref().unwrap_or(&self.original_origin) + }; let trap_weight = Config::AssetTrap::drop_assets(effective_origin, self.holding, &self.context); weight_used.saturating_accrue(trap_weight); @@ -1065,6 +1070,10 @@ impl XcmExecutor { self.error = None; Ok(()) }, + SetAssetClaimer { location } => { + self.assetClaimer = Some(location); + Ok(()) + } ClaimAsset { assets, ticket } => { let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; self.ensure_can_subsume_assets(assets.len())?; From 1a77953fab016194a55bbfd5dabe4d1f809918f4 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 15:43:19 +0300 Subject: [PATCH 043/151] added prdoc --- prdoc/pr_5416.prdoc | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 prdoc/pr_5416.prdoc diff --git a/prdoc/pr_5416.prdoc b/prdoc/pr_5416.prdoc new file mode 100644 index 000000000000..aa970202218a --- /dev/null +++ b/prdoc/pr_5416.prdoc @@ -0,0 +1,11 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Added SetAssetClaimer instruction + +doc: + - audience: Runtime Dev + description: | + ... + +crates: [ ] From eca137586253daec4b6b91c9b527c2f0579a2a9f Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 15:48:49 +0300 Subject: [PATCH 044/151] added missing column --- polkadot/xcm/xcm-executor/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 79c953bd8b83..e44a7db122ee 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -1073,7 +1073,7 @@ impl XcmExecutor { SetAssetClaimer { location } => { self.assetClaimer = Some(location); Ok(()) - } + }, ClaimAsset { assets, ticket } => { let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; self.ensure_can_subsume_assets(assets.len())?; From 09046e6cd2ba23a3abc6fc6fadc7dbd6160cd784 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 16:22:22 +0300 Subject: [PATCH 045/151] fixed prdoc: added crates --- prdoc/pr_5416.prdoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/prdoc/pr_5416.prdoc b/prdoc/pr_5416.prdoc index aa970202218a..330c18390d9e 100644 --- a/prdoc/pr_5416.prdoc +++ b/prdoc/pr_5416.prdoc @@ -8,4 +8,7 @@ doc: description: | ... -crates: [ ] +crates: +- name: staging-xcm-executor + bump: minor + From 7c8e2a43fbbb74598e2417f05a97b4fc942bc89a Mon Sep 17 00:00:00 2001 From: Andrii Date: Tue, 20 Aug 2024 16:41:52 +0300 Subject: [PATCH 046/151] Update SetAssetClaimer description Co-authored-by: Adrian Catangiu --- polkadot/xcm/src/v5/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index f6d5b8f0f47d..4d91d6be32ac 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -740,7 +740,8 @@ pub enum Instruction { /// Set asset claimer for all the trapped assets during the execution. /// - /// - `location`: The claimer of the assets; it might be an arbitrary location, not necessarily the caller or origin. + /// - `location`: The claimer of any assets potentially trapped during the execution of current XCM. + /// It can be an arbitrary location, not necessarily the caller or origin. /// /// Kind: *Command* /// From 0a8d2f91c2e122afe19040fb18dc8c2cd9111218 Mon Sep 17 00:00:00 2001 From: Andrii Date: Tue, 20 Aug 2024 16:42:27 +0300 Subject: [PATCH 047/151] Formated SetAssetClaimer Co-authored-by: Adrian Catangiu --- polkadot/xcm/src/v5/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index 4d91d6be32ac..dadc8f3729b4 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -746,7 +746,7 @@ pub enum Instruction { /// Kind: *Command* /// /// Errors: None. - SetAssetClaimer {location: Location}, + SetAssetClaimer { location: Location }, /// Create some assets which are being held on behalf of the origin. /// From 497bb95818625c3f4acc239c1f60c4dcd5d21014 Mon Sep 17 00:00:00 2001 From: Andrii Date: Tue, 20 Aug 2024 16:42:56 +0300 Subject: [PATCH 048/151] Removed v3::MultiLocation Co-authored-by: Adrian Catangiu --- polkadot/xcm/xcm-executor/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index e44a7db122ee..145c5b3ae4f9 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -29,7 +29,7 @@ use frame_support::{ use sp_core::defer; use sp_io::hashing::blake2_128; use sp_weights::Weight; -use xcm::{latest::prelude::*, v3::MultiLocation}; +use xcm::latest::prelude::*; pub mod traits; use traits::{ From d68ac960d30cc459ecd7eda96dc013fdb5e5932c Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 16:50:27 +0300 Subject: [PATCH 049/151] changed asset claimer variable name from camel case to snake case --- polkadot/xcm/xcm-executor/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 145c5b3ae4f9..4d72190dd775 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -90,7 +90,7 @@ pub struct XcmExecutor { /// Stores the current message's weight. message_weight: Weight, _config: PhantomData, - assetClaimer: Option, + asset_claimer: Option, } #[cfg(any(test, feature = "runtime-benchmarks"))] @@ -1071,7 +1071,7 @@ impl XcmExecutor { Ok(()) }, SetAssetClaimer { location } => { - self.assetClaimer = Some(location); + self.asset_claimer = Some(location); Ok(()) }, ClaimAsset { assets, ticket } => { From 2dd1718a14d321d8703f0832b3d26c4c24c4485d Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 16:51:35 +0300 Subject: [PATCH 050/151] initialized XCMExecutor with an empty asset_claimer --- polkadot/xcm/xcm-executor/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 4d72190dd775..80a2379184c1 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -336,6 +336,7 @@ impl XcmExecutor { fees: AssetsInHolding::new(), message_weight: Weight::zero(), _config: PhantomData, + asset_claimer: None, } } @@ -358,8 +359,8 @@ impl XcmExecutor { original_origin = ?self.original_origin, "Trapping assets in holding register", ); - let effective_orgin = if let Some(assetClaimer) = self.assetClaimer { - assetClaimer.as_ref().unwrap_or(&self.original_origin) + let effective_orgin = if let Some(asset_claimer) = self.asset_claimer { + asset_claimer.as_ref().unwrap_or(&self.original_origin) } else { self.context.origin.as_ref().unwrap_or(&self.original_origin) }; From 69c95709551e147aabc93724f0dc82fb5ef05af7 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 17:51:59 +0300 Subject: [PATCH 051/151] Added missing instructions coverter --- polkadot/xcm/src/v4/mod.rs | 1 + polkadot/xcm/src/v5/mod.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/polkadot/xcm/src/v4/mod.rs b/polkadot/xcm/src/v4/mod.rs index 43629d8f5951..9bc1706dc8ad 100644 --- a/polkadot/xcm/src/v4/mod.rs +++ b/polkadot/xcm/src/v4/mod.rs @@ -1368,6 +1368,7 @@ impl TryFrom> for Instruction { SetErrorHandler(xcm) => Self::SetErrorHandler(xcm.try_into()?), SetAppendix(xcm) => Self::SetAppendix(xcm.try_into()?), ClearError => Self::ClearError, + SetAssetClaimer { location } => {return Err(());}, ClaimAsset { assets, ticket } => { let assets = assets.try_into()?; let ticket = ticket.try_into()?; diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index dadc8f3729b4..d051f4ec0310 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -1103,6 +1103,7 @@ impl Instruction { SetErrorHandler(xcm) => SetErrorHandler(xcm.into()), SetAppendix(xcm) => SetAppendix(xcm.into()), ClearError => ClearError, + SetAssetClaimer { location } => SetAssetClaimer { location }, ClaimAsset { assets, ticket } => ClaimAsset { assets, ticket }, Trap(code) => Trap(code), SubscribeVersion { query_id, max_response_weight } => @@ -1173,6 +1174,7 @@ impl> GetWeight for Instruction { SetErrorHandler(xcm) => W::set_error_handler(xcm), SetAppendix(xcm) => W::set_appendix(xcm), ClearError => W::clear_error(), + SetAssetClaimer { location } => W::set_asset_claimer(location), ClaimAsset { assets, ticket } => W::claim_asset(assets, ticket), Trap(code) => W::trap(code), SubscribeVersion { query_id, max_response_weight } => From 17e758ca714e1c051524f8da6cb190f24c170666 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 18:03:51 +0300 Subject: [PATCH 052/151] applied linter suggestions --- polkadot/xcm/src/v4/mod.rs | 4 +++- polkadot/xcm/src/v5/mod.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/polkadot/xcm/src/v4/mod.rs b/polkadot/xcm/src/v4/mod.rs index 9bc1706dc8ad..1988b5055800 100644 --- a/polkadot/xcm/src/v4/mod.rs +++ b/polkadot/xcm/src/v4/mod.rs @@ -1368,7 +1368,9 @@ impl TryFrom> for Instruction { SetErrorHandler(xcm) => Self::SetErrorHandler(xcm.try_into()?), SetAppendix(xcm) => Self::SetAppendix(xcm.try_into()?), ClearError => Self::ClearError, - SetAssetClaimer { location } => {return Err(());}, + SetAssetClaimer { location } => { + return Err(()); + }, ClaimAsset { assets, ticket } => { let assets = assets.try_into()?; let ticket = ticket.try_into()?; diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index d051f4ec0310..37a506ebd6d9 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -740,8 +740,8 @@ pub enum Instruction { /// Set asset claimer for all the trapped assets during the execution. /// - /// - `location`: The claimer of any assets potentially trapped during the execution of current XCM. - /// It can be an arbitrary location, not necessarily the caller or origin. + /// - `location`: The claimer of any assets potentially trapped during the execution of current + /// XCM. It can be an arbitrary location, not necessarily the caller or origin. /// /// Kind: *Command* /// From 1cd28228634e9e18ac98cd9915e7d39e60648046 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 18:15:38 +0300 Subject: [PATCH 053/151] applied linter suggestions[2] --- polkadot/xcm/src/v5/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index 37a506ebd6d9..63aae405c395 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -747,7 +747,7 @@ pub enum Instruction { /// /// Errors: None. SetAssetClaimer { location: Location }, - + /// Create some assets which are being held on behalf of the origin. /// /// - `assets`: The assets which are to be claimed. This must match exactly with the assets From d070cd7f242c44102cb34a7661031c1169fd4fef Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 21 Aug 2024 14:38:56 +0300 Subject: [PATCH 054/151] fixed type mismatch and other compilation errs --- polkadot/xcm/src/v4/mod.rs | 2 +- polkadot/xcm/xcm-executor/src/lib.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/polkadot/xcm/src/v4/mod.rs b/polkadot/xcm/src/v4/mod.rs index 1988b5055800..b02406f7f452 100644 --- a/polkadot/xcm/src/v4/mod.rs +++ b/polkadot/xcm/src/v4/mod.rs @@ -1368,7 +1368,7 @@ impl TryFrom> for Instruction { SetErrorHandler(xcm) => Self::SetErrorHandler(xcm.try_into()?), SetAppendix(xcm) => Self::SetAppendix(xcm.try_into()?), ClearError => Self::ClearError, - SetAssetClaimer { location } => { + SetAssetClaimer { location: _ } => { return Err(()); }, ClaimAsset { assets, ticket } => { diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 80a2379184c1..67d26165e776 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -359,8 +359,8 @@ impl XcmExecutor { original_origin = ?self.original_origin, "Trapping assets in holding register", ); - let effective_orgin = if let Some(asset_claimer) = self.asset_claimer { - asset_claimer.as_ref().unwrap_or(&self.original_origin) + let effective_origin = if let Some(asset_claimer) = self.asset_claimer.as_ref() { + asset_claimer } else { self.context.origin.as_ref().unwrap_or(&self.original_origin) }; @@ -958,6 +958,9 @@ impl XcmExecutor { &reserve, Some(&mut self.holding), ); + // TODO: modify the message by adding setAssetClaimer. + // replicate for teleport and regular withdraw functions. + // add e2e tests. let mut message = vec![WithdrawAsset(assets), ClearOrigin]; message.extend(xcm.0.into_iter()); self.send(reserve, Xcm(message), FeeReason::InitiateReserveWithdraw)?; From 64cc40e1b7a8f2ef934e5a76c61902a2a0230085 Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 21 Aug 2024 17:29:44 +0300 Subject: [PATCH 055/151] added missing implementation (or todo!() ) for AssetHubWestendXcmWeight --- .../runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 478113359a7e..d2f94a1efe02 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -153,6 +153,10 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } + fn set_asset_claimer(location: &Location,) -> Weight { + // TODO: implement + todo!() + } fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } From 953463cce133967381d63d98f8422fbd36c57414 Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 21 Aug 2024 18:40:31 +0300 Subject: [PATCH 056/151] few minor refactors --- .../runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs | 2 +- polkadot/xcm/src/v4/mod.rs | 2 +- polkadot/xcm/xcm-executor/src/lib.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index d2f94a1efe02..3a1a498a7f80 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -153,7 +153,7 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } - fn set_asset_claimer(location: &Location,) -> Weight { + fn set_asset_claimer(location: &Location) -> Weight { // TODO: implement todo!() } diff --git a/polkadot/xcm/src/v4/mod.rs b/polkadot/xcm/src/v4/mod.rs index b02406f7f452..b22fa8f32e68 100644 --- a/polkadot/xcm/src/v4/mod.rs +++ b/polkadot/xcm/src/v4/mod.rs @@ -1368,7 +1368,7 @@ impl TryFrom> for Instruction { SetErrorHandler(xcm) => Self::SetErrorHandler(xcm.try_into()?), SetAppendix(xcm) => Self::SetAppendix(xcm.try_into()?), ClearError => Self::ClearError, - SetAssetClaimer { location: _ } => { + SetAssetClaimer { .. } => { return Err(()); }, ClaimAsset { assets, ticket } => { diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 67d26165e776..f43a0df84301 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -359,13 +359,13 @@ impl XcmExecutor { original_origin = ?self.original_origin, "Trapping assets in holding register", ); - let effective_origin = if let Some(asset_claimer) = self.asset_claimer.as_ref() { + let claimer = if let Some(asset_claimer) = self.asset_claimer.as_ref() { asset_claimer } else { self.context.origin.as_ref().unwrap_or(&self.original_origin) }; let trap_weight = - Config::AssetTrap::drop_assets(effective_origin, self.holding, &self.context); + Config::AssetTrap::drop_assets(claimer, self.holding, &self.context); weight_used.saturating_accrue(trap_weight); }; From e2b0777d48d8585b3954155f62a70427ca30b370 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 26 Aug 2024 14:48:31 +0300 Subject: [PATCH 057/151] unit tests in progress --- polkadot/xcm/src/v5/mod.rs | 1 + polkadot/xcm/xcm-executor/src/tests/mod.rs | 1 + .../src/tests/set_asset_claimer.rs | 64 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index 63aae405c395..efea42166279 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -746,6 +746,7 @@ pub enum Instruction { /// Kind: *Command* /// /// Errors: None. + #[builder(set_asset_claimer)] SetAssetClaimer { location: Location }, /// Create some assets which are being held on behalf of the origin. diff --git a/polkadot/xcm/xcm-executor/src/tests/mod.rs b/polkadot/xcm/xcm-executor/src/tests/mod.rs index 9892a0277127..c8b8d5b67113 100644 --- a/polkadot/xcm/xcm-executor/src/tests/mod.rs +++ b/polkadot/xcm/xcm-executor/src/tests/mod.rs @@ -22,3 +22,4 @@ mod mock; mod pay_fees; +mod set_asset_claimer; diff --git a/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs new file mode 100644 index 000000000000..379e9b0fcf28 --- /dev/null +++ b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs @@ -0,0 +1,64 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +//! Unit tests related to the `fees` register and `PayFees` instruction. +//! +//! See [Fellowship RFC 105](https://github.com/polkadot-fellows/rfCs/pull/105) +//! and the [specification](https://github.com/polkadot-fellows/xcm-format) for more information. + +use codec::Encode; +use xcm::prelude::*; + +use super::mock::*; +use crate::XcmExecutor; + +#[test] +fn works_with_set_asset_claimer() { + let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + let recipient = Location::new(0, [AccountId32 { id: [1; 32], network: None }]); + + // Make sure the user has enough funds to withdraw. + add_asset(sender.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder() + // .set_asset_claimer(sender) + .withdraw_asset((Here, 100u128)) + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .clear_origin() + .build(); + + // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we + // can inspect its fields. + let mut vm = + XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + + let result = vm.bench_process(xcm); + assert!(result.is_ok()); + + assert_eq!(get_first_fungible(vm.holding()), None); + // Execution fees were 4, so we still have 6 left in the `fees` register. + assert_eq!(get_first_fungible(vm.fees()).unwrap(), (Here, 6u128).into()); + + // The recipient received all the assets in the holding register, so `100` that + // were withdrawn minus the `10` that were destinated for fee payment. + assert_eq!(asset_list(recipient), [(Here, 90u128).into()]); +} + +#[test] +fn works_without_set_asset_claimer() { +} \ No newline at end of file From 236e91f2700af65afa1eb81313e4dc84922ca497 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 26 Aug 2024 18:33:27 +0300 Subject: [PATCH 058/151] Added unit test for SetAssetClaimer --- .../asset-hub-rococo/src/weights/xcm/mod.rs | 8 ++ .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + polkadot/xcm/src/v5/mod.rs | 1 - polkadot/xcm/xcm-executor/src/lib.rs | 1 + .../src/tests/set_asset_claimer.rs | 97 ++++++++++++++++--- 5 files changed, 98 insertions(+), 12 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index 19a10ba370bb..e6c376ebc90a 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -153,6 +153,10 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } + fn set_asset_claimer(location: &Location) -> Weight { + XcmGeneric::::set_asset_claimer() + } + fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } @@ -232,4 +236,8 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 48918767561b..b20dba8a8ab9 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -146,6 +146,9 @@ impl WeightInfo { // Minimum execution time: 727_000 picoseconds. Weight::from_parts(780_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index efea42166279..63aae405c395 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -746,7 +746,6 @@ pub enum Instruction { /// Kind: *Command* /// /// Errors: None. - #[builder(set_asset_claimer)] SetAssetClaimer { location: Location }, /// Create some assets which are being held on behalf of the origin. diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index f43a0df84301..503abc73d338 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -191,6 +191,7 @@ impl XcmExecutor { pub fn set_topic(&mut self, v: Option<[u8; 32]>) { self.context.topic = v; } + pub fn asset_claimer(&self) -> Option { self.asset_claimer.clone() } } pub struct WeighedMessage(Weight, Xcm); diff --git a/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs index 379e9b0fcf28..743da8d68869 100644 --- a/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs +++ b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs @@ -26,19 +26,47 @@ use super::mock::*; use crate::XcmExecutor; #[test] -fn works_with_set_asset_claimer() { +fn set_asset_claimer() { let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); - let recipient = Location::new(0, [AccountId32 { id: [1; 32], network: None }]); + let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); // Make sure the user has enough funds to withdraw. add_asset(sender.clone(), (Here, 100u128)); // Build xcm. - let xcm = Xcm::::builder() - // .set_asset_claimer(sender) + let xcm = Xcm::::builder_unsafe() + // if withdrawing fails we're not missing any corner case. .withdraw_asset((Here, 100u128)) + .clear_origin() + // .trap(0u64) + .set_asset_claimer(bob.clone()) .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .build(); + + // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we + // can inspect its fields. + let mut vm = + XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + + let result = vm.bench_process(xcm); + assert!(result.is_ok()); + assert_eq!(vm.asset_claimer(), Some(bob)); +} + +#[test] +fn do_not_set_asset_claimer_none() { + let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + + // Make sure the user has enough funds to withdraw. + add_asset(sender.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder_unsafe() + // if withdrawing fails we're not missing any corner case. + .withdraw_asset((Here, 100u128)) .clear_origin() + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. .build(); // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we @@ -49,16 +77,63 @@ fn works_with_set_asset_claimer() { let result = vm.bench_process(xcm); assert!(result.is_ok()); + assert_eq!(vm.asset_claimer(), None); +} - assert_eq!(get_first_fungible(vm.holding()), None); - // Execution fees were 4, so we still have 6 left in the `fees` register. - assert_eq!(get_first_fungible(vm.fees()).unwrap(), (Here, 6u128).into()); +#[test] +fn trap_then_set_asset_claimer() { + let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); - // The recipient received all the assets in the holding register, so `100` that - // were withdrawn minus the `10` that were destinated for fee payment. - assert_eq!(asset_list(recipient), [(Here, 90u128).into()]); + // Make sure the user has enough funds to withdraw. + add_asset(sender.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder_unsafe() + // if withdrawing fails we're not missing any corner case. + .withdraw_asset((Here, 100u128)) + .clear_origin() + .trap(0u64) + .set_asset_claimer(bob) + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .build(); + + // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we + // can inspect its fields. + let mut vm = + XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + + let result = vm.bench_process(xcm); + assert!(result.is_err()); + assert_eq!(vm.asset_claimer(), None); } #[test] -fn works_without_set_asset_claimer() { +fn set_asset_claimer_then_trap() { + let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); + + // Make sure the user has enough funds to withdraw. + add_asset(sender.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder_unsafe() + // if withdrawing fails we're not missing any corner case. + .withdraw_asset((Here, 100u128)) + .clear_origin() + .set_asset_claimer(bob.clone()) + .trap(0u64) + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .build(); + + // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we + // can inspect its fields. + let mut vm = + XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + + let result = vm.bench_process(xcm); + assert!(result.is_err()); + assert_eq!(vm.asset_claimer(), Some(bob)); } \ No newline at end of file From 5abbdf6f544c009defcb40d3f24aa69d36cf4938 Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 28 Aug 2024 20:11:41 +0300 Subject: [PATCH 059/151] [WIP] set_asset_claimer e2e test --- .../assets/asset-hub-westend/src/tests/mod.rs | 1 + .../src/tests/set_asset_claimer.rs | 106 + .../asset-hub-westend/src/weights/xcm/mod.rs | 4 + .../bridge-hub-westend/src/weights/xcm/mod.rs | 9 + .../coretime-westend/src/weights/xcm/mod.rs | 9 + .../people-westend/src/weights/xcm/mod.rs | 9 + expansion.rs | 14961 ++++++++++++++++ .../runtime/westend/src/weights/xcm/mod.rs | 9 + 8 files changed, 15108 insertions(+) create mode 100644 cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs create mode 100644 expansion.rs diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs index 73b73b239a1b..089f899696bb 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs @@ -23,3 +23,4 @@ mod swap; mod teleport; mod treasury; mod xcm_fee_estimation; +mod set_asset_claimer; diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs new file mode 100644 index 000000000000..7a053388d741 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -0,0 +1,106 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Tests related to claiming assets trapped during XCM execution. + +use crate::imports::*; + +use frame_support::{ + dispatch::RawOrigin, + sp_runtime::{traits::Dispatchable, DispatchResult}, +}; +use emulated_integration_tests_common::test_chain_can_claim_assets; +use xcm_executor::traits::DropAssets; +use xcm_runtime_apis::{ + dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, + fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, +}; + +#[test] +fn azs() { + let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); + let destination = PenpalA::sibling_location_of(PenpalB::para_id()); + let sender = PenpalASender::get(); + let beneficiary_id = PenpalBReceiver::get(); + let amount_to_send = 1_000_000_000_000; + let assets: Assets = (Parent, amount_to_send).into(); + + // Fund accounts again. + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(PenpalAssetOwner::get()), + Location::parent().clone(), + sender.clone(), + amount_to_send * 2, + ); + + let test_args = TestContext { + sender: PenpalASender::get(), // Bob in PenpalB. + receiver: PenpalBReceiver::get(), // Alice. + args: TestArgs::new_para( + destination, + beneficiary_id.clone(), + amount_to_send, + assets, + None, + 0, + ), + }; + let mut test = ParaToParaThroughAHTest::new(test_args); + transfer_assets(test.clone(), bob.clone()); + // let call = transfer_assets(test.clone(), bob.clone()); + + + // test.set_assertion::(sender_assertions); + // test.set_call(call); + // test.assert(); +} + +fn transfer_assets( + test: ParaToParaThroughAHTest, + claimer: Location +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; + + + + let local_xcm = Xcm::::builder_unsafe() + .clear_origin() + .set_asset_claimer(claimer.clone()) + .withdraw_asset(test.args.assets.clone()) + .pay_fees((Parent, 0)) + .build(); + + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(3_000_000_000, 200_000), + }) +} + +fn sender_assertions(test: ParaToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + // PenpalA::assert_xcm_pallet_attempted_complete(None); + assert_expected_events!( + PenpalA, + vec![ + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance } + ) => { + asset_id: *asset_id == Location::new(1, []), + owner: *owner == test.sender.account_id, + balance: *balance == test.args.amount, + }, + ] + ); +} \ No newline at end of file diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 3a1a498a7f80..1a1746feadc2 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -236,4 +236,8 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index 35abce1083d9..83209d11aeaa 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -155,6 +155,11 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } + + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } + fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } @@ -235,4 +240,8 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs index 24787079e4c0..f6292ff9f6c2 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs @@ -153,6 +153,11 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } + + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } + fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } @@ -232,4 +237,8 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs index 3f0bda0f4f57..1dd5dc3cd742 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs @@ -152,6 +152,11 @@ impl XcmWeightInfo for PeopleWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } + + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } + fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } @@ -231,4 +236,8 @@ impl XcmWeightInfo for PeopleWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/expansion.rs b/expansion.rs new file mode 100644 index 000000000000..7be4f19597a3 --- /dev/null +++ b/expansion.rs @@ -0,0 +1,14961 @@ +#![feature(prelude_import)] +#[prelude_import] +use std::prelude::rust_2021::*; +#[macro_use] +extern crate std; +#[cfg(test)] +mod imports { + pub use codec::Encode; + pub use frame_support::{ + assert_err, assert_ok, pallet_prelude::Weight, + sp_runtime::{DispatchError, DispatchResult, ModuleError}, + traits::fungibles::Inspect, + }; + pub use xcm::prelude::{AccountId32 as AccountId32Junction, *}; + pub use xcm_executor::traits::TransferType; + pub use asset_test_utils::xcm_helpers; + pub use emulated_integration_tests_common::{ + accounts::DUMMY_EMPTY, get_account_id_from_seed, + test_parachain_is_trusted_teleporter, + test_parachain_is_trusted_teleporter_for_relay, test_relay_is_trusted_teleporter, + xcm_emulator::{ + assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, + Test, TestArgs, TestContext, TestExt, + }, + xcm_helpers::{ + get_amount_from_versioned_assets, non_fee_asset, xcm_transact_paid_execution, + }, + ASSETS_PALLET_ID, RESERVABLE_ASSET_ID, XCM_V3, + }; + pub use parachains_common::{AccountId, Balance}; + pub use westend_system_emulated_network::{ + asset_hub_westend_emulated_chain::{ + asset_hub_westend_runtime::{ + xcm_config::{ + self as ahw_xcm_config, WestendLocation as RelayLocation, + XcmConfig as AssetHubWestendXcmConfig, + }, + AssetConversionOrigin as AssetHubWestendAssetConversionOrigin, + ExistentialDeposit as AssetHubWestendExistentialDeposit, + }, + genesis::{AssetHubWestendAssetOwner, ED as ASSET_HUB_WESTEND_ED}, + AssetHubWestendParaPallet as AssetHubWestendPallet, + }, + collectives_westend_emulated_chain::CollectivesWestendParaPallet as CollectivesWestendPallet, + penpal_emulated_chain::{ + penpal_runtime::xcm_config::{ + CustomizableAssetFromSystemAssetHub as PenpalCustomizableAssetFromSystemAssetHub, + LocalReservableFromAssetHub as PenpalLocalReservableFromAssetHub, + LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub, + }, + PenpalAParaPallet as PenpalAPallet, PenpalAssetOwner, + PenpalBParaPallet as PenpalBPallet, + }, + westend_emulated_chain::{ + genesis::ED as WESTEND_ED, + westend_runtime::xcm_config::{ + UniversalLocation as WestendUniversalLocation, + XcmConfig as WestendXcmConfig, + }, + WestendRelayPallet as WestendPallet, + }, + AssetHubWestendPara as AssetHubWestend, + AssetHubWestendParaReceiver as AssetHubWestendReceiver, + AssetHubWestendParaSender as AssetHubWestendSender, + BridgeHubWestendPara as BridgeHubWestend, + BridgeHubWestendParaReceiver as BridgeHubWestendReceiver, + CollectivesWestendPara as CollectivesWestend, PenpalAPara as PenpalA, + PenpalAParaReceiver as PenpalAReceiver, PenpalAParaSender as PenpalASender, + PenpalBPara as PenpalB, PenpalBParaReceiver as PenpalBReceiver, + WestendRelay as Westend, WestendRelayReceiver as WestendReceiver, + WestendRelaySender as WestendSender, + }; + pub const ASSET_ID: u32 = 3; + pub const ASSET_MIN_BALANCE: u128 = 1000; + pub type RelayToParaTest = Test; + pub type ParaToRelayTest = Test; + pub type SystemParaToRelayTest = Test; + pub type SystemParaToParaTest = Test; + pub type ParaToSystemParaTest = Test; + pub type ParaToParaThroughRelayTest = Test; + pub type ParaToParaThroughAHTest = Test; + pub type RelayToParaThroughAHTest = Test; +} +#[cfg(test)] +mod tests { + mod claim_assets { + //! Tests related to claiming assets trapped during XCM execution. + use crate::imports::*; + use frame_support::{ + dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, + }; + use emulated_integration_tests_common::test_chain_can_claim_assets; + use xcm_executor::traits::DropAssets; + use xcm_runtime_apis::{ + dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, + fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, + }; + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::claim_assets::assets_can_be_claimed"] + pub const assets_can_be_claimed: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("tests::claim_assets::assets_can_be_claimed"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/claim_assets.rs", + start_line: 32usize, + start_col: 4usize, + end_line: 32usize, + end_col: 25usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(assets_can_be_claimed()), + ), + }; + fn assets_can_be_claimed() { + let amount = AssetHubWestendExistentialDeposit::get(); + let assets: Assets = (Parent, amount).into(); + let sender = AssetHubWestendSender::get(); + let origin = ::RuntimeOrigin::signed( + sender.clone(), + ); + let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { + network: Some(NetworkId::Westend), + id: sender.clone().into(), + } + .into(); + let versioned_assets: ::emulated_integration_tests_common::macros::VersionedAssets = assets + .clone() + .into(); + ::execute_with(|| { + ::PolkadotXcm::drop_assets( + &beneficiary, + assets.clone().into(), + &XcmContext { + origin: None, + message_id: [0u8; 32], + topic: None, + }, + ); + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsTrapped { + origin: beneficiary, + assets: versioned_assets, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsTrapped {\norigin: beneficiary, assets: versioned_assets, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsTrapped {\norigin: beneficiary, assets: versioned_assets, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::claim_assets", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let balance_before = ::Balances::free_balance( + &sender, + ); + let other_origin = ::RuntimeOrigin::signed( + AssetHubWestendReceiver::get(), + ); + if !::PolkadotXcm::claim_assets( + other_origin, + Box::new(versioned_assets.clone().into()), + Box::new(beneficiary.clone().into()), + ) + .is_err() + { + ::core::panicking::panic( + "assertion failed: ::PolkadotXcm::claim_assets(other_origin,\n bx!(versioned_assets.clone().into()),\n bx!(beneficiary.clone().into())).is_err()", + ) + } + let other_versioned_assets: ::emulated_integration_tests_common::macros::VersionedAssets = Assets::new() + .into(); + if !::PolkadotXcm::claim_assets( + origin.clone(), + Box::new(other_versioned_assets.into()), + Box::new(beneficiary.clone().into()), + ) + .is_err() + { + ::core::panicking::panic( + "assertion failed: ::PolkadotXcm::claim_assets(origin.clone(),\n bx!(other_versioned_assets.into()),\n bx!(beneficiary.clone().into())).is_err()", + ) + } + let is = ::PolkadotXcm::claim_assets( + origin.clone(), + Box::new(versioned_assets.clone().into()), + Box::new(beneficiary.clone().into()), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsClaimed { + origin: beneficiary, + assets: versioned_assets, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsClaimed {\norigin: beneficiary, assets: versioned_assets, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsClaimed {\norigin: beneficiary, assets: versioned_assets, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::claim_assets", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let balance_after = ::Balances::free_balance( + &sender, + ); + match (&balance_after, &(balance_before + amount)) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !::PolkadotXcm::claim_assets( + origin.clone(), + Box::new(versioned_assets.clone().into()), + Box::new(beneficiary.clone().into()), + ) + .is_err() + { + ::core::panicking::panic( + "assertion failed: ::PolkadotXcm::claim_assets(origin.clone(),\n bx!(versioned_assets.clone().into()),\n bx!(beneficiary.clone().into())).is_err()", + ) + } + let balance = ::Balances::free_balance( + &sender, + ); + match (&balance, &balance_after) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + ::PolkadotXcm::drop_assets( + &beneficiary, + assets.clone().into(), + &XcmContext { + origin: None, + message_id: [0u8; 32], + topic: None, + }, + ); + let receiver = AssetHubWestendReceiver::get(); + let other_beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { + network: Some(NetworkId::Westend), + id: receiver.clone().into(), + } + .into(); + let balance_before = ::Balances::free_balance( + &receiver, + ); + let is = ::PolkadotXcm::claim_assets( + origin.clone(), + Box::new(versioned_assets.clone().into()), + Box::new(other_beneficiary.clone().into()), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let balance_after = ::Balances::free_balance( + &receiver, + ); + match (&balance_after, &(balance_before + amount)) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + } + } + mod fellowship_treasury { + use crate::imports::*; + use emulated_integration_tests_common::{ + accounts::{ALICE, BOB}, + USDT_ID, + }; + use frame_support::traits::fungibles::{Inspect, Mutate}; + use polkadot_runtime_common::impls::VersionedLocatableAsset; + use xcm_executor::traits::ConvertLocation; + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::fellowship_treasury::create_and_claim_treasury_spend"] + pub const create_and_claim_treasury_spend: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::fellowship_treasury::create_and_claim_treasury_spend", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/fellowship_treasury.rs", + start_line: 26usize, + start_col: 4usize, + end_line: 26usize, + end_col: 35usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(create_and_claim_treasury_spend()), + ), + }; + fn create_and_claim_treasury_spend() { + const SPEND_AMOUNT: u128 = 1_000_000_000; + let treasury_location: Location = Location::new( + 1, + [Parachain(CollectivesWestend::para_id().into()), PalletInstance(65)], + ); + let treasury_account = ahw_xcm_config::LocationToAccountId::convert_location( + &treasury_location, + ) + .unwrap(); + let asset_hub_location = Location::new( + 1, + [Parachain(AssetHubWestend::para_id().into())], + ); + let root = ::RuntimeOrigin::root(); + let asset_kind = VersionedLocatableAsset::V5 { + location: asset_hub_location, + asset_id: AssetId( + (PalletInstance(50), GeneralIndex(USDT_ID.into())).into(), + ), + }; + let alice: AccountId = Westend::account_id_of(ALICE); + let bob: AccountId = CollectivesWestend::account_id_of(BOB); + let bob_signed = ::RuntimeOrigin::signed( + bob.clone(), + ); + AssetHubWestend::execute_with(|| { + type Assets = ::Assets; + let is = >::mint_into(USDT_ID, &treasury_account, SPEND_AMOUNT * 4); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + match (&>::balance(USDT_ID, &alice), &0u128) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + CollectivesWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type FellowshipTreasury = ::FellowshipTreasury; + type AssetRate = ::AssetRate; + let is = AssetRate::create( + root.clone(), + Box::new(asset_kind.clone()), + 2.into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = FellowshipTreasury::spend( + root, + Box::new(asset_kind), + SPEND_AMOUNT, + Box::new( + Location::new(0, Into::<[u8; 32]>::into(alice.clone())).into(), + ), + None, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = FellowshipTreasury::payout(bob_signed.clone(), 0); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::FellowshipTreasury( + pallet_treasury::Event::Paid { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "CollectivesWestend", + "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::Paid { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "CollectivesWestend", + "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::Paid { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::CollectivesWestend", + "asset_hub_westend_integration_tests::tests::fellowship_treasury", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type Assets = ::Assets; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Transferred { + asset_id: id, + from, + to, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(id == &USDT_ID) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "id", + id, + "id == &USDT_ID", + ), + ); + res + }); + } + meet_conditions &= id == &USDT_ID; + if !(from == &treasury_account) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "from == &treasury_account", + ), + ); + res + }); + } + meet_conditions &= from == &treasury_account; + if !(to == &alice) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "to == &alice", + ), + ); + res + }); + } + meet_conditions &= to == &alice; + if !(amount == &SPEND_AMOUNT) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "amount == &SPEND_AMOUNT", + ), + ); + res + }); + } + meet_conditions &= amount == &SPEND_AMOUNT; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::XcmpQueue( + cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::fellowship_treasury", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + match ( + &>::balance(USDT_ID, &alice), + &SPEND_AMOUNT, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + CollectivesWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type FellowshipTreasury = ::FellowshipTreasury; + let is = FellowshipTreasury::check_status(bob_signed, 0); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::FellowshipTreasury( + pallet_treasury::Event::SpendProcessed { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "CollectivesWestend", + "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::SpendProcessed { ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "CollectivesWestend", + "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::SpendProcessed { ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::CollectivesWestend", + "asset_hub_westend_integration_tests::tests::fellowship_treasury", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + } + mod hybrid_transfers { + use super::reserve_transfer::*; + use crate::{ + imports::*, + tests::teleport::do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt, + }; + fn para_to_para_assethub_hop_assertions(t: ParaToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_penpal_a_on_ah = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + let sov_penpal_b_on_ah = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalB::para_id()), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_a_on_ah) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_a_on_ah", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_a_on_ah; + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_b_on_ah) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_b_on_ah", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_b_on_ah; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::hybrid_transfers", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn ah_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { + let fee_idx = t.args.fee_asset_item as usize; + let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); + let custom_xcm_on_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + beneficiary: t.args.beneficiary, + }, + ]), + ), + ); + ::PolkadotXcm::transfer_assets_using_type_and_then( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.assets.into()), + Box::new(TransferType::LocalReserve), + Box::new(fee.id.into()), + Box::new(TransferType::LocalReserve), + Box::new(VersionedXcm::from(custom_xcm_on_dest)), + t.args.weight_limit, + ) + } + fn para_to_ah_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult { + let fee_idx = t.args.fee_asset_item as usize; + let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); + let custom_xcm_on_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + beneficiary: t.args.beneficiary, + }, + ]), + ), + ); + ::PolkadotXcm::transfer_assets_using_type_and_then( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.assets.into()), + Box::new(TransferType::DestinationReserve), + Box::new(fee.id.into()), + Box::new(TransferType::DestinationReserve), + Box::new(VersionedXcm::from(custom_xcm_on_dest)), + t.args.weight_limit, + ) + } + fn para_to_para_transfer_assets_through_ah( + t: ParaToParaThroughAHTest, + ) -> DispatchResult { + let fee_idx = t.args.fee_asset_item as usize; + let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); + let asset_hub_location: Location = PenpalA::sibling_location_of( + AssetHubWestend::para_id(), + ); + let custom_xcm_on_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + beneficiary: t.args.beneficiary, + }, + ]), + ), + ); + ::PolkadotXcm::transfer_assets_using_type_and_then( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.assets.into()), + Box::new(TransferType::RemoteReserve(asset_hub_location.clone().into())), + Box::new(fee.id.into()), + Box::new(TransferType::RemoteReserve(asset_hub_location.into())), + Box::new(VersionedXcm::from(custom_xcm_on_dest)), + t.args.weight_limit, + ) + } + fn para_to_asset_hub_teleport_foreign_assets( + t: ParaToSystemParaTest, + ) -> DispatchResult { + let fee_idx = t.args.fee_asset_item as usize; + let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); + let custom_xcm_on_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + beneficiary: t.args.beneficiary, + }, + ]), + ), + ); + ::PolkadotXcm::transfer_assets_using_type_and_then( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.assets.into()), + Box::new(TransferType::Teleport), + Box::new(fee.id.into()), + Box::new(TransferType::DestinationReserve), + Box::new(VersionedXcm::from(custom_xcm_on_dest)), + t.args.weight_limit, + ) + } + fn asset_hub_to_para_teleport_foreign_assets( + t: SystemParaToParaTest, + ) -> DispatchResult { + let fee_idx = t.args.fee_asset_item as usize; + let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); + let custom_xcm_on_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + beneficiary: t.args.beneficiary, + }, + ]), + ), + ); + ::PolkadotXcm::transfer_assets_using_type_and_then( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.assets.into()), + Box::new(TransferType::Teleport), + Box::new(fee.id.into()), + Box::new(TransferType::LocalReserve), + Box::new(VersionedXcm::from(custom_xcm_on_dest)), + t.args.weight_limit, + ) + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::hybrid_transfers::transfer_foreign_assets_from_asset_hub_to_para"] + pub const transfer_foreign_assets_from_asset_hub_to_para: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::hybrid_transfers::transfer_foreign_assets_from_asset_hub_to_para", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", + start_line: 156usize, + start_col: 4usize, + end_line: 156usize, + end_col: 50usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + transfer_foreign_assets_from_asset_hub_to_para(), + ), + ), + }; + /// Transfers of native asset plus bridged asset from AssetHub to some Parachain + /// while paying fees using native asset. + fn transfer_foreign_assets_from_asset_hub_to_para() { + let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); + let sender = AssetHubWestendSender::get(); + let native_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let native_asset_location = RelayLocation::get(); + let receiver = PenpalAReceiver::get(); + let assets_owner = PenpalAssetOwner::get(); + let foreign_amount_to_send = ASSET_HUB_WESTEND_ED * 10_000_000; + let roc_at_westend_parachains = Location::new( + 2, + [Junction::GlobalConsensus(NetworkId::Rococo)], + ); + PenpalA::execute_with(|| { + let is = ::System::set_storage( + ::RuntimeOrigin::root(), + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), + Location::new(2, [GlobalConsensus(Rococo)]).encode(), + ), + ]), + ), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + PenpalA::force_create_foreign_asset( + roc_at_westend_parachains.clone(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + AssetHubWestend::force_create_foreign_asset( + roc_at_westend_parachains.clone().try_into().unwrap(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + AssetHubWestend::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner), + roc_at_westend_parachains.clone().try_into().unwrap(), + sender.clone(), + foreign_amount_to_send * 2, + ); + let assets: Vec = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (Parent, native_amount_to_send).into(), + (roc_at_westend_parachains.clone(), foreign_amount_to_send).into(), + ]), + ); + let fee_asset_id = AssetId(Parent.into()); + let fee_asset_item = assets + .iter() + .position(|a| a.id == fee_asset_id) + .unwrap() as u32; + let test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination.clone(), + receiver.clone(), + native_amount_to_send, + assets.into(), + None, + fee_asset_item, + ), + }; + let mut test = SystemParaToParaTest::new(test_args); + let sender_balance_before = test.sender.balance; + let sender_rocs_before = AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &sender, + ) + }); + let receiver_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location.clone(), &receiver) + }); + let receiver_rocs_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.clone(), &receiver) + }); + test.set_assertion::(system_para_to_para_sender_assertions); + test.set_assertion::(system_para_to_para_receiver_assertions); + test.set_dispatchable::(ah_to_para_transfer_assets); + test.assert(); + let sender_balance_after = test.sender.balance; + let sender_rocs_after = AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &sender, + ) + }); + let receiver_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location, &receiver) + }); + let receiver_rocs_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains, &receiver) + }); + if !(sender_balance_after < sender_balance_before - native_amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_balance_after < sender_balance_before - native_amount_to_send", + ) + } + match (&sender_rocs_after, &(sender_rocs_before - foreign_amount_to_send)) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(receiver_assets_after > receiver_assets_before) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after > receiver_assets_before", + ) + } + if !(receiver_assets_after < receiver_assets_before + native_amount_to_send) + { + ::core::panicking::panic( + "assertion failed: receiver_assets_after < receiver_assets_before + native_amount_to_send", + ) + } + match ( + &receiver_rocs_after, + &(receiver_rocs_before + foreign_amount_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_asset_hub"] + pub const transfer_foreign_assets_from_para_to_asset_hub: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_asset_hub", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", + start_line: 285usize, + start_col: 4usize, + end_line: 285usize, + end_col: 50usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + transfer_foreign_assets_from_para_to_asset_hub(), + ), + ), + }; + /// Reserve Transfers of native asset from Parachain to System Parachain should work + /// Transfers of native asset plus bridged asset from some Parachain to AssetHub + /// while paying fees using native asset. + fn transfer_foreign_assets_from_para_to_asset_hub() { + let destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()); + let sender = PenpalASender::get(); + let native_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 10000; + let native_asset_location = RelayLocation::get(); + let assets_owner = PenpalAssetOwner::get(); + let foreign_amount_to_send = ASSET_HUB_WESTEND_ED * 10_000_000; + let roc_at_westend_parachains = Location::new( + 2, + [Junction::GlobalConsensus(NetworkId::Rococo)], + ); + PenpalA::execute_with(|| { + let is = ::System::set_storage( + ::RuntimeOrigin::root(), + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), + Location::new(2, [GlobalConsensus(Rococo)]).encode(), + ), + ]), + ), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + PenpalA::force_create_foreign_asset( + roc_at_westend_parachains.clone(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + AssetHubWestend::force_create_foreign_asset( + roc_at_westend_parachains.clone().try_into().unwrap(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner.clone()), + native_asset_location.clone(), + sender.clone(), + native_amount_to_send * 2, + ); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner.clone()), + roc_at_westend_parachains.clone(), + sender.clone(), + foreign_amount_to_send * 2, + ); + let receiver = AssetHubWestendReceiver::get(); + let penpal_location_as_seen_by_ahr = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + penpal_location_as_seen_by_ahr, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_penpal_on_ahr.clone().into(), native_amount_to_send * 2), + ]), + ), + ); + AssetHubWestend::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner), + roc_at_westend_parachains.clone().try_into().unwrap(), + sov_penpal_on_ahr, + foreign_amount_to_send * 2, + ); + let assets: Vec = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (Parent, native_amount_to_send).into(), + (roc_at_westend_parachains.clone(), foreign_amount_to_send).into(), + ]), + ); + let fee_asset_id = AssetId(Parent.into()); + let fee_asset_item = assets + .iter() + .position(|a| a.id == fee_asset_id) + .unwrap() as u32; + let test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination.clone(), + receiver.clone(), + native_amount_to_send, + assets.into(), + None, + fee_asset_item, + ), + }; + let mut test = ParaToSystemParaTest::new(test_args); + let sender_native_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location.clone(), &sender) + }); + let sender_rocs_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.clone(), &sender) + }); + let receiver_native_before = test.receiver.balance; + let receiver_rocs_before = AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &receiver, + ) + }); + test.set_assertion::(para_to_system_para_sender_assertions); + test.set_assertion::< + AssetHubWestend, + >(para_to_system_para_receiver_assertions); + test.set_dispatchable::(para_to_ah_transfer_assets); + test.assert(); + let sender_native_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location, &sender) + }); + let sender_rocs_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.clone(), &sender) + }); + let receiver_native_after = test.receiver.balance; + let receiver_rocs_after = AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.try_into().unwrap(), &receiver) + }); + if !(sender_native_after < sender_native_before - native_amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_native_after < sender_native_before - native_amount_to_send", + ) + } + match (&sender_rocs_after, &(sender_rocs_before - foreign_amount_to_send)) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(receiver_native_after > receiver_native_before) { + ::core::panicking::panic( + "assertion failed: receiver_native_after > receiver_native_before", + ) + } + if !(receiver_native_after < receiver_native_before + native_amount_to_send) + { + ::core::panicking::panic( + "assertion failed: receiver_native_after < receiver_native_before + native_amount_to_send", + ) + } + match ( + &receiver_rocs_after, + &(receiver_rocs_before + foreign_amount_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_para_through_asset_hub"] + pub const transfer_foreign_assets_from_para_to_para_through_asset_hub: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_para_through_asset_hub", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", + start_line: 440usize, + start_col: 4usize, + end_line: 440usize, + end_col: 63usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + transfer_foreign_assets_from_para_to_para_through_asset_hub(), + ), + ), + }; + /// Transfers of native asset plus bridged asset from Parachain to Parachain + /// (through AssetHub reserve) with fees paid using native asset. + fn transfer_foreign_assets_from_para_to_para_through_asset_hub() { + let destination = PenpalA::sibling_location_of(PenpalB::para_id()); + let sender = PenpalASender::get(); + let wnd_to_send: Balance = WESTEND_ED * 10000; + let assets_owner = PenpalAssetOwner::get(); + let wnd_location = RelayLocation::get(); + let sender_as_seen_by_ah = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_of_sender_on_ah = AssetHubWestend::sovereign_account_id_of( + sender_as_seen_by_ah, + ); + let receiver_as_seen_by_ah = AssetHubWestend::sibling_location_of( + PenpalB::para_id(), + ); + let sov_of_receiver_on_ah = AssetHubWestend::sovereign_account_id_of( + receiver_as_seen_by_ah, + ); + let roc_to_send = ASSET_HUB_WESTEND_ED * 10_000_000; + PenpalB::execute_with(|| { + let is = ::System::set_storage( + ::RuntimeOrigin::root(), + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), + Location::new(2, [GlobalConsensus(Rococo)]).encode(), + ), + ]), + ), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + let roc_at_westend_parachains = Location::new( + 2, + [Junction::GlobalConsensus(NetworkId::Rococo)], + ); + AssetHubWestend::force_create_foreign_asset( + roc_at_westend_parachains.clone().try_into().unwrap(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + PenpalA::force_create_foreign_asset( + roc_at_westend_parachains.clone(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + PenpalB::force_create_foreign_asset( + roc_at_westend_parachains.clone(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner.clone()), + wnd_location.clone(), + sender.clone(), + wnd_to_send * 2, + ); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner.clone()), + roc_at_westend_parachains.clone(), + sender.clone(), + roc_to_send * 2, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_of_sender_on_ah.clone().into(), wnd_to_send * 2), + ]), + ), + ); + AssetHubWestend::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner), + roc_at_westend_parachains.clone().try_into().unwrap(), + sov_of_sender_on_ah.clone(), + roc_to_send * 2, + ); + let receiver = PenpalBReceiver::get(); + let assets: Vec = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (wnd_location.clone(), wnd_to_send).into(), + (roc_at_westend_parachains.clone(), roc_to_send).into(), + ]), + ); + let fee_asset_id: AssetId = wnd_location.clone().into(); + let fee_asset_item = assets + .iter() + .position(|a| a.id == fee_asset_id) + .unwrap() as u32; + let test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination, + receiver.clone(), + wnd_to_send, + assets.into(), + None, + fee_asset_item, + ), + }; + let mut test = ParaToParaThroughAHTest::new(test_args); + let sender_wnds_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(wnd_location.clone(), &sender) + }); + let sender_rocs_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.clone(), &sender) + }); + let wnds_in_sender_reserve_on_ah_before = ::account_data_of( + sov_of_sender_on_ah.clone(), + ) + .free; + let rocs_in_sender_reserve_on_ah_before = AssetHubWestend::execute_with(|| { + type Assets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &sov_of_sender_on_ah, + ) + }); + let wnds_in_receiver_reserve_on_ah_before = ::account_data_of( + sov_of_receiver_on_ah.clone(), + ) + .free; + let rocs_in_receiver_reserve_on_ah_before = AssetHubWestend::execute_with(|| { + type Assets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &sov_of_receiver_on_ah, + ) + }); + let receiver_wnds_before = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(wnd_location.clone(), &receiver) + }); + let receiver_rocs_before = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.clone(), &receiver) + }); + test.set_assertion::(para_to_para_through_hop_sender_assertions); + test.set_assertion::(para_to_para_assethub_hop_assertions); + test.set_assertion::(para_to_para_through_hop_receiver_assertions); + test.set_dispatchable::(para_to_para_transfer_assets_through_ah); + test.assert(); + let sender_wnds_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(wnd_location.clone(), &sender) + }); + let sender_rocs_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.clone(), &sender) + }); + let rocs_in_sender_reserve_on_ah_after = AssetHubWestend::execute_with(|| { + type Assets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &sov_of_sender_on_ah, + ) + }); + let wnds_in_sender_reserve_on_ah_after = ::account_data_of( + sov_of_sender_on_ah, + ) + .free; + let rocs_in_receiver_reserve_on_ah_after = AssetHubWestend::execute_with(|| { + type Assets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &sov_of_receiver_on_ah, + ) + }); + let wnds_in_receiver_reserve_on_ah_after = ::account_data_of( + sov_of_receiver_on_ah, + ) + .free; + let receiver_wnds_after = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(wnd_location, &receiver) + }); + let receiver_rocs_after = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains, &receiver) + }); + if !(sender_wnds_after < sender_wnds_before - wnd_to_send) { + ::core::panicking::panic( + "assertion failed: sender_wnds_after < sender_wnds_before - wnd_to_send", + ) + } + match (&sender_rocs_after, &(sender_rocs_before - roc_to_send)) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &wnds_in_sender_reserve_on_ah_after, + &(wnds_in_sender_reserve_on_ah_before - wnd_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &rocs_in_sender_reserve_on_ah_after, + &(rocs_in_sender_reserve_on_ah_before - roc_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(wnds_in_receiver_reserve_on_ah_after + > wnds_in_receiver_reserve_on_ah_before) + { + ::core::panicking::panic( + "assertion failed: wnds_in_receiver_reserve_on_ah_after > wnds_in_receiver_reserve_on_ah_before", + ) + } + match ( + &rocs_in_receiver_reserve_on_ah_after, + &(rocs_in_receiver_reserve_on_ah_before + roc_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(receiver_wnds_after > receiver_wnds_before) { + ::core::panicking::panic( + "assertion failed: receiver_wnds_after > receiver_wnds_before", + ) + } + match (&receiver_rocs_after, &(receiver_rocs_before + roc_to_send)) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::hybrid_transfers::bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types"] + pub const bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::hybrid_transfers::bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", + start_line: 644usize, + start_col: 4usize, + end_line: 644usize, + end_col: 97usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types(), + ), + ), + }; + /// Transfers of native asset plus teleportable foreign asset from Parachain to AssetHub and back + /// with fees paid using native asset. + fn bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types() { + do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt( + para_to_asset_hub_teleport_foreign_assets, + asset_hub_to_para_teleport_foreign_assets, + ); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::hybrid_transfers::transfer_native_asset_from_relay_to_para_through_asset_hub"] + pub const transfer_native_asset_from_relay_to_para_through_asset_hub: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::hybrid_transfers::transfer_native_asset_from_relay_to_para_through_asset_hub", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", + start_line: 658usize, + start_col: 4usize, + end_line: 658usize, + end_col: 62usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + transfer_native_asset_from_relay_to_para_through_asset_hub(), + ), + ), + }; + /// Transfers of native asset Relay to Parachain (using AssetHub reserve). Parachains want to avoid + /// managing SAs on all system chains, thus want all their DOT-in-reserve to be held in their + /// Sovereign Account on Asset Hub. + fn transfer_native_asset_from_relay_to_para_through_asset_hub() { + let destination = Westend::child_location_of(PenpalA::para_id()); + let sender = WestendSender::get(); + let amount_to_send: Balance = WESTEND_ED * 1000; + let relay_native_asset_location = RelayLocation::get(); + let receiver = PenpalAReceiver::get(); + let test_args = TestContext { + sender, + receiver: receiver.clone(), + args: TestArgs::new_relay( + destination.clone(), + receiver.clone(), + amount_to_send, + ), + }; + let mut test = RelayToParaThroughAHTest::new(test_args); + let sov_penpal_on_ah = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + let sender_balance_before = test.sender.balance; + let sov_penpal_on_ah_before = AssetHubWestend::execute_with(|| { + ::Balances::free_balance( + sov_penpal_on_ah.clone(), + ) + }); + let receiver_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &receiver) + }); + fn relay_assertions(t: RelayToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + Westend::assert_xcm_pallet_attempted_complete(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == t.sender.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *who == t.sender.account_id; + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who + == ::XcmPallet::check_account()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == ::XcmPallet::check_account()", + ), + ); + res + }); + } + meet_conditions + &= *who + == ::XcmPallet::check_account(); + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::hybrid_transfers", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn asset_hub_assertions(_: RelayToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_penpal_on_ah = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_on_ah) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_on_ah", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_on_ah; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::hybrid_transfers", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn penpal_assertions(t: RelayToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + let expected_id = t + .args + .assets + .into_inner() + .first() + .unwrap() + .id + .0 + .clone() + .try_into() + .unwrap(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == t.receiver.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::hybrid_transfers", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn transfer_assets_dispatchable( + t: RelayToParaThroughAHTest, + ) -> DispatchResult { + let fee_idx = t.args.fee_asset_item as usize; + let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); + let asset_hub_location = Westend::child_location_of( + AssetHubWestend::para_id(), + ); + let context = WestendUniversalLocation::get(); + let mut remote_fees = fee + .clone() + .reanchored(&t.args.dest, &context) + .unwrap(); + if let Fungible(ref mut amount) = remote_fees.fun { + *amount = *amount / 2; + } + let xcm_on_final_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + BuyExecution { + fees: remote_fees, + weight_limit: t.args.weight_limit.clone(), + }, + DepositAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + beneficiary: t.args.beneficiary, + }, + ]), + ), + ); + let mut dest = t.args.dest.clone(); + dest.reanchor(&asset_hub_location, &context).unwrap(); + let xcm_on_hop = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositReserveAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + dest, + xcm: xcm_on_final_dest, + }, + ]), + ), + ); + ::XcmPallet::transfer_assets_using_type_and_then( + t.signed_origin, + Box::new(asset_hub_location.into()), + Box::new(t.args.assets.into()), + Box::new(TransferType::Teleport), + Box::new(fee.id.into()), + Box::new(TransferType::Teleport), + Box::new(VersionedXcm::from(xcm_on_hop)), + t.args.weight_limit, + ) + } + test.set_assertion::(relay_assertions); + test.set_assertion::(asset_hub_assertions); + test.set_assertion::(penpal_assertions); + test.set_dispatchable::(transfer_assets_dispatchable); + test.assert(); + let sender_balance_after = test.sender.balance; + let sov_penpal_on_ah_after = AssetHubWestend::execute_with(|| { + ::Balances::free_balance( + sov_penpal_on_ah, + ) + }); + let receiver_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location, &receiver) + }); + if !(sender_balance_after < sender_balance_before - amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_balance_after < sender_balance_before - amount_to_send", + ) + } + if !(sov_penpal_on_ah_after > sov_penpal_on_ah_before) { + ::core::panicking::panic( + "assertion failed: sov_penpal_on_ah_after > sov_penpal_on_ah_before", + ) + } + if !(receiver_assets_after > receiver_assets_before) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after > receiver_assets_before", + ) + } + if !(receiver_assets_after < receiver_assets_before + amount_to_send) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after < receiver_assets_before + amount_to_send", + ) + } + } + } + mod reserve_transfer { + use crate::imports::*; + fn relay_to_para_sender_assertions(t: RelayToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + Westend::assert_xcm_pallet_attempted_complete( + Some(Weight::from_parts(864_610_000, 8_799)), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*from == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "*from == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *from == t.sender.account_id; + if !(*to + == Westend::sovereign_account_id_of(t.args.dest.clone())) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "*to == Westend::sovereign_account_id_of(t.args.dest.clone())", + ), + ); + res + }); + } + meet_conditions + &= *to + == Westend::sovereign_account_id_of(t.args.dest.clone()); + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn para_to_relay_sender_assertions(t: ParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + PenpalA::assert_xcm_pallet_attempted_complete( + Some(Weight::from_parts(864_610_000, 8_799)), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == RelayLocation::get()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == RelayLocation::get()", + ), + ); + res + }); + } + meet_conditions &= *asset_id == RelayLocation::get(); + if !(*owner == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if !(*balance == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *balance == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + pub fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcm_pallet_attempted_complete(None); + let sov_acc_of_dest = AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + ); + for (idx, asset) in t.args.assets.into_inner().into_iter().enumerate() { + let expected_id = asset.id.0.clone().try_into().unwrap(); + let asset_amount = if let Fungible(a) = asset.fun { + Some(a) + } else { + None + } + .unwrap(); + if idx == t.args.fee_asset_item as usize { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*from == t.sender.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "*from == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *from == t.sender.account_id; + if !(*to == sov_acc_of_dest) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "*to == sov_acc_of_dest", + ), + ); + res + }); + } + meet_conditions &= *to == sov_acc_of_dest; + if !(*amount == asset_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } else { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Transferred { + asset_id, + from, + to, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*from == t.sender.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "*from == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *from == t.sender.account_id; + if !(*to == sov_acc_of_dest) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "*to == sov_acc_of_dest", + ), + ); + res + }); + } + meet_conditions &= *to == sov_acc_of_dest; + if !(*amount == asset_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + } + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. }) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + AssetHubWestend::assert_xcm_pallet_sent(); + } + pub fn system_para_to_para_receiver_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + PenpalA::assert_xcmp_queue_success(None); + for asset in t.args.assets.into_inner().into_iter() { + let expected_id = asset.id.0.try_into().unwrap(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == t.receiver.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + } + pub fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + PenpalA::assert_xcm_pallet_attempted_complete(None); + for asset in t.args.assets.into_inner().into_iter() { + let expected_id = asset.id.0; + let asset_amount = if let Fungible(a) = asset.fun { + Some(a) + } else { + None + } + .unwrap(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == t.sender.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if !(*balance == asset_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == asset_amount", + ), + ); + res + }); + } + meet_conditions &= *balance == asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + } + fn para_to_relay_receiver_assertions(t: ParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_penpal_on_relay = Westend::sovereign_account_id_of( + Westend::child_location_of(PenpalA::para_id()), + ); + Westend::assert_ump_queue_processed( + true, + Some(PenpalA::para_id()), + Some(Weight::from_parts(306305000, 7_186)), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_on_relay.clone().into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_on_relay.clone().into()", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_on_relay.clone().into(); + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances(pallet_balances::Event::Minted { .. }) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + pub fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcmp_queue_success(None); + let sov_acc_of_penpal = AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + ); + for (idx, asset) in t.args.assets.into_inner().into_iter().enumerate() { + let expected_id = asset.id.0.clone().try_into().unwrap(); + let asset_amount = if let Fungible(a) = asset.fun { + Some(a) + } else { + None + } + .unwrap(); + if idx == t.args.fee_asset_item as usize { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_acc_of_penpal.clone().into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_acc_of_penpal.clone().into()", + ), + ); + res + }); + } + meet_conditions &= *who == sov_acc_of_penpal.clone().into(); + if !(*amount == asset_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == t.receiver.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *who == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } else { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == sov_acc_of_penpal) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == sov_acc_of_penpal", + ), + ); + res + }); + } + meet_conditions &= *owner == sov_acc_of_penpal; + if !(*balance == asset_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == asset_amount", + ), + ); + res + }); + } + meet_conditions &= *balance == asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == t.receiver.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if !(*amount == asset_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + } + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcm_pallet_attempted_complete( + Some(Weight::from_parts(864_610_000, 8799)), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Transferred { asset_id, from, to, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == RESERVABLE_ASSET_ID) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == RESERVABLE_ASSET_ID", + ), + ); + res + }); + } + meet_conditions &= *asset_id == RESERVABLE_ASSET_ID; + if !(*from == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "*from == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *from == t.sender.account_id; + if !(*to + == AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + )) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "*to == AssetHubWestend::sovereign_account_id_of(t.args.dest.clone())", + ), + ); + res + }); + } + meet_conditions + &= *to + == AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + ); + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who + == AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + )) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == AssetHubWestend::sovereign_account_id_of(t.args.dest.clone())", + ), + ); + res + }); + } + meet_conditions + &= *who + == AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + ); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. }) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn para_to_system_para_assets_sender_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let system_para_native_asset_location = RelayLocation::get(); + let reservable_asset_location = PenpalLocalReservableFromAssetHub::get(); + PenpalA::assert_xcm_pallet_attempted_complete( + Some(Weight::from_parts(864_610_000, 8799)), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == system_para_native_asset_location) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == system_para_native_asset_location", + ), + ); + res + }); + } + meet_conditions + &= *asset_id == system_para_native_asset_location; + if !(*owner == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == reservable_asset_location) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == reservable_asset_location", + ), + ); + res + }); + } + meet_conditions &= *asset_id == reservable_asset_location; + if !(*owner == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if !(*balance == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *balance == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. }) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn system_para_to_para_assets_receiver_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let system_para_asset_location = PenpalLocalReservableFromAssetHub::get(); + PenpalA::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == RelayLocation::get()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == RelayLocation::get()", + ), + ); + res + }); + } + meet_conditions &= *asset_id == RelayLocation::get(); + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == system_para_asset_location) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == system_para_asset_location", + ), + ); + res + }); + } + meet_conditions &= *asset_id == system_para_asset_location; + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn para_to_system_para_assets_receiver_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + AssetHubWestend::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == RESERVABLE_ASSET_ID) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == RESERVABLE_ASSET_ID", + ), + ); + res + }); + } + meet_conditions &= *asset_id == RESERVABLE_ASSET_ID; + if !(*owner == sov_penpal_on_ahr) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == sov_penpal_on_ahr", + ), + ); + res + }); + } + meet_conditions &= *owner == sov_penpal_on_ahr; + if !(*balance == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *balance == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_on_ahr) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_on_ahr", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_on_ahr; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Issued { asset_id, owner, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == RESERVABLE_ASSET_ID) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == RESERVABLE_ASSET_ID", + ), + ); + res + }); + } + meet_conditions &= *asset_id == RESERVABLE_ASSET_ID; + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == t.receiver.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *who == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn relay_to_para_assets_receiver_assertions(t: RelayToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == RelayLocation::get()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == RelayLocation::get()", + ), + ); + res + }); + } + meet_conditions &= *asset_id == RelayLocation::get(); + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + pub fn para_to_para_through_hop_sender_assertions( + t: Test, + ) { + type RuntimeEvent = ::RuntimeEvent; + PenpalA::assert_xcm_pallet_attempted_complete(None); + for asset in t.args.assets.into_inner() { + let expected_id = asset.id.0.clone().try_into().unwrap(); + let amount = if let Fungible(a) = asset.fun { Some(a) } else { None } + .unwrap(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == t.sender.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if !(*balance == amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == amount", + ), + ); + res + }); + } + meet_conditions &= *balance == amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + } + fn para_to_para_relay_hop_assertions(t: ParaToParaThroughRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_penpal_a_on_westend = Westend::sovereign_account_id_of( + Westend::child_location_of(PenpalA::para_id()), + ); + let sov_penpal_b_on_westend = Westend::sovereign_account_id_of( + Westend::child_location_of(PenpalB::para_id()), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_a_on_westend) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_a_on_westend", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_a_on_westend; + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_b_on_westend) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_b_on_westend", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_b_on_westend; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + pub fn para_to_para_through_hop_receiver_assertions( + t: Test, + ) { + type RuntimeEvent = ::RuntimeEvent; + PenpalB::assert_xcmp_queue_success(None); + for asset in t.args.assets.into_inner().into_iter() { + let expected_id = asset.id.0.try_into().unwrap(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == t.receiver.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalB", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalB", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalB", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + } + fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { + ::XcmPallet::limited_reserve_transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + fn para_to_relay_reserve_transfer_assets(t: ParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + fn system_para_to_para_reserve_transfer_assets( + t: SystemParaToParaTest, + ) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + fn para_to_system_para_reserve_transfer_assets( + t: ParaToSystemParaTest, + ) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + fn para_to_para_through_relay_limited_reserve_transfer_assets( + t: ParaToParaThroughRelayTest, + ) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_asset_hub_fails"] + pub const reserve_transfer_native_asset_from_relay_to_asset_hub_fails: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_asset_hub_fails", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 498usize, + start_col: 4usize, + end_line: 498usize, + end_col: 63usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_relay_to_asset_hub_fails(), + ), + ), + }; + /// Reserve Transfers of native asset from Relay Chain to the Asset Hub shouldn't work + fn reserve_transfer_native_asset_from_relay_to_asset_hub_fails() { + let signed_origin = ::RuntimeOrigin::signed( + WestendSender::get().into(), + ); + let destination = Westend::child_location_of(AssetHubWestend::para_id()); + let beneficiary: Location = AccountId32Junction { + network: None, + id: AssetHubWestendReceiver::get().into(), + } + .into(); + let amount_to_send: Balance = WESTEND_ED * 1000; + let assets: Assets = (Here, amount_to_send).into(); + let fee_asset_item = 0; + Westend::execute_with(|| { + let result = ::XcmPallet::limited_reserve_transfer_assets( + signed_origin, + Box::new(destination.into()), + Box::new(beneficiary.into()), + Box::new(assets.into()), + fee_asset_item, + WeightLimit::Unlimited, + ); + match ( + &result, + &Err( + DispatchError::Module(sp_runtime::ModuleError { + index: 99, + error: [2, 0, 0, 0], + message: Some("Filtered"), + }) + .into(), + ), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_relay_fails"] + pub const reserve_transfer_native_asset_from_asset_hub_to_relay_fails: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_relay_fails", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 531usize, + start_col: 4usize, + end_line: 531usize, + end_col: 63usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_asset_hub_to_relay_fails(), + ), + ), + }; + /// Reserve Transfers of native asset from Asset Hub to Relay Chain shouldn't work + fn reserve_transfer_native_asset_from_asset_hub_to_relay_fails() { + let signed_origin = ::RuntimeOrigin::signed( + AssetHubWestendSender::get().into(), + ); + let destination = AssetHubWestend::parent_location(); + let beneficiary_id = WestendReceiver::get(); + let beneficiary: Location = AccountId32Junction { + network: None, + id: beneficiary_id.into(), + } + .into(); + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let assets: Assets = (Parent, amount_to_send).into(); + let fee_asset_item = 0; + AssetHubWestend::execute_with(|| { + let result = ::PolkadotXcm::limited_reserve_transfer_assets( + signed_origin, + Box::new(destination.into()), + Box::new(beneficiary.into()), + Box::new(assets.into()), + fee_asset_item, + WeightLimit::Unlimited, + ); + match ( + &result, + &Err( + DispatchError::Module(sp_runtime::ModuleError { + index: 31, + error: [2, 0, 0, 0], + message: Some("Filtered"), + }) + .into(), + ), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_para"] + pub const reserve_transfer_native_asset_from_relay_to_para: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_para", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 571usize, + start_col: 4usize, + end_line: 571usize, + end_col: 52usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_relay_to_para(), + ), + ), + }; + /// Reserve Transfers of native asset from Relay to Parachain should work + fn reserve_transfer_native_asset_from_relay_to_para() { + let destination = Westend::child_location_of(PenpalA::para_id()); + let sender = WestendSender::get(); + let amount_to_send: Balance = WESTEND_ED * 1000; + let relay_native_asset_location = RelayLocation::get(); + let receiver = PenpalAReceiver::get(); + let test_args = TestContext { + sender, + receiver: receiver.clone(), + args: TestArgs::new_relay( + destination.clone(), + receiver.clone(), + amount_to_send, + ), + }; + let mut test = RelayToParaTest::new(test_args); + let sender_balance_before = test.sender.balance; + let receiver_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &receiver) + }); + test.set_assertion::(relay_to_para_sender_assertions); + test.set_assertion::(relay_to_para_assets_receiver_assertions); + test.set_dispatchable::(relay_to_para_reserve_transfer_assets); + test.assert(); + let sender_balance_after = test.sender.balance; + let receiver_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location, &receiver) + }); + if !(sender_balance_after < sender_balance_before - amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_balance_after < sender_balance_before - amount_to_send", + ) + } + if !(receiver_assets_after > receiver_assets_before) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after > receiver_assets_before", + ) + } + if !(receiver_assets_after < receiver_assets_before + amount_to_send) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after < receiver_assets_before + amount_to_send", + ) + } + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_relay"] + pub const reserve_transfer_native_asset_from_para_to_relay: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_relay", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 621usize, + start_col: 4usize, + end_line: 621usize, + end_col: 52usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_para_to_relay(), + ), + ), + }; + /// Reserve Transfers of native asset from Parachain to Relay should work + fn reserve_transfer_native_asset_from_para_to_relay() { + let destination = PenpalA::parent_location(); + let sender = PenpalASender::get(); + let amount_to_send: Balance = WESTEND_ED * 1000; + let assets: Assets = (Parent, amount_to_send).into(); + let asset_owner = PenpalAssetOwner::get(); + let relay_native_asset_location = RelayLocation::get(); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner), + relay_native_asset_location.clone(), + sender.clone(), + amount_to_send * 2, + ); + let receiver = WestendReceiver::get(); + let penpal_location_as_seen_by_relay = Westend::child_location_of( + PenpalA::para_id(), + ); + let sov_penpal_on_relay = Westend::sovereign_account_id_of( + penpal_location_as_seen_by_relay, + ); + Westend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_penpal_on_relay.into(), amount_to_send * 2), + ]), + ), + ); + let test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination.clone(), + receiver, + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let mut test = ParaToRelayTest::new(test_args); + let sender_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &sender) + }); + let receiver_balance_before = test.receiver.balance; + test.set_assertion::(para_to_relay_sender_assertions); + test.set_assertion::(para_to_relay_receiver_assertions); + test.set_dispatchable::(para_to_relay_reserve_transfer_assets); + test.assert(); + let sender_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location, &sender) + }); + let receiver_balance_after = test.receiver.balance; + if !(sender_assets_after < sender_assets_before - amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_assets_after < sender_assets_before - amount_to_send", + ) + } + if !(receiver_balance_after > receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: receiver_balance_after > receiver_balance_before", + ) + } + if !(receiver_balance_after < receiver_balance_before + amount_to_send) { + ::core::panicking::panic( + "assertion failed: receiver_balance_after < receiver_balance_before + amount_to_send", + ) + } + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_para"] + pub const reserve_transfer_native_asset_from_asset_hub_to_para: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_para", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 696usize, + start_col: 4usize, + end_line: 696usize, + end_col: 56usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_asset_hub_to_para(), + ), + ), + }; + /// Reserve Transfers of native asset from Asset Hub to Parachain should work + fn reserve_transfer_native_asset_from_asset_hub_to_para() { + let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); + let sender = AssetHubWestendSender::get(); + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 2000; + let assets: Assets = (Parent, amount_to_send).into(); + let system_para_native_asset_location = RelayLocation::get(); + let receiver = PenpalAReceiver::get(); + let test_args = TestContext { + sender, + receiver: receiver.clone(), + args: TestArgs::new_para( + destination.clone(), + receiver.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let mut test = SystemParaToParaTest::new(test_args); + let sender_balance_before = test.sender.balance; + let receiver_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location.clone(), &receiver) + }); + test.set_assertion::(system_para_to_para_sender_assertions); + test.set_assertion::(system_para_to_para_receiver_assertions); + test.set_dispatchable::< + AssetHubWestend, + >(system_para_to_para_reserve_transfer_assets); + test.assert(); + let sender_balance_after = test.sender.balance; + let receiver_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location, &receiver) + }); + if !(sender_balance_after < sender_balance_before - amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_balance_after < sender_balance_before - amount_to_send", + ) + } + if !(receiver_assets_after > receiver_assets_before) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after > receiver_assets_before", + ) + } + if !(receiver_assets_after < receiver_assets_before + amount_to_send) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after < receiver_assets_before + amount_to_send", + ) + } + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_asset_hub"] + pub const reserve_transfer_native_asset_from_para_to_asset_hub: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_asset_hub", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 754usize, + start_col: 4usize, + end_line: 754usize, + end_col: 56usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_para_to_asset_hub(), + ), + ), + }; + /// Reserve Transfers of native asset from Parachain to Asset Hub should work + fn reserve_transfer_native_asset_from_para_to_asset_hub() { + let destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()); + let sender = PenpalASender::get(); + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let assets: Assets = (Parent, amount_to_send).into(); + let system_para_native_asset_location = RelayLocation::get(); + let asset_owner = PenpalAssetOwner::get(); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner), + system_para_native_asset_location.clone(), + sender.clone(), + amount_to_send * 2, + ); + let receiver = AssetHubWestendReceiver::get(); + let penpal_location_as_seen_by_ahr = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + penpal_location_as_seen_by_ahr, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_penpal_on_ahr.into(), amount_to_send * 2), + ]), + ), + ); + let test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination.clone(), + receiver.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let mut test = ParaToSystemParaTest::new(test_args); + let sender_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location.clone(), &sender) + }); + let receiver_balance_before = test.receiver.balance; + test.set_assertion::(para_to_system_para_sender_assertions); + test.set_assertion::< + AssetHubWestend, + >(para_to_system_para_receiver_assertions); + test.set_dispatchable::< + PenpalA, + >(para_to_system_para_reserve_transfer_assets); + test.assert(); + let sender_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location, &sender) + }); + let receiver_balance_after = test.receiver.balance; + if !(sender_assets_after < sender_assets_before - amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_assets_after < sender_assets_before - amount_to_send", + ) + } + if !(receiver_balance_after > receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: receiver_balance_after > receiver_balance_before", + ) + } + if !(receiver_balance_after < receiver_balance_before + amount_to_send) { + ::core::panicking::panic( + "assertion failed: receiver_balance_after < receiver_balance_before + amount_to_send", + ) + } + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_multiple_assets_from_asset_hub_to_para"] + pub const reserve_transfer_multiple_assets_from_asset_hub_to_para: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_multiple_assets_from_asset_hub_to_para", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 831usize, + start_col: 4usize, + end_line: 831usize, + end_col: 59usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_multiple_assets_from_asset_hub_to_para(), + ), + ), + }; + /// Reserve Transfers of a local asset and native asset from Asset Hub to Parachain should + /// work + fn reserve_transfer_multiple_assets_from_asset_hub_to_para() { + let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + destination.clone(), + ); + let sender = AssetHubWestendSender::get(); + let fee_amount_to_send = ASSET_HUB_WESTEND_ED * 100; + let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100; + let asset_owner = AssetHubWestendAssetOwner::get(); + let asset_owner_signer = ::RuntimeOrigin::signed( + asset_owner.clone(), + ); + let assets: Assets = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (Parent, fee_amount_to_send).into(), + ( + [ + PalletInstance(ASSETS_PALLET_ID), + GeneralIndex(RESERVABLE_ASSET_ID.into()), + ], + asset_amount_to_send, + ) + .into(), + ]), + ) + .into(); + let fee_asset_index = assets + .inner() + .iter() + .position(|r| r == &(Parent, fee_amount_to_send).into()) + .unwrap() as u32; + AssetHubWestend::mint_asset( + asset_owner_signer, + RESERVABLE_ASSET_ID, + asset_owner, + asset_amount_to_send * 2, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_penpal_on_ahr.into(), ASSET_HUB_WESTEND_ED), + ]), + ), + ); + let receiver = PenpalAReceiver::get(); + let system_para_native_asset_location = RelayLocation::get(); + let system_para_foreign_asset_location = PenpalLocalReservableFromAssetHub::get(); + let para_test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination, + receiver.clone(), + asset_amount_to_send, + assets, + None, + fee_asset_index, + ), + }; + let mut test = SystemParaToParaTest::new(para_test_args); + let sender_balance_before = test.sender.balance; + let sender_assets_before = AssetHubWestend::execute_with(|| { + type Assets = ::Assets; + >::balance(RESERVABLE_ASSET_ID, &sender) + }); + let receiver_system_native_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location.clone(), &receiver) + }); + let receiver_foreign_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_foreign_asset_location.clone(), &receiver) + }); + test.set_assertion::< + AssetHubWestend, + >(system_para_to_para_assets_sender_assertions); + test.set_assertion::< + PenpalA, + >(system_para_to_para_assets_receiver_assertions); + test.set_dispatchable::< + AssetHubWestend, + >(system_para_to_para_reserve_transfer_assets); + test.assert(); + let sender_balance_after = test.sender.balance; + let sender_assets_after = AssetHubWestend::execute_with(|| { + type Assets = ::Assets; + >::balance(RESERVABLE_ASSET_ID, &sender) + }); + let receiver_system_native_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location, &receiver) + }); + let receiver_foreign_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_foreign_asset_location, &receiver) + }); + if !(sender_balance_after < sender_balance_before) { + ::core::panicking::panic( + "assertion failed: sender_balance_after < sender_balance_before", + ) + } + if !(receiver_foreign_assets_after > receiver_foreign_assets_before) { + ::core::panicking::panic( + "assertion failed: receiver_foreign_assets_after > receiver_foreign_assets_before", + ) + } + if !(receiver_system_native_assets_after + < receiver_system_native_assets_before + fee_amount_to_send) + { + ::core::panicking::panic( + "assertion failed: receiver_system_native_assets_after <\n receiver_system_native_assets_before + fee_amount_to_send", + ) + } + match ( + &(sender_assets_before - asset_amount_to_send), + &sender_assets_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &receiver_foreign_assets_after, + &(receiver_foreign_assets_before + asset_amount_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_multiple_assets_from_para_to_asset_hub"] + pub const reserve_transfer_multiple_assets_from_para_to_asset_hub: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_multiple_assets_from_para_to_asset_hub", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 948usize, + start_col: 4usize, + end_line: 948usize, + end_col: 59usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_multiple_assets_from_para_to_asset_hub(), + ), + ), + }; + /// Reserve Transfers of a random asset and native asset from Parachain to Asset Hub should work + /// Receiver is empty account to show deposit works as long as transfer includes enough DOT for ED. + /// Once we have https://github.com/paritytech/polkadot-sdk/issues/5298, + /// we should do equivalent test with USDT instead of DOT. + fn reserve_transfer_multiple_assets_from_para_to_asset_hub() { + let destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()); + let sender = PenpalASender::get(); + let fee_amount_to_send = ASSET_HUB_WESTEND_ED * 100; + let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100; + let penpal_asset_owner = PenpalAssetOwner::get(); + let penpal_asset_owner_signer = ::RuntimeOrigin::signed( + penpal_asset_owner, + ); + let asset_location_on_penpal = PenpalLocalReservableFromAssetHub::get(); + let system_asset_location_on_penpal = RelayLocation::get(); + let assets: Assets = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (Parent, fee_amount_to_send).into(), + (asset_location_on_penpal.clone(), asset_amount_to_send).into(), + ]), + ) + .into(); + let fee_asset_index = assets + .inner() + .iter() + .position(|r| r == &(Parent, fee_amount_to_send).into()) + .unwrap() as u32; + PenpalA::mint_foreign_asset( + penpal_asset_owner_signer.clone(), + asset_location_on_penpal.clone(), + sender.clone(), + asset_amount_to_send * 2, + ); + PenpalA::mint_foreign_asset( + penpal_asset_owner_signer, + system_asset_location_on_penpal.clone(), + sender.clone(), + fee_amount_to_send * 2, + ); + let receiver = get_account_id_from_seed::< + sp_runtime::testing::sr25519::Public, + >(DUMMY_EMPTY); + let penpal_location_as_seen_by_ahr = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + penpal_location_as_seen_by_ahr, + ); + let ah_asset_owner = AssetHubWestendAssetOwner::get(); + let ah_asset_owner_signer = ::RuntimeOrigin::signed( + ah_asset_owner, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_penpal_on_ahr.clone().into(), ASSET_HUB_WESTEND_ED * 1000), + ]), + ), + ); + AssetHubWestend::mint_asset( + ah_asset_owner_signer, + RESERVABLE_ASSET_ID, + sov_penpal_on_ahr, + asset_amount_to_send * 2, + ); + let para_test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination, + receiver.clone(), + asset_amount_to_send, + assets, + None, + fee_asset_index, + ), + }; + let mut test = ParaToSystemParaTest::new(para_test_args); + let sender_system_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_asset_location_on_penpal.clone(), &sender) + }); + let sender_foreign_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(asset_location_on_penpal.clone(), &sender) + }); + let receiver_balance_before = test.receiver.balance; + let receiver_assets_before = AssetHubWestend::execute_with(|| { + type Assets = ::Assets; + >::balance(RESERVABLE_ASSET_ID, &receiver) + }); + test.set_assertion::(para_to_system_para_assets_sender_assertions); + test.set_assertion::< + AssetHubWestend, + >(para_to_system_para_assets_receiver_assertions); + test.set_dispatchable::< + PenpalA, + >(para_to_system_para_reserve_transfer_assets); + test.assert(); + let sender_system_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_asset_location_on_penpal, &sender) + }); + let sender_foreign_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(asset_location_on_penpal, &sender) + }); + let receiver_balance_after = test.receiver.balance; + let receiver_assets_after = AssetHubWestend::execute_with(|| { + type Assets = ::Assets; + >::balance(RESERVABLE_ASSET_ID, &receiver) + }); + if !(sender_system_assets_after < sender_system_assets_before) { + ::core::panicking::panic( + "assertion failed: sender_system_assets_after < sender_system_assets_before", + ) + } + if !(receiver_balance_after > receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: receiver_balance_after > receiver_balance_before", + ) + } + if !(receiver_balance_after < receiver_balance_before + fee_amount_to_send) { + ::core::panicking::panic( + "assertion failed: receiver_balance_after < receiver_balance_before + fee_amount_to_send", + ) + } + match ( + &(sender_foreign_assets_before - asset_amount_to_send), + &sender_foreign_assets_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &receiver_assets_after, + &(receiver_assets_before + asset_amount_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_para_through_relay"] + pub const reserve_transfer_native_asset_from_para_to_para_through_relay: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_para_through_relay", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 1076usize, + start_col: 4usize, + end_line: 1076usize, + end_col: 65usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_para_to_para_through_relay(), + ), + ), + }; + /// Reserve Transfers of native asset from Parachain to Parachain (through Relay reserve) should + /// work + fn reserve_transfer_native_asset_from_para_to_para_through_relay() { + let destination = PenpalA::sibling_location_of(PenpalB::para_id()); + let sender = PenpalASender::get(); + let amount_to_send: Balance = WESTEND_ED * 10000; + let asset_owner = PenpalAssetOwner::get(); + let assets = (Parent, amount_to_send).into(); + let relay_native_asset_location = RelayLocation::get(); + let sender_as_seen_by_relay = Westend::child_location_of(PenpalA::para_id()); + let sov_of_sender_on_relay = Westend::sovereign_account_id_of( + sender_as_seen_by_relay, + ); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner), + relay_native_asset_location.clone(), + sender.clone(), + amount_to_send * 2, + ); + Westend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_of_sender_on_relay.into(), amount_to_send * 2), + ]), + ), + ); + let receiver = PenpalBReceiver::get(); + let test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination, + receiver.clone(), + amount_to_send, + assets, + None, + 0, + ), + }; + let mut test = ParaToParaThroughRelayTest::new(test_args); + let sender_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &sender) + }); + let receiver_assets_before = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &receiver) + }); + test.set_assertion::(para_to_para_through_hop_sender_assertions); + test.set_assertion::(para_to_para_relay_hop_assertions); + test.set_assertion::(para_to_para_through_hop_receiver_assertions); + test.set_dispatchable::< + PenpalA, + >(para_to_para_through_relay_limited_reserve_transfer_assets); + test.assert(); + let sender_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &sender) + }); + let receiver_assets_after = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location, &receiver) + }); + if !(sender_assets_after < sender_assets_before - amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_assets_after < sender_assets_before - amount_to_send", + ) + } + if !(receiver_assets_after > receiver_assets_before) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after > receiver_assets_before", + ) + } + } + } + mod send { + use crate::imports::*; + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::send::send_transact_as_superuser_from_relay_to_asset_hub_works"] + pub const send_transact_as_superuser_from_relay_to_asset_hub_works: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::send::send_transact_as_superuser_from_relay_to_asset_hub_works", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/send.rs", + start_line: 21usize, + start_col: 4usize, + end_line: 21usize, + end_col: 60usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + send_transact_as_superuser_from_relay_to_asset_hub_works(), + ), + ), + }; + /// Relay Chain should be able to execute `Transact` instructions in System Parachain + /// when `OriginKind::Superuser`. + fn send_transact_as_superuser_from_relay_to_asset_hub_works() { + AssetHubWestend::force_create_asset_from_relay_as_root( + ASSET_ID, + ASSET_MIN_BALANCE, + true, + AssetHubWestendSender::get().into(), + Some(Weight::from_parts(1_019_445_000, 200_000)), + ) + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset"] + pub const send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/send.rs", + start_line: 35usize, + start_col: 4usize, + end_line: 35usize, + end_col: 64usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset(), + ), + ), + }; + /// We tests two things here: + /// - Parachain should be able to send XCM paying its fee at Asset Hub using system asset + /// - Parachain should be able to create a new Foreign Asset at Asset Hub + fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() { + let para_sovereign_account = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + let asset_location_on_penpal = Location::new( + 0, + [ + Junction::PalletInstance(ASSETS_PALLET_ID), + Junction::GeneralIndex(ASSET_ID.into()), + ], + ); + let foreign_asset_at_asset_hub = Location::new( + 1, + [Junction::Parachain(PenpalA::para_id().into())], + ) + .appended_with(asset_location_on_penpal) + .unwrap(); + let call = AssetHubWestend::create_foreign_asset_call( + foreign_asset_at_asset_hub.clone(), + ASSET_MIN_BALANCE, + para_sovereign_account.clone(), + ); + let origin_kind = OriginKind::Xcm; + let fee_amount = ASSET_HUB_WESTEND_ED * 1000000; + let system_asset = (Parent, fee_amount).into(); + let root_origin = ::RuntimeOrigin::root(); + let system_para_destination = PenpalA::sibling_location_of( + AssetHubWestend::para_id(), + ) + .into(); + let xcm = xcm_transact_paid_execution( + call, + origin_kind, + system_asset, + para_sovereign_account.clone(), + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + para_sovereign_account.clone().into(), + ASSET_HUB_WESTEND_ED * 10000000000, + ), + ]), + ), + ); + PenpalA::execute_with(|| { + let is = ::PolkadotXcm::send( + root_origin, + Box::new(system_para_destination), + Box::new(xcm), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + PenpalA::assert_xcm_pallet_sent(); + }); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == para_sovereign_account) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == para_sovereign_account", + ), + ); + res + }); + } + meet_conditions &= *who == para_sovereign_account; + if !(*amount == fee_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == fee_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == fee_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Created { asset_id, creator, owner }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == foreign_asset_at_asset_hub) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == foreign_asset_at_asset_hub", + ), + ); + res + }); + } + meet_conditions &= *asset_id == foreign_asset_at_asset_hub; + if !(*creator == para_sovereign_account.clone()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "creator", + creator, + "*creator == para_sovereign_account.clone()", + ), + ); + res + }); + } + meet_conditions + &= *creator == para_sovereign_account.clone(); + if !(*owner == para_sovereign_account) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == para_sovereign_account", + ), + ); + res + }); + } + meet_conditions &= *owner == para_sovereign_account; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Created {\nasset_id, creator, owner })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Created {\nasset_id, creator, owner })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::send", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + type ForeignAssets = ::ForeignAssets; + if !ForeignAssets::asset_exists(foreign_asset_at_asset_hub) { + ::core::panicking::panic( + "assertion failed: ForeignAssets::asset_exists(foreign_asset_at_asset_hub)", + ) + } + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset"] + pub const send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/send.rs", + start_line: 113usize, + start_col: 4usize, + end_line: 113usize, + end_col: 68usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset(), + ), + ), + }; + /// We tests two things here: + /// - Parachain should be able to send XCM paying its fee at Asset Hub using sufficient asset + /// - Parachain should be able to create a new Asset at Asset Hub + fn send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset() { + let para_sovereign_account = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + AssetHubWestend::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + true, + para_sovereign_account.clone(), + Some(Weight::from_parts(1_019_445_000, 200_000)), + ASSET_MIN_BALANCE * 1000000000, + ); + let new_asset_id = ASSET_ID + 1; + let call = AssetHubWestend::create_asset_call( + new_asset_id, + ASSET_MIN_BALANCE, + para_sovereign_account.clone(), + ); + let origin_kind = OriginKind::SovereignAccount; + let fee_amount = ASSET_MIN_BALANCE * 1000000; + let asset = ( + [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], + fee_amount, + ) + .into(); + let root_origin = ::RuntimeOrigin::root(); + let system_para_destination = PenpalA::sibling_location_of( + AssetHubWestend::para_id(), + ) + .into(); + let xcm = xcm_transact_paid_execution( + call, + origin_kind, + asset, + para_sovereign_account.clone(), + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + para_sovereign_account.clone().into(), + ASSET_HUB_WESTEND_ED * 10000000000, + ), + ]), + ), + ); + PenpalA::execute_with(|| { + let is = ::PolkadotXcm::send( + root_origin, + Box::new(system_para_destination), + Box::new(xcm), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + PenpalA::assert_xcm_pallet_sent(); + }); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == ASSET_ID) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == ASSET_ID", + ), + ); + res + }); + } + meet_conditions &= *asset_id == ASSET_ID; + if !(*owner == para_sovereign_account) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == para_sovereign_account", + ), + ); + res + }); + } + meet_conditions &= *owner == para_sovereign_account; + if !(*balance == fee_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == fee_amount", + ), + ); + res + }); + } + meet_conditions &= *balance == fee_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Created { asset_id, creator, owner }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == new_asset_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == new_asset_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == new_asset_id; + if !(*creator == para_sovereign_account.clone()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "creator", + creator, + "*creator == para_sovereign_account.clone()", + ), + ); + res + }); + } + meet_conditions + &= *creator == para_sovereign_account.clone(); + if !(*owner == para_sovereign_account) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == para_sovereign_account", + ), + ); + res + }); + } + meet_conditions &= *owner == para_sovereign_account; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Created { asset_id, creator, owner\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Created { asset_id, creator, owner\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::send", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + } + mod set_xcm_versions { + use crate::imports::*; + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::set_xcm_versions::relay_sets_system_para_xcm_supported_version"] + pub const relay_sets_system_para_xcm_supported_version: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::set_xcm_versions::relay_sets_system_para_xcm_supported_version", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_xcm_versions.rs", + start_line: 19usize, + start_col: 4usize, + end_line: 19usize, + end_col: 48usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + relay_sets_system_para_xcm_supported_version(), + ), + ), + }; + fn relay_sets_system_para_xcm_supported_version() { + let sudo_origin = ::RuntimeOrigin::root(); + let system_para_destination: Location = Westend::child_location_of( + AssetHubWestend::para_id(), + ); + Westend::execute_with(|| { + let is = ::XcmPallet::force_xcm_version( + sudo_origin, + Box::new(system_para_destination.clone()), + XCM_V3, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::XcmPallet( + pallet_xcm::Event::SupportedVersionChanged { + location, + version: XCM_V3, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*location == system_para_destination) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "location", + location, + "*location == system_para_destination", + ), + ); + res + }); + } + meet_conditions &= *location == system_para_destination; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::set_xcm_versions", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::set_xcm_versions::system_para_sets_relay_xcm_supported_version"] + pub const system_para_sets_relay_xcm_supported_version: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::set_xcm_versions::system_para_sets_relay_xcm_supported_version", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_xcm_versions.rs", + start_line: 47usize, + start_col: 4usize, + end_line: 47usize, + end_col: 48usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + system_para_sets_relay_xcm_supported_version(), + ), + ), + }; + fn system_para_sets_relay_xcm_supported_version() { + let parent_location = AssetHubWestend::parent_location(); + let force_xcm_version_call = ::RuntimeCall::PolkadotXcm(pallet_xcm::Call::< + ::Runtime, + >::force_xcm_version { + location: Box::new(parent_location.clone()), + version: XCM_V3, + }) + .encode() + .into(); + Westend::send_unpaid_transact_to_parachain_as_root( + AssetHubWestend::para_id(), + force_xcm_version_call, + ); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_dmp_queue_complete( + Some(Weight::from_parts(1_019_210_000, 200_000)), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm( + pallet_xcm::Event::SupportedVersionChanged { + location, + version: XCM_V3, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*location == parent_location) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "location", + location, + "*location == parent_location", + ), + ); + res + }); + } + meet_conditions &= *location == parent_location; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::set_xcm_versions", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + } + mod swap { + use crate::imports::*; + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::swap::swap_locally_on_chain_using_local_assets"] + pub const swap_locally_on_chain_using_local_assets: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::swap::swap_locally_on_chain_using_local_assets", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", + start_line: 19usize, + start_col: 4usize, + end_line: 19usize, + end_col: 44usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(swap_locally_on_chain_using_local_assets()), + ), + }; + fn swap_locally_on_chain_using_local_assets() { + let asset_native = Box::new( + Location::try_from(RelayLocation::get()).expect("conversion works"), + ); + let asset_one = Box::new(Location { + parents: 0, + interior: [ + Junction::PalletInstance(ASSETS_PALLET_ID), + Junction::GeneralIndex(ASSET_ID.into()), + ] + .into(), + }); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + let is = ::Assets::create( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + ASSET_ID.into(), + AssetHubWestendSender::get().into(), + 1000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + if !::Assets::asset_exists( + ASSET_ID, + ) { + ::core::panicking::panic( + "assertion failed: ::Assets::asset_exists(ASSET_ID)", + ) + } + let is = ::Assets::mint( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + ASSET_ID.into(), + AssetHubWestendSender::get().into(), + 3_000_000_000_000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = ::AssetConversion::create_pool( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + asset_native.clone(), + asset_one.clone(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::PoolCreated { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let is = ::AssetConversion::add_liquidity( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + asset_native.clone(), + asset_one.clone(), + 1_000_000_000_000, + 2_000_000_000_000, + 0, + 0, + AssetHubWestendSender::get().into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::LiquidityAdded { + lp_token_minted, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*lp_token_minted == 1414213562273) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "lp_token_minted", + lp_token_minted, + "*lp_token_minted == 1414213562273", + ), + ); + res + }); + } + meet_conditions &= *lp_token_minted == 1414213562273; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let path = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([asset_native.clone(), asset_one.clone()]), + ); + let is = ::AssetConversion::swap_exact_tokens_for_tokens( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + path, + 100, + 1, + AssetHubWestendSender::get().into(), + true, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::SwapExecuted { + amount_in, + amount_out, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*amount_in == 100) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount_in", + amount_in, + "*amount_in == 100", + ), + ); + res + }); + } + meet_conditions &= *amount_in == 100; + if !(*amount_out == 199) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount_out", + amount_out, + "*amount_out == 199", + ), + ); + res + }); + } + meet_conditions &= *amount_out == 199; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let is = ::AssetConversion::remove_liquidity( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + asset_native.clone(), + asset_one.clone(), + 1414213562273 - 2_000_000_000, + 0, + 0, + AssetHubWestendSender::get().into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::swap::swap_locally_on_chain_using_foreign_assets"] + pub const swap_locally_on_chain_using_foreign_assets: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::swap::swap_locally_on_chain_using_foreign_assets", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", + start_line: 114usize, + start_col: 4usize, + end_line: 114usize, + end_col: 46usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(swap_locally_on_chain_using_foreign_assets()), + ), + }; + fn swap_locally_on_chain_using_foreign_assets() { + let asset_native = Box::new( + Location::try_from(RelayLocation::get()).unwrap(), + ); + let asset_location_on_penpal = Location::try_from( + PenpalLocalTeleportableToAssetHub::get(), + ) + .expect("conversion_works"); + let foreign_asset_at_asset_hub_westend = Location::new( + 1, + [Junction::Parachain(PenpalA::para_id().into())], + ) + .appended_with(asset_location_on_penpal) + .unwrap(); + let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + penpal_as_seen_by_ah, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + AssetHubWestendSender::get().into(), + 5_000_000 * ASSET_HUB_WESTEND_ED, + ), + ( + sov_penpal_on_ahr.clone().into(), + 100_000_000 * ASSET_HUB_WESTEND_ED, + ), + ]), + ), + ); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + let is = ::ForeignAssets::mint( + ::RuntimeOrigin::signed( + sov_penpal_on_ahr.clone().into(), + ), + foreign_asset_at_asset_hub_westend.clone(), + sov_penpal_on_ahr.clone().into(), + ASSET_HUB_WESTEND_ED * 3_000_000_000_000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let is = ::AssetConversion::create_pool( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + asset_native.clone(), + Box::new(foreign_asset_at_asset_hub_westend.clone()), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::PoolCreated { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let is = ::AssetConversion::add_liquidity( + ::RuntimeOrigin::signed( + sov_penpal_on_ahr.clone(), + ), + asset_native.clone(), + Box::new(foreign_asset_at_asset_hub_westend.clone()), + 1_000_000_000_000_000, + 2_000_000_000_000_000, + 0, + 0, + sov_penpal_on_ahr.clone().into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::LiquidityAdded { + lp_token_minted, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*lp_token_minted == 1414213562372995) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "lp_token_minted", + lp_token_minted, + "*lp_token_minted == 1414213562372995", + ), + ); + res + }); + } + meet_conditions &= *lp_token_minted == 1414213562372995; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let path = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + asset_native.clone(), + Box::new(foreign_asset_at_asset_hub_westend.clone()), + ]), + ); + let is = ::AssetConversion::swap_exact_tokens_for_tokens( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + path, + 100000 * ASSET_HUB_WESTEND_ED, + 1000 * ASSET_HUB_WESTEND_ED, + AssetHubWestendSender::get().into(), + true, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::SwapExecuted { + amount_in, + amount_out, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*amount_in == 100000000000000) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount_in", + amount_in, + "*amount_in == 100000000000000", + ), + ); + res + }); + } + meet_conditions &= *amount_in == 100000000000000; + if !(*amount_out == 181322178776029) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount_out", + amount_out, + "*amount_out == 181322178776029", + ), + ); + res + }); + } + meet_conditions &= *amount_out == 181322178776029; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let is = ::AssetConversion::remove_liquidity( + ::RuntimeOrigin::signed( + sov_penpal_on_ahr.clone(), + ), + asset_native.clone(), + Box::new(foreign_asset_at_asset_hub_westend), + 1414213562372995 - ASSET_HUB_WESTEND_ED * 2, + 0, + 0, + sov_penpal_on_ahr.clone().into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::swap::cannot_create_pool_from_pool_assets"] + pub const cannot_create_pool_from_pool_assets: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::swap::cannot_create_pool_from_pool_assets", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", + start_line: 229usize, + start_col: 4usize, + end_line: 229usize, + end_col: 39usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(cannot_create_pool_from_pool_assets()), + ), + }; + fn cannot_create_pool_from_pool_assets() { + let asset_native = RelayLocation::get(); + let mut asset_one = ahw_xcm_config::PoolAssetsPalletLocation::get(); + asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets"); + AssetHubWestend::execute_with(|| { + let pool_owner_account_id = AssetHubWestendAssetConversionOrigin::get(); + let is = ::PoolAssets::create( + ::RuntimeOrigin::signed( + pool_owner_account_id.clone(), + ), + ASSET_ID.into(), + pool_owner_account_id.clone().into(), + 1000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + if !::PoolAssets::asset_exists( + ASSET_ID, + ) { + ::core::panicking::panic( + "assertion failed: ::PoolAssets::asset_exists(ASSET_ID)", + ) + } + let is = ::PoolAssets::mint( + ::RuntimeOrigin::signed( + pool_owner_account_id, + ), + ASSET_ID.into(), + AssetHubWestendSender::get().into(), + 3_000_000_000_000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + match ::AssetConversion::create_pool( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + Box::new( + Location::try_from(asset_native).expect("conversion works"), + ), + Box::new(Location::try_from(asset_one).expect("conversion works")), + ) { + Err( + DispatchError::Module( + ModuleError { index: _, error: _, message }, + ), + ) => { + match (&message, &Some("Unknown")) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + } + } + ref e => { + ::std::rt::panic_fmt( + format_args!( + "assertion failed: `{0:?}` does not match `{1}`", + e, + "Err(DispatchError::Module(ModuleError { index: _, error: _, message }))", + ), + ); + } + }; + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::swap::pay_xcm_fee_with_some_asset_swapped_for_native"] + pub const pay_xcm_fee_with_some_asset_swapped_for_native: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::swap::pay_xcm_fee_with_some_asset_swapped_for_native", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", + start_line: 264usize, + start_col: 4usize, + end_line: 264usize, + end_col: 50usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + pay_xcm_fee_with_some_asset_swapped_for_native(), + ), + ), + }; + fn pay_xcm_fee_with_some_asset_swapped_for_native() { + let asset_native = Location::try_from(RelayLocation::get()) + .expect("conversion works"); + let asset_one = Location { + parents: 0, + interior: [ + Junction::PalletInstance(ASSETS_PALLET_ID), + Junction::GeneralIndex(ASSET_ID.into()), + ] + .into(), + }; + let penpal = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + let is = ::Assets::create( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + ASSET_ID.into(), + AssetHubWestendSender::get().into(), + ASSET_MIN_BALANCE, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + if !::Assets::asset_exists( + ASSET_ID, + ) { + ::core::panicking::panic( + "assertion failed: ::Assets::asset_exists(ASSET_ID)", + ) + } + let is = ::Assets::mint( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + ASSET_ID.into(), + AssetHubWestendSender::get().into(), + 3_000_000_000_000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = ::AssetConversion::create_pool( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + Box::new(asset_native.clone()), + Box::new(asset_one.clone()), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::PoolCreated { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let is = ::AssetConversion::add_liquidity( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + Box::new(asset_native), + Box::new(asset_one), + 1_000_000_000_000, + 2_000_000_000_000, + 0, + 0, + AssetHubWestendSender::get().into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::LiquidityAdded { + lp_token_minted, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*lp_token_minted == 1414213562273) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "lp_token_minted", + lp_token_minted, + "*lp_token_minted == 1414213562273", + ), + ); + res + }); + } + meet_conditions &= *lp_token_minted == 1414213562273; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + match ( + &::Balances::free_balance( + penpal.clone(), + ), + &0, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + let is = ::Assets::touch_other( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + ASSET_ID.into(), + penpal.clone().into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = ::Assets::mint( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + ASSET_ID.into(), + penpal.clone().into(), + 10_000_000_000_000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + PenpalA::execute_with(|| { + let call = AssetHubWestend::force_create_asset_call( + ASSET_ID + 1000, + penpal.clone(), + true, + ASSET_MIN_BALANCE, + ); + let penpal_root = ::RuntimeOrigin::root(); + let fee_amount = 4_000_000_000_000u128; + let asset_one = ( + [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], + fee_amount, + ) + .into(); + let asset_hub_location = PenpalA::sibling_location_of( + AssetHubWestend::para_id(), + ) + .into(); + let xcm = xcm_transact_paid_execution( + call, + OriginKind::SovereignAccount, + asset_one, + penpal.clone(), + ); + let is = ::PolkadotXcm::send( + penpal_root, + Box::new(asset_hub_location), + Box::new(xcm), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + PenpalA::assert_xcm_pallet_sent(); + }); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::SwapCreditExecuted { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapCreditExecuted {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapCreditExecuted {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + } + mod teleport { + use crate::imports::*; + fn relay_dest_assertions_fail(_t: SystemParaToRelayTest) { + Westend::assert_ump_queue_processed( + false, + Some(AssetHubWestend::para_id()), + Some(Weight::from_parts(157_718_000, 3_593)), + ); + } + fn para_origin_assertions(t: SystemParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcm_pallet_attempted_complete( + Some(Weight::from_parts(720_053_000, 7_203)), + ); + AssetHubWestend::assert_parachain_system_ump_sent(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *who == t.sender.account_id; + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn penpal_to_ah_foreign_assets_sender_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let system_para_native_asset_location = RelayLocation::get(); + let expected_asset_id = t.args.asset_id.unwrap(); + let (_, expected_asset_amount) = non_fee_asset( + &t.args.assets, + t.args.fee_asset_item as usize, + ) + .unwrap(); + PenpalA::assert_xcm_pallet_attempted_complete(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == system_para_native_asset_location) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == system_para_native_asset_location", + ), + ); + res + }); + } + meet_conditions + &= *asset_id == system_para_native_asset_location; + if !(*owner == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_asset_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_asset_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_asset_id; + if !(*owner == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if !(*balance == expected_asset_amount) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == expected_asset_amount", + ), + ); + res + }); + } + meet_conditions &= *balance == expected_asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + let (expected_foreign_asset_id, expected_foreign_asset_amount) = non_fee_asset( + &t.args.assets, + t.args.fee_asset_item as usize, + ) + .unwrap(); + AssetHubWestend::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_on_ahr.clone().into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_on_ahr.clone().into()", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_on_ahr.clone().into(); + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == t.receiver.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *who == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_foreign_asset_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_foreign_asset_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_foreign_asset_id; + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if !(*amount == expected_foreign_asset_amount) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == expected_foreign_asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == expected_foreign_asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn ah_to_penpal_foreign_assets_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcm_pallet_attempted_complete(None); + let (expected_foreign_asset_id, expected_foreign_asset_amount) = non_fee_asset( + &t.args.assets, + t.args.fee_asset_item as usize, + ) + .unwrap(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*from == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "*from == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *from == t.sender.account_id; + if !(*to + == AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + )) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "*to == AssetHubWestend::sovereign_account_id_of(t.args.dest.clone())", + ), + ); + res + }); + } + meet_conditions + &= *to + == AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + ); + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_foreign_asset_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_foreign_asset_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_foreign_asset_id; + if !(*owner == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if !(*balance == expected_foreign_asset_amount) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == expected_foreign_asset_amount", + ), + ); + res + }); + } + meet_conditions &= *balance == expected_foreign_asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn ah_to_penpal_foreign_assets_receiver_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let expected_asset_id = t.args.asset_id.unwrap(); + let (_, expected_asset_amount) = non_fee_asset( + &t.args.assets, + t.args.fee_asset_item as usize, + ) + .unwrap(); + let checking_account = ::PolkadotXcm::check_account(); + let system_para_native_asset_location = RelayLocation::get(); + PenpalA::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_asset_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_asset_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_asset_id; + if !(*owner == checking_account) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == checking_account", + ), + ); + res + }); + } + meet_conditions &= *owner == checking_account; + if !(*balance == expected_asset_amount) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == expected_asset_amount", + ), + ); + res + }); + } + meet_conditions &= *balance == expected_asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Issued { asset_id, owner, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_asset_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_asset_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_asset_id; + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if !(*amount == expected_asset_amount) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == expected_asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == expected_asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == system_para_native_asset_location) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == system_para_native_asset_location", + ), + ); + res + }); + } + meet_conditions + &= *asset_id == system_para_native_asset_location; + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if !(*amount == expected_asset_amount) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == expected_asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == expected_asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn system_para_limited_teleport_assets( + t: SystemParaToRelayTest, + ) -> DispatchResult { + ::PolkadotXcm::limited_teleport_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + fn para_to_system_para_transfer_assets( + t: ParaToSystemParaTest, + ) -> DispatchResult { + ::PolkadotXcm::transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + fn system_para_to_para_transfer_assets( + t: SystemParaToParaTest, + ) -> DispatchResult { + ::PolkadotXcm::transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::teleport::teleport_to_other_system_parachains_works"] + pub const teleport_to_other_system_parachains_works: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::teleport::teleport_to_other_system_parachains_works", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", + start_line: 204usize, + start_col: 4usize, + end_line: 204usize, + end_col: 45usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(teleport_to_other_system_parachains_works()), + ), + }; + fn teleport_to_other_system_parachains_works() { + let amount = ASSET_HUB_WESTEND_ED * 100; + let native_asset: Assets = (Parent, amount).into(); + let sender = AssetHubWestendSender::get(); + let mut para_sender_balance_before = ::account_data_of( + sender.clone(), + ) + .free; + let origin = ::RuntimeOrigin::signed( + sender.clone(), + ); + let fee_asset_item = 0; + let weight_limit = ::emulated_integration_tests_common::macros::WeightLimit::Unlimited; + { + let receiver = BridgeHubWestendReceiver::get(); + let para_receiver_balance_before = ::account_data_of( + receiver.clone(), + ) + .free; + let para_destination = ::sibling_location_of( + ::para_id(), + ); + let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { + network: None, + id: receiver.clone().into(), + } + .into(); + ::execute_with(|| { + let is = ::PolkadotXcm::limited_teleport_assets( + origin.clone(), + Box::new(para_destination.clone().into()), + Box::new(beneficiary.clone().into()), + Box::new(native_asset.clone().into()), + fee_asset_item, + weight_limit.clone(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted { + outcome: Outcome::Complete { .. }, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::XcmpQueue( + ::emulated_integration_tests_common::macros::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::XcmpQueue(::emulated_integration_tests_common::macros::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::XcmpQueue(::emulated_integration_tests_common::macros::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + ::emulated_integration_tests_common::macros::pallet_balances::Event::Burned { + who: sender, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + ::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + ::emulated_integration_tests_common::macros::pallet_balances::Event::Minted { + who: receiver, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "BridgeHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "BridgeHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + ::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed { + success: true, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "BridgeHubWestend", + "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "BridgeHubWestend", + "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::BridgeHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + let para_sender_balance_after = ::account_data_of( + sender.clone(), + ) + .free; + let para_receiver_balance_after = ::account_data_of( + receiver.clone(), + ) + .free; + let delivery_fees = ::execute_with(|| { + ::emulated_integration_tests_common::macros::asset_test_utils::xcm_helpers::teleport_assets_delivery_fees::< + ::XcmSender, + >( + native_asset.clone(), + fee_asset_item, + weight_limit.clone(), + beneficiary, + para_destination, + ) + }); + match ( + &(para_sender_balance_before - amount - delivery_fees), + ¶_sender_balance_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(para_receiver_balance_after > para_receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: para_receiver_balance_after > para_receiver_balance_before", + ) + } + para_sender_balance_before = ::account_data_of( + sender.clone(), + ) + .free; + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::teleport::teleport_from_and_to_relay"] + pub const teleport_from_and_to_relay: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::teleport::teleport_from_and_to_relay", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", + start_line: 217usize, + start_col: 4usize, + end_line: 217usize, + end_col: 30usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(teleport_from_and_to_relay()), + ), + }; + fn teleport_from_and_to_relay() { + let amount = WESTEND_ED * 100; + let native_asset: Assets = (Here, amount).into(); + let sender = WestendSender::get(); + let mut relay_sender_balance_before = ::account_data_of( + sender.clone(), + ) + .free; + let origin = ::RuntimeOrigin::signed( + sender.clone(), + ); + let fee_asset_item = 0; + let weight_limit = ::emulated_integration_tests_common::macros::WeightLimit::Unlimited; + { + let receiver = AssetHubWestendReceiver::get(); + let para_receiver_balance_before = ::account_data_of( + receiver.clone(), + ) + .free; + let para_destination = ::child_location_of( + ::para_id(), + ); + let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { + network: None, + id: receiver.clone().into(), + } + .into(); + ::execute_with(|| { + let is = ::XcmPallet::limited_teleport_assets( + origin.clone(), + Box::new(para_destination.clone().into()), + Box::new(beneficiary.clone().into()), + Box::new(native_asset.clone().into()), + fee_asset_item, + weight_limit.clone(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::XcmPallet( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted { + outcome: Outcome::Complete { .. }, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + ::emulated_integration_tests_common::macros::pallet_balances::Event::Burned { + who: sender, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::XcmPallet( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + ::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + ::emulated_integration_tests_common::macros::pallet_balances::Event::Minted { + who: receiver, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + ::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed { + success: true, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + let relay_sender_balance_after = ::account_data_of( + sender.clone(), + ) + .free; + let para_receiver_balance_after = ::account_data_of( + receiver.clone(), + ) + .free; + let delivery_fees = ::execute_with(|| { + ::emulated_integration_tests_common::macros::asset_test_utils::xcm_helpers::teleport_assets_delivery_fees::< + ::XcmSender, + >( + native_asset.clone(), + fee_asset_item, + weight_limit.clone(), + beneficiary, + para_destination, + ) + }); + match ( + &(relay_sender_balance_before - amount - delivery_fees), + &relay_sender_balance_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(para_receiver_balance_after > para_receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: para_receiver_balance_after > para_receiver_balance_before", + ) + } + relay_sender_balance_before = ::account_data_of( + sender.clone(), + ) + .free; + }; + let sender = AssetHubWestendSender::get(); + let para_sender_balance_before = ::account_data_of( + sender.clone(), + ) + .free; + let origin = ::RuntimeOrigin::signed( + sender.clone(), + ); + let assets: Assets = (Parent, amount).into(); + let fee_asset_item = 0; + let weight_limit = ::emulated_integration_tests_common::macros::WeightLimit::Unlimited; + let receiver = WestendReceiver::get(); + let relay_receiver_balance_before = ::account_data_of( + receiver.clone(), + ) + .free; + let relay_destination: Location = Parent.into(); + let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { + network: None, + id: receiver.clone().into(), + } + .into(); + ::execute_with(|| { + let is = ::PolkadotXcm::limited_teleport_assets( + origin.clone(), + Box::new(relay_destination.clone().into()), + Box::new(beneficiary.clone().into()), + Box::new(assets.clone().into()), + fee_asset_item, + weight_limit.clone(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted { + outcome: Outcome::Complete { .. }, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + ::emulated_integration_tests_common::macros::pallet_balances::Event::Burned { + who: sender, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + ::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + ::emulated_integration_tests_common::macros::pallet_balances::Event::Minted { + who: receiver, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + ::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed { + success: true, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + let para_sender_balance_after = ::account_data_of( + sender.clone(), + ) + .free; + let relay_receiver_balance_after = ::account_data_of( + receiver.clone(), + ) + .free; + let delivery_fees = ::execute_with(|| { + ::emulated_integration_tests_common::macros::asset_test_utils::xcm_helpers::teleport_assets_delivery_fees::< + ::XcmSender, + >( + assets, + fee_asset_item, + weight_limit.clone(), + beneficiary, + relay_destination, + ) + }); + match ( + &(para_sender_balance_before - amount - delivery_fees), + ¶_sender_balance_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(relay_receiver_balance_after > relay_receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: relay_receiver_balance_after > relay_receiver_balance_before", + ) + } + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::teleport::limited_teleport_native_assets_from_system_para_to_relay_fails"] + pub const limited_teleport_native_assets_from_system_para_to_relay_fails: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::teleport::limited_teleport_native_assets_from_system_para_to_relay_fails", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", + start_line: 239usize, + start_col: 4usize, + end_line: 239usize, + end_col: 66usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + limited_teleport_native_assets_from_system_para_to_relay_fails(), + ), + ), + }; + /// Limited Teleport of native asset from System Parachain to Relay Chain + /// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` + fn limited_teleport_native_assets_from_system_para_to_relay_fails() { + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let destination = AssetHubWestend::parent_location().into(); + let beneficiary_id = WestendReceiver::get().into(); + let assets = (Parent, amount_to_send).into(); + let test_args = TestContext { + sender: AssetHubWestendSender::get(), + receiver: WestendReceiver::get(), + args: TestArgs::new_para( + destination, + beneficiary_id, + amount_to_send, + assets, + None, + 0, + ), + }; + let mut test = SystemParaToRelayTest::new(test_args); + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + test.set_assertion::(para_origin_assertions); + test.set_assertion::(relay_dest_assertions_fail); + test.set_dispatchable::< + AssetHubWestend, + >(system_para_limited_teleport_assets); + test.assert(); + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + let delivery_fees = AssetHubWestend::execute_with(|| { + xcm_helpers::teleport_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + match ( + &(sender_balance_before - amount_to_send - delivery_fees), + &sender_balance_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match (&receiver_balance_after, &receiver_balance_before) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + /// Bidirectional teleports of local Penpal assets to Asset Hub as foreign assets while paying + /// fees using (reserve transferred) native asset. + pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt( + para_to_ah_dispatchable: fn(ParaToSystemParaTest) -> DispatchResult, + ah_to_para_dispatchable: fn(SystemParaToParaTest) -> DispatchResult, + ) { + let fee_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 100; + let asset_location_on_penpal = PenpalLocalTeleportableToAssetHub::get(); + let asset_id_on_penpal = match asset_location_on_penpal.last() { + Some(Junction::GeneralIndex(id)) => *id as u32, + _ => ::core::panicking::panic("internal error: entered unreachable code"), + }; + let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100; + let asset_owner = PenpalAssetOwner::get(); + let system_para_native_asset_location = RelayLocation::get(); + let sender = PenpalASender::get(); + let penpal_check_account = ::PolkadotXcm::check_account(); + let ah_as_seen_by_penpal = PenpalA::sibling_location_of( + AssetHubWestend::para_id(), + ); + let penpal_assets: Assets = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (Parent, fee_amount_to_send).into(), + (asset_location_on_penpal.clone(), asset_amount_to_send).into(), + ]), + ) + .into(); + let fee_asset_index = penpal_assets + .inner() + .iter() + .position(|r| r == &(Parent, fee_amount_to_send).into()) + .unwrap() as u32; + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner.clone()), + system_para_native_asset_location.clone(), + sender.clone(), + fee_amount_to_send * 2, + ); + PenpalA::mint_asset( + ::RuntimeOrigin::signed(asset_owner.clone()), + asset_id_on_penpal, + sender.clone(), + asset_amount_to_send, + ); + PenpalA::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + penpal_check_account.clone().into(), + ASSET_HUB_WESTEND_ED * 1000, + ), + ]), + ), + ); + let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_penpal_on_ah = AssetHubWestend::sovereign_account_id_of( + penpal_as_seen_by_ah, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + sov_penpal_on_ah.clone().into(), + ASSET_HUB_WESTEND_ED * 100_000_000_000, + ), + ]), + ), + ); + let foreign_asset_at_asset_hub_westend = Location::new( + 1, + [Junction::Parachain(PenpalA::para_id().into())], + ) + .appended_with(asset_location_on_penpal) + .unwrap(); + let penpal_to_ah_beneficiary_id = AssetHubWestendReceiver::get(); + let penpal_to_ah_test_args = TestContext { + sender: PenpalASender::get(), + receiver: AssetHubWestendReceiver::get(), + args: TestArgs::new_para( + ah_as_seen_by_penpal, + penpal_to_ah_beneficiary_id, + asset_amount_to_send, + penpal_assets, + Some(asset_id_on_penpal), + fee_asset_index, + ), + }; + let mut penpal_to_ah = ParaToSystemParaTest::new(penpal_to_ah_test_args); + let penpal_sender_balance_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + system_para_native_asset_location.clone(), + &PenpalASender::get(), + ) + }); + let ah_receiver_balance_before = penpal_to_ah.receiver.balance; + let penpal_sender_assets_before = PenpalA::execute_with(|| { + type Assets = ::Assets; + >::balance(asset_id_on_penpal, &PenpalASender::get()) + }); + let ah_receiver_assets_before = AssetHubWestend::execute_with(|| { + type Assets = ::ForeignAssets; + >::balance( + foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), + &AssetHubWestendReceiver::get(), + ) + }); + penpal_to_ah + .set_assertion::(penpal_to_ah_foreign_assets_sender_assertions); + penpal_to_ah + .set_assertion::< + AssetHubWestend, + >(penpal_to_ah_foreign_assets_receiver_assertions); + penpal_to_ah.set_dispatchable::(para_to_ah_dispatchable); + penpal_to_ah.assert(); + let penpal_sender_balance_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + system_para_native_asset_location.clone(), + &PenpalASender::get(), + ) + }); + let ah_receiver_balance_after = penpal_to_ah.receiver.balance; + let penpal_sender_assets_after = PenpalA::execute_with(|| { + type Assets = ::Assets; + >::balance(asset_id_on_penpal, &PenpalASender::get()) + }); + let ah_receiver_assets_after = AssetHubWestend::execute_with(|| { + type Assets = ::ForeignAssets; + >::balance( + foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), + &AssetHubWestendReceiver::get(), + ) + }); + if !(penpal_sender_balance_after < penpal_sender_balance_before) { + ::core::panicking::panic( + "assertion failed: penpal_sender_balance_after < penpal_sender_balance_before", + ) + } + if !(ah_receiver_balance_after > ah_receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: ah_receiver_balance_after > ah_receiver_balance_before", + ) + } + if !(ah_receiver_balance_after + < ah_receiver_balance_before + fee_amount_to_send) + { + ::core::panicking::panic( + "assertion failed: ah_receiver_balance_after < ah_receiver_balance_before + fee_amount_to_send", + ) + } + match ( + &(penpal_sender_assets_before - asset_amount_to_send), + &penpal_sender_assets_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &ah_receiver_assets_after, + &(ah_receiver_assets_before + asset_amount_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + let is = ForeignAssets::transfer( + ::RuntimeOrigin::signed( + AssetHubWestendReceiver::get(), + ), + foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), + AssetHubWestendSender::get().into(), + asset_amount_to_send, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + let ah_to_penpal_beneficiary_id = PenpalAReceiver::get(); + let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let ah_assets: Assets = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (Parent, fee_amount_to_send).into(), + ( + foreign_asset_at_asset_hub_westend.clone(), + asset_amount_to_send, + ) + .into(), + ]), + ) + .into(); + let fee_asset_index = ah_assets + .inner() + .iter() + .position(|r| r == &(Parent, fee_amount_to_send).into()) + .unwrap() as u32; + let ah_to_penpal_test_args = TestContext { + sender: AssetHubWestendSender::get(), + receiver: PenpalAReceiver::get(), + args: TestArgs::new_para( + penpal_as_seen_by_ah, + ah_to_penpal_beneficiary_id, + asset_amount_to_send, + ah_assets, + Some(asset_id_on_penpal), + fee_asset_index, + ), + }; + let mut ah_to_penpal = SystemParaToParaTest::new(ah_to_penpal_test_args); + let ah_sender_balance_before = ah_to_penpal.sender.balance; + let penpal_receiver_balance_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + system_para_native_asset_location.clone(), + &PenpalAReceiver::get(), + ) + }); + let ah_sender_assets_before = AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), + &AssetHubWestendSender::get(), + ) + }); + let penpal_receiver_assets_before = PenpalA::execute_with(|| { + type Assets = ::Assets; + >::balance(asset_id_on_penpal, &PenpalAReceiver::get()) + }); + ah_to_penpal + .set_assertion::< + AssetHubWestend, + >(ah_to_penpal_foreign_assets_sender_assertions); + ah_to_penpal + .set_assertion::< + PenpalA, + >(ah_to_penpal_foreign_assets_receiver_assertions); + ah_to_penpal.set_dispatchable::(ah_to_para_dispatchable); + ah_to_penpal.assert(); + let ah_sender_balance_after = ah_to_penpal.sender.balance; + let penpal_receiver_balance_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location, &PenpalAReceiver::get()) + }); + let ah_sender_assets_after = AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), + &AssetHubWestendSender::get(), + ) + }); + let penpal_receiver_assets_after = PenpalA::execute_with(|| { + type Assets = ::Assets; + >::balance(asset_id_on_penpal, &PenpalAReceiver::get()) + }); + if !(ah_sender_balance_after < ah_sender_balance_before) { + ::core::panicking::panic( + "assertion failed: ah_sender_balance_after < ah_sender_balance_before", + ) + } + if !(penpal_receiver_balance_after > penpal_receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: penpal_receiver_balance_after > penpal_receiver_balance_before", + ) + } + if !(penpal_receiver_balance_after + < penpal_receiver_balance_before + fee_amount_to_send) + { + ::core::panicking::panic( + "assertion failed: penpal_receiver_balance_after <\n penpal_receiver_balance_before + fee_amount_to_send", + ) + } + match ( + &(ah_sender_assets_before - asset_amount_to_send), + &ah_sender_assets_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &penpal_receiver_assets_after, + &(penpal_receiver_assets_before + asset_amount_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::teleport::bidirectional_teleport_foreign_assets_between_para_and_asset_hub"] + pub const bidirectional_teleport_foreign_assets_between_para_and_asset_hub: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::teleport::bidirectional_teleport_foreign_assets_between_para_and_asset_hub", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", + start_line: 527usize, + start_col: 4usize, + end_line: 527usize, + end_col: 68usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + bidirectional_teleport_foreign_assets_between_para_and_asset_hub(), + ), + ), + }; + /// Bidirectional teleports of local Penpal assets to Asset Hub as foreign assets should work + /// (using native reserve-based transfer for fees) + fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() { + do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt( + para_to_system_para_transfer_assets, + system_para_to_para_transfer_assets, + ); + } + } + mod treasury { + use crate::imports::*; + use emulated_integration_tests_common::{ + accounts::{ALICE, BOB}, + USDT_ID, + }; + use frame_support::traits::fungibles::{Inspect, Mutate}; + use polkadot_runtime_common::impls::VersionedLocatableAsset; + use xcm_executor::traits::ConvertLocation; + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::treasury::create_and_claim_treasury_spend"] + pub const create_and_claim_treasury_spend: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::treasury::create_and_claim_treasury_spend", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs", + start_line: 26usize, + start_col: 4usize, + end_line: 26usize, + end_col: 35usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(create_and_claim_treasury_spend()), + ), + }; + fn create_and_claim_treasury_spend() { + const SPEND_AMOUNT: u128 = 1_000_000_000; + let treasury_location: Location = Location::new(1, PalletInstance(37)); + let treasury_account = ahw_xcm_config::LocationToAccountId::convert_location( + &treasury_location, + ) + .unwrap(); + let asset_hub_location = Location::new( + 0, + Parachain(AssetHubWestend::para_id().into()), + ); + let root = ::RuntimeOrigin::root(); + let asset_kind = VersionedLocatableAsset::V5 { + location: asset_hub_location, + asset_id: AssetId( + [PalletInstance(50), GeneralIndex(USDT_ID.into())].into(), + ), + }; + let alice: AccountId = Westend::account_id_of(ALICE); + let bob: AccountId = Westend::account_id_of(BOB); + let bob_signed = ::RuntimeOrigin::signed(bob.clone()); + AssetHubWestend::execute_with(|| { + type Assets = ::Assets; + let is = >::mint_into(USDT_ID, &treasury_account, SPEND_AMOUNT * 4); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + match (&>::balance(USDT_ID, &alice), &0u128) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + Westend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type Treasury = ::Treasury; + type AssetRate = ::AssetRate; + let is = AssetRate::create( + root.clone(), + Box::new(asset_kind.clone()), + 2.into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = Treasury::spend( + root, + Box::new(asset_kind), + SPEND_AMOUNT, + Box::new( + Location::new(0, Into::<[u8; 32]>::into(alice.clone())).into(), + ), + None, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = Treasury::payout(bob_signed.clone(), 0); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. }) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::treasury", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type Assets = ::Assets; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Transferred { + asset_id: id, + from, + to, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(id == &USDT_ID) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "id", + id, + "id == &USDT_ID", + ), + ); + res + }); + } + meet_conditions &= id == &USDT_ID; + if !(from == &treasury_account) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "from == &treasury_account", + ), + ); + res + }); + } + meet_conditions &= from == &treasury_account; + if !(to == &alice) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "to == &alice", + ), + ); + res + }); + } + meet_conditions &= to == &alice; + if !(amount == &SPEND_AMOUNT) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "amount == &SPEND_AMOUNT", + ), + ); + res + }); + } + meet_conditions &= amount == &SPEND_AMOUNT; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ParachainSystem( + cumulus_pallet_parachain_system::Event::UpwardMessageSent { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ParachainSystem(cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ParachainSystem(cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::treasury", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + match ( + &>::balance(USDT_ID, &alice), + &SPEND_AMOUNT, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + Westend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type Treasury = ::Treasury; + let is = Treasury::check_status(bob_signed, 0); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Treasury( + pallet_treasury::Event::SpendProcessed { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Treasury(pallet_treasury::Event::SpendProcessed { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Treasury(pallet_treasury::Event::SpendProcessed { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::treasury", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + } + mod xcm_fee_estimation { + //! Tests to ensure correct XCM fee estimation for cross-chain asset transfers. + use crate::imports::*; + use frame_support::{ + dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, + }; + use xcm_runtime_apis::{ + dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, + fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, + }; + fn sender_assertions(test: ParaToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + PenpalA::assert_xcm_pallet_attempted_complete(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == Location::new(1, [])) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == Location::new(1, [])", + ), + ); + res + }); + } + meet_conditions &= *asset_id == Location::new(1, []); + if !(*owner == test.sender.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == test.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == test.sender.account_id; + if !(*balance == test.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == test.args.amount", + ), + ); + res + }); + } + meet_conditions &= *balance == test.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::xcm_fee_estimation", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn hop_assertions(test: ParaToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { amount, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*amount == test.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == test.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == test.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { amount, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { amount, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::xcm_fee_estimation", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn receiver_assertions(test: ParaToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + PenpalB::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == Location::new(1, [])) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == Location::new(1, [])", + ), + ); + res + }); + } + meet_conditions &= *asset_id == Location::new(1, []); + if !(*owner == test.receiver.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == test.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == test.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalB", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalB", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalB", + "asset_hub_westend_integration_tests::tests::xcm_fee_estimation", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn transfer_assets_para_to_para_through_ah_dispatchable( + test: ParaToParaThroughAHTest, + ) -> DispatchResult { + let call = transfer_assets_para_to_para_through_ah_call(test.clone()); + match call.dispatch(test.signed_origin) { + Ok(_) => Ok(()), + Err(error_with_post_info) => Err(error_with_post_info.error), + } + } + fn transfer_assets_para_to_para_through_ah_call( + test: ParaToParaThroughAHTest, + ) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; + let asset_hub_location: Location = PenpalB::sibling_location_of( + AssetHubWestend::para_id(), + ); + let custom_xcm_on_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositAsset { + assets: Wild(AllCounted(test.args.assets.len() as u32)), + beneficiary: test.args.beneficiary, + }, + ]), + ), + ); + RuntimeCall::PolkadotXcm(pallet_xcm::Call::transfer_assets_using_type_and_then { + dest: Box::new(test.args.dest.into()), + assets: Box::new(test.args.assets.clone().into()), + assets_transfer_type: Box::new( + TransferType::RemoteReserve(asset_hub_location.clone().into()), + ), + remote_fees_id: Box::new( + VersionedAssetId::V5(AssetId(Location::new(1, []))), + ), + fees_transfer_type: Box::new( + TransferType::RemoteReserve(asset_hub_location.into()), + ), + custom_xcm_on_dest: Box::new(VersionedXcm::from(custom_xcm_on_dest)), + weight_limit: test.args.weight_limit, + }) + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::xcm_fee_estimation::multi_hop_works"] + pub const multi_hop_works: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("tests::xcm_fee_estimation::multi_hop_works"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs", + start_line: 115usize, + start_col: 4usize, + end_line: 115usize, + end_col: 19usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(multi_hop_works()), + ), + }; + /// We are able to dry-run and estimate the fees for a multi-hop XCM journey. + /// Scenario: Alice on PenpalA has some WND and wants to send them to PenpalB. + /// We want to know the fees using the `DryRunApi` and `XcmPaymentApi`. + fn multi_hop_works() { + let destination = PenpalA::sibling_location_of(PenpalB::para_id()); + let sender = PenpalASender::get(); + let amount_to_send = 1_000_000_000_000; + let asset_owner = PenpalAssetOwner::get(); + let assets: Assets = (Parent, amount_to_send).into(); + let relay_native_asset_location = Location::parent(); + let sender_as_seen_by_ah = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_of_sender_on_ah = AssetHubWestend::sovereign_account_id_of( + sender_as_seen_by_ah.clone(), + ); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner.clone()), + relay_native_asset_location.clone(), + sender.clone(), + amount_to_send * 2, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_of_sender_on_ah.clone(), amount_to_send * 2), + ]), + ), + ); + let beneficiary_id = PenpalBReceiver::get(); + let test_args = TestContext { + sender: PenpalASender::get(), + receiver: PenpalBReceiver::get(), + args: TestArgs::new_para( + destination, + beneficiary_id.clone(), + amount_to_send, + assets, + None, + 0, + ), + }; + let mut test = ParaToParaThroughAHTest::new(test_args); + let mut delivery_fees_amount = 0; + let mut remote_message = VersionedXcm::V5(Xcm(Vec::new())); + ::execute_with(|| { + type Runtime = ::Runtime; + type OriginCaller = ::OriginCaller; + let call = transfer_assets_para_to_para_through_ah_call(test.clone()); + let origin = OriginCaller::system(RawOrigin::Signed(sender.clone())); + let result = Runtime::dry_run_call(origin, call).unwrap(); + let (destination_to_query, messages_to_query) = &result + .forwarded_xcms + .iter() + .find(|(destination, _)| { + *destination + == VersionedLocation::V5(Location::new(1, [Parachain(1000)])) + }) + .unwrap(); + match (&messages_to_query.len(), &1) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + remote_message = messages_to_query[0].clone(); + let delivery_fees = Runtime::query_delivery_fees( + destination_to_query.clone(), + remote_message.clone(), + ) + .unwrap(); + delivery_fees_amount = get_amount_from_versioned_assets(delivery_fees); + }); + let mut intermediate_execution_fees = 0; + let mut intermediate_delivery_fees_amount = 0; + let mut intermediate_remote_message = VersionedXcm::V5( + Xcm::<()>(Vec::new()), + ); + ::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + let weight = Runtime::query_xcm_weight(remote_message.clone()).unwrap(); + intermediate_execution_fees = Runtime::query_weight_to_asset_fee( + weight, + VersionedAssetId::V5(Location::new(1, []).into()), + ) + .unwrap(); + let xcm_program = VersionedXcm::V5( + Xcm::::from(remote_message.clone().try_into().unwrap()), + ); + let result = Runtime::dry_run_xcm( + sender_as_seen_by_ah.clone().into(), + xcm_program, + ) + .unwrap(); + let (destination_to_query, messages_to_query) = &result + .forwarded_xcms + .iter() + .find(|(destination, _)| { + *destination + == VersionedLocation::V5(Location::new(1, [Parachain(2001)])) + }) + .unwrap(); + intermediate_remote_message = messages_to_query[0].clone(); + let delivery_fees = Runtime::query_delivery_fees( + destination_to_query.clone(), + intermediate_remote_message.clone(), + ) + .unwrap(); + intermediate_delivery_fees_amount = get_amount_from_versioned_assets( + delivery_fees, + ); + }); + let mut final_execution_fees = 0; + ::execute_with(|| { + type Runtime = ::Runtime; + let weight = Runtime::query_xcm_weight( + intermediate_remote_message.clone(), + ) + .unwrap(); + final_execution_fees = Runtime::query_weight_to_asset_fee( + weight, + VersionedAssetId::V5(Parent.into()), + ) + .unwrap(); + }); + PenpalA::reset_ext(); + AssetHubWestend::reset_ext(); + PenpalB::reset_ext(); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner), + relay_native_asset_location.clone(), + sender.clone(), + amount_to_send * 2, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([(sov_of_sender_on_ah, amount_to_send * 2)]), + ), + ); + let sender_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &sender) + }); + let receiver_assets_before = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &beneficiary_id) + }); + test.set_assertion::(sender_assertions); + test.set_assertion::(hop_assertions); + test.set_assertion::(receiver_assertions); + test.set_dispatchable::< + PenpalA, + >(transfer_assets_para_to_para_through_ah_dispatchable); + test.assert(); + let sender_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &sender) + }); + let receiver_assets_after = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location, &beneficiary_id) + }); + match ( + &sender_assets_after, + &(sender_assets_before - amount_to_send - delivery_fees_amount), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &receiver_assets_after, + &(receiver_assets_before + amount_to_send - intermediate_execution_fees + - intermediate_delivery_fees_amount - final_execution_fees), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + } +} +#[rustc_main] +#[coverage(off)] +pub fn main() -> () { + extern crate test; + test::test_main_static( + &[ + &assets_can_be_claimed, + &create_and_claim_treasury_spend, + &bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types, + &transfer_foreign_assets_from_asset_hub_to_para, + &transfer_foreign_assets_from_para_to_asset_hub, + &transfer_foreign_assets_from_para_to_para_through_asset_hub, + &transfer_native_asset_from_relay_to_para_through_asset_hub, + &reserve_transfer_multiple_assets_from_asset_hub_to_para, + &reserve_transfer_multiple_assets_from_para_to_asset_hub, + &reserve_transfer_native_asset_from_asset_hub_to_para, + &reserve_transfer_native_asset_from_asset_hub_to_relay_fails, + &reserve_transfer_native_asset_from_para_to_asset_hub, + &reserve_transfer_native_asset_from_para_to_para_through_relay, + &reserve_transfer_native_asset_from_para_to_relay, + &reserve_transfer_native_asset_from_relay_to_asset_hub_fails, + &reserve_transfer_native_asset_from_relay_to_para, + &send_transact_as_superuser_from_relay_to_asset_hub_works, + &send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset, + &send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset, + &relay_sets_system_para_xcm_supported_version, + &system_para_sets_relay_xcm_supported_version, + &cannot_create_pool_from_pool_assets, + &pay_xcm_fee_with_some_asset_swapped_for_native, + &swap_locally_on_chain_using_foreign_assets, + &swap_locally_on_chain_using_local_assets, + &bidirectional_teleport_foreign_assets_between_para_and_asset_hub, + &limited_teleport_native_assets_from_system_para_to_relay_fails, + &teleport_from_and_to_relay, + &teleport_to_other_system_parachains_works, + &create_and_claim_treasury_spend, + &multi_hop_works, + ], + ) +} diff --git a/polkadot/runtime/westend/src/weights/xcm/mod.rs b/polkadot/runtime/westend/src/weights/xcm/mod.rs index 8035439e8892..aebf287ca578 100644 --- a/polkadot/runtime/westend/src/weights/xcm/mod.rs +++ b/polkadot/runtime/westend/src/weights/xcm/mod.rs @@ -187,6 +187,11 @@ impl XcmWeightInfo for WestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } + + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } + fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } @@ -272,6 +277,10 @@ impl XcmWeightInfo for WestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } #[test] From 5a7c1954cf71291da661121dc42e73815565313c Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 28 Aug 2024 20:39:00 +0300 Subject: [PATCH 060/151] Implemented pay_fees for the testnets --- .../runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs | 2 +- polkadot/runtime/westend/src/weights/xcm/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index e6c376ebc90a..be4aa3e989bf 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -238,6 +238,6 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { } fn pay_fees(asset: &Asset) -> Weight { - todo!() + XcmGeneric::::pay_fees() } } diff --git a/polkadot/runtime/westend/src/weights/xcm/mod.rs b/polkadot/runtime/westend/src/weights/xcm/mod.rs index aebf287ca578..b664c1714b18 100644 --- a/polkadot/runtime/westend/src/weights/xcm/mod.rs +++ b/polkadot/runtime/westend/src/weights/xcm/mod.rs @@ -279,7 +279,7 @@ impl XcmWeightInfo for WestendXcmWeight { } fn pay_fees(asset: &Asset) -> Weight { - todo!() + XcmGeneric::::pay_fees() } } From 6800d9fbce93343f031aef0a3c408bd0ba3c7f94 Mon Sep 17 00:00:00 2001 From: ndk Date: Fri, 30 Aug 2024 13:54:58 +0300 Subject: [PATCH 061/151] WIP e2e tests - claimAssets step --- .../src/tests/set_asset_claimer.rs | 126 +++++++++++++----- .../asset-hub-westend/src/weights/xcm/mod.rs | 4 - .../bridge-hub-rococo/src/weights/xcm/mod.rs | 4 + .../bridge-hub-westend/src/weights/xcm/mod.rs | 4 - .../coretime-westend/src/weights/xcm/mod.rs | 4 - .../people-rococo/src/weights/xcm/mod.rs | 3 + .../people-westend/src/weights/xcm/mod.rs | 4 - .../runtime/rococo/src/weights/xcm/mod.rs | 4 + .../runtime/westend/src/weights/xcm/mod.rs | 4 - 9 files changed, 100 insertions(+), 57 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 7a053388d741..2e3feac13b38 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -15,7 +15,10 @@ //! Tests related to claiming assets trapped during XCM execution. -use crate::imports::*; +use emulated_integration_tests_common::accounts::BOB; +use crate::{ + imports::*, +}; use frame_support::{ dispatch::RawOrigin, @@ -30,77 +33,126 @@ use xcm_runtime_apis::{ #[test] fn azs() { - let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); let destination = PenpalA::sibling_location_of(PenpalB::para_id()); let sender = PenpalASender::get(); - let beneficiary_id = PenpalBReceiver::get(); - let amount_to_send = 1_000_000_000_000; + + let amount_to_send = 16_000_000_000_000; + let asset_owner = PenpalAssetOwner::get(); + let native_asset_location = RelayLocation::get(); let assets: Assets = (Parent, amount_to_send).into(); - // Fund accounts again. + + + let bob_account: AccountId = PenpalA::account_id_of(BOB); + let bob_location: Location = + [Junction::AccountId32 { network: None, id: PenpalA::account_id_of(BOB).into() }] + .into(); + + + + // Fund accounts. + let relay_native_asset_location = Location::parent(); PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(PenpalAssetOwner::get()), - Location::parent().clone(), + ::RuntimeOrigin::signed(asset_owner), + relay_native_asset_location.clone(), sender.clone(), amount_to_send * 2, ); + let sender_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location.clone(), &sender) + }); + + dbg!(sender_assets_before); + + // Init values for Parachain Destination + let beneficiary_id = PenpalBReceiver::get(); + let test_args = TestContext { + sender: PenpalASender::get(), + receiver: PenpalBReceiver::get(), + args: TestArgs::new_para( + destination.clone(), + beneficiary_id.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let mut test = ParaToParaThroughAHTest::new(test_args); + let call = transfer_assets(test.clone(), bob_location.clone()); + PenpalA::execute_with(|| { + assert!(call.dispatch(test.signed_origin).is_ok()); + }); + + let sender_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location.clone(), &sender) + }); + + dbg!(sender_assets_after); + let test_args = TestContext { - sender: PenpalASender::get(), // Bob in PenpalB. - receiver: PenpalBReceiver::get(), // Alice. + sender: PenpalASender::get(), + receiver: PenpalBReceiver::get(), args: TestArgs::new_para( - destination, + destination.clone(), beneficiary_id.clone(), amount_to_send, - assets, + assets.clone(), None, 0, ), }; let mut test = ParaToParaThroughAHTest::new(test_args); - transfer_assets(test.clone(), bob.clone()); - // let call = transfer_assets(test.clone(), bob.clone()); + let call = claim_assets(test.clone(), bob_location.clone()); + call.dispatch(::RuntimeOrigin::signed(bob_account.clone())); + // PenpalA::execute_with(|| { + // assert!(call.dispatch(test.signed_origin).is_ok()); + // }); + let bob_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location.clone(), &bob_account) + }); - // test.set_assertion::(sender_assertions); - // test.set_call(call); - // test.assert(); + dbg!(bob_assets_after); } -fn transfer_assets( +fn claim_assets( test: ParaToParaThroughAHTest, claimer: Location ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; + let local_xcm = Xcm::::builder_unsafe() + .claim_asset(test.args.assets.clone(), Here) + .deposit_asset(AllCounted(test.args.assets.len() as u32), claimer) + .pay_fees((Parent, 10u128)) + .build(); + + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(4_000_000_000_000, 300_000), + }) +} +fn transfer_assets( + test: ParaToParaThroughAHTest, + claimer: Location +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; let local_xcm = Xcm::::builder_unsafe() - .clear_origin() .set_asset_claimer(claimer.clone()) .withdraw_asset(test.args.assets.clone()) - .pay_fees((Parent, 0)) + .clear_origin() + // .pay_fees((Parent, 4_000_000_000_000u128)) .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { message: bx!(VersionedXcm::from(local_xcm)), - max_weight: Weight::from_parts(3_000_000_000, 200_000), + max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) -} - -fn sender_assertions(test: ParaToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - // PenpalA::assert_xcm_pallet_attempted_complete(None); - assert_expected_events!( - PenpalA, - vec![ - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance } - ) => { - asset_id: *asset_id == Location::new(1, []), - owner: *owner == test.sender.account_id, - balance: *balance == test.args.amount, - }, - ] - ); } \ No newline at end of file diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 1a1746feadc2..3a1a498a7f80 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -236,8 +236,4 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs index bc1c9980e140..5e5cdf624656 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs @@ -234,4 +234,8 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index 83209d11aeaa..86e9de516df9 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -240,8 +240,4 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs index f6292ff9f6c2..443f9007898c 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs @@ -237,8 +237,4 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs index 09e3b3732206..7ba4b17ebc70 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs @@ -231,4 +231,7 @@ impl XcmWeightInfo for PeopleRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs index 1dd5dc3cd742..b9e1f9a4a735 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs @@ -236,8 +236,4 @@ impl XcmWeightInfo for PeopleWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/polkadot/runtime/rococo/src/weights/xcm/mod.rs b/polkadot/runtime/rococo/src/weights/xcm/mod.rs index 0c4b7e7c1596..4e8d403f757d 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/mod.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/mod.rs @@ -269,6 +269,10 @@ impl XcmWeightInfo for RococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } } #[test] diff --git a/polkadot/runtime/westend/src/weights/xcm/mod.rs b/polkadot/runtime/westend/src/weights/xcm/mod.rs index b664c1714b18..f978df67ad2b 100644 --- a/polkadot/runtime/westend/src/weights/xcm/mod.rs +++ b/polkadot/runtime/westend/src/weights/xcm/mod.rs @@ -277,10 +277,6 @@ impl XcmWeightInfo for WestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - XcmGeneric::::pay_fees() - } } #[test] From b5a2cd04463fc5853c78bfc35783ace1c7c12f96 Mon Sep 17 00:00:00 2001 From: ndk Date: Fri, 30 Aug 2024 14:01:40 +0300 Subject: [PATCH 062/151] Fixed dispatch --- .../asset-hub-westend/src/tests/set_asset_claimer.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 2e3feac13b38..9f64c16be213 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -107,10 +107,11 @@ fn azs() { }; let mut test = ParaToParaThroughAHTest::new(test_args); let call = claim_assets(test.clone(), bob_location.clone()); - call.dispatch(::RuntimeOrigin::signed(bob_account.clone())); - // PenpalA::execute_with(|| { - // assert!(call.dispatch(test.signed_origin).is_ok()); - // }); + // call.dispatch(::RuntimeOrigin::signed(bob_account.clone())); + PenpalA::execute_with(|| { + assert!(call.dispatch(::RuntimeOrigin::signed(bob_account.clone())).is_ok()); + // assert!(call.dispatch(test.signed_origin).is_ok()); + }); let bob_assets_after = PenpalA::execute_with(|| { type ForeignAssets = ::ForeignAssets; From 2fec6d4ed44ae2018ab72c8b93030d8aa21543e1 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 2 Sep 2024 13:16:30 +0300 Subject: [PATCH 063/151] finished first SAC e2e single chain test --- .../src/tests/set_asset_claimer.rs | 124 ++++++++---------- 1 file changed, 57 insertions(+), 67 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 9f64c16be213..cf751e4ed49b 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -15,7 +15,8 @@ //! Tests related to claiming assets trapped during XCM execution. -use emulated_integration_tests_common::accounts::BOB; +use emulated_integration_tests_common::accounts::{ALICE, BOB, CHARLIE}; +use emulated_integration_tests_common::impls::AccountId32; use crate::{ imports::*, }; @@ -24,56 +25,28 @@ use frame_support::{ dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, }; -use emulated_integration_tests_common::test_chain_can_claim_assets; -use xcm_executor::traits::DropAssets; -use xcm_runtime_apis::{ - dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, - fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, -}; #[test] -fn azs() { - let destination = PenpalA::sibling_location_of(PenpalB::para_id()); - let sender = PenpalASender::get(); +fn test_set_asset_claimer_within_a_chain() { + let (alice_account, alice_location) = account_and_location(ALICE); + let (bob_account, bob_location) = account_and_location(BOB); let amount_to_send = 16_000_000_000_000; - let asset_owner = PenpalAssetOwner::get(); let native_asset_location = RelayLocation::get(); let assets: Assets = (Parent, amount_to_send).into(); - - - let bob_account: AccountId = PenpalA::account_id_of(BOB); - let bob_location: Location = - [Junction::AccountId32 { network: None, id: PenpalA::account_id_of(BOB).into() }] - .into(); - - - // Fund accounts. - let relay_native_asset_location = Location::parent(); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - relay_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); + fund_account(&alice_account, amount_to_send * 2); - let sender_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location.clone(), &sender) - }); - - dbg!(sender_assets_before); + let alice_assets_before = query_balance(&alice_account, &native_asset_location); + assert_eq!(alice_assets_before, amount_to_send * 2); - // Init values for Parachain Destination - let beneficiary_id = PenpalBReceiver::get(); let test_args = TestContext { - sender: PenpalASender::get(), - receiver: PenpalBReceiver::get(), + sender: alice_account.clone(), + receiver: bob_account.clone(), args: TestArgs::new_para( - destination.clone(), - beneficiary_id.clone(), + bob_location.clone(), + bob_account.clone(), amount_to_send, assets.clone(), None, @@ -81,24 +54,17 @@ fn azs() { ), }; let mut test = ParaToParaThroughAHTest::new(test_args); - let call = transfer_assets(test.clone(), bob_location.clone()); - PenpalA::execute_with(|| { - assert!(call.dispatch(test.signed_origin).is_ok()); - }); + execute_test(test.clone(), bob_location.clone(), transfer_assets); - let sender_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location.clone(), &sender) - }); - - dbg!(sender_assets_after); + let alice_assets_after = query_balance(&alice_account, &native_asset_location); + assert_eq!(alice_assets_after, amount_to_send); let test_args = TestContext { - sender: PenpalASender::get(), - receiver: PenpalBReceiver::get(), + sender: bob_account.clone(), + receiver: alice_account.clone(), args: TestArgs::new_para( - destination.clone(), - beneficiary_id.clone(), + alice_location.clone(), + alice_account.clone(), amount_to_send, assets.clone(), None, @@ -106,19 +72,45 @@ fn azs() { ), }; let mut test = ParaToParaThroughAHTest::new(test_args); - let call = claim_assets(test.clone(), bob_location.clone()); - // call.dispatch(::RuntimeOrigin::signed(bob_account.clone())); - PenpalA::execute_with(|| { - assert!(call.dispatch(::RuntimeOrigin::signed(bob_account.clone())).is_ok()); - // assert!(call.dispatch(test.signed_origin).is_ok()); - }); + execute_test(test.clone(), bob_location.clone(), claim_assets); - let bob_assets_after = PenpalA::execute_with(|| { + let bob_assets_after = query_balance(&bob_account, &native_asset_location); + assert_eq!(bob_assets_after, amount_to_send); +} + +fn account_and_location(account: &str) -> (AccountId32, Location) { + let account_id = PenpalA::account_id_of(account); + let clone = account_id.clone(); + let location: Location = [Junction::AccountId32 { network: Some(Rococo), id: account_id.into() }].into(); + (clone, location) +} + +fn fund_account(account: &AccountId, amount: u128) { + let asset_owner = PenpalAssetOwner::get(); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner), + Location::parent(), + account.clone(), + amount, + ); +} + +fn query_balance(account: &AccountId, asset_location: &Location) -> u128 { + PenpalA::execute_with(|| { type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location.clone(), &bob_account) - }); + >::balance(asset_location.clone(), account) + }) +} - dbg!(bob_assets_after); +fn execute_test( + test: ParaToParaThroughAHTest, + location: Location, + xcm_fn: impl Fn(ParaToParaThroughAHTest, Location) -> ::RuntimeCall, +) { + let call = xcm_fn(test.clone(), location.clone()); + PenpalA::execute_with(|| { + assert!(call.dispatch(test.signed_origin).is_ok()); + }); } fn claim_assets( @@ -126,11 +118,10 @@ fn claim_assets( claimer: Location ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; - + let local_xcm = Xcm::::builder_unsafe() .claim_asset(test.args.assets.clone(), Here) .deposit_asset(AllCounted(test.args.assets.len() as u32), claimer) - .pay_fees((Parent, 10u128)) .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { @@ -144,12 +135,11 @@ fn transfer_assets( claimer: Location ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; - + let local_xcm = Xcm::::builder_unsafe() .set_asset_claimer(claimer.clone()) .withdraw_asset(test.args.assets.clone()) .clear_origin() - // .pay_fees((Parent, 4_000_000_000_000u128)) .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { From 0ff7c6703b4b71be4f984f800ad9c555a1190a46 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 2 Sep 2024 18:56:42 +0300 Subject: [PATCH 064/151] benchmarks initial commit --- .../src/tests/set_asset_claimer.rs | 20 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 374 ++---------------- .../bridge-hub-rococo/src/weights/xcm/mod.rs | 2 +- .../src/generic/benchmarking.rs | 14 + .../src/migrations/v1/weights.rs | 2 +- 5 files changed, 62 insertions(+), 350 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index cf751e4ed49b..966971f80eab 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -113,15 +113,16 @@ fn execute_test( }); } -fn claim_assets( +fn transfer_assets( test: ParaToParaThroughAHTest, claimer: Location ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; - + let local_xcm = Xcm::::builder_unsafe() - .claim_asset(test.args.assets.clone(), Here) - .deposit_asset(AllCounted(test.args.assets.len() as u32), claimer) + .set_asset_claimer(claimer.clone()) + .withdraw_asset(test.args.assets.clone()) + .clear_origin() .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { @@ -130,20 +131,19 @@ fn claim_assets( }) } -fn transfer_assets( +fn claim_assets( test: ParaToParaThroughAHTest, claimer: Location ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; - + let local_xcm = Xcm::::builder_unsafe() - .set_asset_claimer(claimer.clone()) - .withdraw_asset(test.args.assets.clone()) - .clear_origin() + .claim_asset(test.args.assets.clone(), Here) + .deposit_asset(AllCounted(test.args.assets.len() as u32), claimer) .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { message: bx!(VersionedXcm::from(local_xcm)), max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) -} \ No newline at end of file +} diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 6a960e1a073e..66b2a0bc5e7f 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -1,362 +1,60 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.0 +//! DATE: 2024-09-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 +//! HOSTNAME: `PAR03612`, CPU: `` +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: -// target/production/polkadot-parachain +// frame-omni-bencher +// v1 // benchmark // pallet -// --steps=50 -// --repeat=20 -// --extrinsic=* -// --wasm-execution=compiled -// --heap-pages=4096 -// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json -// --pallet=pallet_xcm_benchmarks::generic -// --chain=asset-hub-westend-dev -// --header=./cumulus/file_header.txt -// --template=./cumulus/templates/xcm-bench-template.hbs -// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ +// --runtime +// target/release/wbuild/asset-hub-westend-runtime/asset_hub_westend_runtime.compact.compressed.wasm +// --pallet +// pallet_xcm_benchmarks::generic +// --extrinsic +// pay_fees +// --template +// substrate/.maintain/frame-weight-template.hbs +// --output +// cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] -use frame_support::{traits::Get, weights::Weight}; +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; -/// Weights for `pallet_xcm_benchmarks::generic`. -pub struct WeightInfo(PhantomData); -impl WeightInfo { - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn report_holding() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 97_854_000 picoseconds. - Weight::from_parts(100_164_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - pub fn buy_execution() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 723_000 picoseconds. - Weight::from_parts(769_000, 0) - } - pub fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_933_000 picoseconds. - Weight::from_parts(4_168_000, 0) - } - // Storage: `PolkadotXcm::Queries` (r:1 w:0) - // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn query_response() -> Weight { - // Proof Size summary in bytes: - // Measured: `103` - // Estimated: `3568` - // Minimum execution time: 8_228_000 picoseconds. - Weight::from_parts(8_428_000, 3568) - .saturating_add(T::DbWeight::get().reads(1)) - } - pub fn transact() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 7_123_000 picoseconds. - Weight::from_parts(7_371_000, 0) - } - pub fn refund_surplus() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_718_000 picoseconds. - Weight::from_parts(2_877_000, 0) - } - pub fn set_error_handler() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 737_000 picoseconds. - Weight::from_parts(769_000, 0) - } - pub fn set_appendix() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 705_000 picoseconds. - Weight::from_parts(766_000, 0) - } - pub fn clear_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 688_000 picoseconds. - Weight::from_parts(742_000, 0) - } - pub fn descend_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 736_000 picoseconds. - Weight::from_parts(800_000, 0) - } - pub fn clear_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 698_000 picoseconds. - Weight::from_parts(730_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn report_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 65_608_000 picoseconds. - Weight::from_parts(67_828_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) - // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn claim_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `160` - // Estimated: `3625` - // Minimum execution time: 12_895_000 picoseconds. - Weight::from_parts(13_134_000, 3625) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - pub fn trap() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 705_000 picoseconds. - Weight::from_parts(741_000, 0) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn subscribe_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 27_604_000 picoseconds. - Weight::from_parts(28_364_000, 3610) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:0 w:1) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn unsubscribe_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_584_000 picoseconds. - Weight::from_parts(2_706_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - pub fn burn_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 22_537_000 picoseconds. - Weight::from_parts(22_881_000, 0) - } - pub fn expect_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 6_248_000 picoseconds. - Weight::from_parts(6_464_000, 0) - } - pub fn expect_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 734_000 picoseconds. - Weight::from_parts(780_000, 0) - } - pub fn expect_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 684_000 picoseconds. - Weight::from_parts(741_000, 0) - } - pub fn expect_transact_status() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 863_000 picoseconds. - Weight::from_parts(930_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn query_pallet() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 71_041_000 picoseconds. - Weight::from_parts(72_948_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - pub fn expect_pallet() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 4_267_000 picoseconds. - Weight::from_parts(4_557_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn report_transact_status() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 65_605_000 picoseconds. - Weight::from_parts(67_382_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - pub fn clear_transact_status() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 743_000 picoseconds. - Weight::from_parts(791_000, 0) - } - pub fn set_topic() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 711_000 picoseconds. - Weight::from_parts(751_000, 0) - } - pub fn clear_topic() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 722_000 picoseconds. - Weight::from_parts(753_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - pub fn universal_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `1489` - // Minimum execution time: 2_653_000 picoseconds. - Weight::from_parts(2_720_000, 1489) - .saturating_add(T::DbWeight::get().reads(1)) - } - pub fn set_fees_mode() -> Weight { +/// Weight functions needed for `pallet_xcm_benchmarks::generic`. +pub trait WeightInfo { + fn pay_fees() -> Weight; +} + +/// Weights for `pallet_xcm_benchmarks::generic` using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 668_000 picoseconds. - Weight::from_parts(695_000, 0) + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) } - pub fn unpaid_execution() -> Weight { +} + +// For backwards compatibility and tests. +impl WeightInfo for () { + fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 742_000 picoseconds. - Weight::from_parts(773_000, 0) + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs index 5e5cdf624656..2337e3ca1e70 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs @@ -236,6 +236,6 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight { } fn set_asset_claimer(location: &Location) -> Weight { - todo!() + XcmGeneric::::set_asset_claimer() } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index cf2312b61c25..9edbabb7677f 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -113,6 +113,20 @@ benchmarks! { executor.bench_process(xcm)?; } verify {} + set_asset_claimer { + let mut executor = new_executor::(Default::default()); + let (sender_account, sender_location) = account_and_location::(1); + + executor.set_asset_claimer(sender_location.clone()); + let instruction = Instruction::SetAssetClaimer{ location: Some(sender_location.clone()) }; + + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } verify { + assert_eq!(executor.asset_claimer(), sender_location.clone()); + } + query_response { let mut executor = new_executor::(Default::default()); let (query_id, response) = T::worst_case_response(); diff --git a/substrate/frame/examples/multi-block-migrations/src/migrations/v1/weights.rs b/substrate/frame/examples/multi-block-migrations/src/migrations/v1/weights.rs index 6a5cf2ac5936..a436d6a8ab40 100644 --- a/substrate/frame/examples/multi-block-migrations/src/migrations/v1/weights.rs +++ b/substrate/frame/examples/multi-block-migrations/src/migrations/v1/weights.rs @@ -33,7 +33,7 @@ // --pallet // pallet_example_mbm // --extrinsic -// +// // --template // substrate/.maintain/frame-weight-template.hbs // --output From 4f8aada9cbeb01b31585d407b3c7ff6c3d2ac8cb Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 12:19:17 +0300 Subject: [PATCH 065/151] Reverted cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs --- .../xcm/pallet_xcm_benchmarks_generic.rs | 374 ++++++++++++++++-- 1 file changed, 338 insertions(+), 36 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 66b2a0bc5e7f..6a960e1a073e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -1,60 +1,362 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.0 -//! DATE: 2024-09-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `PAR03612`, CPU: `` -//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: -// frame-omni-bencher -// v1 +// target/production/polkadot-parachain // benchmark // pallet -// --runtime -// target/release/wbuild/asset-hub-westend-runtime/asset_hub_westend_runtime.compact.compressed.wasm -// --pallet -// pallet_xcm_benchmarks::generic -// --extrinsic -// pay_fees -// --template -// substrate/.maintain/frame-weight-template.hbs -// --output -// cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_xcm_benchmarks::generic +// --chain=asset-hub-westend-dev +// --header=./cumulus/file_header.txt +// --template=./cumulus/templates/xcm-bench-template.hbs +// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] -#![allow(missing_docs)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::Weight}; use core::marker::PhantomData; -/// Weight functions needed for `pallet_xcm_benchmarks::generic`. -pub trait WeightInfo { - fn pay_fees() -> Weight; -} - -/// Weights for `pallet_xcm_benchmarks::generic` using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - fn pay_fees() -> Weight { +/// Weights for `pallet_xcm_benchmarks::generic`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn report_holding() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 97_854_000 picoseconds. + Weight::from_parts(100_164_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + pub fn buy_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(5_000_000, 0) + // Minimum execution time: 723_000 picoseconds. + Weight::from_parts(769_000, 0) } -} - -// For backwards compatibility and tests. -impl WeightInfo for () { - fn pay_fees() -> Weight { + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_933_000 picoseconds. + Weight::from_parts(4_168_000, 0) + } + // Storage: `PolkadotXcm::Queries` (r:1 w:0) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn query_response() -> Weight { + // Proof Size summary in bytes: + // Measured: `103` + // Estimated: `3568` + // Minimum execution time: 8_228_000 picoseconds. + Weight::from_parts(8_428_000, 3568) + .saturating_add(T::DbWeight::get().reads(1)) + } + pub fn transact() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_123_000 picoseconds. + Weight::from_parts(7_371_000, 0) + } + pub fn refund_surplus() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_718_000 picoseconds. + Weight::from_parts(2_877_000, 0) + } + pub fn set_error_handler() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 737_000 picoseconds. + Weight::from_parts(769_000, 0) + } + pub fn set_appendix() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 705_000 picoseconds. + Weight::from_parts(766_000, 0) + } + pub fn clear_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 688_000 picoseconds. + Weight::from_parts(742_000, 0) + } + pub fn descend_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 736_000 picoseconds. + Weight::from_parts(800_000, 0) + } + pub fn clear_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 698_000 picoseconds. + Weight::from_parts(730_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn report_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 65_608_000 picoseconds. + Weight::from_parts(67_828_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) + // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn claim_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `160` + // Estimated: `3625` + // Minimum execution time: 12_895_000 picoseconds. + Weight::from_parts(13_134_000, 3625) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + pub fn trap() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 705_000 picoseconds. + Weight::from_parts(741_000, 0) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn subscribe_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3610` + // Minimum execution time: 27_604_000 picoseconds. + Weight::from_parts(28_364_000, 3610) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:0 w:1) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn unsubscribe_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_584_000 picoseconds. + Weight::from_parts(2_706_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + pub fn burn_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 22_537_000 picoseconds. + Weight::from_parts(22_881_000, 0) + } + pub fn expect_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_248_000 picoseconds. + Weight::from_parts(6_464_000, 0) + } + pub fn expect_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 734_000 picoseconds. + Weight::from_parts(780_000, 0) + } + pub fn expect_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 684_000 picoseconds. + Weight::from_parts(741_000, 0) + } + pub fn expect_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 863_000 picoseconds. + Weight::from_parts(930_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn query_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 71_041_000 picoseconds. + Weight::from_parts(72_948_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + pub fn expect_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_267_000 picoseconds. + Weight::from_parts(4_557_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn report_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 65_605_000 picoseconds. + Weight::from_parts(67_382_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + pub fn clear_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 743_000 picoseconds. + Weight::from_parts(791_000, 0) + } + pub fn set_topic() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 711_000 picoseconds. + Weight::from_parts(751_000, 0) + } + pub fn clear_topic() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 722_000 picoseconds. + Weight::from_parts(753_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + pub fn universal_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1489` + // Minimum execution time: 2_653_000 picoseconds. + Weight::from_parts(2_720_000, 1489) + .saturating_add(T::DbWeight::get().reads(1)) + } + pub fn set_fees_mode() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 668_000 picoseconds. + Weight::from_parts(695_000, 0) + } + pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(5_000_000, 0) + // Minimum execution time: 742_000 picoseconds. + Weight::from_parts(773_000, 0) } } From 7c8df660d44a881311524450d97273c8002d39fc Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 14:22:02 +0300 Subject: [PATCH 066/151] add made-up benchmarks to all runtimes --- .../asset-hub-rococo/src/weights/xcm/mod.rs | 4 - .../asset-hub-westend/src/weights/xcm/mod.rs | 3 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 374 ++---------------- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../bridge-hub-westend/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../coretime-rococo/src/weights/xcm/mod.rs | 3 + .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../coretime-westend/src/weights/xcm/mod.rs | 4 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../people-rococo/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../people-westend/src/weights/xcm/mod.rs | 8 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../runtime/rococo/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../runtime/westend/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../src/generic/benchmarking.rs | 6 +- 19 files changed, 75 insertions(+), 359 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index be4aa3e989bf..31dcbfaf5b7c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -236,8 +236,4 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - XcmGeneric::::pay_fees() - } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 3a1a498a7f80..758f024cbb9e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -154,8 +154,7 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { XcmGeneric::::clear_error() } fn set_asset_claimer(location: &Location) -> Weight { - // TODO: implement - todo!() + XcmGeneric::::set_asset_claimer() } fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 6a960e1a073e..12ae69f62c7a 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -1,362 +1,60 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.0 +//! DATE: 2024-09-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 +//! HOSTNAME: `PAR03612`, CPU: `` +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: -// target/production/polkadot-parachain +// frame-omni-bencher +// v1 // benchmark // pallet -// --steps=50 -// --repeat=20 -// --extrinsic=* -// --wasm-execution=compiled -// --heap-pages=4096 -// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json -// --pallet=pallet_xcm_benchmarks::generic -// --chain=asset-hub-westend-dev -// --header=./cumulus/file_header.txt -// --template=./cumulus/templates/xcm-bench-template.hbs -// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ +// --runtime +// target/release/wbuild/asset-hub-westend-runtime/asset_hub_westend_runtime.compact.compressed.wasm +// --pallet +// pallet_xcm_benchmarks::generic +// --extrinsic +// set_asset_claimer +// --template +// substrate/.maintain/frame-weight-template.hbs +// --output +// cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] -use frame_support::{traits::Get, weights::Weight}; +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; -/// Weights for `pallet_xcm_benchmarks::generic`. -pub struct WeightInfo(PhantomData); -impl WeightInfo { - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn report_holding() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 97_854_000 picoseconds. - Weight::from_parts(100_164_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - pub fn buy_execution() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 723_000 picoseconds. - Weight::from_parts(769_000, 0) - } - pub fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_933_000 picoseconds. - Weight::from_parts(4_168_000, 0) - } - // Storage: `PolkadotXcm::Queries` (r:1 w:0) - // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn query_response() -> Weight { - // Proof Size summary in bytes: - // Measured: `103` - // Estimated: `3568` - // Minimum execution time: 8_228_000 picoseconds. - Weight::from_parts(8_428_000, 3568) - .saturating_add(T::DbWeight::get().reads(1)) - } - pub fn transact() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 7_123_000 picoseconds. - Weight::from_parts(7_371_000, 0) - } - pub fn refund_surplus() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_718_000 picoseconds. - Weight::from_parts(2_877_000, 0) - } - pub fn set_error_handler() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 737_000 picoseconds. - Weight::from_parts(769_000, 0) - } - pub fn set_appendix() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 705_000 picoseconds. - Weight::from_parts(766_000, 0) - } - pub fn clear_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 688_000 picoseconds. - Weight::from_parts(742_000, 0) - } - pub fn descend_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 736_000 picoseconds. - Weight::from_parts(800_000, 0) - } - pub fn clear_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 698_000 picoseconds. - Weight::from_parts(730_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn report_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 65_608_000 picoseconds. - Weight::from_parts(67_828_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) - // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn claim_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `160` - // Estimated: `3625` - // Minimum execution time: 12_895_000 picoseconds. - Weight::from_parts(13_134_000, 3625) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - pub fn trap() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 705_000 picoseconds. - Weight::from_parts(741_000, 0) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn subscribe_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 27_604_000 picoseconds. - Weight::from_parts(28_364_000, 3610) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:0 w:1) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn unsubscribe_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_584_000 picoseconds. - Weight::from_parts(2_706_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - pub fn burn_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 22_537_000 picoseconds. - Weight::from_parts(22_881_000, 0) - } - pub fn expect_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 6_248_000 picoseconds. - Weight::from_parts(6_464_000, 0) - } - pub fn expect_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 734_000 picoseconds. - Weight::from_parts(780_000, 0) - } - pub fn expect_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 684_000 picoseconds. - Weight::from_parts(741_000, 0) - } - pub fn expect_transact_status() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 863_000 picoseconds. - Weight::from_parts(930_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn query_pallet() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 71_041_000 picoseconds. - Weight::from_parts(72_948_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - pub fn expect_pallet() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 4_267_000 picoseconds. - Weight::from_parts(4_557_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn report_transact_status() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 65_605_000 picoseconds. - Weight::from_parts(67_382_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - pub fn clear_transact_status() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 743_000 picoseconds. - Weight::from_parts(791_000, 0) - } - pub fn set_topic() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 711_000 picoseconds. - Weight::from_parts(751_000, 0) - } - pub fn clear_topic() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 722_000 picoseconds. - Weight::from_parts(753_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - pub fn universal_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `1489` - // Minimum execution time: 2_653_000 picoseconds. - Weight::from_parts(2_720_000, 1489) - .saturating_add(T::DbWeight::get().reads(1)) - } - pub fn set_fees_mode() -> Weight { +/// Weight functions needed for `pallet_xcm_benchmarks::generic`. +pub trait WeightInfo { + fn set_asset_claimer() -> Weight; +} + +/// Weights for `pallet_xcm_benchmarks::generic` using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn set_asset_claimer() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 668_000 picoseconds. - Weight::from_parts(695_000, 0) + // Minimum execution time: 0_000 picoseconds. + Weight::from_parts(1_000_000, 0) } - pub fn unpaid_execution() -> Weight { +} + +// For backwards compatibility and tests. +impl WeightInfo for () { + fn set_asset_claimer() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 742_000 picoseconds. - Weight::from_parts(773_000, 0) + // Minimum execution time: 0_000 picoseconds. + Weight::from_parts(1_000_000, 0) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 5d6ce1ff0e87..245e6fb4fde8 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -373,4 +373,7 @@ impl WeightInfo { // Minimum execution time: 1_085_000 picoseconds. Weight::from_parts(1_161_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index 86e9de516df9..35a9bdd908a9 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -157,7 +157,7 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { } fn set_asset_claimer(location: &Location) -> Weight { - todo!() + XcmGeneric::::set_asset_claimer() } fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 8d5861fe763b..23871856f561 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -373,4 +373,7 @@ impl WeightInfo { // Minimum execution time: 995_000 picoseconds. Weight::from_parts(1_060_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs index 9983aaf4c0ed..31ff0440fd9a 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs @@ -232,4 +232,7 @@ impl XcmWeightInfo for CoretimeRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + fn set_asset_claimer(location: &Location) -> Weight { + XcmGeneric::::set_asset_claimer() + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 3a93c80766de..40321fa0261b 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -331,4 +331,7 @@ impl WeightInfo { // Minimum execution time: 650_000 picoseconds. Weight::from_parts(673_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs index 443f9007898c..ccaffc946b2c 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs @@ -153,11 +153,9 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } - fn set_asset_claimer(location: &Location) -> Weight { - todo!() + XcmGeneric::::set_asset_claimer() } - fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index c8ba2d8b4ce7..98f31390c666 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -331,4 +331,7 @@ impl WeightInfo { // Minimum execution time: 624_000 picoseconds. Weight::from_parts(659_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs index 7ba4b17ebc70..2b4b1e367f16 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs @@ -232,6 +232,6 @@ impl XcmWeightInfo for PeopleRococoXcmWeight { XcmGeneric::::unpaid_execution() } fn set_asset_claimer(location: &Location) -> Weight { - todo!() + XcmGeneric::::set_asset_claimer() } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index e4f103e25370..a03267080c12 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -331,4 +331,7 @@ impl WeightInfo { // Minimum execution time: 685_000 picoseconds. Weight::from_parts(757_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs index b9e1f9a4a735..19cc8e3f1061 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs @@ -152,11 +152,6 @@ impl XcmWeightInfo for PeopleWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } - - fn set_asset_claimer(location: &Location) -> Weight { - todo!() - } - fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } @@ -236,4 +231,7 @@ impl XcmWeightInfo for PeopleWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + fn set_asset_claimer(location: &Location) -> Weight { + XcmGeneric::::set_asset_claimer() + } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 818c2e23a2e9..b4f067dbe9b8 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -331,4 +331,7 @@ impl WeightInfo { // Minimum execution time: 598_000 picoseconds. Weight::from_parts(655_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/polkadot/runtime/rococo/src/weights/xcm/mod.rs b/polkadot/runtime/rococo/src/weights/xcm/mod.rs index 4e8d403f757d..0d2cc309d6d9 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/mod.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/mod.rs @@ -271,7 +271,7 @@ impl XcmWeightInfo for RococoXcmWeight { } fn set_asset_claimer(location: &Location) -> Weight { - todo!() + XcmGeneric::::set_asset_claimer() } } diff --git a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 53d42a0e5c47..84a9a7ce5851 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -322,4 +322,7 @@ impl WeightInfo { // Minimum execution time: 798_000 picoseconds. Weight::from_parts(845_000, 0) } + pub(crate) fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/polkadot/runtime/westend/src/weights/xcm/mod.rs b/polkadot/runtime/westend/src/weights/xcm/mod.rs index f978df67ad2b..4ad9df20b83d 100644 --- a/polkadot/runtime/westend/src/weights/xcm/mod.rs +++ b/polkadot/runtime/westend/src/weights/xcm/mod.rs @@ -189,7 +189,7 @@ impl XcmWeightInfo for WestendXcmWeight { } fn set_asset_claimer(location: &Location) -> Weight { - todo!() + XcmGeneric::::set_asset_claimer() } fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { diff --git a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 4cc979959483..f178d56cc375 100644 --- a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -322,4 +322,7 @@ impl WeightInfo { // Minimum execution time: 735_000 picoseconds. Weight::from_parts(811_000, 0) } + pub(crate) fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 9edbabb7677f..cc41d5a93e32 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -117,14 +117,14 @@ benchmarks! { let mut executor = new_executor::(Default::default()); let (sender_account, sender_location) = account_and_location::(1); - executor.set_asset_claimer(sender_location.clone()); - let instruction = Instruction::SetAssetClaimer{ location: Some(sender_location.clone()) }; + // executor.set_asset_claimer(sender_location.clone()); + let instruction = Instruction::SetAssetClaimer{ location:sender_location.clone() }; let xcm = Xcm(vec![instruction]); }: { executor.bench_process(xcm)?; } verify { - assert_eq!(executor.asset_claimer(), sender_location.clone()); + assert_eq!(executor.asset_claimer(), Some(sender_location.clone())); } query_response { From 7f4412ec57aabad3e0c7e3da8416a20cdc6c51a0 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 14:24:02 +0300 Subject: [PATCH 067/151] removed commented instruction --- polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index cc41d5a93e32..ece7a95ab7b7 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -116,8 +116,7 @@ benchmarks! { set_asset_claimer { let mut executor = new_executor::(Default::default()); let (sender_account, sender_location) = account_and_location::(1); - - // executor.set_asset_claimer(sender_location.clone()); + let instruction = Instruction::SetAssetClaimer{ location:sender_location.clone() }; let xcm = Xcm(vec![instruction]); From c8cddbbe96a990c608c172db453d3d7a5089233d Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 17:38:32 +0300 Subject: [PATCH 068/151] added set_asset_claimer to pallet_xcm WeightInfo trait and implemented it on WestHub --- .../bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs | 1 - polkadot/runtime/westend/src/weights/pallet_xcm.rs | 7 +++++++ .../xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 2 +- polkadot/xcm/pallet-xcm/src/lib.rs | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs index 2337e3ca1e70..2493d93bc2bf 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs @@ -234,7 +234,6 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - fn set_asset_claimer(location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } diff --git a/polkadot/runtime/westend/src/weights/pallet_xcm.rs b/polkadot/runtime/westend/src/weights/pallet_xcm.rs index 10725cecf249..63c60fe51915 100644 --- a/polkadot/runtime/westend/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/westend/src/weights/pallet_xcm.rs @@ -348,4 +348,11 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(35_299_000, 0) + .saturating_add(Weight::from_parts(0, 3488)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index ece7a95ab7b7..5d1d643d828c 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -116,7 +116,7 @@ benchmarks! { set_asset_claimer { let mut executor = new_executor::(Default::default()); let (sender_account, sender_location) = account_and_location::(1); - + let instruction = Instruction::SetAssetClaimer{ location:sender_location.clone() }; let xcm = Xcm(vec![instruction]); diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 6451901279b1..2587f3d0c02f 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -96,6 +96,7 @@ pub trait WeightInfo { fn new_query() -> Weight; fn take_response() -> Weight; fn claim_assets() -> Weight; + fn set_asset_claimer() -> Weight; } /// fallback implementation @@ -180,6 +181,8 @@ impl WeightInfo for TestWeightInfo { fn claim_assets() -> Weight { Weight::from_parts(100_000_000, 0) } + + fn set_asset_claimer() -> Weight { Weight::from_parts(100_000_000, 0) } } #[frame_support::pallet] From 38f3691cf1b4fd67c61886408c713bc82fbb2c4a Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 17:56:53 +0300 Subject: [PATCH 069/151] resolved merge conflicts --- polkadot/xcm/src/v5/mod.rs | 1 - polkadot/xcm/xcm-executor/src/lib.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index 63aae405c395..04e4f5d7d966 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -747,7 +747,6 @@ pub enum Instruction { /// /// Errors: None. SetAssetClaimer { location: Location }, - /// Create some assets which are being held on behalf of the origin. /// /// - `assets`: The assets which are to be claimed. This must match exactly with the assets diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 503abc73d338..bb2acdc24b96 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -29,7 +29,7 @@ use frame_support::{ use sp_core::defer; use sp_io::hashing::blake2_128; use sp_weights::Weight; -use xcm::latest::prelude::*; +use xcm::{latest::prelude::*, v3::MultiLocation}; pub mod traits; use traits::{ From cfb23bf05eacc0500e95cfa0f5dc76aa15e1f453 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 26 Aug 2024 18:33:27 +0300 Subject: [PATCH 070/151] Added unit test for SetAssetClaimer --- .../runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index 31dcbfaf5b7c..e6c376ebc90a 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -236,4 +236,8 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } From 5ced85ab451b1e6d2ad8c0b8ecf11dfa9c65ef6c Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 18:00:47 +0300 Subject: [PATCH 071/151] resolved merge conflicts[3] --- .../src/tests/set_asset_claimer.rs | 84 +++++++++++++++++++ .../asset-hub-westend/src/weights/xcm/mod.rs | 4 + .../bridge-hub-westend/src/weights/xcm/mod.rs | 4 + .../coretime-westend/src/weights/xcm/mod.rs | 4 + .../runtime/westend/src/weights/xcm/mod.rs | 2 +- 5 files changed, 97 insertions(+), 1 deletion(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 966971f80eab..22e02a23414b 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -15,16 +15,21 @@ //! Tests related to claiming assets trapped during XCM execution. +<<<<<<< HEAD use emulated_integration_tests_common::accounts::{ALICE, BOB, CHARLIE}; use emulated_integration_tests_common::impls::AccountId32; use crate::{ imports::*, }; +======= +use crate::imports::*; +>>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) use frame_support::{ dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, }; +<<<<<<< HEAD #[test] fn test_set_asset_claimer_within_a_chain() { @@ -111,6 +116,52 @@ fn execute_test( PenpalA::execute_with(|| { assert!(call.dispatch(test.signed_origin).is_ok()); }); +======= +use emulated_integration_tests_common::test_chain_can_claim_assets; +use xcm_executor::traits::DropAssets; +use xcm_runtime_apis::{ + dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, + fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, +}; + +#[test] +fn azs() { + let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); + let destination = PenpalA::sibling_location_of(PenpalB::para_id()); + let sender = PenpalASender::get(); + let beneficiary_id = PenpalBReceiver::get(); + let amount_to_send = 1_000_000_000_000; + let assets: Assets = (Parent, amount_to_send).into(); + + // Fund accounts again. + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(PenpalAssetOwner::get()), + Location::parent().clone(), + sender.clone(), + amount_to_send * 2, + ); + + let test_args = TestContext { + sender: PenpalASender::get(), // Bob in PenpalB. + receiver: PenpalBReceiver::get(), // Alice. + args: TestArgs::new_para( + destination, + beneficiary_id.clone(), + amount_to_send, + assets, + None, + 0, + ), + }; + let mut test = ParaToParaThroughAHTest::new(test_args); + transfer_assets(test.clone(), bob.clone()); + // let call = transfer_assets(test.clone(), bob.clone()); + + + // test.set_assertion::(sender_assertions); + // test.set_call(call); + // test.assert(); +>>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) } fn transfer_assets( @@ -119,14 +170,25 @@ fn transfer_assets( ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; +<<<<<<< HEAD let local_xcm = Xcm::::builder_unsafe() .set_asset_claimer(claimer.clone()) .withdraw_asset(test.args.assets.clone()) .clear_origin() +======= + + + let local_xcm = Xcm::::builder_unsafe() + .clear_origin() + .set_asset_claimer(claimer.clone()) + .withdraw_asset(test.args.assets.clone()) + .pay_fees((Parent, 0)) +>>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { message: bx!(VersionedXcm::from(local_xcm)), +<<<<<<< HEAD max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) } @@ -147,3 +209,25 @@ fn claim_assets( max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) } +======= + max_weight: Weight::from_parts(3_000_000_000, 200_000), + }) +} + +fn sender_assertions(test: ParaToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + // PenpalA::assert_xcm_pallet_attempted_complete(None); + assert_expected_events!( + PenpalA, + vec![ + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance } + ) => { + asset_id: *asset_id == Location::new(1, []), + owner: *owner == test.sender.account_id, + balance: *balance == test.args.amount, + }, + ] + ); +} +>>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 758f024cbb9e..f440308a5c4c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -235,4 +235,8 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index 35a9bdd908a9..a33f54e96744 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -240,4 +240,8 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs index ccaffc946b2c..a0878d52ea0e 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs @@ -235,4 +235,8 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/polkadot/runtime/westend/src/weights/xcm/mod.rs b/polkadot/runtime/westend/src/weights/xcm/mod.rs index 4ad9df20b83d..b0f7c18fee35 100644 --- a/polkadot/runtime/westend/src/weights/xcm/mod.rs +++ b/polkadot/runtime/westend/src/weights/xcm/mod.rs @@ -189,7 +189,7 @@ impl XcmWeightInfo for WestendXcmWeight { } fn set_asset_claimer(location: &Location) -> Weight { - XcmGeneric::::set_asset_claimer() + XcmGeneric::::set_asset_claimer() } fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { From ef911c5dc2fdca05950144f207f47f7fbc02183c Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 18:40:25 +0300 Subject: [PATCH 072/151] resolved merge conflicts[4] --- .../src/tests/set_asset_claimer.rs | 85 ------------------- 1 file changed, 85 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 22e02a23414b..01ba9ca9d0f7 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -15,22 +15,16 @@ //! Tests related to claiming assets trapped during XCM execution. -<<<<<<< HEAD use emulated_integration_tests_common::accounts::{ALICE, BOB, CHARLIE}; use emulated_integration_tests_common::impls::AccountId32; use crate::{ imports::*, }; -======= -use crate::imports::*; ->>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) use frame_support::{ dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, }; -<<<<<<< HEAD - #[test] fn test_set_asset_claimer_within_a_chain() { let (alice_account, alice_location) = account_and_location(ALICE); @@ -116,52 +110,6 @@ fn execute_test( PenpalA::execute_with(|| { assert!(call.dispatch(test.signed_origin).is_ok()); }); -======= -use emulated_integration_tests_common::test_chain_can_claim_assets; -use xcm_executor::traits::DropAssets; -use xcm_runtime_apis::{ - dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, - fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, -}; - -#[test] -fn azs() { - let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); - let destination = PenpalA::sibling_location_of(PenpalB::para_id()); - let sender = PenpalASender::get(); - let beneficiary_id = PenpalBReceiver::get(); - let amount_to_send = 1_000_000_000_000; - let assets: Assets = (Parent, amount_to_send).into(); - - // Fund accounts again. - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(PenpalAssetOwner::get()), - Location::parent().clone(), - sender.clone(), - amount_to_send * 2, - ); - - let test_args = TestContext { - sender: PenpalASender::get(), // Bob in PenpalB. - receiver: PenpalBReceiver::get(), // Alice. - args: TestArgs::new_para( - destination, - beneficiary_id.clone(), - amount_to_send, - assets, - None, - 0, - ), - }; - let mut test = ParaToParaThroughAHTest::new(test_args); - transfer_assets(test.clone(), bob.clone()); - // let call = transfer_assets(test.clone(), bob.clone()); - - - // test.set_assertion::(sender_assertions); - // test.set_call(call); - // test.assert(); ->>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) } fn transfer_assets( @@ -170,25 +118,14 @@ fn transfer_assets( ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; -<<<<<<< HEAD let local_xcm = Xcm::::builder_unsafe() .set_asset_claimer(claimer.clone()) .withdraw_asset(test.args.assets.clone()) .clear_origin() -======= - - - let local_xcm = Xcm::::builder_unsafe() - .clear_origin() - .set_asset_claimer(claimer.clone()) - .withdraw_asset(test.args.assets.clone()) - .pay_fees((Parent, 0)) ->>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { message: bx!(VersionedXcm::from(local_xcm)), -<<<<<<< HEAD max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) } @@ -209,25 +146,3 @@ fn claim_assets( max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) } -======= - max_weight: Weight::from_parts(3_000_000_000, 200_000), - }) -} - -fn sender_assertions(test: ParaToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - // PenpalA::assert_xcm_pallet_attempted_complete(None); - assert_expected_events!( - PenpalA, - vec![ - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance } - ) => { - asset_id: *asset_id == Location::new(1, []), - owner: *owner == test.sender.account_id, - balance: *balance == test.args.amount, - }, - ] - ); -} ->>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) From 84ad4ce5fe739c8016d256f4beec5062dc6705ed Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 19:01:01 +0300 Subject: [PATCH 073/151] reverted cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs --- .../asset-hub-rococo/src/weights/xcm/mod.rs | 4 - .../asset-hub-westend/src/weights/xcm/mod.rs | 4 - .../xcm/pallet_xcm_benchmarks_generic.rs | 374 ++++++++++++++++-- .../bridge-hub-westend/src/weights/xcm/mod.rs | 4 - .../coretime-westend/src/weights/xcm/mod.rs | 4 - polkadot/xcm/pallet-xcm/src/lib.rs | 3 - 6 files changed, 338 insertions(+), 55 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index e6c376ebc90a..31dcbfaf5b7c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -236,8 +236,4 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index f440308a5c4c..758f024cbb9e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -235,8 +235,4 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 12ae69f62c7a..6a960e1a073e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -1,60 +1,362 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.0 -//! DATE: 2024-09-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `PAR03612`, CPU: `` -//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: -// frame-omni-bencher -// v1 +// target/production/polkadot-parachain // benchmark // pallet -// --runtime -// target/release/wbuild/asset-hub-westend-runtime/asset_hub_westend_runtime.compact.compressed.wasm -// --pallet -// pallet_xcm_benchmarks::generic -// --extrinsic -// set_asset_claimer -// --template -// substrate/.maintain/frame-weight-template.hbs -// --output -// cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_xcm_benchmarks::generic +// --chain=asset-hub-westend-dev +// --header=./cumulus/file_header.txt +// --template=./cumulus/templates/xcm-bench-template.hbs +// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] -#![allow(missing_docs)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::Weight}; use core::marker::PhantomData; -/// Weight functions needed for `pallet_xcm_benchmarks::generic`. -pub trait WeightInfo { - fn set_asset_claimer() -> Weight; -} - -/// Weights for `pallet_xcm_benchmarks::generic` using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - fn set_asset_claimer() -> Weight { +/// Weights for `pallet_xcm_benchmarks::generic`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn report_holding() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 97_854_000 picoseconds. + Weight::from_parts(100_164_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + pub fn buy_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 0_000 picoseconds. - Weight::from_parts(1_000_000, 0) + // Minimum execution time: 723_000 picoseconds. + Weight::from_parts(769_000, 0) } -} - -// For backwards compatibility and tests. -impl WeightInfo for () { - fn set_asset_claimer() -> Weight { + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_933_000 picoseconds. + Weight::from_parts(4_168_000, 0) + } + // Storage: `PolkadotXcm::Queries` (r:1 w:0) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn query_response() -> Weight { + // Proof Size summary in bytes: + // Measured: `103` + // Estimated: `3568` + // Minimum execution time: 8_228_000 picoseconds. + Weight::from_parts(8_428_000, 3568) + .saturating_add(T::DbWeight::get().reads(1)) + } + pub fn transact() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_123_000 picoseconds. + Weight::from_parts(7_371_000, 0) + } + pub fn refund_surplus() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_718_000 picoseconds. + Weight::from_parts(2_877_000, 0) + } + pub fn set_error_handler() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 737_000 picoseconds. + Weight::from_parts(769_000, 0) + } + pub fn set_appendix() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 705_000 picoseconds. + Weight::from_parts(766_000, 0) + } + pub fn clear_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 688_000 picoseconds. + Weight::from_parts(742_000, 0) + } + pub fn descend_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 736_000 picoseconds. + Weight::from_parts(800_000, 0) + } + pub fn clear_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 698_000 picoseconds. + Weight::from_parts(730_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn report_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 65_608_000 picoseconds. + Weight::from_parts(67_828_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) + // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn claim_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `160` + // Estimated: `3625` + // Minimum execution time: 12_895_000 picoseconds. + Weight::from_parts(13_134_000, 3625) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + pub fn trap() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 705_000 picoseconds. + Weight::from_parts(741_000, 0) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn subscribe_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3610` + // Minimum execution time: 27_604_000 picoseconds. + Weight::from_parts(28_364_000, 3610) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:0 w:1) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn unsubscribe_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_584_000 picoseconds. + Weight::from_parts(2_706_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + pub fn burn_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 22_537_000 picoseconds. + Weight::from_parts(22_881_000, 0) + } + pub fn expect_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_248_000 picoseconds. + Weight::from_parts(6_464_000, 0) + } + pub fn expect_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 734_000 picoseconds. + Weight::from_parts(780_000, 0) + } + pub fn expect_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 684_000 picoseconds. + Weight::from_parts(741_000, 0) + } + pub fn expect_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 863_000 picoseconds. + Weight::from_parts(930_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn query_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 71_041_000 picoseconds. + Weight::from_parts(72_948_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + pub fn expect_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_267_000 picoseconds. + Weight::from_parts(4_557_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn report_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 65_605_000 picoseconds. + Weight::from_parts(67_382_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + pub fn clear_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 743_000 picoseconds. + Weight::from_parts(791_000, 0) + } + pub fn set_topic() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 711_000 picoseconds. + Weight::from_parts(751_000, 0) + } + pub fn clear_topic() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 722_000 picoseconds. + Weight::from_parts(753_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + pub fn universal_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1489` + // Minimum execution time: 2_653_000 picoseconds. + Weight::from_parts(2_720_000, 1489) + .saturating_add(T::DbWeight::get().reads(1)) + } + pub fn set_fees_mode() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 668_000 picoseconds. + Weight::from_parts(695_000, 0) + } + pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 0_000 picoseconds. - Weight::from_parts(1_000_000, 0) + // Minimum execution time: 742_000 picoseconds. + Weight::from_parts(773_000, 0) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index a33f54e96744..35a9bdd908a9 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -240,8 +240,4 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs index a0878d52ea0e..ccaffc946b2c 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs @@ -235,8 +235,4 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 2587f3d0c02f..6451901279b1 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -96,7 +96,6 @@ pub trait WeightInfo { fn new_query() -> Weight; fn take_response() -> Weight; fn claim_assets() -> Weight; - fn set_asset_claimer() -> Weight; } /// fallback implementation @@ -181,8 +180,6 @@ impl WeightInfo for TestWeightInfo { fn claim_assets() -> Weight { Weight::from_parts(100_000_000, 0) } - - fn set_asset_claimer() -> Weight { Weight::from_parts(100_000_000, 0) } } #[frame_support::pallet] From dd39a1be81662477be677af71137ba330b82e1b4 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 19:03:59 +0300 Subject: [PATCH 074/151] fixed benchmark --- .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 6a960e1a073e..8f03695c0d1e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -359,4 +359,7 @@ impl WeightInfo { // Minimum execution time: 742_000 picoseconds. Weight::from_parts(773_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } From 69362da3479fd46a46e833f7b18384f31b0877f3 Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 4 Sep 2024 13:43:59 +0300 Subject: [PATCH 075/151] removed unused file and import --- expansion.rs | 14961 ------------------------- polkadot/xcm/xcm-executor/src/lib.rs | 2 +- 2 files changed, 1 insertion(+), 14962 deletions(-) delete mode 100644 expansion.rs diff --git a/expansion.rs b/expansion.rs deleted file mode 100644 index 7be4f19597a3..000000000000 --- a/expansion.rs +++ /dev/null @@ -1,14961 +0,0 @@ -#![feature(prelude_import)] -#[prelude_import] -use std::prelude::rust_2021::*; -#[macro_use] -extern crate std; -#[cfg(test)] -mod imports { - pub use codec::Encode; - pub use frame_support::{ - assert_err, assert_ok, pallet_prelude::Weight, - sp_runtime::{DispatchError, DispatchResult, ModuleError}, - traits::fungibles::Inspect, - }; - pub use xcm::prelude::{AccountId32 as AccountId32Junction, *}; - pub use xcm_executor::traits::TransferType; - pub use asset_test_utils::xcm_helpers; - pub use emulated_integration_tests_common::{ - accounts::DUMMY_EMPTY, get_account_id_from_seed, - test_parachain_is_trusted_teleporter, - test_parachain_is_trusted_teleporter_for_relay, test_relay_is_trusted_teleporter, - xcm_emulator::{ - assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, - Test, TestArgs, TestContext, TestExt, - }, - xcm_helpers::{ - get_amount_from_versioned_assets, non_fee_asset, xcm_transact_paid_execution, - }, - ASSETS_PALLET_ID, RESERVABLE_ASSET_ID, XCM_V3, - }; - pub use parachains_common::{AccountId, Balance}; - pub use westend_system_emulated_network::{ - asset_hub_westend_emulated_chain::{ - asset_hub_westend_runtime::{ - xcm_config::{ - self as ahw_xcm_config, WestendLocation as RelayLocation, - XcmConfig as AssetHubWestendXcmConfig, - }, - AssetConversionOrigin as AssetHubWestendAssetConversionOrigin, - ExistentialDeposit as AssetHubWestendExistentialDeposit, - }, - genesis::{AssetHubWestendAssetOwner, ED as ASSET_HUB_WESTEND_ED}, - AssetHubWestendParaPallet as AssetHubWestendPallet, - }, - collectives_westend_emulated_chain::CollectivesWestendParaPallet as CollectivesWestendPallet, - penpal_emulated_chain::{ - penpal_runtime::xcm_config::{ - CustomizableAssetFromSystemAssetHub as PenpalCustomizableAssetFromSystemAssetHub, - LocalReservableFromAssetHub as PenpalLocalReservableFromAssetHub, - LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub, - }, - PenpalAParaPallet as PenpalAPallet, PenpalAssetOwner, - PenpalBParaPallet as PenpalBPallet, - }, - westend_emulated_chain::{ - genesis::ED as WESTEND_ED, - westend_runtime::xcm_config::{ - UniversalLocation as WestendUniversalLocation, - XcmConfig as WestendXcmConfig, - }, - WestendRelayPallet as WestendPallet, - }, - AssetHubWestendPara as AssetHubWestend, - AssetHubWestendParaReceiver as AssetHubWestendReceiver, - AssetHubWestendParaSender as AssetHubWestendSender, - BridgeHubWestendPara as BridgeHubWestend, - BridgeHubWestendParaReceiver as BridgeHubWestendReceiver, - CollectivesWestendPara as CollectivesWestend, PenpalAPara as PenpalA, - PenpalAParaReceiver as PenpalAReceiver, PenpalAParaSender as PenpalASender, - PenpalBPara as PenpalB, PenpalBParaReceiver as PenpalBReceiver, - WestendRelay as Westend, WestendRelayReceiver as WestendReceiver, - WestendRelaySender as WestendSender, - }; - pub const ASSET_ID: u32 = 3; - pub const ASSET_MIN_BALANCE: u128 = 1000; - pub type RelayToParaTest = Test; - pub type ParaToRelayTest = Test; - pub type SystemParaToRelayTest = Test; - pub type SystemParaToParaTest = Test; - pub type ParaToSystemParaTest = Test; - pub type ParaToParaThroughRelayTest = Test; - pub type ParaToParaThroughAHTest = Test; - pub type RelayToParaThroughAHTest = Test; -} -#[cfg(test)] -mod tests { - mod claim_assets { - //! Tests related to claiming assets trapped during XCM execution. - use crate::imports::*; - use frame_support::{ - dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, - }; - use emulated_integration_tests_common::test_chain_can_claim_assets; - use xcm_executor::traits::DropAssets; - use xcm_runtime_apis::{ - dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, - fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, - }; - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::claim_assets::assets_can_be_claimed"] - pub const assets_can_be_claimed: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName("tests::claim_assets::assets_can_be_claimed"), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/claim_assets.rs", - start_line: 32usize, - start_col: 4usize, - end_line: 32usize, - end_col: 25usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(assets_can_be_claimed()), - ), - }; - fn assets_can_be_claimed() { - let amount = AssetHubWestendExistentialDeposit::get(); - let assets: Assets = (Parent, amount).into(); - let sender = AssetHubWestendSender::get(); - let origin = ::RuntimeOrigin::signed( - sender.clone(), - ); - let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { - network: Some(NetworkId::Westend), - id: sender.clone().into(), - } - .into(); - let versioned_assets: ::emulated_integration_tests_common::macros::VersionedAssets = assets - .clone() - .into(); - ::execute_with(|| { - ::PolkadotXcm::drop_assets( - &beneficiary, - assets.clone().into(), - &XcmContext { - origin: None, - message_id: [0u8; 32], - topic: None, - }, - ); - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsTrapped { - origin: beneficiary, - assets: versioned_assets, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsTrapped {\norigin: beneficiary, assets: versioned_assets, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsTrapped {\norigin: beneficiary, assets: versioned_assets, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::claim_assets", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let balance_before = ::Balances::free_balance( - &sender, - ); - let other_origin = ::RuntimeOrigin::signed( - AssetHubWestendReceiver::get(), - ); - if !::PolkadotXcm::claim_assets( - other_origin, - Box::new(versioned_assets.clone().into()), - Box::new(beneficiary.clone().into()), - ) - .is_err() - { - ::core::panicking::panic( - "assertion failed: ::PolkadotXcm::claim_assets(other_origin,\n bx!(versioned_assets.clone().into()),\n bx!(beneficiary.clone().into())).is_err()", - ) - } - let other_versioned_assets: ::emulated_integration_tests_common::macros::VersionedAssets = Assets::new() - .into(); - if !::PolkadotXcm::claim_assets( - origin.clone(), - Box::new(other_versioned_assets.into()), - Box::new(beneficiary.clone().into()), - ) - .is_err() - { - ::core::panicking::panic( - "assertion failed: ::PolkadotXcm::claim_assets(origin.clone(),\n bx!(other_versioned_assets.into()),\n bx!(beneficiary.clone().into())).is_err()", - ) - } - let is = ::PolkadotXcm::claim_assets( - origin.clone(), - Box::new(versioned_assets.clone().into()), - Box::new(beneficiary.clone().into()), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsClaimed { - origin: beneficiary, - assets: versioned_assets, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsClaimed {\norigin: beneficiary, assets: versioned_assets, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsClaimed {\norigin: beneficiary, assets: versioned_assets, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::claim_assets", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let balance_after = ::Balances::free_balance( - &sender, - ); - match (&balance_after, &(balance_before + amount)) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !::PolkadotXcm::claim_assets( - origin.clone(), - Box::new(versioned_assets.clone().into()), - Box::new(beneficiary.clone().into()), - ) - .is_err() - { - ::core::panicking::panic( - "assertion failed: ::PolkadotXcm::claim_assets(origin.clone(),\n bx!(versioned_assets.clone().into()),\n bx!(beneficiary.clone().into())).is_err()", - ) - } - let balance = ::Balances::free_balance( - &sender, - ); - match (&balance, &balance_after) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - ::PolkadotXcm::drop_assets( - &beneficiary, - assets.clone().into(), - &XcmContext { - origin: None, - message_id: [0u8; 32], - topic: None, - }, - ); - let receiver = AssetHubWestendReceiver::get(); - let other_beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { - network: Some(NetworkId::Westend), - id: receiver.clone().into(), - } - .into(); - let balance_before = ::Balances::free_balance( - &receiver, - ); - let is = ::PolkadotXcm::claim_assets( - origin.clone(), - Box::new(versioned_assets.clone().into()), - Box::new(other_beneficiary.clone().into()), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let balance_after = ::Balances::free_balance( - &receiver, - ); - match (&balance_after, &(balance_before + amount)) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - } - } - mod fellowship_treasury { - use crate::imports::*; - use emulated_integration_tests_common::{ - accounts::{ALICE, BOB}, - USDT_ID, - }; - use frame_support::traits::fungibles::{Inspect, Mutate}; - use polkadot_runtime_common::impls::VersionedLocatableAsset; - use xcm_executor::traits::ConvertLocation; - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::fellowship_treasury::create_and_claim_treasury_spend"] - pub const create_and_claim_treasury_spend: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::fellowship_treasury::create_and_claim_treasury_spend", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/fellowship_treasury.rs", - start_line: 26usize, - start_col: 4usize, - end_line: 26usize, - end_col: 35usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(create_and_claim_treasury_spend()), - ), - }; - fn create_and_claim_treasury_spend() { - const SPEND_AMOUNT: u128 = 1_000_000_000; - let treasury_location: Location = Location::new( - 1, - [Parachain(CollectivesWestend::para_id().into()), PalletInstance(65)], - ); - let treasury_account = ahw_xcm_config::LocationToAccountId::convert_location( - &treasury_location, - ) - .unwrap(); - let asset_hub_location = Location::new( - 1, - [Parachain(AssetHubWestend::para_id().into())], - ); - let root = ::RuntimeOrigin::root(); - let asset_kind = VersionedLocatableAsset::V5 { - location: asset_hub_location, - asset_id: AssetId( - (PalletInstance(50), GeneralIndex(USDT_ID.into())).into(), - ), - }; - let alice: AccountId = Westend::account_id_of(ALICE); - let bob: AccountId = CollectivesWestend::account_id_of(BOB); - let bob_signed = ::RuntimeOrigin::signed( - bob.clone(), - ); - AssetHubWestend::execute_with(|| { - type Assets = ::Assets; - let is = >::mint_into(USDT_ID, &treasury_account, SPEND_AMOUNT * 4); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - match (&>::balance(USDT_ID, &alice), &0u128) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - CollectivesWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type FellowshipTreasury = ::FellowshipTreasury; - type AssetRate = ::AssetRate; - let is = AssetRate::create( - root.clone(), - Box::new(asset_kind.clone()), - 2.into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = FellowshipTreasury::spend( - root, - Box::new(asset_kind), - SPEND_AMOUNT, - Box::new( - Location::new(0, Into::<[u8; 32]>::into(alice.clone())).into(), - ), - None, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = FellowshipTreasury::payout(bob_signed.clone(), 0); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::FellowshipTreasury( - pallet_treasury::Event::Paid { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "CollectivesWestend", - "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::Paid { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "CollectivesWestend", - "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::Paid { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::CollectivesWestend", - "asset_hub_westend_integration_tests::tests::fellowship_treasury", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type Assets = ::Assets; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Transferred { - asset_id: id, - from, - to, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(id == &USDT_ID) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "id", - id, - "id == &USDT_ID", - ), - ); - res - }); - } - meet_conditions &= id == &USDT_ID; - if !(from == &treasury_account) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "from == &treasury_account", - ), - ); - res - }); - } - meet_conditions &= from == &treasury_account; - if !(to == &alice) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "to == &alice", - ), - ); - res - }); - } - meet_conditions &= to == &alice; - if !(amount == &SPEND_AMOUNT) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "amount == &SPEND_AMOUNT", - ), - ); - res - }); - } - meet_conditions &= amount == &SPEND_AMOUNT; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::XcmpQueue( - cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::fellowship_treasury", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - match ( - &>::balance(USDT_ID, &alice), - &SPEND_AMOUNT, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - CollectivesWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type FellowshipTreasury = ::FellowshipTreasury; - let is = FellowshipTreasury::check_status(bob_signed, 0); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::FellowshipTreasury( - pallet_treasury::Event::SpendProcessed { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "CollectivesWestend", - "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::SpendProcessed { ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "CollectivesWestend", - "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::SpendProcessed { ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::CollectivesWestend", - "asset_hub_westend_integration_tests::tests::fellowship_treasury", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - } - mod hybrid_transfers { - use super::reserve_transfer::*; - use crate::{ - imports::*, - tests::teleport::do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt, - }; - fn para_to_para_assethub_hop_assertions(t: ParaToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_penpal_a_on_ah = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - let sov_penpal_b_on_ah = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalB::para_id()), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_a_on_ah) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_a_on_ah", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_a_on_ah; - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_b_on_ah) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_b_on_ah", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_b_on_ah; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::hybrid_transfers", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn ah_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { - let fee_idx = t.args.fee_asset_item as usize; - let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); - let custom_xcm_on_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - beneficiary: t.args.beneficiary, - }, - ]), - ), - ); - ::PolkadotXcm::transfer_assets_using_type_and_then( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.assets.into()), - Box::new(TransferType::LocalReserve), - Box::new(fee.id.into()), - Box::new(TransferType::LocalReserve), - Box::new(VersionedXcm::from(custom_xcm_on_dest)), - t.args.weight_limit, - ) - } - fn para_to_ah_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult { - let fee_idx = t.args.fee_asset_item as usize; - let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); - let custom_xcm_on_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - beneficiary: t.args.beneficiary, - }, - ]), - ), - ); - ::PolkadotXcm::transfer_assets_using_type_and_then( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.assets.into()), - Box::new(TransferType::DestinationReserve), - Box::new(fee.id.into()), - Box::new(TransferType::DestinationReserve), - Box::new(VersionedXcm::from(custom_xcm_on_dest)), - t.args.weight_limit, - ) - } - fn para_to_para_transfer_assets_through_ah( - t: ParaToParaThroughAHTest, - ) -> DispatchResult { - let fee_idx = t.args.fee_asset_item as usize; - let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); - let asset_hub_location: Location = PenpalA::sibling_location_of( - AssetHubWestend::para_id(), - ); - let custom_xcm_on_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - beneficiary: t.args.beneficiary, - }, - ]), - ), - ); - ::PolkadotXcm::transfer_assets_using_type_and_then( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.assets.into()), - Box::new(TransferType::RemoteReserve(asset_hub_location.clone().into())), - Box::new(fee.id.into()), - Box::new(TransferType::RemoteReserve(asset_hub_location.into())), - Box::new(VersionedXcm::from(custom_xcm_on_dest)), - t.args.weight_limit, - ) - } - fn para_to_asset_hub_teleport_foreign_assets( - t: ParaToSystemParaTest, - ) -> DispatchResult { - let fee_idx = t.args.fee_asset_item as usize; - let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); - let custom_xcm_on_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - beneficiary: t.args.beneficiary, - }, - ]), - ), - ); - ::PolkadotXcm::transfer_assets_using_type_and_then( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.assets.into()), - Box::new(TransferType::Teleport), - Box::new(fee.id.into()), - Box::new(TransferType::DestinationReserve), - Box::new(VersionedXcm::from(custom_xcm_on_dest)), - t.args.weight_limit, - ) - } - fn asset_hub_to_para_teleport_foreign_assets( - t: SystemParaToParaTest, - ) -> DispatchResult { - let fee_idx = t.args.fee_asset_item as usize; - let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); - let custom_xcm_on_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - beneficiary: t.args.beneficiary, - }, - ]), - ), - ); - ::PolkadotXcm::transfer_assets_using_type_and_then( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.assets.into()), - Box::new(TransferType::Teleport), - Box::new(fee.id.into()), - Box::new(TransferType::LocalReserve), - Box::new(VersionedXcm::from(custom_xcm_on_dest)), - t.args.weight_limit, - ) - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::hybrid_transfers::transfer_foreign_assets_from_asset_hub_to_para"] - pub const transfer_foreign_assets_from_asset_hub_to_para: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::hybrid_transfers::transfer_foreign_assets_from_asset_hub_to_para", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", - start_line: 156usize, - start_col: 4usize, - end_line: 156usize, - end_col: 50usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - transfer_foreign_assets_from_asset_hub_to_para(), - ), - ), - }; - /// Transfers of native asset plus bridged asset from AssetHub to some Parachain - /// while paying fees using native asset. - fn transfer_foreign_assets_from_asset_hub_to_para() { - let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); - let sender = AssetHubWestendSender::get(); - let native_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let native_asset_location = RelayLocation::get(); - let receiver = PenpalAReceiver::get(); - let assets_owner = PenpalAssetOwner::get(); - let foreign_amount_to_send = ASSET_HUB_WESTEND_ED * 10_000_000; - let roc_at_westend_parachains = Location::new( - 2, - [Junction::GlobalConsensus(NetworkId::Rococo)], - ); - PenpalA::execute_with(|| { - let is = ::System::set_storage( - ::RuntimeOrigin::root(), - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), - Location::new(2, [GlobalConsensus(Rococo)]).encode(), - ), - ]), - ), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - PenpalA::force_create_foreign_asset( - roc_at_westend_parachains.clone(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - AssetHubWestend::force_create_foreign_asset( - roc_at_westend_parachains.clone().try_into().unwrap(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - AssetHubWestend::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner), - roc_at_westend_parachains.clone().try_into().unwrap(), - sender.clone(), - foreign_amount_to_send * 2, - ); - let assets: Vec = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (Parent, native_amount_to_send).into(), - (roc_at_westend_parachains.clone(), foreign_amount_to_send).into(), - ]), - ); - let fee_asset_id = AssetId(Parent.into()); - let fee_asset_item = assets - .iter() - .position(|a| a.id == fee_asset_id) - .unwrap() as u32; - let test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination.clone(), - receiver.clone(), - native_amount_to_send, - assets.into(), - None, - fee_asset_item, - ), - }; - let mut test = SystemParaToParaTest::new(test_args); - let sender_balance_before = test.sender.balance; - let sender_rocs_before = AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &sender, - ) - }); - let receiver_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location.clone(), &receiver) - }); - let receiver_rocs_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.clone(), &receiver) - }); - test.set_assertion::(system_para_to_para_sender_assertions); - test.set_assertion::(system_para_to_para_receiver_assertions); - test.set_dispatchable::(ah_to_para_transfer_assets); - test.assert(); - let sender_balance_after = test.sender.balance; - let sender_rocs_after = AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &sender, - ) - }); - let receiver_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location, &receiver) - }); - let receiver_rocs_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains, &receiver) - }); - if !(sender_balance_after < sender_balance_before - native_amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_balance_after < sender_balance_before - native_amount_to_send", - ) - } - match (&sender_rocs_after, &(sender_rocs_before - foreign_amount_to_send)) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(receiver_assets_after > receiver_assets_before) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after > receiver_assets_before", - ) - } - if !(receiver_assets_after < receiver_assets_before + native_amount_to_send) - { - ::core::panicking::panic( - "assertion failed: receiver_assets_after < receiver_assets_before + native_amount_to_send", - ) - } - match ( - &receiver_rocs_after, - &(receiver_rocs_before + foreign_amount_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_asset_hub"] - pub const transfer_foreign_assets_from_para_to_asset_hub: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_asset_hub", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", - start_line: 285usize, - start_col: 4usize, - end_line: 285usize, - end_col: 50usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - transfer_foreign_assets_from_para_to_asset_hub(), - ), - ), - }; - /// Reserve Transfers of native asset from Parachain to System Parachain should work - /// Transfers of native asset plus bridged asset from some Parachain to AssetHub - /// while paying fees using native asset. - fn transfer_foreign_assets_from_para_to_asset_hub() { - let destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()); - let sender = PenpalASender::get(); - let native_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 10000; - let native_asset_location = RelayLocation::get(); - let assets_owner = PenpalAssetOwner::get(); - let foreign_amount_to_send = ASSET_HUB_WESTEND_ED * 10_000_000; - let roc_at_westend_parachains = Location::new( - 2, - [Junction::GlobalConsensus(NetworkId::Rococo)], - ); - PenpalA::execute_with(|| { - let is = ::System::set_storage( - ::RuntimeOrigin::root(), - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), - Location::new(2, [GlobalConsensus(Rococo)]).encode(), - ), - ]), - ), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - PenpalA::force_create_foreign_asset( - roc_at_westend_parachains.clone(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - AssetHubWestend::force_create_foreign_asset( - roc_at_westend_parachains.clone().try_into().unwrap(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner.clone()), - native_asset_location.clone(), - sender.clone(), - native_amount_to_send * 2, - ); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner.clone()), - roc_at_westend_parachains.clone(), - sender.clone(), - foreign_amount_to_send * 2, - ); - let receiver = AssetHubWestendReceiver::get(); - let penpal_location_as_seen_by_ahr = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - penpal_location_as_seen_by_ahr, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_penpal_on_ahr.clone().into(), native_amount_to_send * 2), - ]), - ), - ); - AssetHubWestend::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner), - roc_at_westend_parachains.clone().try_into().unwrap(), - sov_penpal_on_ahr, - foreign_amount_to_send * 2, - ); - let assets: Vec = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (Parent, native_amount_to_send).into(), - (roc_at_westend_parachains.clone(), foreign_amount_to_send).into(), - ]), - ); - let fee_asset_id = AssetId(Parent.into()); - let fee_asset_item = assets - .iter() - .position(|a| a.id == fee_asset_id) - .unwrap() as u32; - let test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination.clone(), - receiver.clone(), - native_amount_to_send, - assets.into(), - None, - fee_asset_item, - ), - }; - let mut test = ParaToSystemParaTest::new(test_args); - let sender_native_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location.clone(), &sender) - }); - let sender_rocs_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.clone(), &sender) - }); - let receiver_native_before = test.receiver.balance; - let receiver_rocs_before = AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &receiver, - ) - }); - test.set_assertion::(para_to_system_para_sender_assertions); - test.set_assertion::< - AssetHubWestend, - >(para_to_system_para_receiver_assertions); - test.set_dispatchable::(para_to_ah_transfer_assets); - test.assert(); - let sender_native_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location, &sender) - }); - let sender_rocs_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.clone(), &sender) - }); - let receiver_native_after = test.receiver.balance; - let receiver_rocs_after = AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.try_into().unwrap(), &receiver) - }); - if !(sender_native_after < sender_native_before - native_amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_native_after < sender_native_before - native_amount_to_send", - ) - } - match (&sender_rocs_after, &(sender_rocs_before - foreign_amount_to_send)) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(receiver_native_after > receiver_native_before) { - ::core::panicking::panic( - "assertion failed: receiver_native_after > receiver_native_before", - ) - } - if !(receiver_native_after < receiver_native_before + native_amount_to_send) - { - ::core::panicking::panic( - "assertion failed: receiver_native_after < receiver_native_before + native_amount_to_send", - ) - } - match ( - &receiver_rocs_after, - &(receiver_rocs_before + foreign_amount_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_para_through_asset_hub"] - pub const transfer_foreign_assets_from_para_to_para_through_asset_hub: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_para_through_asset_hub", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", - start_line: 440usize, - start_col: 4usize, - end_line: 440usize, - end_col: 63usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - transfer_foreign_assets_from_para_to_para_through_asset_hub(), - ), - ), - }; - /// Transfers of native asset plus bridged asset from Parachain to Parachain - /// (through AssetHub reserve) with fees paid using native asset. - fn transfer_foreign_assets_from_para_to_para_through_asset_hub() { - let destination = PenpalA::sibling_location_of(PenpalB::para_id()); - let sender = PenpalASender::get(); - let wnd_to_send: Balance = WESTEND_ED * 10000; - let assets_owner = PenpalAssetOwner::get(); - let wnd_location = RelayLocation::get(); - let sender_as_seen_by_ah = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_of_sender_on_ah = AssetHubWestend::sovereign_account_id_of( - sender_as_seen_by_ah, - ); - let receiver_as_seen_by_ah = AssetHubWestend::sibling_location_of( - PenpalB::para_id(), - ); - let sov_of_receiver_on_ah = AssetHubWestend::sovereign_account_id_of( - receiver_as_seen_by_ah, - ); - let roc_to_send = ASSET_HUB_WESTEND_ED * 10_000_000; - PenpalB::execute_with(|| { - let is = ::System::set_storage( - ::RuntimeOrigin::root(), - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), - Location::new(2, [GlobalConsensus(Rococo)]).encode(), - ), - ]), - ), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - let roc_at_westend_parachains = Location::new( - 2, - [Junction::GlobalConsensus(NetworkId::Rococo)], - ); - AssetHubWestend::force_create_foreign_asset( - roc_at_westend_parachains.clone().try_into().unwrap(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - PenpalA::force_create_foreign_asset( - roc_at_westend_parachains.clone(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - PenpalB::force_create_foreign_asset( - roc_at_westend_parachains.clone(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner.clone()), - wnd_location.clone(), - sender.clone(), - wnd_to_send * 2, - ); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner.clone()), - roc_at_westend_parachains.clone(), - sender.clone(), - roc_to_send * 2, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_of_sender_on_ah.clone().into(), wnd_to_send * 2), - ]), - ), - ); - AssetHubWestend::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner), - roc_at_westend_parachains.clone().try_into().unwrap(), - sov_of_sender_on_ah.clone(), - roc_to_send * 2, - ); - let receiver = PenpalBReceiver::get(); - let assets: Vec = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (wnd_location.clone(), wnd_to_send).into(), - (roc_at_westend_parachains.clone(), roc_to_send).into(), - ]), - ); - let fee_asset_id: AssetId = wnd_location.clone().into(); - let fee_asset_item = assets - .iter() - .position(|a| a.id == fee_asset_id) - .unwrap() as u32; - let test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination, - receiver.clone(), - wnd_to_send, - assets.into(), - None, - fee_asset_item, - ), - }; - let mut test = ParaToParaThroughAHTest::new(test_args); - let sender_wnds_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(wnd_location.clone(), &sender) - }); - let sender_rocs_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.clone(), &sender) - }); - let wnds_in_sender_reserve_on_ah_before = ::account_data_of( - sov_of_sender_on_ah.clone(), - ) - .free; - let rocs_in_sender_reserve_on_ah_before = AssetHubWestend::execute_with(|| { - type Assets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &sov_of_sender_on_ah, - ) - }); - let wnds_in_receiver_reserve_on_ah_before = ::account_data_of( - sov_of_receiver_on_ah.clone(), - ) - .free; - let rocs_in_receiver_reserve_on_ah_before = AssetHubWestend::execute_with(|| { - type Assets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &sov_of_receiver_on_ah, - ) - }); - let receiver_wnds_before = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(wnd_location.clone(), &receiver) - }); - let receiver_rocs_before = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.clone(), &receiver) - }); - test.set_assertion::(para_to_para_through_hop_sender_assertions); - test.set_assertion::(para_to_para_assethub_hop_assertions); - test.set_assertion::(para_to_para_through_hop_receiver_assertions); - test.set_dispatchable::(para_to_para_transfer_assets_through_ah); - test.assert(); - let sender_wnds_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(wnd_location.clone(), &sender) - }); - let sender_rocs_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.clone(), &sender) - }); - let rocs_in_sender_reserve_on_ah_after = AssetHubWestend::execute_with(|| { - type Assets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &sov_of_sender_on_ah, - ) - }); - let wnds_in_sender_reserve_on_ah_after = ::account_data_of( - sov_of_sender_on_ah, - ) - .free; - let rocs_in_receiver_reserve_on_ah_after = AssetHubWestend::execute_with(|| { - type Assets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &sov_of_receiver_on_ah, - ) - }); - let wnds_in_receiver_reserve_on_ah_after = ::account_data_of( - sov_of_receiver_on_ah, - ) - .free; - let receiver_wnds_after = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(wnd_location, &receiver) - }); - let receiver_rocs_after = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains, &receiver) - }); - if !(sender_wnds_after < sender_wnds_before - wnd_to_send) { - ::core::panicking::panic( - "assertion failed: sender_wnds_after < sender_wnds_before - wnd_to_send", - ) - } - match (&sender_rocs_after, &(sender_rocs_before - roc_to_send)) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &wnds_in_sender_reserve_on_ah_after, - &(wnds_in_sender_reserve_on_ah_before - wnd_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &rocs_in_sender_reserve_on_ah_after, - &(rocs_in_sender_reserve_on_ah_before - roc_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(wnds_in_receiver_reserve_on_ah_after - > wnds_in_receiver_reserve_on_ah_before) - { - ::core::panicking::panic( - "assertion failed: wnds_in_receiver_reserve_on_ah_after > wnds_in_receiver_reserve_on_ah_before", - ) - } - match ( - &rocs_in_receiver_reserve_on_ah_after, - &(rocs_in_receiver_reserve_on_ah_before + roc_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(receiver_wnds_after > receiver_wnds_before) { - ::core::panicking::panic( - "assertion failed: receiver_wnds_after > receiver_wnds_before", - ) - } - match (&receiver_rocs_after, &(receiver_rocs_before + roc_to_send)) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::hybrid_transfers::bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types"] - pub const bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::hybrid_transfers::bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", - start_line: 644usize, - start_col: 4usize, - end_line: 644usize, - end_col: 97usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types(), - ), - ), - }; - /// Transfers of native asset plus teleportable foreign asset from Parachain to AssetHub and back - /// with fees paid using native asset. - fn bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types() { - do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt( - para_to_asset_hub_teleport_foreign_assets, - asset_hub_to_para_teleport_foreign_assets, - ); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::hybrid_transfers::transfer_native_asset_from_relay_to_para_through_asset_hub"] - pub const transfer_native_asset_from_relay_to_para_through_asset_hub: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::hybrid_transfers::transfer_native_asset_from_relay_to_para_through_asset_hub", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", - start_line: 658usize, - start_col: 4usize, - end_line: 658usize, - end_col: 62usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - transfer_native_asset_from_relay_to_para_through_asset_hub(), - ), - ), - }; - /// Transfers of native asset Relay to Parachain (using AssetHub reserve). Parachains want to avoid - /// managing SAs on all system chains, thus want all their DOT-in-reserve to be held in their - /// Sovereign Account on Asset Hub. - fn transfer_native_asset_from_relay_to_para_through_asset_hub() { - let destination = Westend::child_location_of(PenpalA::para_id()); - let sender = WestendSender::get(); - let amount_to_send: Balance = WESTEND_ED * 1000; - let relay_native_asset_location = RelayLocation::get(); - let receiver = PenpalAReceiver::get(); - let test_args = TestContext { - sender, - receiver: receiver.clone(), - args: TestArgs::new_relay( - destination.clone(), - receiver.clone(), - amount_to_send, - ), - }; - let mut test = RelayToParaThroughAHTest::new(test_args); - let sov_penpal_on_ah = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - let sender_balance_before = test.sender.balance; - let sov_penpal_on_ah_before = AssetHubWestend::execute_with(|| { - ::Balances::free_balance( - sov_penpal_on_ah.clone(), - ) - }); - let receiver_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &receiver) - }); - fn relay_assertions(t: RelayToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - Westend::assert_xcm_pallet_attempted_complete(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == t.sender.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *who == t.sender.account_id; - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who - == ::XcmPallet::check_account()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == ::XcmPallet::check_account()", - ), - ); - res - }); - } - meet_conditions - &= *who - == ::XcmPallet::check_account(); - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::hybrid_transfers", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn asset_hub_assertions(_: RelayToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_penpal_on_ah = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_on_ah) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_on_ah", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_on_ah; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::hybrid_transfers", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn penpal_assertions(t: RelayToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - let expected_id = t - .args - .assets - .into_inner() - .first() - .unwrap() - .id - .0 - .clone() - .try_into() - .unwrap(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == t.receiver.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::hybrid_transfers", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn transfer_assets_dispatchable( - t: RelayToParaThroughAHTest, - ) -> DispatchResult { - let fee_idx = t.args.fee_asset_item as usize; - let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); - let asset_hub_location = Westend::child_location_of( - AssetHubWestend::para_id(), - ); - let context = WestendUniversalLocation::get(); - let mut remote_fees = fee - .clone() - .reanchored(&t.args.dest, &context) - .unwrap(); - if let Fungible(ref mut amount) = remote_fees.fun { - *amount = *amount / 2; - } - let xcm_on_final_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - BuyExecution { - fees: remote_fees, - weight_limit: t.args.weight_limit.clone(), - }, - DepositAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - beneficiary: t.args.beneficiary, - }, - ]), - ), - ); - let mut dest = t.args.dest.clone(); - dest.reanchor(&asset_hub_location, &context).unwrap(); - let xcm_on_hop = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositReserveAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - dest, - xcm: xcm_on_final_dest, - }, - ]), - ), - ); - ::XcmPallet::transfer_assets_using_type_and_then( - t.signed_origin, - Box::new(asset_hub_location.into()), - Box::new(t.args.assets.into()), - Box::new(TransferType::Teleport), - Box::new(fee.id.into()), - Box::new(TransferType::Teleport), - Box::new(VersionedXcm::from(xcm_on_hop)), - t.args.weight_limit, - ) - } - test.set_assertion::(relay_assertions); - test.set_assertion::(asset_hub_assertions); - test.set_assertion::(penpal_assertions); - test.set_dispatchable::(transfer_assets_dispatchable); - test.assert(); - let sender_balance_after = test.sender.balance; - let sov_penpal_on_ah_after = AssetHubWestend::execute_with(|| { - ::Balances::free_balance( - sov_penpal_on_ah, - ) - }); - let receiver_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location, &receiver) - }); - if !(sender_balance_after < sender_balance_before - amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_balance_after < sender_balance_before - amount_to_send", - ) - } - if !(sov_penpal_on_ah_after > sov_penpal_on_ah_before) { - ::core::panicking::panic( - "assertion failed: sov_penpal_on_ah_after > sov_penpal_on_ah_before", - ) - } - if !(receiver_assets_after > receiver_assets_before) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after > receiver_assets_before", - ) - } - if !(receiver_assets_after < receiver_assets_before + amount_to_send) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after < receiver_assets_before + amount_to_send", - ) - } - } - } - mod reserve_transfer { - use crate::imports::*; - fn relay_to_para_sender_assertions(t: RelayToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - Westend::assert_xcm_pallet_attempted_complete( - Some(Weight::from_parts(864_610_000, 8_799)), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from, to, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*from == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "*from == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *from == t.sender.account_id; - if !(*to - == Westend::sovereign_account_id_of(t.args.dest.clone())) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "*to == Westend::sovereign_account_id_of(t.args.dest.clone())", - ), - ); - res - }); - } - meet_conditions - &= *to - == Westend::sovereign_account_id_of(t.args.dest.clone()); - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn para_to_relay_sender_assertions(t: ParaToRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - PenpalA::assert_xcm_pallet_attempted_complete( - Some(Weight::from_parts(864_610_000, 8_799)), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == RelayLocation::get()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == RelayLocation::get()", - ), - ); - res - }); - } - meet_conditions &= *asset_id == RelayLocation::get(); - if !(*owner == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if !(*balance == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *balance == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - pub fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcm_pallet_attempted_complete(None); - let sov_acc_of_dest = AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - ); - for (idx, asset) in t.args.assets.into_inner().into_iter().enumerate() { - let expected_id = asset.id.0.clone().try_into().unwrap(); - let asset_amount = if let Fungible(a) = asset.fun { - Some(a) - } else { - None - } - .unwrap(); - if idx == t.args.fee_asset_item as usize { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from, to, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*from == t.sender.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "*from == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *from == t.sender.account_id; - if !(*to == sov_acc_of_dest) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "*to == sov_acc_of_dest", - ), - ); - res - }); - } - meet_conditions &= *to == sov_acc_of_dest; - if !(*amount == asset_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } else { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Transferred { - asset_id, - from, - to, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*from == t.sender.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "*from == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *from == t.sender.account_id; - if !(*to == sov_acc_of_dest) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "*to == sov_acc_of_dest", - ), - ); - res - }); - } - meet_conditions &= *to == sov_acc_of_dest; - if !(*amount == asset_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - } - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. }) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - AssetHubWestend::assert_xcm_pallet_sent(); - } - pub fn system_para_to_para_receiver_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - PenpalA::assert_xcmp_queue_success(None); - for asset in t.args.assets.into_inner().into_iter() { - let expected_id = asset.id.0.try_into().unwrap(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == t.receiver.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - } - pub fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - PenpalA::assert_xcm_pallet_attempted_complete(None); - for asset in t.args.assets.into_inner().into_iter() { - let expected_id = asset.id.0; - let asset_amount = if let Fungible(a) = asset.fun { - Some(a) - } else { - None - } - .unwrap(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == t.sender.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if !(*balance == asset_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == asset_amount", - ), - ); - res - }); - } - meet_conditions &= *balance == asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - } - fn para_to_relay_receiver_assertions(t: ParaToRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_penpal_on_relay = Westend::sovereign_account_id_of( - Westend::child_location_of(PenpalA::para_id()), - ); - Westend::assert_ump_queue_processed( - true, - Some(PenpalA::para_id()), - Some(Weight::from_parts(306305000, 7_186)), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_on_relay.clone().into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_on_relay.clone().into()", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_on_relay.clone().into(); - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances(pallet_balances::Event::Minted { .. }) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - pub fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcmp_queue_success(None); - let sov_acc_of_penpal = AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - ); - for (idx, asset) in t.args.assets.into_inner().into_iter().enumerate() { - let expected_id = asset.id.0.clone().try_into().unwrap(); - let asset_amount = if let Fungible(a) = asset.fun { - Some(a) - } else { - None - } - .unwrap(); - if idx == t.args.fee_asset_item as usize { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_acc_of_penpal.clone().into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_acc_of_penpal.clone().into()", - ), - ); - res - }); - } - meet_conditions &= *who == sov_acc_of_penpal.clone().into(); - if !(*amount == asset_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == t.receiver.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *who == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } else { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == sov_acc_of_penpal) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == sov_acc_of_penpal", - ), - ); - res - }); - } - meet_conditions &= *owner == sov_acc_of_penpal; - if !(*balance == asset_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == asset_amount", - ), - ); - res - }); - } - meet_conditions &= *balance == asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == t.receiver.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if !(*amount == asset_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - } - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcm_pallet_attempted_complete( - Some(Weight::from_parts(864_610_000, 8799)), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Transferred { asset_id, from, to, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == RESERVABLE_ASSET_ID) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == RESERVABLE_ASSET_ID", - ), - ); - res - }); - } - meet_conditions &= *asset_id == RESERVABLE_ASSET_ID; - if !(*from == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "*from == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *from == t.sender.account_id; - if !(*to - == AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - )) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "*to == AssetHubWestend::sovereign_account_id_of(t.args.dest.clone())", - ), - ); - res - }); - } - meet_conditions - &= *to - == AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - ); - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who - == AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - )) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == AssetHubWestend::sovereign_account_id_of(t.args.dest.clone())", - ), - ); - res - }); - } - meet_conditions - &= *who - == AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - ); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. }) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn para_to_system_para_assets_sender_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let system_para_native_asset_location = RelayLocation::get(); - let reservable_asset_location = PenpalLocalReservableFromAssetHub::get(); - PenpalA::assert_xcm_pallet_attempted_complete( - Some(Weight::from_parts(864_610_000, 8799)), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == system_para_native_asset_location) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == system_para_native_asset_location", - ), - ); - res - }); - } - meet_conditions - &= *asset_id == system_para_native_asset_location; - if !(*owner == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == reservable_asset_location) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == reservable_asset_location", - ), - ); - res - }); - } - meet_conditions &= *asset_id == reservable_asset_location; - if !(*owner == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if !(*balance == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *balance == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. }) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn system_para_to_para_assets_receiver_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let system_para_asset_location = PenpalLocalReservableFromAssetHub::get(); - PenpalA::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == RelayLocation::get()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == RelayLocation::get()", - ), - ); - res - }); - } - meet_conditions &= *asset_id == RelayLocation::get(); - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == system_para_asset_location) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == system_para_asset_location", - ), - ); - res - }); - } - meet_conditions &= *asset_id == system_para_asset_location; - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn para_to_system_para_assets_receiver_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - AssetHubWestend::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == RESERVABLE_ASSET_ID) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == RESERVABLE_ASSET_ID", - ), - ); - res - }); - } - meet_conditions &= *asset_id == RESERVABLE_ASSET_ID; - if !(*owner == sov_penpal_on_ahr) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == sov_penpal_on_ahr", - ), - ); - res - }); - } - meet_conditions &= *owner == sov_penpal_on_ahr; - if !(*balance == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *balance == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_on_ahr) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_on_ahr", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_on_ahr; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Issued { asset_id, owner, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == RESERVABLE_ASSET_ID) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == RESERVABLE_ASSET_ID", - ), - ); - res - }); - } - meet_conditions &= *asset_id == RESERVABLE_ASSET_ID; - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == t.receiver.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *who == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn relay_to_para_assets_receiver_assertions(t: RelayToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == RelayLocation::get()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == RelayLocation::get()", - ), - ); - res - }); - } - meet_conditions &= *asset_id == RelayLocation::get(); - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - pub fn para_to_para_through_hop_sender_assertions( - t: Test, - ) { - type RuntimeEvent = ::RuntimeEvent; - PenpalA::assert_xcm_pallet_attempted_complete(None); - for asset in t.args.assets.into_inner() { - let expected_id = asset.id.0.clone().try_into().unwrap(); - let amount = if let Fungible(a) = asset.fun { Some(a) } else { None } - .unwrap(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == t.sender.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if !(*balance == amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == amount", - ), - ); - res - }); - } - meet_conditions &= *balance == amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - } - fn para_to_para_relay_hop_assertions(t: ParaToParaThroughRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_penpal_a_on_westend = Westend::sovereign_account_id_of( - Westend::child_location_of(PenpalA::para_id()), - ); - let sov_penpal_b_on_westend = Westend::sovereign_account_id_of( - Westend::child_location_of(PenpalB::para_id()), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_a_on_westend) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_a_on_westend", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_a_on_westend; - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_b_on_westend) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_b_on_westend", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_b_on_westend; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - pub fn para_to_para_through_hop_receiver_assertions( - t: Test, - ) { - type RuntimeEvent = ::RuntimeEvent; - PenpalB::assert_xcmp_queue_success(None); - for asset in t.args.assets.into_inner().into_iter() { - let expected_id = asset.id.0.try_into().unwrap(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == t.receiver.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalB", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalB", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalB", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - } - fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { - ::XcmPallet::limited_reserve_transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - fn para_to_relay_reserve_transfer_assets(t: ParaToRelayTest) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - fn system_para_to_para_reserve_transfer_assets( - t: SystemParaToParaTest, - ) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - fn para_to_system_para_reserve_transfer_assets( - t: ParaToSystemParaTest, - ) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - fn para_to_para_through_relay_limited_reserve_transfer_assets( - t: ParaToParaThroughRelayTest, - ) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_asset_hub_fails"] - pub const reserve_transfer_native_asset_from_relay_to_asset_hub_fails: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_asset_hub_fails", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 498usize, - start_col: 4usize, - end_line: 498usize, - end_col: 63usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_relay_to_asset_hub_fails(), - ), - ), - }; - /// Reserve Transfers of native asset from Relay Chain to the Asset Hub shouldn't work - fn reserve_transfer_native_asset_from_relay_to_asset_hub_fails() { - let signed_origin = ::RuntimeOrigin::signed( - WestendSender::get().into(), - ); - let destination = Westend::child_location_of(AssetHubWestend::para_id()); - let beneficiary: Location = AccountId32Junction { - network: None, - id: AssetHubWestendReceiver::get().into(), - } - .into(); - let amount_to_send: Balance = WESTEND_ED * 1000; - let assets: Assets = (Here, amount_to_send).into(); - let fee_asset_item = 0; - Westend::execute_with(|| { - let result = ::XcmPallet::limited_reserve_transfer_assets( - signed_origin, - Box::new(destination.into()), - Box::new(beneficiary.into()), - Box::new(assets.into()), - fee_asset_item, - WeightLimit::Unlimited, - ); - match ( - &result, - &Err( - DispatchError::Module(sp_runtime::ModuleError { - index: 99, - error: [2, 0, 0, 0], - message: Some("Filtered"), - }) - .into(), - ), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_relay_fails"] - pub const reserve_transfer_native_asset_from_asset_hub_to_relay_fails: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_relay_fails", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 531usize, - start_col: 4usize, - end_line: 531usize, - end_col: 63usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_asset_hub_to_relay_fails(), - ), - ), - }; - /// Reserve Transfers of native asset from Asset Hub to Relay Chain shouldn't work - fn reserve_transfer_native_asset_from_asset_hub_to_relay_fails() { - let signed_origin = ::RuntimeOrigin::signed( - AssetHubWestendSender::get().into(), - ); - let destination = AssetHubWestend::parent_location(); - let beneficiary_id = WestendReceiver::get(); - let beneficiary: Location = AccountId32Junction { - network: None, - id: beneficiary_id.into(), - } - .into(); - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let assets: Assets = (Parent, amount_to_send).into(); - let fee_asset_item = 0; - AssetHubWestend::execute_with(|| { - let result = ::PolkadotXcm::limited_reserve_transfer_assets( - signed_origin, - Box::new(destination.into()), - Box::new(beneficiary.into()), - Box::new(assets.into()), - fee_asset_item, - WeightLimit::Unlimited, - ); - match ( - &result, - &Err( - DispatchError::Module(sp_runtime::ModuleError { - index: 31, - error: [2, 0, 0, 0], - message: Some("Filtered"), - }) - .into(), - ), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_para"] - pub const reserve_transfer_native_asset_from_relay_to_para: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_para", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 571usize, - start_col: 4usize, - end_line: 571usize, - end_col: 52usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_relay_to_para(), - ), - ), - }; - /// Reserve Transfers of native asset from Relay to Parachain should work - fn reserve_transfer_native_asset_from_relay_to_para() { - let destination = Westend::child_location_of(PenpalA::para_id()); - let sender = WestendSender::get(); - let amount_to_send: Balance = WESTEND_ED * 1000; - let relay_native_asset_location = RelayLocation::get(); - let receiver = PenpalAReceiver::get(); - let test_args = TestContext { - sender, - receiver: receiver.clone(), - args: TestArgs::new_relay( - destination.clone(), - receiver.clone(), - amount_to_send, - ), - }; - let mut test = RelayToParaTest::new(test_args); - let sender_balance_before = test.sender.balance; - let receiver_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &receiver) - }); - test.set_assertion::(relay_to_para_sender_assertions); - test.set_assertion::(relay_to_para_assets_receiver_assertions); - test.set_dispatchable::(relay_to_para_reserve_transfer_assets); - test.assert(); - let sender_balance_after = test.sender.balance; - let receiver_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location, &receiver) - }); - if !(sender_balance_after < sender_balance_before - amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_balance_after < sender_balance_before - amount_to_send", - ) - } - if !(receiver_assets_after > receiver_assets_before) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after > receiver_assets_before", - ) - } - if !(receiver_assets_after < receiver_assets_before + amount_to_send) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after < receiver_assets_before + amount_to_send", - ) - } - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_relay"] - pub const reserve_transfer_native_asset_from_para_to_relay: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_relay", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 621usize, - start_col: 4usize, - end_line: 621usize, - end_col: 52usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_para_to_relay(), - ), - ), - }; - /// Reserve Transfers of native asset from Parachain to Relay should work - fn reserve_transfer_native_asset_from_para_to_relay() { - let destination = PenpalA::parent_location(); - let sender = PenpalASender::get(); - let amount_to_send: Balance = WESTEND_ED * 1000; - let assets: Assets = (Parent, amount_to_send).into(); - let asset_owner = PenpalAssetOwner::get(); - let relay_native_asset_location = RelayLocation::get(); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - relay_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); - let receiver = WestendReceiver::get(); - let penpal_location_as_seen_by_relay = Westend::child_location_of( - PenpalA::para_id(), - ); - let sov_penpal_on_relay = Westend::sovereign_account_id_of( - penpal_location_as_seen_by_relay, - ); - Westend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_penpal_on_relay.into(), amount_to_send * 2), - ]), - ), - ); - let test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination.clone(), - receiver, - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let mut test = ParaToRelayTest::new(test_args); - let sender_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &sender) - }); - let receiver_balance_before = test.receiver.balance; - test.set_assertion::(para_to_relay_sender_assertions); - test.set_assertion::(para_to_relay_receiver_assertions); - test.set_dispatchable::(para_to_relay_reserve_transfer_assets); - test.assert(); - let sender_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location, &sender) - }); - let receiver_balance_after = test.receiver.balance; - if !(sender_assets_after < sender_assets_before - amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_assets_after < sender_assets_before - amount_to_send", - ) - } - if !(receiver_balance_after > receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: receiver_balance_after > receiver_balance_before", - ) - } - if !(receiver_balance_after < receiver_balance_before + amount_to_send) { - ::core::panicking::panic( - "assertion failed: receiver_balance_after < receiver_balance_before + amount_to_send", - ) - } - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_para"] - pub const reserve_transfer_native_asset_from_asset_hub_to_para: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_para", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 696usize, - start_col: 4usize, - end_line: 696usize, - end_col: 56usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_asset_hub_to_para(), - ), - ), - }; - /// Reserve Transfers of native asset from Asset Hub to Parachain should work - fn reserve_transfer_native_asset_from_asset_hub_to_para() { - let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); - let sender = AssetHubWestendSender::get(); - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 2000; - let assets: Assets = (Parent, amount_to_send).into(); - let system_para_native_asset_location = RelayLocation::get(); - let receiver = PenpalAReceiver::get(); - let test_args = TestContext { - sender, - receiver: receiver.clone(), - args: TestArgs::new_para( - destination.clone(), - receiver.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let mut test = SystemParaToParaTest::new(test_args); - let sender_balance_before = test.sender.balance; - let receiver_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location.clone(), &receiver) - }); - test.set_assertion::(system_para_to_para_sender_assertions); - test.set_assertion::(system_para_to_para_receiver_assertions); - test.set_dispatchable::< - AssetHubWestend, - >(system_para_to_para_reserve_transfer_assets); - test.assert(); - let sender_balance_after = test.sender.balance; - let receiver_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location, &receiver) - }); - if !(sender_balance_after < sender_balance_before - amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_balance_after < sender_balance_before - amount_to_send", - ) - } - if !(receiver_assets_after > receiver_assets_before) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after > receiver_assets_before", - ) - } - if !(receiver_assets_after < receiver_assets_before + amount_to_send) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after < receiver_assets_before + amount_to_send", - ) - } - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_asset_hub"] - pub const reserve_transfer_native_asset_from_para_to_asset_hub: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_asset_hub", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 754usize, - start_col: 4usize, - end_line: 754usize, - end_col: 56usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_para_to_asset_hub(), - ), - ), - }; - /// Reserve Transfers of native asset from Parachain to Asset Hub should work - fn reserve_transfer_native_asset_from_para_to_asset_hub() { - let destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()); - let sender = PenpalASender::get(); - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let assets: Assets = (Parent, amount_to_send).into(); - let system_para_native_asset_location = RelayLocation::get(); - let asset_owner = PenpalAssetOwner::get(); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - system_para_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); - let receiver = AssetHubWestendReceiver::get(); - let penpal_location_as_seen_by_ahr = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - penpal_location_as_seen_by_ahr, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_penpal_on_ahr.into(), amount_to_send * 2), - ]), - ), - ); - let test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination.clone(), - receiver.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let mut test = ParaToSystemParaTest::new(test_args); - let sender_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location.clone(), &sender) - }); - let receiver_balance_before = test.receiver.balance; - test.set_assertion::(para_to_system_para_sender_assertions); - test.set_assertion::< - AssetHubWestend, - >(para_to_system_para_receiver_assertions); - test.set_dispatchable::< - PenpalA, - >(para_to_system_para_reserve_transfer_assets); - test.assert(); - let sender_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location, &sender) - }); - let receiver_balance_after = test.receiver.balance; - if !(sender_assets_after < sender_assets_before - amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_assets_after < sender_assets_before - amount_to_send", - ) - } - if !(receiver_balance_after > receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: receiver_balance_after > receiver_balance_before", - ) - } - if !(receiver_balance_after < receiver_balance_before + amount_to_send) { - ::core::panicking::panic( - "assertion failed: receiver_balance_after < receiver_balance_before + amount_to_send", - ) - } - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_multiple_assets_from_asset_hub_to_para"] - pub const reserve_transfer_multiple_assets_from_asset_hub_to_para: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_multiple_assets_from_asset_hub_to_para", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 831usize, - start_col: 4usize, - end_line: 831usize, - end_col: 59usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_multiple_assets_from_asset_hub_to_para(), - ), - ), - }; - /// Reserve Transfers of a local asset and native asset from Asset Hub to Parachain should - /// work - fn reserve_transfer_multiple_assets_from_asset_hub_to_para() { - let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - destination.clone(), - ); - let sender = AssetHubWestendSender::get(); - let fee_amount_to_send = ASSET_HUB_WESTEND_ED * 100; - let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100; - let asset_owner = AssetHubWestendAssetOwner::get(); - let asset_owner_signer = ::RuntimeOrigin::signed( - asset_owner.clone(), - ); - let assets: Assets = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (Parent, fee_amount_to_send).into(), - ( - [ - PalletInstance(ASSETS_PALLET_ID), - GeneralIndex(RESERVABLE_ASSET_ID.into()), - ], - asset_amount_to_send, - ) - .into(), - ]), - ) - .into(); - let fee_asset_index = assets - .inner() - .iter() - .position(|r| r == &(Parent, fee_amount_to_send).into()) - .unwrap() as u32; - AssetHubWestend::mint_asset( - asset_owner_signer, - RESERVABLE_ASSET_ID, - asset_owner, - asset_amount_to_send * 2, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_penpal_on_ahr.into(), ASSET_HUB_WESTEND_ED), - ]), - ), - ); - let receiver = PenpalAReceiver::get(); - let system_para_native_asset_location = RelayLocation::get(); - let system_para_foreign_asset_location = PenpalLocalReservableFromAssetHub::get(); - let para_test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination, - receiver.clone(), - asset_amount_to_send, - assets, - None, - fee_asset_index, - ), - }; - let mut test = SystemParaToParaTest::new(para_test_args); - let sender_balance_before = test.sender.balance; - let sender_assets_before = AssetHubWestend::execute_with(|| { - type Assets = ::Assets; - >::balance(RESERVABLE_ASSET_ID, &sender) - }); - let receiver_system_native_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location.clone(), &receiver) - }); - let receiver_foreign_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_foreign_asset_location.clone(), &receiver) - }); - test.set_assertion::< - AssetHubWestend, - >(system_para_to_para_assets_sender_assertions); - test.set_assertion::< - PenpalA, - >(system_para_to_para_assets_receiver_assertions); - test.set_dispatchable::< - AssetHubWestend, - >(system_para_to_para_reserve_transfer_assets); - test.assert(); - let sender_balance_after = test.sender.balance; - let sender_assets_after = AssetHubWestend::execute_with(|| { - type Assets = ::Assets; - >::balance(RESERVABLE_ASSET_ID, &sender) - }); - let receiver_system_native_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location, &receiver) - }); - let receiver_foreign_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_foreign_asset_location, &receiver) - }); - if !(sender_balance_after < sender_balance_before) { - ::core::panicking::panic( - "assertion failed: sender_balance_after < sender_balance_before", - ) - } - if !(receiver_foreign_assets_after > receiver_foreign_assets_before) { - ::core::panicking::panic( - "assertion failed: receiver_foreign_assets_after > receiver_foreign_assets_before", - ) - } - if !(receiver_system_native_assets_after - < receiver_system_native_assets_before + fee_amount_to_send) - { - ::core::panicking::panic( - "assertion failed: receiver_system_native_assets_after <\n receiver_system_native_assets_before + fee_amount_to_send", - ) - } - match ( - &(sender_assets_before - asset_amount_to_send), - &sender_assets_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &receiver_foreign_assets_after, - &(receiver_foreign_assets_before + asset_amount_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_multiple_assets_from_para_to_asset_hub"] - pub const reserve_transfer_multiple_assets_from_para_to_asset_hub: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_multiple_assets_from_para_to_asset_hub", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 948usize, - start_col: 4usize, - end_line: 948usize, - end_col: 59usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_multiple_assets_from_para_to_asset_hub(), - ), - ), - }; - /// Reserve Transfers of a random asset and native asset from Parachain to Asset Hub should work - /// Receiver is empty account to show deposit works as long as transfer includes enough DOT for ED. - /// Once we have https://github.com/paritytech/polkadot-sdk/issues/5298, - /// we should do equivalent test with USDT instead of DOT. - fn reserve_transfer_multiple_assets_from_para_to_asset_hub() { - let destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()); - let sender = PenpalASender::get(); - let fee_amount_to_send = ASSET_HUB_WESTEND_ED * 100; - let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100; - let penpal_asset_owner = PenpalAssetOwner::get(); - let penpal_asset_owner_signer = ::RuntimeOrigin::signed( - penpal_asset_owner, - ); - let asset_location_on_penpal = PenpalLocalReservableFromAssetHub::get(); - let system_asset_location_on_penpal = RelayLocation::get(); - let assets: Assets = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (Parent, fee_amount_to_send).into(), - (asset_location_on_penpal.clone(), asset_amount_to_send).into(), - ]), - ) - .into(); - let fee_asset_index = assets - .inner() - .iter() - .position(|r| r == &(Parent, fee_amount_to_send).into()) - .unwrap() as u32; - PenpalA::mint_foreign_asset( - penpal_asset_owner_signer.clone(), - asset_location_on_penpal.clone(), - sender.clone(), - asset_amount_to_send * 2, - ); - PenpalA::mint_foreign_asset( - penpal_asset_owner_signer, - system_asset_location_on_penpal.clone(), - sender.clone(), - fee_amount_to_send * 2, - ); - let receiver = get_account_id_from_seed::< - sp_runtime::testing::sr25519::Public, - >(DUMMY_EMPTY); - let penpal_location_as_seen_by_ahr = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - penpal_location_as_seen_by_ahr, - ); - let ah_asset_owner = AssetHubWestendAssetOwner::get(); - let ah_asset_owner_signer = ::RuntimeOrigin::signed( - ah_asset_owner, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_penpal_on_ahr.clone().into(), ASSET_HUB_WESTEND_ED * 1000), - ]), - ), - ); - AssetHubWestend::mint_asset( - ah_asset_owner_signer, - RESERVABLE_ASSET_ID, - sov_penpal_on_ahr, - asset_amount_to_send * 2, - ); - let para_test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination, - receiver.clone(), - asset_amount_to_send, - assets, - None, - fee_asset_index, - ), - }; - let mut test = ParaToSystemParaTest::new(para_test_args); - let sender_system_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_asset_location_on_penpal.clone(), &sender) - }); - let sender_foreign_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(asset_location_on_penpal.clone(), &sender) - }); - let receiver_balance_before = test.receiver.balance; - let receiver_assets_before = AssetHubWestend::execute_with(|| { - type Assets = ::Assets; - >::balance(RESERVABLE_ASSET_ID, &receiver) - }); - test.set_assertion::(para_to_system_para_assets_sender_assertions); - test.set_assertion::< - AssetHubWestend, - >(para_to_system_para_assets_receiver_assertions); - test.set_dispatchable::< - PenpalA, - >(para_to_system_para_reserve_transfer_assets); - test.assert(); - let sender_system_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_asset_location_on_penpal, &sender) - }); - let sender_foreign_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(asset_location_on_penpal, &sender) - }); - let receiver_balance_after = test.receiver.balance; - let receiver_assets_after = AssetHubWestend::execute_with(|| { - type Assets = ::Assets; - >::balance(RESERVABLE_ASSET_ID, &receiver) - }); - if !(sender_system_assets_after < sender_system_assets_before) { - ::core::panicking::panic( - "assertion failed: sender_system_assets_after < sender_system_assets_before", - ) - } - if !(receiver_balance_after > receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: receiver_balance_after > receiver_balance_before", - ) - } - if !(receiver_balance_after < receiver_balance_before + fee_amount_to_send) { - ::core::panicking::panic( - "assertion failed: receiver_balance_after < receiver_balance_before + fee_amount_to_send", - ) - } - match ( - &(sender_foreign_assets_before - asset_amount_to_send), - &sender_foreign_assets_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &receiver_assets_after, - &(receiver_assets_before + asset_amount_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_para_through_relay"] - pub const reserve_transfer_native_asset_from_para_to_para_through_relay: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_para_through_relay", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 1076usize, - start_col: 4usize, - end_line: 1076usize, - end_col: 65usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_para_to_para_through_relay(), - ), - ), - }; - /// Reserve Transfers of native asset from Parachain to Parachain (through Relay reserve) should - /// work - fn reserve_transfer_native_asset_from_para_to_para_through_relay() { - let destination = PenpalA::sibling_location_of(PenpalB::para_id()); - let sender = PenpalASender::get(); - let amount_to_send: Balance = WESTEND_ED * 10000; - let asset_owner = PenpalAssetOwner::get(); - let assets = (Parent, amount_to_send).into(); - let relay_native_asset_location = RelayLocation::get(); - let sender_as_seen_by_relay = Westend::child_location_of(PenpalA::para_id()); - let sov_of_sender_on_relay = Westend::sovereign_account_id_of( - sender_as_seen_by_relay, - ); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - relay_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); - Westend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_of_sender_on_relay.into(), amount_to_send * 2), - ]), - ), - ); - let receiver = PenpalBReceiver::get(); - let test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination, - receiver.clone(), - amount_to_send, - assets, - None, - 0, - ), - }; - let mut test = ParaToParaThroughRelayTest::new(test_args); - let sender_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &sender) - }); - let receiver_assets_before = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &receiver) - }); - test.set_assertion::(para_to_para_through_hop_sender_assertions); - test.set_assertion::(para_to_para_relay_hop_assertions); - test.set_assertion::(para_to_para_through_hop_receiver_assertions); - test.set_dispatchable::< - PenpalA, - >(para_to_para_through_relay_limited_reserve_transfer_assets); - test.assert(); - let sender_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &sender) - }); - let receiver_assets_after = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location, &receiver) - }); - if !(sender_assets_after < sender_assets_before - amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_assets_after < sender_assets_before - amount_to_send", - ) - } - if !(receiver_assets_after > receiver_assets_before) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after > receiver_assets_before", - ) - } - } - } - mod send { - use crate::imports::*; - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::send::send_transact_as_superuser_from_relay_to_asset_hub_works"] - pub const send_transact_as_superuser_from_relay_to_asset_hub_works: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::send::send_transact_as_superuser_from_relay_to_asset_hub_works", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/send.rs", - start_line: 21usize, - start_col: 4usize, - end_line: 21usize, - end_col: 60usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - send_transact_as_superuser_from_relay_to_asset_hub_works(), - ), - ), - }; - /// Relay Chain should be able to execute `Transact` instructions in System Parachain - /// when `OriginKind::Superuser`. - fn send_transact_as_superuser_from_relay_to_asset_hub_works() { - AssetHubWestend::force_create_asset_from_relay_as_root( - ASSET_ID, - ASSET_MIN_BALANCE, - true, - AssetHubWestendSender::get().into(), - Some(Weight::from_parts(1_019_445_000, 200_000)), - ) - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset"] - pub const send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/send.rs", - start_line: 35usize, - start_col: 4usize, - end_line: 35usize, - end_col: 64usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset(), - ), - ), - }; - /// We tests two things here: - /// - Parachain should be able to send XCM paying its fee at Asset Hub using system asset - /// - Parachain should be able to create a new Foreign Asset at Asset Hub - fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() { - let para_sovereign_account = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - let asset_location_on_penpal = Location::new( - 0, - [ - Junction::PalletInstance(ASSETS_PALLET_ID), - Junction::GeneralIndex(ASSET_ID.into()), - ], - ); - let foreign_asset_at_asset_hub = Location::new( - 1, - [Junction::Parachain(PenpalA::para_id().into())], - ) - .appended_with(asset_location_on_penpal) - .unwrap(); - let call = AssetHubWestend::create_foreign_asset_call( - foreign_asset_at_asset_hub.clone(), - ASSET_MIN_BALANCE, - para_sovereign_account.clone(), - ); - let origin_kind = OriginKind::Xcm; - let fee_amount = ASSET_HUB_WESTEND_ED * 1000000; - let system_asset = (Parent, fee_amount).into(); - let root_origin = ::RuntimeOrigin::root(); - let system_para_destination = PenpalA::sibling_location_of( - AssetHubWestend::para_id(), - ) - .into(); - let xcm = xcm_transact_paid_execution( - call, - origin_kind, - system_asset, - para_sovereign_account.clone(), - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - para_sovereign_account.clone().into(), - ASSET_HUB_WESTEND_ED * 10000000000, - ), - ]), - ), - ); - PenpalA::execute_with(|| { - let is = ::PolkadotXcm::send( - root_origin, - Box::new(system_para_destination), - Box::new(xcm), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - PenpalA::assert_xcm_pallet_sent(); - }); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == para_sovereign_account) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == para_sovereign_account", - ), - ); - res - }); - } - meet_conditions &= *who == para_sovereign_account; - if !(*amount == fee_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == fee_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == fee_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Created { asset_id, creator, owner }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == foreign_asset_at_asset_hub) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == foreign_asset_at_asset_hub", - ), - ); - res - }); - } - meet_conditions &= *asset_id == foreign_asset_at_asset_hub; - if !(*creator == para_sovereign_account.clone()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "creator", - creator, - "*creator == para_sovereign_account.clone()", - ), - ); - res - }); - } - meet_conditions - &= *creator == para_sovereign_account.clone(); - if !(*owner == para_sovereign_account) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == para_sovereign_account", - ), - ); - res - }); - } - meet_conditions &= *owner == para_sovereign_account; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Created {\nasset_id, creator, owner })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Created {\nasset_id, creator, owner })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::send", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - type ForeignAssets = ::ForeignAssets; - if !ForeignAssets::asset_exists(foreign_asset_at_asset_hub) { - ::core::panicking::panic( - "assertion failed: ForeignAssets::asset_exists(foreign_asset_at_asset_hub)", - ) - } - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset"] - pub const send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/send.rs", - start_line: 113usize, - start_col: 4usize, - end_line: 113usize, - end_col: 68usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset(), - ), - ), - }; - /// We tests two things here: - /// - Parachain should be able to send XCM paying its fee at Asset Hub using sufficient asset - /// - Parachain should be able to create a new Asset at Asset Hub - fn send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset() { - let para_sovereign_account = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - AssetHubWestend::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - true, - para_sovereign_account.clone(), - Some(Weight::from_parts(1_019_445_000, 200_000)), - ASSET_MIN_BALANCE * 1000000000, - ); - let new_asset_id = ASSET_ID + 1; - let call = AssetHubWestend::create_asset_call( - new_asset_id, - ASSET_MIN_BALANCE, - para_sovereign_account.clone(), - ); - let origin_kind = OriginKind::SovereignAccount; - let fee_amount = ASSET_MIN_BALANCE * 1000000; - let asset = ( - [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], - fee_amount, - ) - .into(); - let root_origin = ::RuntimeOrigin::root(); - let system_para_destination = PenpalA::sibling_location_of( - AssetHubWestend::para_id(), - ) - .into(); - let xcm = xcm_transact_paid_execution( - call, - origin_kind, - asset, - para_sovereign_account.clone(), - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - para_sovereign_account.clone().into(), - ASSET_HUB_WESTEND_ED * 10000000000, - ), - ]), - ), - ); - PenpalA::execute_with(|| { - let is = ::PolkadotXcm::send( - root_origin, - Box::new(system_para_destination), - Box::new(xcm), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - PenpalA::assert_xcm_pallet_sent(); - }); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == ASSET_ID) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == ASSET_ID", - ), - ); - res - }); - } - meet_conditions &= *asset_id == ASSET_ID; - if !(*owner == para_sovereign_account) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == para_sovereign_account", - ), - ); - res - }); - } - meet_conditions &= *owner == para_sovereign_account; - if !(*balance == fee_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == fee_amount", - ), - ); - res - }); - } - meet_conditions &= *balance == fee_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Created { asset_id, creator, owner }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == new_asset_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == new_asset_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == new_asset_id; - if !(*creator == para_sovereign_account.clone()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "creator", - creator, - "*creator == para_sovereign_account.clone()", - ), - ); - res - }); - } - meet_conditions - &= *creator == para_sovereign_account.clone(); - if !(*owner == para_sovereign_account) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == para_sovereign_account", - ), - ); - res - }); - } - meet_conditions &= *owner == para_sovereign_account; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Created { asset_id, creator, owner\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Created { asset_id, creator, owner\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::send", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - } - mod set_xcm_versions { - use crate::imports::*; - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::set_xcm_versions::relay_sets_system_para_xcm_supported_version"] - pub const relay_sets_system_para_xcm_supported_version: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::set_xcm_versions::relay_sets_system_para_xcm_supported_version", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_xcm_versions.rs", - start_line: 19usize, - start_col: 4usize, - end_line: 19usize, - end_col: 48usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - relay_sets_system_para_xcm_supported_version(), - ), - ), - }; - fn relay_sets_system_para_xcm_supported_version() { - let sudo_origin = ::RuntimeOrigin::root(); - let system_para_destination: Location = Westend::child_location_of( - AssetHubWestend::para_id(), - ); - Westend::execute_with(|| { - let is = ::XcmPallet::force_xcm_version( - sudo_origin, - Box::new(system_para_destination.clone()), - XCM_V3, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::XcmPallet( - pallet_xcm::Event::SupportedVersionChanged { - location, - version: XCM_V3, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*location == system_para_destination) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "location", - location, - "*location == system_para_destination", - ), - ); - res - }); - } - meet_conditions &= *location == system_para_destination; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::set_xcm_versions", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::set_xcm_versions::system_para_sets_relay_xcm_supported_version"] - pub const system_para_sets_relay_xcm_supported_version: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::set_xcm_versions::system_para_sets_relay_xcm_supported_version", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_xcm_versions.rs", - start_line: 47usize, - start_col: 4usize, - end_line: 47usize, - end_col: 48usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - system_para_sets_relay_xcm_supported_version(), - ), - ), - }; - fn system_para_sets_relay_xcm_supported_version() { - let parent_location = AssetHubWestend::parent_location(); - let force_xcm_version_call = ::RuntimeCall::PolkadotXcm(pallet_xcm::Call::< - ::Runtime, - >::force_xcm_version { - location: Box::new(parent_location.clone()), - version: XCM_V3, - }) - .encode() - .into(); - Westend::send_unpaid_transact_to_parachain_as_root( - AssetHubWestend::para_id(), - force_xcm_version_call, - ); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_dmp_queue_complete( - Some(Weight::from_parts(1_019_210_000, 200_000)), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm( - pallet_xcm::Event::SupportedVersionChanged { - location, - version: XCM_V3, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*location == parent_location) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "location", - location, - "*location == parent_location", - ), - ); - res - }); - } - meet_conditions &= *location == parent_location; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::set_xcm_versions", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - } - mod swap { - use crate::imports::*; - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::swap::swap_locally_on_chain_using_local_assets"] - pub const swap_locally_on_chain_using_local_assets: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::swap::swap_locally_on_chain_using_local_assets", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", - start_line: 19usize, - start_col: 4usize, - end_line: 19usize, - end_col: 44usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(swap_locally_on_chain_using_local_assets()), - ), - }; - fn swap_locally_on_chain_using_local_assets() { - let asset_native = Box::new( - Location::try_from(RelayLocation::get()).expect("conversion works"), - ); - let asset_one = Box::new(Location { - parents: 0, - interior: [ - Junction::PalletInstance(ASSETS_PALLET_ID), - Junction::GeneralIndex(ASSET_ID.into()), - ] - .into(), - }); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - let is = ::Assets::create( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - ASSET_ID.into(), - AssetHubWestendSender::get().into(), - 1000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - if !::Assets::asset_exists( - ASSET_ID, - ) { - ::core::panicking::panic( - "assertion failed: ::Assets::asset_exists(ASSET_ID)", - ) - } - let is = ::Assets::mint( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - ASSET_ID.into(), - AssetHubWestendSender::get().into(), - 3_000_000_000_000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = ::AssetConversion::create_pool( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - asset_native.clone(), - asset_one.clone(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::PoolCreated { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let is = ::AssetConversion::add_liquidity( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - asset_native.clone(), - asset_one.clone(), - 1_000_000_000_000, - 2_000_000_000_000, - 0, - 0, - AssetHubWestendSender::get().into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::LiquidityAdded { - lp_token_minted, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*lp_token_minted == 1414213562273) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "lp_token_minted", - lp_token_minted, - "*lp_token_minted == 1414213562273", - ), - ); - res - }); - } - meet_conditions &= *lp_token_minted == 1414213562273; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let path = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([asset_native.clone(), asset_one.clone()]), - ); - let is = ::AssetConversion::swap_exact_tokens_for_tokens( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - path, - 100, - 1, - AssetHubWestendSender::get().into(), - true, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::SwapExecuted { - amount_in, - amount_out, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*amount_in == 100) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount_in", - amount_in, - "*amount_in == 100", - ), - ); - res - }); - } - meet_conditions &= *amount_in == 100; - if !(*amount_out == 199) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount_out", - amount_out, - "*amount_out == 199", - ), - ); - res - }); - } - meet_conditions &= *amount_out == 199; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let is = ::AssetConversion::remove_liquidity( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - asset_native.clone(), - asset_one.clone(), - 1414213562273 - 2_000_000_000, - 0, - 0, - AssetHubWestendSender::get().into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::swap::swap_locally_on_chain_using_foreign_assets"] - pub const swap_locally_on_chain_using_foreign_assets: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::swap::swap_locally_on_chain_using_foreign_assets", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", - start_line: 114usize, - start_col: 4usize, - end_line: 114usize, - end_col: 46usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(swap_locally_on_chain_using_foreign_assets()), - ), - }; - fn swap_locally_on_chain_using_foreign_assets() { - let asset_native = Box::new( - Location::try_from(RelayLocation::get()).unwrap(), - ); - let asset_location_on_penpal = Location::try_from( - PenpalLocalTeleportableToAssetHub::get(), - ) - .expect("conversion_works"); - let foreign_asset_at_asset_hub_westend = Location::new( - 1, - [Junction::Parachain(PenpalA::para_id().into())], - ) - .appended_with(asset_location_on_penpal) - .unwrap(); - let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - penpal_as_seen_by_ah, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - AssetHubWestendSender::get().into(), - 5_000_000 * ASSET_HUB_WESTEND_ED, - ), - ( - sov_penpal_on_ahr.clone().into(), - 100_000_000 * ASSET_HUB_WESTEND_ED, - ), - ]), - ), - ); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - let is = ::ForeignAssets::mint( - ::RuntimeOrigin::signed( - sov_penpal_on_ahr.clone().into(), - ), - foreign_asset_at_asset_hub_westend.clone(), - sov_penpal_on_ahr.clone().into(), - ASSET_HUB_WESTEND_ED * 3_000_000_000_000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let is = ::AssetConversion::create_pool( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - asset_native.clone(), - Box::new(foreign_asset_at_asset_hub_westend.clone()), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::PoolCreated { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let is = ::AssetConversion::add_liquidity( - ::RuntimeOrigin::signed( - sov_penpal_on_ahr.clone(), - ), - asset_native.clone(), - Box::new(foreign_asset_at_asset_hub_westend.clone()), - 1_000_000_000_000_000, - 2_000_000_000_000_000, - 0, - 0, - sov_penpal_on_ahr.clone().into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::LiquidityAdded { - lp_token_minted, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*lp_token_minted == 1414213562372995) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "lp_token_minted", - lp_token_minted, - "*lp_token_minted == 1414213562372995", - ), - ); - res - }); - } - meet_conditions &= *lp_token_minted == 1414213562372995; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let path = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - asset_native.clone(), - Box::new(foreign_asset_at_asset_hub_westend.clone()), - ]), - ); - let is = ::AssetConversion::swap_exact_tokens_for_tokens( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - path, - 100000 * ASSET_HUB_WESTEND_ED, - 1000 * ASSET_HUB_WESTEND_ED, - AssetHubWestendSender::get().into(), - true, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::SwapExecuted { - amount_in, - amount_out, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*amount_in == 100000000000000) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount_in", - amount_in, - "*amount_in == 100000000000000", - ), - ); - res - }); - } - meet_conditions &= *amount_in == 100000000000000; - if !(*amount_out == 181322178776029) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount_out", - amount_out, - "*amount_out == 181322178776029", - ), - ); - res - }); - } - meet_conditions &= *amount_out == 181322178776029; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let is = ::AssetConversion::remove_liquidity( - ::RuntimeOrigin::signed( - sov_penpal_on_ahr.clone(), - ), - asset_native.clone(), - Box::new(foreign_asset_at_asset_hub_westend), - 1414213562372995 - ASSET_HUB_WESTEND_ED * 2, - 0, - 0, - sov_penpal_on_ahr.clone().into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::swap::cannot_create_pool_from_pool_assets"] - pub const cannot_create_pool_from_pool_assets: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::swap::cannot_create_pool_from_pool_assets", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", - start_line: 229usize, - start_col: 4usize, - end_line: 229usize, - end_col: 39usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(cannot_create_pool_from_pool_assets()), - ), - }; - fn cannot_create_pool_from_pool_assets() { - let asset_native = RelayLocation::get(); - let mut asset_one = ahw_xcm_config::PoolAssetsPalletLocation::get(); - asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets"); - AssetHubWestend::execute_with(|| { - let pool_owner_account_id = AssetHubWestendAssetConversionOrigin::get(); - let is = ::PoolAssets::create( - ::RuntimeOrigin::signed( - pool_owner_account_id.clone(), - ), - ASSET_ID.into(), - pool_owner_account_id.clone().into(), - 1000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - if !::PoolAssets::asset_exists( - ASSET_ID, - ) { - ::core::panicking::panic( - "assertion failed: ::PoolAssets::asset_exists(ASSET_ID)", - ) - } - let is = ::PoolAssets::mint( - ::RuntimeOrigin::signed( - pool_owner_account_id, - ), - ASSET_ID.into(), - AssetHubWestendSender::get().into(), - 3_000_000_000_000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - match ::AssetConversion::create_pool( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - Box::new( - Location::try_from(asset_native).expect("conversion works"), - ), - Box::new(Location::try_from(asset_one).expect("conversion works")), - ) { - Err( - DispatchError::Module( - ModuleError { index: _, error: _, message }, - ), - ) => { - match (&message, &Some("Unknown")) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - } - } - ref e => { - ::std::rt::panic_fmt( - format_args!( - "assertion failed: `{0:?}` does not match `{1}`", - e, - "Err(DispatchError::Module(ModuleError { index: _, error: _, message }))", - ), - ); - } - }; - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::swap::pay_xcm_fee_with_some_asset_swapped_for_native"] - pub const pay_xcm_fee_with_some_asset_swapped_for_native: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::swap::pay_xcm_fee_with_some_asset_swapped_for_native", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", - start_line: 264usize, - start_col: 4usize, - end_line: 264usize, - end_col: 50usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - pay_xcm_fee_with_some_asset_swapped_for_native(), - ), - ), - }; - fn pay_xcm_fee_with_some_asset_swapped_for_native() { - let asset_native = Location::try_from(RelayLocation::get()) - .expect("conversion works"); - let asset_one = Location { - parents: 0, - interior: [ - Junction::PalletInstance(ASSETS_PALLET_ID), - Junction::GeneralIndex(ASSET_ID.into()), - ] - .into(), - }; - let penpal = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - let is = ::Assets::create( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - ASSET_ID.into(), - AssetHubWestendSender::get().into(), - ASSET_MIN_BALANCE, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - if !::Assets::asset_exists( - ASSET_ID, - ) { - ::core::panicking::panic( - "assertion failed: ::Assets::asset_exists(ASSET_ID)", - ) - } - let is = ::Assets::mint( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - ASSET_ID.into(), - AssetHubWestendSender::get().into(), - 3_000_000_000_000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = ::AssetConversion::create_pool( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - Box::new(asset_native.clone()), - Box::new(asset_one.clone()), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::PoolCreated { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let is = ::AssetConversion::add_liquidity( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - Box::new(asset_native), - Box::new(asset_one), - 1_000_000_000_000, - 2_000_000_000_000, - 0, - 0, - AssetHubWestendSender::get().into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::LiquidityAdded { - lp_token_minted, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*lp_token_minted == 1414213562273) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "lp_token_minted", - lp_token_minted, - "*lp_token_minted == 1414213562273", - ), - ); - res - }); - } - meet_conditions &= *lp_token_minted == 1414213562273; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - match ( - &::Balances::free_balance( - penpal.clone(), - ), - &0, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - let is = ::Assets::touch_other( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - ASSET_ID.into(), - penpal.clone().into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = ::Assets::mint( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - ASSET_ID.into(), - penpal.clone().into(), - 10_000_000_000_000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - PenpalA::execute_with(|| { - let call = AssetHubWestend::force_create_asset_call( - ASSET_ID + 1000, - penpal.clone(), - true, - ASSET_MIN_BALANCE, - ); - let penpal_root = ::RuntimeOrigin::root(); - let fee_amount = 4_000_000_000_000u128; - let asset_one = ( - [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], - fee_amount, - ) - .into(); - let asset_hub_location = PenpalA::sibling_location_of( - AssetHubWestend::para_id(), - ) - .into(); - let xcm = xcm_transact_paid_execution( - call, - OriginKind::SovereignAccount, - asset_one, - penpal.clone(), - ); - let is = ::PolkadotXcm::send( - penpal_root, - Box::new(asset_hub_location), - Box::new(xcm), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - PenpalA::assert_xcm_pallet_sent(); - }); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::SwapCreditExecuted { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapCreditExecuted {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapCreditExecuted {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - } - mod teleport { - use crate::imports::*; - fn relay_dest_assertions_fail(_t: SystemParaToRelayTest) { - Westend::assert_ump_queue_processed( - false, - Some(AssetHubWestend::para_id()), - Some(Weight::from_parts(157_718_000, 3_593)), - ); - } - fn para_origin_assertions(t: SystemParaToRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcm_pallet_attempted_complete( - Some(Weight::from_parts(720_053_000, 7_203)), - ); - AssetHubWestend::assert_parachain_system_ump_sent(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *who == t.sender.account_id; - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn penpal_to_ah_foreign_assets_sender_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let system_para_native_asset_location = RelayLocation::get(); - let expected_asset_id = t.args.asset_id.unwrap(); - let (_, expected_asset_amount) = non_fee_asset( - &t.args.assets, - t.args.fee_asset_item as usize, - ) - .unwrap(); - PenpalA::assert_xcm_pallet_attempted_complete(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == system_para_native_asset_location) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == system_para_native_asset_location", - ), - ); - res - }); - } - meet_conditions - &= *asset_id == system_para_native_asset_location; - if !(*owner == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_asset_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_asset_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_asset_id; - if !(*owner == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if !(*balance == expected_asset_amount) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == expected_asset_amount", - ), - ); - res - }); - } - meet_conditions &= *balance == expected_asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - let (expected_foreign_asset_id, expected_foreign_asset_amount) = non_fee_asset( - &t.args.assets, - t.args.fee_asset_item as usize, - ) - .unwrap(); - AssetHubWestend::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_on_ahr.clone().into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_on_ahr.clone().into()", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_on_ahr.clone().into(); - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == t.receiver.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *who == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_foreign_asset_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_foreign_asset_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_foreign_asset_id; - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if !(*amount == expected_foreign_asset_amount) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == expected_foreign_asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == expected_foreign_asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn ah_to_penpal_foreign_assets_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcm_pallet_attempted_complete(None); - let (expected_foreign_asset_id, expected_foreign_asset_amount) = non_fee_asset( - &t.args.assets, - t.args.fee_asset_item as usize, - ) - .unwrap(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from, to, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*from == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "*from == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *from == t.sender.account_id; - if !(*to - == AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - )) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "*to == AssetHubWestend::sovereign_account_id_of(t.args.dest.clone())", - ), - ); - res - }); - } - meet_conditions - &= *to - == AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - ); - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_foreign_asset_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_foreign_asset_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_foreign_asset_id; - if !(*owner == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if !(*balance == expected_foreign_asset_amount) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == expected_foreign_asset_amount", - ), - ); - res - }); - } - meet_conditions &= *balance == expected_foreign_asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn ah_to_penpal_foreign_assets_receiver_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let expected_asset_id = t.args.asset_id.unwrap(); - let (_, expected_asset_amount) = non_fee_asset( - &t.args.assets, - t.args.fee_asset_item as usize, - ) - .unwrap(); - let checking_account = ::PolkadotXcm::check_account(); - let system_para_native_asset_location = RelayLocation::get(); - PenpalA::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_asset_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_asset_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_asset_id; - if !(*owner == checking_account) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == checking_account", - ), - ); - res - }); - } - meet_conditions &= *owner == checking_account; - if !(*balance == expected_asset_amount) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == expected_asset_amount", - ), - ); - res - }); - } - meet_conditions &= *balance == expected_asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Issued { asset_id, owner, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_asset_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_asset_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_asset_id; - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if !(*amount == expected_asset_amount) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == expected_asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == expected_asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == system_para_native_asset_location) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == system_para_native_asset_location", - ), - ); - res - }); - } - meet_conditions - &= *asset_id == system_para_native_asset_location; - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if !(*amount == expected_asset_amount) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == expected_asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == expected_asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn system_para_limited_teleport_assets( - t: SystemParaToRelayTest, - ) -> DispatchResult { - ::PolkadotXcm::limited_teleport_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - fn para_to_system_para_transfer_assets( - t: ParaToSystemParaTest, - ) -> DispatchResult { - ::PolkadotXcm::transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - fn system_para_to_para_transfer_assets( - t: SystemParaToParaTest, - ) -> DispatchResult { - ::PolkadotXcm::transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::teleport::teleport_to_other_system_parachains_works"] - pub const teleport_to_other_system_parachains_works: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::teleport::teleport_to_other_system_parachains_works", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", - start_line: 204usize, - start_col: 4usize, - end_line: 204usize, - end_col: 45usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(teleport_to_other_system_parachains_works()), - ), - }; - fn teleport_to_other_system_parachains_works() { - let amount = ASSET_HUB_WESTEND_ED * 100; - let native_asset: Assets = (Parent, amount).into(); - let sender = AssetHubWestendSender::get(); - let mut para_sender_balance_before = ::account_data_of( - sender.clone(), - ) - .free; - let origin = ::RuntimeOrigin::signed( - sender.clone(), - ); - let fee_asset_item = 0; - let weight_limit = ::emulated_integration_tests_common::macros::WeightLimit::Unlimited; - { - let receiver = BridgeHubWestendReceiver::get(); - let para_receiver_balance_before = ::account_data_of( - receiver.clone(), - ) - .free; - let para_destination = ::sibling_location_of( - ::para_id(), - ); - let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { - network: None, - id: receiver.clone().into(), - } - .into(); - ::execute_with(|| { - let is = ::PolkadotXcm::limited_teleport_assets( - origin.clone(), - Box::new(para_destination.clone().into()), - Box::new(beneficiary.clone().into()), - Box::new(native_asset.clone().into()), - fee_asset_item, - weight_limit.clone(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted { - outcome: Outcome::Complete { .. }, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::XcmpQueue( - ::emulated_integration_tests_common::macros::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::XcmpQueue(::emulated_integration_tests_common::macros::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::XcmpQueue(::emulated_integration_tests_common::macros::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - ::emulated_integration_tests_common::macros::pallet_balances::Event::Burned { - who: sender, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - ::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - ::emulated_integration_tests_common::macros::pallet_balances::Event::Minted { - who: receiver, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "BridgeHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "BridgeHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - ::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed { - success: true, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "BridgeHubWestend", - "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "BridgeHubWestend", - "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::BridgeHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - let para_sender_balance_after = ::account_data_of( - sender.clone(), - ) - .free; - let para_receiver_balance_after = ::account_data_of( - receiver.clone(), - ) - .free; - let delivery_fees = ::execute_with(|| { - ::emulated_integration_tests_common::macros::asset_test_utils::xcm_helpers::teleport_assets_delivery_fees::< - ::XcmSender, - >( - native_asset.clone(), - fee_asset_item, - weight_limit.clone(), - beneficiary, - para_destination, - ) - }); - match ( - &(para_sender_balance_before - amount - delivery_fees), - ¶_sender_balance_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(para_receiver_balance_after > para_receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: para_receiver_balance_after > para_receiver_balance_before", - ) - } - para_sender_balance_before = ::account_data_of( - sender.clone(), - ) - .free; - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::teleport::teleport_from_and_to_relay"] - pub const teleport_from_and_to_relay: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::teleport::teleport_from_and_to_relay", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", - start_line: 217usize, - start_col: 4usize, - end_line: 217usize, - end_col: 30usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(teleport_from_and_to_relay()), - ), - }; - fn teleport_from_and_to_relay() { - let amount = WESTEND_ED * 100; - let native_asset: Assets = (Here, amount).into(); - let sender = WestendSender::get(); - let mut relay_sender_balance_before = ::account_data_of( - sender.clone(), - ) - .free; - let origin = ::RuntimeOrigin::signed( - sender.clone(), - ); - let fee_asset_item = 0; - let weight_limit = ::emulated_integration_tests_common::macros::WeightLimit::Unlimited; - { - let receiver = AssetHubWestendReceiver::get(); - let para_receiver_balance_before = ::account_data_of( - receiver.clone(), - ) - .free; - let para_destination = ::child_location_of( - ::para_id(), - ); - let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { - network: None, - id: receiver.clone().into(), - } - .into(); - ::execute_with(|| { - let is = ::XcmPallet::limited_teleport_assets( - origin.clone(), - Box::new(para_destination.clone().into()), - Box::new(beneficiary.clone().into()), - Box::new(native_asset.clone().into()), - fee_asset_item, - weight_limit.clone(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::XcmPallet( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted { - outcome: Outcome::Complete { .. }, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - ::emulated_integration_tests_common::macros::pallet_balances::Event::Burned { - who: sender, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::XcmPallet( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - ::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - ::emulated_integration_tests_common::macros::pallet_balances::Event::Minted { - who: receiver, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - ::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed { - success: true, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - let relay_sender_balance_after = ::account_data_of( - sender.clone(), - ) - .free; - let para_receiver_balance_after = ::account_data_of( - receiver.clone(), - ) - .free; - let delivery_fees = ::execute_with(|| { - ::emulated_integration_tests_common::macros::asset_test_utils::xcm_helpers::teleport_assets_delivery_fees::< - ::XcmSender, - >( - native_asset.clone(), - fee_asset_item, - weight_limit.clone(), - beneficiary, - para_destination, - ) - }); - match ( - &(relay_sender_balance_before - amount - delivery_fees), - &relay_sender_balance_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(para_receiver_balance_after > para_receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: para_receiver_balance_after > para_receiver_balance_before", - ) - } - relay_sender_balance_before = ::account_data_of( - sender.clone(), - ) - .free; - }; - let sender = AssetHubWestendSender::get(); - let para_sender_balance_before = ::account_data_of( - sender.clone(), - ) - .free; - let origin = ::RuntimeOrigin::signed( - sender.clone(), - ); - let assets: Assets = (Parent, amount).into(); - let fee_asset_item = 0; - let weight_limit = ::emulated_integration_tests_common::macros::WeightLimit::Unlimited; - let receiver = WestendReceiver::get(); - let relay_receiver_balance_before = ::account_data_of( - receiver.clone(), - ) - .free; - let relay_destination: Location = Parent.into(); - let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { - network: None, - id: receiver.clone().into(), - } - .into(); - ::execute_with(|| { - let is = ::PolkadotXcm::limited_teleport_assets( - origin.clone(), - Box::new(relay_destination.clone().into()), - Box::new(beneficiary.clone().into()), - Box::new(assets.clone().into()), - fee_asset_item, - weight_limit.clone(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted { - outcome: Outcome::Complete { .. }, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - ::emulated_integration_tests_common::macros::pallet_balances::Event::Burned { - who: sender, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - ::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - ::emulated_integration_tests_common::macros::pallet_balances::Event::Minted { - who: receiver, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - ::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed { - success: true, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - let para_sender_balance_after = ::account_data_of( - sender.clone(), - ) - .free; - let relay_receiver_balance_after = ::account_data_of( - receiver.clone(), - ) - .free; - let delivery_fees = ::execute_with(|| { - ::emulated_integration_tests_common::macros::asset_test_utils::xcm_helpers::teleport_assets_delivery_fees::< - ::XcmSender, - >( - assets, - fee_asset_item, - weight_limit.clone(), - beneficiary, - relay_destination, - ) - }); - match ( - &(para_sender_balance_before - amount - delivery_fees), - ¶_sender_balance_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(relay_receiver_balance_after > relay_receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: relay_receiver_balance_after > relay_receiver_balance_before", - ) - } - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::teleport::limited_teleport_native_assets_from_system_para_to_relay_fails"] - pub const limited_teleport_native_assets_from_system_para_to_relay_fails: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::teleport::limited_teleport_native_assets_from_system_para_to_relay_fails", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", - start_line: 239usize, - start_col: 4usize, - end_line: 239usize, - end_col: 66usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - limited_teleport_native_assets_from_system_para_to_relay_fails(), - ), - ), - }; - /// Limited Teleport of native asset from System Parachain to Relay Chain - /// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` - fn limited_teleport_native_assets_from_system_para_to_relay_fails() { - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let destination = AssetHubWestend::parent_location().into(); - let beneficiary_id = WestendReceiver::get().into(); - let assets = (Parent, amount_to_send).into(); - let test_args = TestContext { - sender: AssetHubWestendSender::get(), - receiver: WestendReceiver::get(), - args: TestArgs::new_para( - destination, - beneficiary_id, - amount_to_send, - assets, - None, - 0, - ), - }; - let mut test = SystemParaToRelayTest::new(test_args); - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - test.set_assertion::(para_origin_assertions); - test.set_assertion::(relay_dest_assertions_fail); - test.set_dispatchable::< - AssetHubWestend, - >(system_para_limited_teleport_assets); - test.assert(); - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - let delivery_fees = AssetHubWestend::execute_with(|| { - xcm_helpers::teleport_assets_delivery_fees::< - ::XcmSender, - >( - test.args.assets.clone(), - 0, - test.args.weight_limit, - test.args.beneficiary, - test.args.dest, - ) - }); - match ( - &(sender_balance_before - amount_to_send - delivery_fees), - &sender_balance_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match (&receiver_balance_after, &receiver_balance_before) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - /// Bidirectional teleports of local Penpal assets to Asset Hub as foreign assets while paying - /// fees using (reserve transferred) native asset. - pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt( - para_to_ah_dispatchable: fn(ParaToSystemParaTest) -> DispatchResult, - ah_to_para_dispatchable: fn(SystemParaToParaTest) -> DispatchResult, - ) { - let fee_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 100; - let asset_location_on_penpal = PenpalLocalTeleportableToAssetHub::get(); - let asset_id_on_penpal = match asset_location_on_penpal.last() { - Some(Junction::GeneralIndex(id)) => *id as u32, - _ => ::core::panicking::panic("internal error: entered unreachable code"), - }; - let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100; - let asset_owner = PenpalAssetOwner::get(); - let system_para_native_asset_location = RelayLocation::get(); - let sender = PenpalASender::get(); - let penpal_check_account = ::PolkadotXcm::check_account(); - let ah_as_seen_by_penpal = PenpalA::sibling_location_of( - AssetHubWestend::para_id(), - ); - let penpal_assets: Assets = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (Parent, fee_amount_to_send).into(), - (asset_location_on_penpal.clone(), asset_amount_to_send).into(), - ]), - ) - .into(); - let fee_asset_index = penpal_assets - .inner() - .iter() - .position(|r| r == &(Parent, fee_amount_to_send).into()) - .unwrap() as u32; - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner.clone()), - system_para_native_asset_location.clone(), - sender.clone(), - fee_amount_to_send * 2, - ); - PenpalA::mint_asset( - ::RuntimeOrigin::signed(asset_owner.clone()), - asset_id_on_penpal, - sender.clone(), - asset_amount_to_send, - ); - PenpalA::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - penpal_check_account.clone().into(), - ASSET_HUB_WESTEND_ED * 1000, - ), - ]), - ), - ); - let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_penpal_on_ah = AssetHubWestend::sovereign_account_id_of( - penpal_as_seen_by_ah, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - sov_penpal_on_ah.clone().into(), - ASSET_HUB_WESTEND_ED * 100_000_000_000, - ), - ]), - ), - ); - let foreign_asset_at_asset_hub_westend = Location::new( - 1, - [Junction::Parachain(PenpalA::para_id().into())], - ) - .appended_with(asset_location_on_penpal) - .unwrap(); - let penpal_to_ah_beneficiary_id = AssetHubWestendReceiver::get(); - let penpal_to_ah_test_args = TestContext { - sender: PenpalASender::get(), - receiver: AssetHubWestendReceiver::get(), - args: TestArgs::new_para( - ah_as_seen_by_penpal, - penpal_to_ah_beneficiary_id, - asset_amount_to_send, - penpal_assets, - Some(asset_id_on_penpal), - fee_asset_index, - ), - }; - let mut penpal_to_ah = ParaToSystemParaTest::new(penpal_to_ah_test_args); - let penpal_sender_balance_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - system_para_native_asset_location.clone(), - &PenpalASender::get(), - ) - }); - let ah_receiver_balance_before = penpal_to_ah.receiver.balance; - let penpal_sender_assets_before = PenpalA::execute_with(|| { - type Assets = ::Assets; - >::balance(asset_id_on_penpal, &PenpalASender::get()) - }); - let ah_receiver_assets_before = AssetHubWestend::execute_with(|| { - type Assets = ::ForeignAssets; - >::balance( - foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), - &AssetHubWestendReceiver::get(), - ) - }); - penpal_to_ah - .set_assertion::(penpal_to_ah_foreign_assets_sender_assertions); - penpal_to_ah - .set_assertion::< - AssetHubWestend, - >(penpal_to_ah_foreign_assets_receiver_assertions); - penpal_to_ah.set_dispatchable::(para_to_ah_dispatchable); - penpal_to_ah.assert(); - let penpal_sender_balance_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - system_para_native_asset_location.clone(), - &PenpalASender::get(), - ) - }); - let ah_receiver_balance_after = penpal_to_ah.receiver.balance; - let penpal_sender_assets_after = PenpalA::execute_with(|| { - type Assets = ::Assets; - >::balance(asset_id_on_penpal, &PenpalASender::get()) - }); - let ah_receiver_assets_after = AssetHubWestend::execute_with(|| { - type Assets = ::ForeignAssets; - >::balance( - foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), - &AssetHubWestendReceiver::get(), - ) - }); - if !(penpal_sender_balance_after < penpal_sender_balance_before) { - ::core::panicking::panic( - "assertion failed: penpal_sender_balance_after < penpal_sender_balance_before", - ) - } - if !(ah_receiver_balance_after > ah_receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: ah_receiver_balance_after > ah_receiver_balance_before", - ) - } - if !(ah_receiver_balance_after - < ah_receiver_balance_before + fee_amount_to_send) - { - ::core::panicking::panic( - "assertion failed: ah_receiver_balance_after < ah_receiver_balance_before + fee_amount_to_send", - ) - } - match ( - &(penpal_sender_assets_before - asset_amount_to_send), - &penpal_sender_assets_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &ah_receiver_assets_after, - &(ah_receiver_assets_before + asset_amount_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - let is = ForeignAssets::transfer( - ::RuntimeOrigin::signed( - AssetHubWestendReceiver::get(), - ), - foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), - AssetHubWestendSender::get().into(), - asset_amount_to_send, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - let ah_to_penpal_beneficiary_id = PenpalAReceiver::get(); - let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let ah_assets: Assets = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (Parent, fee_amount_to_send).into(), - ( - foreign_asset_at_asset_hub_westend.clone(), - asset_amount_to_send, - ) - .into(), - ]), - ) - .into(); - let fee_asset_index = ah_assets - .inner() - .iter() - .position(|r| r == &(Parent, fee_amount_to_send).into()) - .unwrap() as u32; - let ah_to_penpal_test_args = TestContext { - sender: AssetHubWestendSender::get(), - receiver: PenpalAReceiver::get(), - args: TestArgs::new_para( - penpal_as_seen_by_ah, - ah_to_penpal_beneficiary_id, - asset_amount_to_send, - ah_assets, - Some(asset_id_on_penpal), - fee_asset_index, - ), - }; - let mut ah_to_penpal = SystemParaToParaTest::new(ah_to_penpal_test_args); - let ah_sender_balance_before = ah_to_penpal.sender.balance; - let penpal_receiver_balance_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - system_para_native_asset_location.clone(), - &PenpalAReceiver::get(), - ) - }); - let ah_sender_assets_before = AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), - &AssetHubWestendSender::get(), - ) - }); - let penpal_receiver_assets_before = PenpalA::execute_with(|| { - type Assets = ::Assets; - >::balance(asset_id_on_penpal, &PenpalAReceiver::get()) - }); - ah_to_penpal - .set_assertion::< - AssetHubWestend, - >(ah_to_penpal_foreign_assets_sender_assertions); - ah_to_penpal - .set_assertion::< - PenpalA, - >(ah_to_penpal_foreign_assets_receiver_assertions); - ah_to_penpal.set_dispatchable::(ah_to_para_dispatchable); - ah_to_penpal.assert(); - let ah_sender_balance_after = ah_to_penpal.sender.balance; - let penpal_receiver_balance_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location, &PenpalAReceiver::get()) - }); - let ah_sender_assets_after = AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), - &AssetHubWestendSender::get(), - ) - }); - let penpal_receiver_assets_after = PenpalA::execute_with(|| { - type Assets = ::Assets; - >::balance(asset_id_on_penpal, &PenpalAReceiver::get()) - }); - if !(ah_sender_balance_after < ah_sender_balance_before) { - ::core::panicking::panic( - "assertion failed: ah_sender_balance_after < ah_sender_balance_before", - ) - } - if !(penpal_receiver_balance_after > penpal_receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: penpal_receiver_balance_after > penpal_receiver_balance_before", - ) - } - if !(penpal_receiver_balance_after - < penpal_receiver_balance_before + fee_amount_to_send) - { - ::core::panicking::panic( - "assertion failed: penpal_receiver_balance_after <\n penpal_receiver_balance_before + fee_amount_to_send", - ) - } - match ( - &(ah_sender_assets_before - asset_amount_to_send), - &ah_sender_assets_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &penpal_receiver_assets_after, - &(penpal_receiver_assets_before + asset_amount_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::teleport::bidirectional_teleport_foreign_assets_between_para_and_asset_hub"] - pub const bidirectional_teleport_foreign_assets_between_para_and_asset_hub: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::teleport::bidirectional_teleport_foreign_assets_between_para_and_asset_hub", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", - start_line: 527usize, - start_col: 4usize, - end_line: 527usize, - end_col: 68usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - bidirectional_teleport_foreign_assets_between_para_and_asset_hub(), - ), - ), - }; - /// Bidirectional teleports of local Penpal assets to Asset Hub as foreign assets should work - /// (using native reserve-based transfer for fees) - fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() { - do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt( - para_to_system_para_transfer_assets, - system_para_to_para_transfer_assets, - ); - } - } - mod treasury { - use crate::imports::*; - use emulated_integration_tests_common::{ - accounts::{ALICE, BOB}, - USDT_ID, - }; - use frame_support::traits::fungibles::{Inspect, Mutate}; - use polkadot_runtime_common::impls::VersionedLocatableAsset; - use xcm_executor::traits::ConvertLocation; - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::treasury::create_and_claim_treasury_spend"] - pub const create_and_claim_treasury_spend: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::treasury::create_and_claim_treasury_spend", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs", - start_line: 26usize, - start_col: 4usize, - end_line: 26usize, - end_col: 35usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(create_and_claim_treasury_spend()), - ), - }; - fn create_and_claim_treasury_spend() { - const SPEND_AMOUNT: u128 = 1_000_000_000; - let treasury_location: Location = Location::new(1, PalletInstance(37)); - let treasury_account = ahw_xcm_config::LocationToAccountId::convert_location( - &treasury_location, - ) - .unwrap(); - let asset_hub_location = Location::new( - 0, - Parachain(AssetHubWestend::para_id().into()), - ); - let root = ::RuntimeOrigin::root(); - let asset_kind = VersionedLocatableAsset::V5 { - location: asset_hub_location, - asset_id: AssetId( - [PalletInstance(50), GeneralIndex(USDT_ID.into())].into(), - ), - }; - let alice: AccountId = Westend::account_id_of(ALICE); - let bob: AccountId = Westend::account_id_of(BOB); - let bob_signed = ::RuntimeOrigin::signed(bob.clone()); - AssetHubWestend::execute_with(|| { - type Assets = ::Assets; - let is = >::mint_into(USDT_ID, &treasury_account, SPEND_AMOUNT * 4); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - match (&>::balance(USDT_ID, &alice), &0u128) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - Westend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type Treasury = ::Treasury; - type AssetRate = ::AssetRate; - let is = AssetRate::create( - root.clone(), - Box::new(asset_kind.clone()), - 2.into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = Treasury::spend( - root, - Box::new(asset_kind), - SPEND_AMOUNT, - Box::new( - Location::new(0, Into::<[u8; 32]>::into(alice.clone())).into(), - ), - None, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = Treasury::payout(bob_signed.clone(), 0); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. }) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::treasury", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type Assets = ::Assets; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Transferred { - asset_id: id, - from, - to, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(id == &USDT_ID) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "id", - id, - "id == &USDT_ID", - ), - ); - res - }); - } - meet_conditions &= id == &USDT_ID; - if !(from == &treasury_account) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "from == &treasury_account", - ), - ); - res - }); - } - meet_conditions &= from == &treasury_account; - if !(to == &alice) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "to == &alice", - ), - ); - res - }); - } - meet_conditions &= to == &alice; - if !(amount == &SPEND_AMOUNT) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "amount == &SPEND_AMOUNT", - ), - ); - res - }); - } - meet_conditions &= amount == &SPEND_AMOUNT; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ParachainSystem( - cumulus_pallet_parachain_system::Event::UpwardMessageSent { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ParachainSystem(cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ParachainSystem(cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::treasury", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - match ( - &>::balance(USDT_ID, &alice), - &SPEND_AMOUNT, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - Westend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type Treasury = ::Treasury; - let is = Treasury::check_status(bob_signed, 0); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Treasury( - pallet_treasury::Event::SpendProcessed { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Treasury(pallet_treasury::Event::SpendProcessed { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Treasury(pallet_treasury::Event::SpendProcessed { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::treasury", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - } - mod xcm_fee_estimation { - //! Tests to ensure correct XCM fee estimation for cross-chain asset transfers. - use crate::imports::*; - use frame_support::{ - dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, - }; - use xcm_runtime_apis::{ - dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, - fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, - }; - fn sender_assertions(test: ParaToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - PenpalA::assert_xcm_pallet_attempted_complete(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == Location::new(1, [])) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == Location::new(1, [])", - ), - ); - res - }); - } - meet_conditions &= *asset_id == Location::new(1, []); - if !(*owner == test.sender.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == test.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == test.sender.account_id; - if !(*balance == test.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == test.args.amount", - ), - ); - res - }); - } - meet_conditions &= *balance == test.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::xcm_fee_estimation", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn hop_assertions(test: ParaToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { amount, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*amount == test.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == test.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == test.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { amount, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { amount, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::xcm_fee_estimation", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn receiver_assertions(test: ParaToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - PenpalB::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == Location::new(1, [])) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == Location::new(1, [])", - ), - ); - res - }); - } - meet_conditions &= *asset_id == Location::new(1, []); - if !(*owner == test.receiver.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == test.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == test.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalB", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalB", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalB", - "asset_hub_westend_integration_tests::tests::xcm_fee_estimation", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn transfer_assets_para_to_para_through_ah_dispatchable( - test: ParaToParaThroughAHTest, - ) -> DispatchResult { - let call = transfer_assets_para_to_para_through_ah_call(test.clone()); - match call.dispatch(test.signed_origin) { - Ok(_) => Ok(()), - Err(error_with_post_info) => Err(error_with_post_info.error), - } - } - fn transfer_assets_para_to_para_through_ah_call( - test: ParaToParaThroughAHTest, - ) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; - let asset_hub_location: Location = PenpalB::sibling_location_of( - AssetHubWestend::para_id(), - ); - let custom_xcm_on_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositAsset { - assets: Wild(AllCounted(test.args.assets.len() as u32)), - beneficiary: test.args.beneficiary, - }, - ]), - ), - ); - RuntimeCall::PolkadotXcm(pallet_xcm::Call::transfer_assets_using_type_and_then { - dest: Box::new(test.args.dest.into()), - assets: Box::new(test.args.assets.clone().into()), - assets_transfer_type: Box::new( - TransferType::RemoteReserve(asset_hub_location.clone().into()), - ), - remote_fees_id: Box::new( - VersionedAssetId::V5(AssetId(Location::new(1, []))), - ), - fees_transfer_type: Box::new( - TransferType::RemoteReserve(asset_hub_location.into()), - ), - custom_xcm_on_dest: Box::new(VersionedXcm::from(custom_xcm_on_dest)), - weight_limit: test.args.weight_limit, - }) - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::xcm_fee_estimation::multi_hop_works"] - pub const multi_hop_works: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName("tests::xcm_fee_estimation::multi_hop_works"), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs", - start_line: 115usize, - start_col: 4usize, - end_line: 115usize, - end_col: 19usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(multi_hop_works()), - ), - }; - /// We are able to dry-run and estimate the fees for a multi-hop XCM journey. - /// Scenario: Alice on PenpalA has some WND and wants to send them to PenpalB. - /// We want to know the fees using the `DryRunApi` and `XcmPaymentApi`. - fn multi_hop_works() { - let destination = PenpalA::sibling_location_of(PenpalB::para_id()); - let sender = PenpalASender::get(); - let amount_to_send = 1_000_000_000_000; - let asset_owner = PenpalAssetOwner::get(); - let assets: Assets = (Parent, amount_to_send).into(); - let relay_native_asset_location = Location::parent(); - let sender_as_seen_by_ah = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_of_sender_on_ah = AssetHubWestend::sovereign_account_id_of( - sender_as_seen_by_ah.clone(), - ); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner.clone()), - relay_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_of_sender_on_ah.clone(), amount_to_send * 2), - ]), - ), - ); - let beneficiary_id = PenpalBReceiver::get(); - let test_args = TestContext { - sender: PenpalASender::get(), - receiver: PenpalBReceiver::get(), - args: TestArgs::new_para( - destination, - beneficiary_id.clone(), - amount_to_send, - assets, - None, - 0, - ), - }; - let mut test = ParaToParaThroughAHTest::new(test_args); - let mut delivery_fees_amount = 0; - let mut remote_message = VersionedXcm::V5(Xcm(Vec::new())); - ::execute_with(|| { - type Runtime = ::Runtime; - type OriginCaller = ::OriginCaller; - let call = transfer_assets_para_to_para_through_ah_call(test.clone()); - let origin = OriginCaller::system(RawOrigin::Signed(sender.clone())); - let result = Runtime::dry_run_call(origin, call).unwrap(); - let (destination_to_query, messages_to_query) = &result - .forwarded_xcms - .iter() - .find(|(destination, _)| { - *destination - == VersionedLocation::V5(Location::new(1, [Parachain(1000)])) - }) - .unwrap(); - match (&messages_to_query.len(), &1) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - remote_message = messages_to_query[0].clone(); - let delivery_fees = Runtime::query_delivery_fees( - destination_to_query.clone(), - remote_message.clone(), - ) - .unwrap(); - delivery_fees_amount = get_amount_from_versioned_assets(delivery_fees); - }); - let mut intermediate_execution_fees = 0; - let mut intermediate_delivery_fees_amount = 0; - let mut intermediate_remote_message = VersionedXcm::V5( - Xcm::<()>(Vec::new()), - ); - ::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - let weight = Runtime::query_xcm_weight(remote_message.clone()).unwrap(); - intermediate_execution_fees = Runtime::query_weight_to_asset_fee( - weight, - VersionedAssetId::V5(Location::new(1, []).into()), - ) - .unwrap(); - let xcm_program = VersionedXcm::V5( - Xcm::::from(remote_message.clone().try_into().unwrap()), - ); - let result = Runtime::dry_run_xcm( - sender_as_seen_by_ah.clone().into(), - xcm_program, - ) - .unwrap(); - let (destination_to_query, messages_to_query) = &result - .forwarded_xcms - .iter() - .find(|(destination, _)| { - *destination - == VersionedLocation::V5(Location::new(1, [Parachain(2001)])) - }) - .unwrap(); - intermediate_remote_message = messages_to_query[0].clone(); - let delivery_fees = Runtime::query_delivery_fees( - destination_to_query.clone(), - intermediate_remote_message.clone(), - ) - .unwrap(); - intermediate_delivery_fees_amount = get_amount_from_versioned_assets( - delivery_fees, - ); - }); - let mut final_execution_fees = 0; - ::execute_with(|| { - type Runtime = ::Runtime; - let weight = Runtime::query_xcm_weight( - intermediate_remote_message.clone(), - ) - .unwrap(); - final_execution_fees = Runtime::query_weight_to_asset_fee( - weight, - VersionedAssetId::V5(Parent.into()), - ) - .unwrap(); - }); - PenpalA::reset_ext(); - AssetHubWestend::reset_ext(); - PenpalB::reset_ext(); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - relay_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([(sov_of_sender_on_ah, amount_to_send * 2)]), - ), - ); - let sender_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &sender) - }); - let receiver_assets_before = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &beneficiary_id) - }); - test.set_assertion::(sender_assertions); - test.set_assertion::(hop_assertions); - test.set_assertion::(receiver_assertions); - test.set_dispatchable::< - PenpalA, - >(transfer_assets_para_to_para_through_ah_dispatchable); - test.assert(); - let sender_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &sender) - }); - let receiver_assets_after = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location, &beneficiary_id) - }); - match ( - &sender_assets_after, - &(sender_assets_before - amount_to_send - delivery_fees_amount), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &receiver_assets_after, - &(receiver_assets_before + amount_to_send - intermediate_execution_fees - - intermediate_delivery_fees_amount - final_execution_fees), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - } -} -#[rustc_main] -#[coverage(off)] -pub fn main() -> () { - extern crate test; - test::test_main_static( - &[ - &assets_can_be_claimed, - &create_and_claim_treasury_spend, - &bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types, - &transfer_foreign_assets_from_asset_hub_to_para, - &transfer_foreign_assets_from_para_to_asset_hub, - &transfer_foreign_assets_from_para_to_para_through_asset_hub, - &transfer_native_asset_from_relay_to_para_through_asset_hub, - &reserve_transfer_multiple_assets_from_asset_hub_to_para, - &reserve_transfer_multiple_assets_from_para_to_asset_hub, - &reserve_transfer_native_asset_from_asset_hub_to_para, - &reserve_transfer_native_asset_from_asset_hub_to_relay_fails, - &reserve_transfer_native_asset_from_para_to_asset_hub, - &reserve_transfer_native_asset_from_para_to_para_through_relay, - &reserve_transfer_native_asset_from_para_to_relay, - &reserve_transfer_native_asset_from_relay_to_asset_hub_fails, - &reserve_transfer_native_asset_from_relay_to_para, - &send_transact_as_superuser_from_relay_to_asset_hub_works, - &send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset, - &send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset, - &relay_sets_system_para_xcm_supported_version, - &system_para_sets_relay_xcm_supported_version, - &cannot_create_pool_from_pool_assets, - &pay_xcm_fee_with_some_asset_swapped_for_native, - &swap_locally_on_chain_using_foreign_assets, - &swap_locally_on_chain_using_local_assets, - &bidirectional_teleport_foreign_assets_between_para_and_asset_hub, - &limited_teleport_native_assets_from_system_para_to_relay_fails, - &teleport_from_and_to_relay, - &teleport_to_other_system_parachains_works, - &create_and_claim_treasury_spend, - &multi_hop_works, - ], - ) -} diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index bb2acdc24b96..503abc73d338 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -29,7 +29,7 @@ use frame_support::{ use sp_core::defer; use sp_io::hashing::blake2_128; use sp_weights::Weight; -use xcm::{latest::prelude::*, v3::MultiLocation}; +use xcm::latest::prelude::*; pub mod traits; use traits::{ From 416fe4ad3c0e3cb8d41b8355d390d7541f760e7b Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 10:02:18 +0300 Subject: [PATCH 076/151] added missing fn definition to trait --- polkadot/xcm/pallet-xcm/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 6451901279b1..b10cc223aacf 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -96,6 +96,7 @@ pub trait WeightInfo { fn new_query() -> Weight; fn take_response() -> Weight; fn claim_assets() -> Weight; + fn set_asset_claimer() -> Weight; } /// fallback implementation From 9b364a6d13d9bf3e07d00991cb6bad00be67cbcd Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 10:13:01 +0300 Subject: [PATCH 077/151] added westhub sac weights --- .../assets/asset-hub-westend/src/weights/pallet_xcm.rs | 4 ++++ polkadot/xcm/pallet-xcm/src/lib.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs index be3d7661ab3c..c67b4896df0b 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs @@ -393,4 +393,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index b10cc223aacf..1543279059b4 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -181,6 +181,10 @@ impl WeightInfo for TestWeightInfo { fn claim_assets() -> Weight { Weight::from_parts(100_000_000, 0) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } #[frame_support::pallet] From aa0d457d57f531d4094c4767b42f1981538b22c9 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 10:27:29 +0300 Subject: [PATCH 078/151] removed unused sender_account --- polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 5d1d643d828c..ffa0a7c302c1 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -115,7 +115,7 @@ benchmarks! { set_asset_claimer { let mut executor = new_executor::(Default::default()); - let (sender_account, sender_location) = account_and_location::(1); + let (_, sender_location) = account_and_location::(1); let instruction = Instruction::SetAssetClaimer{ location:sender_location.clone() }; From 18576bba813ecf1c3ce7d1ffbd86b20f432c9eeb Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 10:41:39 +0300 Subject: [PATCH 079/151] added sac to people-westend --- .../runtimes/people/people-westend/src/weights/pallet_xcm.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs index c337289243b7..3edcdbd5c4db 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs @@ -343,4 +343,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } From 8c3e3c34cf94a79331c82b8fb81193b0bcda9cfc Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 10:51:55 +0300 Subject: [PATCH 080/151] added sac to runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs --- .../collectives/collectives-westend/src/weights/pallet_xcm.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs index 5d427d850046..9206943997c1 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs @@ -373,4 +373,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } From ebd96685f590acbcd8d43c15c88bef48a35c1514 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 10:57:54 +0300 Subject: [PATCH 081/151] added sac to rococo runtime --- polkadot/runtime/rococo/src/weights/pallet_xcm.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs index 5544ca44658c..b40725240b02 100644 --- a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs @@ -346,4 +346,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } From 139a0665464da6981132860a51447c7c4033caba Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 11:15:06 +0300 Subject: [PATCH 082/151] added sac to all the weights/xcm_pallet --- .../assets/asset-hub-rococo/src/weights/pallet_xcm.rs | 4 ++++ .../bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs | 4 ++++ .../bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs | 4 ++++ .../coretime/coretime-rococo/src/weights/pallet_xcm.rs | 4 ++++ .../coretime/coretime-westend/src/weights/pallet_xcm.rs | 4 ++++ .../runtimes/people/people-rococo/src/weights/pallet_xcm.rs | 4 ++++ polkadot/runtime/rococo/src/weights/pallet_xcm.rs | 5 ++++- 7 files changed, 28 insertions(+), 1 deletion(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs index 51b6543bae82..ca96284b5c52 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs @@ -395,4 +395,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs index a732e1a57343..e37ec773deef 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs @@ -373,4 +373,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs index a78ff2355efa..722ebe3443ba 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs @@ -373,4 +373,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs index 7fb492173dad..24baf0b9ff0e 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs @@ -361,4 +361,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs index fa588e982f09..3736dc14c623 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs @@ -361,4 +361,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs index fabce29b5fd9..dfbbec08ee8f 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs @@ -343,4 +343,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs index b40725240b02..a8049ab13252 100644 --- a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs @@ -348,6 +348,9 @@ impl pallet_xcm::WeightInfo for WeightInfo { } fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + Weight::from_parts(35_299_000, 0) + .saturating_add(Weight::from_parts(0, 3488)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } } From 68efec55ef5f29c0c4b28cc24ef301ed47d52e70 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Thu, 5 Sep 2024 08:38:44 +0000 Subject: [PATCH 083/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=westend --target_dir=polkadot --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 128 +++++++++--------- 1 file changed, 66 insertions(+), 62 deletions(-) diff --git a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index f178d56cc375..f35636a79a4f 100644 --- a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,7 +17,7 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-09-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 @@ -63,8 +63,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6196` - // Minimum execution time: 68_015_000 picoseconds. - Weight::from_parts(69_575_000, 6196) + // Minimum execution time: 67_863_000 picoseconds. + Weight::from_parts(70_014_000, 6196) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -72,15 +72,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 738_000 picoseconds. - Weight::from_parts(780_000, 0) + // Minimum execution time: 695_000 picoseconds. + Weight::from_parts(755_000, 0) } pub(crate) fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_621_000 picoseconds. - Weight::from_parts(1_750_000, 0) + // Minimum execution time: 1_703_000 picoseconds. + Weight::from_parts(1_839_000, 0) + } + pub(crate) fn set_asset_claimer() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 678_000 picoseconds. + Weight::from_parts(712_000, 0) } /// Storage: `XcmPallet::Queries` (r:1 w:0) /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -88,58 +95,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3465` - // Minimum execution time: 6_548_000 picoseconds. - Weight::from_parts(6_765_000, 3465) + // Minimum execution time: 6_470_000 picoseconds. + Weight::from_parts(6_722_000, 3465) .saturating_add(T::DbWeight::get().reads(1)) } pub(crate) fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_049_000 picoseconds. - Weight::from_parts(7_267_000, 0) + // Minimum execution time: 7_178_000 picoseconds. + Weight::from_parts(7_447_000, 0) } pub(crate) fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_300_000 picoseconds. - Weight::from_parts(1_408_000, 0) + // Minimum execution time: 1_236_000 picoseconds. + Weight::from_parts(1_326_000, 0) } pub(crate) fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 738_000 picoseconds. - Weight::from_parts(810_000, 0) + // Minimum execution time: 704_000 picoseconds. + Weight::from_parts(746_000, 0) } pub(crate) fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 759_000 picoseconds. - Weight::from_parts(796_000, 0) + // Minimum execution time: 729_000 picoseconds. + Weight::from_parts(768_000, 0) } pub(crate) fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 707_000 picoseconds. - Weight::from_parts(780_000, 0) + // Minimum execution time: 685_000 picoseconds. + Weight::from_parts(738_000, 0) } pub(crate) fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 749_000 picoseconds. - Weight::from_parts(835_000, 0) + // Minimum execution time: 736_000 picoseconds. + Weight::from_parts(776_000, 0) } pub(crate) fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 751_000 picoseconds. - Weight::from_parts(799_000, 0) + // Minimum execution time: 700_000 picoseconds. + Weight::from_parts(756_000, 0) } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -155,8 +162,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6196` - // Minimum execution time: 65_464_000 picoseconds. - Weight::from_parts(67_406_000, 6196) + // Minimum execution time: 65_431_000 picoseconds. + Weight::from_parts(66_937_000, 6196) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -166,8 +173,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `23` // Estimated: `3488` - // Minimum execution time: 9_887_000 picoseconds. - Weight::from_parts(10_310_000, 3488) + // Minimum execution time: 9_667_000 picoseconds. + Weight::from_parts(10_074_000, 3488) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -175,8 +182,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 737_000 picoseconds. - Weight::from_parts(792_000, 0) + // Minimum execution time: 684_000 picoseconds. + Weight::from_parts(719_000, 0) } /// Storage: `XcmPallet::VersionNotifyTargets` (r:1 w:1) /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -192,8 +199,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `147` // Estimated: `3612` - // Minimum execution time: 30_726_000 picoseconds. - Weight::from_parts(31_268_000, 3612) + // Minimum execution time: 30_607_000 picoseconds. + Weight::from_parts(31_576_000, 3612) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -203,44 +210,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_051_000 picoseconds. - Weight::from_parts(3_154_000, 0) + // Minimum execution time: 2_833_000 picoseconds. + Weight::from_parts(2_989_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub(crate) fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_146_000 picoseconds. - Weight::from_parts(1_223_000, 0) + // Minimum execution time: 1_131_000 picoseconds. + Weight::from_parts(1_205_000, 0) } pub(crate) fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 821_000 picoseconds. - Weight::from_parts(901_000, 0) + // Minimum execution time: 845_000 picoseconds. + Weight::from_parts(887_000, 0) } pub(crate) fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 762_000 picoseconds. - Weight::from_parts(808_000, 0) + // Minimum execution time: 713_000 picoseconds. + Weight::from_parts(753_000, 0) } pub(crate) fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 727_000 picoseconds. - Weight::from_parts(789_000, 0) + // Minimum execution time: 705_000 picoseconds. + Weight::from_parts(742_000, 0) } pub(crate) fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 867_000 picoseconds. - Weight::from_parts(933_000, 0) + // Minimum execution time: 876_000 picoseconds. + Weight::from_parts(920_000, 0) } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -256,8 +263,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6196` - // Minimum execution time: 74_949_000 picoseconds. - Weight::from_parts(76_124_000, 6196) + // Minimum execution time: 74_354_000 picoseconds. + Weight::from_parts(76_278_000, 6196) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -265,8 +272,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_553_000 picoseconds. - Weight::from_parts(7_889_000, 0) + // Minimum execution time: 7_316_000 picoseconds. + Weight::from_parts(7_553_000, 0) } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -282,8 +289,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6196` - // Minimum execution time: 65_953_000 picoseconds. - Weight::from_parts(67_221_000, 6196) + // Minimum execution time: 65_391_000 picoseconds. + Weight::from_parts(67_302_000, 6196) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -291,38 +298,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 770_000 picoseconds. - Weight::from_parts(848_000, 0) + // Minimum execution time: 728_000 picoseconds. + Weight::from_parts(790_000, 0) } pub(crate) fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 685_000 picoseconds. - Weight::from_parts(766_000, 0) + // Minimum execution time: 671_000 picoseconds. + Weight::from_parts(715_000, 0) } pub(crate) fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 693_000 picoseconds. - Weight::from_parts(759_000, 0) + // Minimum execution time: 670_000 picoseconds. + Weight::from_parts(725_000, 0) } pub(crate) fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 739_000 picoseconds. - Weight::from_parts(791_000, 0) + // Minimum execution time: 677_000 picoseconds. + Weight::from_parts(739_000, 0) } pub(crate) fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 735_000 picoseconds. - Weight::from_parts(811_000, 0) - } - pub(crate) fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Minimum execution time: 705_000 picoseconds. + Weight::from_parts(770_000, 0) } } From 43a1231f4d41cd177a21d9a14cddbf7201bd904a Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 15:00:20 +0300 Subject: [PATCH 084/151] Added SetAssetClaimer instruction --- polkadot/xcm/src/v5/mod.rs | 9 +++++++++ polkadot/xcm/xcm-executor/src/lib.rs | 13 +++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index 0fcaa1784392..f6d5b8f0f47d 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -738,6 +738,15 @@ pub enum Instruction { /// Errors: None. ClearError, + /// Set asset claimer for all the trapped assets during the execution. + /// + /// - `location`: The claimer of the assets; it might be an arbitrary location, not necessarily the caller or origin. + /// + /// Kind: *Command* + /// + /// Errors: None. + SetAssetClaimer {location: Location}, + /// Create some assets which are being held on behalf of the origin. /// /// - `assets`: The assets which are to be claimed. This must match exactly with the assets diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index ee816a31e81c..4add5fbf8531 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -29,7 +29,7 @@ use frame_support::{ use sp_core::defer; use sp_io::hashing::blake2_128; use sp_weights::Weight; -use xcm::latest::prelude::*; +use xcm::{latest::prelude::*, v3::MultiLocation}; pub mod traits; use traits::{ @@ -93,6 +93,7 @@ pub struct XcmExecutor { /// Stores the current message's weight. message_weight: Weight, _config: PhantomData, + assetClaimer: Option, } #[cfg(any(test, feature = "runtime-benchmarks"))] @@ -361,7 +362,11 @@ impl XcmExecutor { original_origin = ?self.original_origin, "Trapping assets in holding register", ); - let effective_origin = self.context.origin.as_ref().unwrap_or(&self.original_origin); + let effective_orgin = if let Some(assetClaimer) = self.assetClaimer { + assetClaimer.as_ref().unwrap_or(&self.original_origin) + } else { + self.context.origin.as_ref().unwrap_or(&self.original_origin) + }; let trap_weight = Config::AssetTrap::drop_assets(effective_origin, self.holding, &self.context); weight_used.saturating_accrue(trap_weight); @@ -1161,6 +1166,10 @@ impl XcmExecutor { self.error = None; Ok(()) }, + SetAssetClaimer { location } => { + self.assetClaimer = Some(location); + Ok(()) + } ClaimAsset { assets, ticket } => { let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; self.ensure_can_subsume_assets(assets.len())?; From 1d71fb752ba5f94233475f4ddb226a1797b63dc2 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 15:43:19 +0300 Subject: [PATCH 085/151] added prdoc --- prdoc/pr_5416.prdoc | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 prdoc/pr_5416.prdoc diff --git a/prdoc/pr_5416.prdoc b/prdoc/pr_5416.prdoc new file mode 100644 index 000000000000..aa970202218a --- /dev/null +++ b/prdoc/pr_5416.prdoc @@ -0,0 +1,11 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Added SetAssetClaimer instruction + +doc: + - audience: Runtime Dev + description: | + ... + +crates: [ ] From 224a6d6d47c8c0e5152f358236a54ecef3ea54e3 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 15:48:49 +0300 Subject: [PATCH 086/151] added missing column --- polkadot/xcm/xcm-executor/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 4add5fbf8531..2dcfe337d179 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -1169,7 +1169,7 @@ impl XcmExecutor { SetAssetClaimer { location } => { self.assetClaimer = Some(location); Ok(()) - } + }, ClaimAsset { assets, ticket } => { let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; self.ensure_can_subsume_assets(assets.len())?; From 5c035cc67357ca056f829a0476203a651e806339 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 16:22:22 +0300 Subject: [PATCH 087/151] fixed prdoc: added crates --- prdoc/pr_5416.prdoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/prdoc/pr_5416.prdoc b/prdoc/pr_5416.prdoc index aa970202218a..330c18390d9e 100644 --- a/prdoc/pr_5416.prdoc +++ b/prdoc/pr_5416.prdoc @@ -8,4 +8,7 @@ doc: description: | ... -crates: [ ] +crates: +- name: staging-xcm-executor + bump: minor + From bfe7627b4b7e9d6fc70197bbbe9d1e7d60cb436d Mon Sep 17 00:00:00 2001 From: Andrii Date: Tue, 20 Aug 2024 16:41:52 +0300 Subject: [PATCH 088/151] Update SetAssetClaimer description Co-authored-by: Adrian Catangiu --- polkadot/xcm/src/v5/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index f6d5b8f0f47d..4d91d6be32ac 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -740,7 +740,8 @@ pub enum Instruction { /// Set asset claimer for all the trapped assets during the execution. /// - /// - `location`: The claimer of the assets; it might be an arbitrary location, not necessarily the caller or origin. + /// - `location`: The claimer of any assets potentially trapped during the execution of current XCM. + /// It can be an arbitrary location, not necessarily the caller or origin. /// /// Kind: *Command* /// From 802ece4919bf0f00929b6918216d8756fed683d2 Mon Sep 17 00:00:00 2001 From: Andrii Date: Tue, 20 Aug 2024 16:42:27 +0300 Subject: [PATCH 089/151] Formated SetAssetClaimer Co-authored-by: Adrian Catangiu --- polkadot/xcm/src/v5/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index 4d91d6be32ac..dadc8f3729b4 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -746,7 +746,7 @@ pub enum Instruction { /// Kind: *Command* /// /// Errors: None. - SetAssetClaimer {location: Location}, + SetAssetClaimer { location: Location }, /// Create some assets which are being held on behalf of the origin. /// From ee9e8d5c013b69ff9955cc59136eab4b498ce934 Mon Sep 17 00:00:00 2001 From: Andrii Date: Tue, 20 Aug 2024 16:42:56 +0300 Subject: [PATCH 090/151] Removed v3::MultiLocation Co-authored-by: Adrian Catangiu --- polkadot/xcm/xcm-executor/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 2dcfe337d179..2bd0c47df454 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -29,7 +29,7 @@ use frame_support::{ use sp_core::defer; use sp_io::hashing::blake2_128; use sp_weights::Weight; -use xcm::{latest::prelude::*, v3::MultiLocation}; +use xcm::latest::prelude::*; pub mod traits; use traits::{ From 3be83393c51a312a0422329c9df7d78befdee8ea Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 16:50:27 +0300 Subject: [PATCH 091/151] changed asset claimer variable name from camel case to snake case --- polkadot/xcm/xcm-executor/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 2bd0c47df454..bdb6573d3551 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -93,7 +93,7 @@ pub struct XcmExecutor { /// Stores the current message's weight. message_weight: Weight, _config: PhantomData, - assetClaimer: Option, + asset_claimer: Option, } #[cfg(any(test, feature = "runtime-benchmarks"))] @@ -1167,7 +1167,7 @@ impl XcmExecutor { Ok(()) }, SetAssetClaimer { location } => { - self.assetClaimer = Some(location); + self.asset_claimer = Some(location); Ok(()) }, ClaimAsset { assets, ticket } => { From 202d4d1b0c7d26ee5c4e3b31aaea4027ececa3b9 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 16:51:35 +0300 Subject: [PATCH 092/151] initialized XCMExecutor with an empty asset_claimer --- polkadot/xcm/xcm-executor/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index bdb6573d3551..15407a103460 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -340,6 +340,7 @@ impl XcmExecutor { asset_used_for_fees: None, message_weight: Weight::zero(), _config: PhantomData, + asset_claimer: None, } } @@ -362,8 +363,8 @@ impl XcmExecutor { original_origin = ?self.original_origin, "Trapping assets in holding register", ); - let effective_orgin = if let Some(assetClaimer) = self.assetClaimer { - assetClaimer.as_ref().unwrap_or(&self.original_origin) + let effective_orgin = if let Some(asset_claimer) = self.asset_claimer { + asset_claimer.as_ref().unwrap_or(&self.original_origin) } else { self.context.origin.as_ref().unwrap_or(&self.original_origin) }; From 455678da53c6d1cbdad7fa93d2156ef3a63d144f Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 17:51:59 +0300 Subject: [PATCH 093/151] Added missing instructions coverter --- polkadot/xcm/src/v4/mod.rs | 1 + polkadot/xcm/src/v5/mod.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/polkadot/xcm/src/v4/mod.rs b/polkadot/xcm/src/v4/mod.rs index 43629d8f5951..9bc1706dc8ad 100644 --- a/polkadot/xcm/src/v4/mod.rs +++ b/polkadot/xcm/src/v4/mod.rs @@ -1368,6 +1368,7 @@ impl TryFrom> for Instruction { SetErrorHandler(xcm) => Self::SetErrorHandler(xcm.try_into()?), SetAppendix(xcm) => Self::SetAppendix(xcm.try_into()?), ClearError => Self::ClearError, + SetAssetClaimer { location } => {return Err(());}, ClaimAsset { assets, ticket } => { let assets = assets.try_into()?; let ticket = ticket.try_into()?; diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index dadc8f3729b4..d051f4ec0310 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -1103,6 +1103,7 @@ impl Instruction { SetErrorHandler(xcm) => SetErrorHandler(xcm.into()), SetAppendix(xcm) => SetAppendix(xcm.into()), ClearError => ClearError, + SetAssetClaimer { location } => SetAssetClaimer { location }, ClaimAsset { assets, ticket } => ClaimAsset { assets, ticket }, Trap(code) => Trap(code), SubscribeVersion { query_id, max_response_weight } => @@ -1173,6 +1174,7 @@ impl> GetWeight for Instruction { SetErrorHandler(xcm) => W::set_error_handler(xcm), SetAppendix(xcm) => W::set_appendix(xcm), ClearError => W::clear_error(), + SetAssetClaimer { location } => W::set_asset_claimer(location), ClaimAsset { assets, ticket } => W::claim_asset(assets, ticket), Trap(code) => W::trap(code), SubscribeVersion { query_id, max_response_weight } => From 3d47c4b43751d8f5927e9c3dc4189ddccc376e90 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 18:03:51 +0300 Subject: [PATCH 094/151] applied linter suggestions --- polkadot/xcm/src/v4/mod.rs | 4 +++- polkadot/xcm/src/v5/mod.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/polkadot/xcm/src/v4/mod.rs b/polkadot/xcm/src/v4/mod.rs index 9bc1706dc8ad..1988b5055800 100644 --- a/polkadot/xcm/src/v4/mod.rs +++ b/polkadot/xcm/src/v4/mod.rs @@ -1368,7 +1368,9 @@ impl TryFrom> for Instruction { SetErrorHandler(xcm) => Self::SetErrorHandler(xcm.try_into()?), SetAppendix(xcm) => Self::SetAppendix(xcm.try_into()?), ClearError => Self::ClearError, - SetAssetClaimer { location } => {return Err(());}, + SetAssetClaimer { location } => { + return Err(()); + }, ClaimAsset { assets, ticket } => { let assets = assets.try_into()?; let ticket = ticket.try_into()?; diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index d051f4ec0310..37a506ebd6d9 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -740,8 +740,8 @@ pub enum Instruction { /// Set asset claimer for all the trapped assets during the execution. /// - /// - `location`: The claimer of any assets potentially trapped during the execution of current XCM. - /// It can be an arbitrary location, not necessarily the caller or origin. + /// - `location`: The claimer of any assets potentially trapped during the execution of current + /// XCM. It can be an arbitrary location, not necessarily the caller or origin. /// /// Kind: *Command* /// From d4a700432bfb2c39b35b6d93d678a59afcf744bd Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 20 Aug 2024 18:15:38 +0300 Subject: [PATCH 095/151] applied linter suggestions[2] --- polkadot/xcm/src/v5/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index 37a506ebd6d9..63aae405c395 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -747,7 +747,7 @@ pub enum Instruction { /// /// Errors: None. SetAssetClaimer { location: Location }, - + /// Create some assets which are being held on behalf of the origin. /// /// - `assets`: The assets which are to be claimed. This must match exactly with the assets From c4da6f16764c225f651162bb6d77c261c7774d6b Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 21 Aug 2024 14:38:56 +0300 Subject: [PATCH 096/151] fixed type mismatch and other compilation errs --- polkadot/xcm/src/v4/mod.rs | 2 +- polkadot/xcm/xcm-executor/src/lib.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/polkadot/xcm/src/v4/mod.rs b/polkadot/xcm/src/v4/mod.rs index 1988b5055800..b02406f7f452 100644 --- a/polkadot/xcm/src/v4/mod.rs +++ b/polkadot/xcm/src/v4/mod.rs @@ -1368,7 +1368,7 @@ impl TryFrom> for Instruction { SetErrorHandler(xcm) => Self::SetErrorHandler(xcm.try_into()?), SetAppendix(xcm) => Self::SetAppendix(xcm.try_into()?), ClearError => Self::ClearError, - SetAssetClaimer { location } => { + SetAssetClaimer { location: _ } => { return Err(()); }, ClaimAsset { assets, ticket } => { diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 15407a103460..6c7707eac43a 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -363,8 +363,8 @@ impl XcmExecutor { original_origin = ?self.original_origin, "Trapping assets in holding register", ); - let effective_orgin = if let Some(asset_claimer) = self.asset_claimer { - asset_claimer.as_ref().unwrap_or(&self.original_origin) + let effective_origin = if let Some(asset_claimer) = self.asset_claimer.as_ref() { + asset_claimer } else { self.context.origin.as_ref().unwrap_or(&self.original_origin) }; @@ -1050,6 +1050,9 @@ impl XcmExecutor { &reserve, Some(&mut self.holding), ); + // TODO: modify the message by adding setAssetClaimer. + // replicate for teleport and regular withdraw functions. + // add e2e tests. let mut message = vec![WithdrawAsset(assets), ClearOrigin]; message.extend(xcm.0.into_iter()); self.send(reserve, Xcm(message), FeeReason::InitiateReserveWithdraw)?; From 8212c5bc49080e32dc297d5a577b095b4101fd28 Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 21 Aug 2024 17:29:44 +0300 Subject: [PATCH 097/151] added missing implementation (or todo!() ) for AssetHubWestendXcmWeight --- .../runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 478113359a7e..d2f94a1efe02 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -153,6 +153,10 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } + fn set_asset_claimer(location: &Location,) -> Weight { + // TODO: implement + todo!() + } fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } From a43735dfb6cde3fe0687d573af77a46f38e2fff7 Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 21 Aug 2024 18:40:31 +0300 Subject: [PATCH 098/151] few minor refactors --- .../runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs | 2 +- polkadot/xcm/src/v4/mod.rs | 2 +- polkadot/xcm/xcm-executor/src/lib.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index d2f94a1efe02..3a1a498a7f80 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -153,7 +153,7 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } - fn set_asset_claimer(location: &Location,) -> Weight { + fn set_asset_claimer(location: &Location) -> Weight { // TODO: implement todo!() } diff --git a/polkadot/xcm/src/v4/mod.rs b/polkadot/xcm/src/v4/mod.rs index b02406f7f452..b22fa8f32e68 100644 --- a/polkadot/xcm/src/v4/mod.rs +++ b/polkadot/xcm/src/v4/mod.rs @@ -1368,7 +1368,7 @@ impl TryFrom> for Instruction { SetErrorHandler(xcm) => Self::SetErrorHandler(xcm.try_into()?), SetAppendix(xcm) => Self::SetAppendix(xcm.try_into()?), ClearError => Self::ClearError, - SetAssetClaimer { location: _ } => { + SetAssetClaimer { .. } => { return Err(()); }, ClaimAsset { assets, ticket } => { diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 6c7707eac43a..56ac4b734dc1 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -363,13 +363,13 @@ impl XcmExecutor { original_origin = ?self.original_origin, "Trapping assets in holding register", ); - let effective_origin = if let Some(asset_claimer) = self.asset_claimer.as_ref() { + let claimer = if let Some(asset_claimer) = self.asset_claimer.as_ref() { asset_claimer } else { self.context.origin.as_ref().unwrap_or(&self.original_origin) }; let trap_weight = - Config::AssetTrap::drop_assets(effective_origin, self.holding, &self.context); + Config::AssetTrap::drop_assets(claimer, self.holding, &self.context); weight_used.saturating_accrue(trap_weight); }; From 50e566d9ae54d116f39a1de921a6ea81dbbcd7a1 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 26 Aug 2024 14:48:31 +0300 Subject: [PATCH 099/151] unit tests in progress --- polkadot/xcm/src/v5/mod.rs | 1 + polkadot/xcm/xcm-executor/src/tests/mod.rs | 1 + .../src/tests/set_asset_claimer.rs | 64 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index 63aae405c395..efea42166279 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -746,6 +746,7 @@ pub enum Instruction { /// Kind: *Command* /// /// Errors: None. + #[builder(set_asset_claimer)] SetAssetClaimer { location: Location }, /// Create some assets which are being held on behalf of the origin. diff --git a/polkadot/xcm/xcm-executor/src/tests/mod.rs b/polkadot/xcm/xcm-executor/src/tests/mod.rs index 9892a0277127..c8b8d5b67113 100644 --- a/polkadot/xcm/xcm-executor/src/tests/mod.rs +++ b/polkadot/xcm/xcm-executor/src/tests/mod.rs @@ -22,3 +22,4 @@ mod mock; mod pay_fees; +mod set_asset_claimer; diff --git a/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs new file mode 100644 index 000000000000..379e9b0fcf28 --- /dev/null +++ b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs @@ -0,0 +1,64 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +//! Unit tests related to the `fees` register and `PayFees` instruction. +//! +//! See [Fellowship RFC 105](https://github.com/polkadot-fellows/rfCs/pull/105) +//! and the [specification](https://github.com/polkadot-fellows/xcm-format) for more information. + +use codec::Encode; +use xcm::prelude::*; + +use super::mock::*; +use crate::XcmExecutor; + +#[test] +fn works_with_set_asset_claimer() { + let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + let recipient = Location::new(0, [AccountId32 { id: [1; 32], network: None }]); + + // Make sure the user has enough funds to withdraw. + add_asset(sender.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder() + // .set_asset_claimer(sender) + .withdraw_asset((Here, 100u128)) + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .clear_origin() + .build(); + + // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we + // can inspect its fields. + let mut vm = + XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + + let result = vm.bench_process(xcm); + assert!(result.is_ok()); + + assert_eq!(get_first_fungible(vm.holding()), None); + // Execution fees were 4, so we still have 6 left in the `fees` register. + assert_eq!(get_first_fungible(vm.fees()).unwrap(), (Here, 6u128).into()); + + // The recipient received all the assets in the holding register, so `100` that + // were withdrawn minus the `10` that were destinated for fee payment. + assert_eq!(asset_list(recipient), [(Here, 90u128).into()]); +} + +#[test] +fn works_without_set_asset_claimer() { +} \ No newline at end of file From cb2fc15120f9514879dd07c7690896c62e22062e Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 26 Aug 2024 18:33:27 +0300 Subject: [PATCH 100/151] Added unit test for SetAssetClaimer --- .../asset-hub-rococo/src/weights/xcm/mod.rs | 8 ++ .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + polkadot/xcm/src/v5/mod.rs | 1 - polkadot/xcm/xcm-executor/src/lib.rs | 1 + .../src/tests/set_asset_claimer.rs | 97 ++++++++++++++++--- 5 files changed, 98 insertions(+), 12 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index 19a10ba370bb..e6c376ebc90a 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -153,6 +153,10 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } + fn set_asset_claimer(location: &Location) -> Weight { + XcmGeneric::::set_asset_claimer() + } + fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } @@ -232,4 +236,8 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 48918767561b..b20dba8a8ab9 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -146,6 +146,9 @@ impl WeightInfo { // Minimum execution time: 727_000 picoseconds. Weight::from_parts(780_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index efea42166279..63aae405c395 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -746,7 +746,6 @@ pub enum Instruction { /// Kind: *Command* /// /// Errors: None. - #[builder(set_asset_claimer)] SetAssetClaimer { location: Location }, /// Create some assets which are being held on behalf of the origin. diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 56ac4b734dc1..4313ea8c561a 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -194,6 +194,7 @@ impl XcmExecutor { pub fn set_topic(&mut self, v: Option<[u8; 32]>) { self.context.topic = v; } + pub fn asset_claimer(&self) -> Option { self.asset_claimer.clone() } } pub struct WeighedMessage(Weight, Xcm); diff --git a/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs index 379e9b0fcf28..743da8d68869 100644 --- a/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs +++ b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs @@ -26,19 +26,47 @@ use super::mock::*; use crate::XcmExecutor; #[test] -fn works_with_set_asset_claimer() { +fn set_asset_claimer() { let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); - let recipient = Location::new(0, [AccountId32 { id: [1; 32], network: None }]); + let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); // Make sure the user has enough funds to withdraw. add_asset(sender.clone(), (Here, 100u128)); // Build xcm. - let xcm = Xcm::::builder() - // .set_asset_claimer(sender) + let xcm = Xcm::::builder_unsafe() + // if withdrawing fails we're not missing any corner case. .withdraw_asset((Here, 100u128)) + .clear_origin() + // .trap(0u64) + .set_asset_claimer(bob.clone()) .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .build(); + + // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we + // can inspect its fields. + let mut vm = + XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + + let result = vm.bench_process(xcm); + assert!(result.is_ok()); + assert_eq!(vm.asset_claimer(), Some(bob)); +} + +#[test] +fn do_not_set_asset_claimer_none() { + let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + + // Make sure the user has enough funds to withdraw. + add_asset(sender.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder_unsafe() + // if withdrawing fails we're not missing any corner case. + .withdraw_asset((Here, 100u128)) .clear_origin() + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. .build(); // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we @@ -49,16 +77,63 @@ fn works_with_set_asset_claimer() { let result = vm.bench_process(xcm); assert!(result.is_ok()); + assert_eq!(vm.asset_claimer(), None); +} - assert_eq!(get_first_fungible(vm.holding()), None); - // Execution fees were 4, so we still have 6 left in the `fees` register. - assert_eq!(get_first_fungible(vm.fees()).unwrap(), (Here, 6u128).into()); +#[test] +fn trap_then_set_asset_claimer() { + let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); - // The recipient received all the assets in the holding register, so `100` that - // were withdrawn minus the `10` that were destinated for fee payment. - assert_eq!(asset_list(recipient), [(Here, 90u128).into()]); + // Make sure the user has enough funds to withdraw. + add_asset(sender.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder_unsafe() + // if withdrawing fails we're not missing any corner case. + .withdraw_asset((Here, 100u128)) + .clear_origin() + .trap(0u64) + .set_asset_claimer(bob) + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .build(); + + // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we + // can inspect its fields. + let mut vm = + XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + + let result = vm.bench_process(xcm); + assert!(result.is_err()); + assert_eq!(vm.asset_claimer(), None); } #[test] -fn works_without_set_asset_claimer() { +fn set_asset_claimer_then_trap() { + let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); + + // Make sure the user has enough funds to withdraw. + add_asset(sender.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder_unsafe() + // if withdrawing fails we're not missing any corner case. + .withdraw_asset((Here, 100u128)) + .clear_origin() + .set_asset_claimer(bob.clone()) + .trap(0u64) + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .build(); + + // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we + // can inspect its fields. + let mut vm = + XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + + let result = vm.bench_process(xcm); + assert!(result.is_err()); + assert_eq!(vm.asset_claimer(), Some(bob)); } \ No newline at end of file From d89fb700c00a6ed3b7a3b8191214baffb6173175 Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 28 Aug 2024 20:11:41 +0300 Subject: [PATCH 101/151] [WIP] set_asset_claimer e2e test --- .../assets/asset-hub-westend/src/tests/mod.rs | 1 + .../src/tests/set_asset_claimer.rs | 106 + .../asset-hub-westend/src/weights/xcm/mod.rs | 4 + .../bridge-hub-westend/src/weights/xcm/mod.rs | 9 + .../coretime-westend/src/weights/xcm/mod.rs | 9 + .../people-westend/src/weights/xcm/mod.rs | 9 + expansion.rs | 14961 ++++++++++++++++ .../runtime/westend/src/weights/xcm/mod.rs | 9 + 8 files changed, 15108 insertions(+) create mode 100644 cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs create mode 100644 expansion.rs diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs index 73b73b239a1b..089f899696bb 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs @@ -23,3 +23,4 @@ mod swap; mod teleport; mod treasury; mod xcm_fee_estimation; +mod set_asset_claimer; diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs new file mode 100644 index 000000000000..7a053388d741 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -0,0 +1,106 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Tests related to claiming assets trapped during XCM execution. + +use crate::imports::*; + +use frame_support::{ + dispatch::RawOrigin, + sp_runtime::{traits::Dispatchable, DispatchResult}, +}; +use emulated_integration_tests_common::test_chain_can_claim_assets; +use xcm_executor::traits::DropAssets; +use xcm_runtime_apis::{ + dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, + fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, +}; + +#[test] +fn azs() { + let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); + let destination = PenpalA::sibling_location_of(PenpalB::para_id()); + let sender = PenpalASender::get(); + let beneficiary_id = PenpalBReceiver::get(); + let amount_to_send = 1_000_000_000_000; + let assets: Assets = (Parent, amount_to_send).into(); + + // Fund accounts again. + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(PenpalAssetOwner::get()), + Location::parent().clone(), + sender.clone(), + amount_to_send * 2, + ); + + let test_args = TestContext { + sender: PenpalASender::get(), // Bob in PenpalB. + receiver: PenpalBReceiver::get(), // Alice. + args: TestArgs::new_para( + destination, + beneficiary_id.clone(), + amount_to_send, + assets, + None, + 0, + ), + }; + let mut test = ParaToParaThroughAHTest::new(test_args); + transfer_assets(test.clone(), bob.clone()); + // let call = transfer_assets(test.clone(), bob.clone()); + + + // test.set_assertion::(sender_assertions); + // test.set_call(call); + // test.assert(); +} + +fn transfer_assets( + test: ParaToParaThroughAHTest, + claimer: Location +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; + + + + let local_xcm = Xcm::::builder_unsafe() + .clear_origin() + .set_asset_claimer(claimer.clone()) + .withdraw_asset(test.args.assets.clone()) + .pay_fees((Parent, 0)) + .build(); + + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(3_000_000_000, 200_000), + }) +} + +fn sender_assertions(test: ParaToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + // PenpalA::assert_xcm_pallet_attempted_complete(None); + assert_expected_events!( + PenpalA, + vec![ + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance } + ) => { + asset_id: *asset_id == Location::new(1, []), + owner: *owner == test.sender.account_id, + balance: *balance == test.args.amount, + }, + ] + ); +} \ No newline at end of file diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 3a1a498a7f80..1a1746feadc2 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -236,4 +236,8 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index 35abce1083d9..83209d11aeaa 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -155,6 +155,11 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } + + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } + fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } @@ -235,4 +240,8 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs index 24787079e4c0..f6292ff9f6c2 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs @@ -153,6 +153,11 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } + + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } + fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } @@ -232,4 +237,8 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs index 3f0bda0f4f57..1dd5dc3cd742 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs @@ -152,6 +152,11 @@ impl XcmWeightInfo for PeopleWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } + + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } + fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } @@ -231,4 +236,8 @@ impl XcmWeightInfo for PeopleWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/expansion.rs b/expansion.rs new file mode 100644 index 000000000000..7be4f19597a3 --- /dev/null +++ b/expansion.rs @@ -0,0 +1,14961 @@ +#![feature(prelude_import)] +#[prelude_import] +use std::prelude::rust_2021::*; +#[macro_use] +extern crate std; +#[cfg(test)] +mod imports { + pub use codec::Encode; + pub use frame_support::{ + assert_err, assert_ok, pallet_prelude::Weight, + sp_runtime::{DispatchError, DispatchResult, ModuleError}, + traits::fungibles::Inspect, + }; + pub use xcm::prelude::{AccountId32 as AccountId32Junction, *}; + pub use xcm_executor::traits::TransferType; + pub use asset_test_utils::xcm_helpers; + pub use emulated_integration_tests_common::{ + accounts::DUMMY_EMPTY, get_account_id_from_seed, + test_parachain_is_trusted_teleporter, + test_parachain_is_trusted_teleporter_for_relay, test_relay_is_trusted_teleporter, + xcm_emulator::{ + assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, + Test, TestArgs, TestContext, TestExt, + }, + xcm_helpers::{ + get_amount_from_versioned_assets, non_fee_asset, xcm_transact_paid_execution, + }, + ASSETS_PALLET_ID, RESERVABLE_ASSET_ID, XCM_V3, + }; + pub use parachains_common::{AccountId, Balance}; + pub use westend_system_emulated_network::{ + asset_hub_westend_emulated_chain::{ + asset_hub_westend_runtime::{ + xcm_config::{ + self as ahw_xcm_config, WestendLocation as RelayLocation, + XcmConfig as AssetHubWestendXcmConfig, + }, + AssetConversionOrigin as AssetHubWestendAssetConversionOrigin, + ExistentialDeposit as AssetHubWestendExistentialDeposit, + }, + genesis::{AssetHubWestendAssetOwner, ED as ASSET_HUB_WESTEND_ED}, + AssetHubWestendParaPallet as AssetHubWestendPallet, + }, + collectives_westend_emulated_chain::CollectivesWestendParaPallet as CollectivesWestendPallet, + penpal_emulated_chain::{ + penpal_runtime::xcm_config::{ + CustomizableAssetFromSystemAssetHub as PenpalCustomizableAssetFromSystemAssetHub, + LocalReservableFromAssetHub as PenpalLocalReservableFromAssetHub, + LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub, + }, + PenpalAParaPallet as PenpalAPallet, PenpalAssetOwner, + PenpalBParaPallet as PenpalBPallet, + }, + westend_emulated_chain::{ + genesis::ED as WESTEND_ED, + westend_runtime::xcm_config::{ + UniversalLocation as WestendUniversalLocation, + XcmConfig as WestendXcmConfig, + }, + WestendRelayPallet as WestendPallet, + }, + AssetHubWestendPara as AssetHubWestend, + AssetHubWestendParaReceiver as AssetHubWestendReceiver, + AssetHubWestendParaSender as AssetHubWestendSender, + BridgeHubWestendPara as BridgeHubWestend, + BridgeHubWestendParaReceiver as BridgeHubWestendReceiver, + CollectivesWestendPara as CollectivesWestend, PenpalAPara as PenpalA, + PenpalAParaReceiver as PenpalAReceiver, PenpalAParaSender as PenpalASender, + PenpalBPara as PenpalB, PenpalBParaReceiver as PenpalBReceiver, + WestendRelay as Westend, WestendRelayReceiver as WestendReceiver, + WestendRelaySender as WestendSender, + }; + pub const ASSET_ID: u32 = 3; + pub const ASSET_MIN_BALANCE: u128 = 1000; + pub type RelayToParaTest = Test; + pub type ParaToRelayTest = Test; + pub type SystemParaToRelayTest = Test; + pub type SystemParaToParaTest = Test; + pub type ParaToSystemParaTest = Test; + pub type ParaToParaThroughRelayTest = Test; + pub type ParaToParaThroughAHTest = Test; + pub type RelayToParaThroughAHTest = Test; +} +#[cfg(test)] +mod tests { + mod claim_assets { + //! Tests related to claiming assets trapped during XCM execution. + use crate::imports::*; + use frame_support::{ + dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, + }; + use emulated_integration_tests_common::test_chain_can_claim_assets; + use xcm_executor::traits::DropAssets; + use xcm_runtime_apis::{ + dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, + fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, + }; + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::claim_assets::assets_can_be_claimed"] + pub const assets_can_be_claimed: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("tests::claim_assets::assets_can_be_claimed"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/claim_assets.rs", + start_line: 32usize, + start_col: 4usize, + end_line: 32usize, + end_col: 25usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(assets_can_be_claimed()), + ), + }; + fn assets_can_be_claimed() { + let amount = AssetHubWestendExistentialDeposit::get(); + let assets: Assets = (Parent, amount).into(); + let sender = AssetHubWestendSender::get(); + let origin = ::RuntimeOrigin::signed( + sender.clone(), + ); + let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { + network: Some(NetworkId::Westend), + id: sender.clone().into(), + } + .into(); + let versioned_assets: ::emulated_integration_tests_common::macros::VersionedAssets = assets + .clone() + .into(); + ::execute_with(|| { + ::PolkadotXcm::drop_assets( + &beneficiary, + assets.clone().into(), + &XcmContext { + origin: None, + message_id: [0u8; 32], + topic: None, + }, + ); + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsTrapped { + origin: beneficiary, + assets: versioned_assets, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsTrapped {\norigin: beneficiary, assets: versioned_assets, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsTrapped {\norigin: beneficiary, assets: versioned_assets, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::claim_assets", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let balance_before = ::Balances::free_balance( + &sender, + ); + let other_origin = ::RuntimeOrigin::signed( + AssetHubWestendReceiver::get(), + ); + if !::PolkadotXcm::claim_assets( + other_origin, + Box::new(versioned_assets.clone().into()), + Box::new(beneficiary.clone().into()), + ) + .is_err() + { + ::core::panicking::panic( + "assertion failed: ::PolkadotXcm::claim_assets(other_origin,\n bx!(versioned_assets.clone().into()),\n bx!(beneficiary.clone().into())).is_err()", + ) + } + let other_versioned_assets: ::emulated_integration_tests_common::macros::VersionedAssets = Assets::new() + .into(); + if !::PolkadotXcm::claim_assets( + origin.clone(), + Box::new(other_versioned_assets.into()), + Box::new(beneficiary.clone().into()), + ) + .is_err() + { + ::core::panicking::panic( + "assertion failed: ::PolkadotXcm::claim_assets(origin.clone(),\n bx!(other_versioned_assets.into()),\n bx!(beneficiary.clone().into())).is_err()", + ) + } + let is = ::PolkadotXcm::claim_assets( + origin.clone(), + Box::new(versioned_assets.clone().into()), + Box::new(beneficiary.clone().into()), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsClaimed { + origin: beneficiary, + assets: versioned_assets, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsClaimed {\norigin: beneficiary, assets: versioned_assets, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsClaimed {\norigin: beneficiary, assets: versioned_assets, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::claim_assets", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let balance_after = ::Balances::free_balance( + &sender, + ); + match (&balance_after, &(balance_before + amount)) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !::PolkadotXcm::claim_assets( + origin.clone(), + Box::new(versioned_assets.clone().into()), + Box::new(beneficiary.clone().into()), + ) + .is_err() + { + ::core::panicking::panic( + "assertion failed: ::PolkadotXcm::claim_assets(origin.clone(),\n bx!(versioned_assets.clone().into()),\n bx!(beneficiary.clone().into())).is_err()", + ) + } + let balance = ::Balances::free_balance( + &sender, + ); + match (&balance, &balance_after) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + ::PolkadotXcm::drop_assets( + &beneficiary, + assets.clone().into(), + &XcmContext { + origin: None, + message_id: [0u8; 32], + topic: None, + }, + ); + let receiver = AssetHubWestendReceiver::get(); + let other_beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { + network: Some(NetworkId::Westend), + id: receiver.clone().into(), + } + .into(); + let balance_before = ::Balances::free_balance( + &receiver, + ); + let is = ::PolkadotXcm::claim_assets( + origin.clone(), + Box::new(versioned_assets.clone().into()), + Box::new(other_beneficiary.clone().into()), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let balance_after = ::Balances::free_balance( + &receiver, + ); + match (&balance_after, &(balance_before + amount)) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + } + } + mod fellowship_treasury { + use crate::imports::*; + use emulated_integration_tests_common::{ + accounts::{ALICE, BOB}, + USDT_ID, + }; + use frame_support::traits::fungibles::{Inspect, Mutate}; + use polkadot_runtime_common::impls::VersionedLocatableAsset; + use xcm_executor::traits::ConvertLocation; + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::fellowship_treasury::create_and_claim_treasury_spend"] + pub const create_and_claim_treasury_spend: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::fellowship_treasury::create_and_claim_treasury_spend", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/fellowship_treasury.rs", + start_line: 26usize, + start_col: 4usize, + end_line: 26usize, + end_col: 35usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(create_and_claim_treasury_spend()), + ), + }; + fn create_and_claim_treasury_spend() { + const SPEND_AMOUNT: u128 = 1_000_000_000; + let treasury_location: Location = Location::new( + 1, + [Parachain(CollectivesWestend::para_id().into()), PalletInstance(65)], + ); + let treasury_account = ahw_xcm_config::LocationToAccountId::convert_location( + &treasury_location, + ) + .unwrap(); + let asset_hub_location = Location::new( + 1, + [Parachain(AssetHubWestend::para_id().into())], + ); + let root = ::RuntimeOrigin::root(); + let asset_kind = VersionedLocatableAsset::V5 { + location: asset_hub_location, + asset_id: AssetId( + (PalletInstance(50), GeneralIndex(USDT_ID.into())).into(), + ), + }; + let alice: AccountId = Westend::account_id_of(ALICE); + let bob: AccountId = CollectivesWestend::account_id_of(BOB); + let bob_signed = ::RuntimeOrigin::signed( + bob.clone(), + ); + AssetHubWestend::execute_with(|| { + type Assets = ::Assets; + let is = >::mint_into(USDT_ID, &treasury_account, SPEND_AMOUNT * 4); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + match (&>::balance(USDT_ID, &alice), &0u128) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + CollectivesWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type FellowshipTreasury = ::FellowshipTreasury; + type AssetRate = ::AssetRate; + let is = AssetRate::create( + root.clone(), + Box::new(asset_kind.clone()), + 2.into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = FellowshipTreasury::spend( + root, + Box::new(asset_kind), + SPEND_AMOUNT, + Box::new( + Location::new(0, Into::<[u8; 32]>::into(alice.clone())).into(), + ), + None, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = FellowshipTreasury::payout(bob_signed.clone(), 0); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::FellowshipTreasury( + pallet_treasury::Event::Paid { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "CollectivesWestend", + "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::Paid { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "CollectivesWestend", + "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::Paid { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::CollectivesWestend", + "asset_hub_westend_integration_tests::tests::fellowship_treasury", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type Assets = ::Assets; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Transferred { + asset_id: id, + from, + to, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(id == &USDT_ID) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "id", + id, + "id == &USDT_ID", + ), + ); + res + }); + } + meet_conditions &= id == &USDT_ID; + if !(from == &treasury_account) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "from == &treasury_account", + ), + ); + res + }); + } + meet_conditions &= from == &treasury_account; + if !(to == &alice) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "to == &alice", + ), + ); + res + }); + } + meet_conditions &= to == &alice; + if !(amount == &SPEND_AMOUNT) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "amount == &SPEND_AMOUNT", + ), + ); + res + }); + } + meet_conditions &= amount == &SPEND_AMOUNT; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::XcmpQueue( + cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::fellowship_treasury", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + match ( + &>::balance(USDT_ID, &alice), + &SPEND_AMOUNT, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + CollectivesWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type FellowshipTreasury = ::FellowshipTreasury; + let is = FellowshipTreasury::check_status(bob_signed, 0); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::FellowshipTreasury( + pallet_treasury::Event::SpendProcessed { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "CollectivesWestend", + "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::SpendProcessed { ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "CollectivesWestend", + "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::SpendProcessed { ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::CollectivesWestend", + "asset_hub_westend_integration_tests::tests::fellowship_treasury", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + } + mod hybrid_transfers { + use super::reserve_transfer::*; + use crate::{ + imports::*, + tests::teleport::do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt, + }; + fn para_to_para_assethub_hop_assertions(t: ParaToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_penpal_a_on_ah = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + let sov_penpal_b_on_ah = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalB::para_id()), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_a_on_ah) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_a_on_ah", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_a_on_ah; + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_b_on_ah) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_b_on_ah", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_b_on_ah; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::hybrid_transfers", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn ah_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { + let fee_idx = t.args.fee_asset_item as usize; + let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); + let custom_xcm_on_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + beneficiary: t.args.beneficiary, + }, + ]), + ), + ); + ::PolkadotXcm::transfer_assets_using_type_and_then( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.assets.into()), + Box::new(TransferType::LocalReserve), + Box::new(fee.id.into()), + Box::new(TransferType::LocalReserve), + Box::new(VersionedXcm::from(custom_xcm_on_dest)), + t.args.weight_limit, + ) + } + fn para_to_ah_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult { + let fee_idx = t.args.fee_asset_item as usize; + let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); + let custom_xcm_on_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + beneficiary: t.args.beneficiary, + }, + ]), + ), + ); + ::PolkadotXcm::transfer_assets_using_type_and_then( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.assets.into()), + Box::new(TransferType::DestinationReserve), + Box::new(fee.id.into()), + Box::new(TransferType::DestinationReserve), + Box::new(VersionedXcm::from(custom_xcm_on_dest)), + t.args.weight_limit, + ) + } + fn para_to_para_transfer_assets_through_ah( + t: ParaToParaThroughAHTest, + ) -> DispatchResult { + let fee_idx = t.args.fee_asset_item as usize; + let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); + let asset_hub_location: Location = PenpalA::sibling_location_of( + AssetHubWestend::para_id(), + ); + let custom_xcm_on_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + beneficiary: t.args.beneficiary, + }, + ]), + ), + ); + ::PolkadotXcm::transfer_assets_using_type_and_then( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.assets.into()), + Box::new(TransferType::RemoteReserve(asset_hub_location.clone().into())), + Box::new(fee.id.into()), + Box::new(TransferType::RemoteReserve(asset_hub_location.into())), + Box::new(VersionedXcm::from(custom_xcm_on_dest)), + t.args.weight_limit, + ) + } + fn para_to_asset_hub_teleport_foreign_assets( + t: ParaToSystemParaTest, + ) -> DispatchResult { + let fee_idx = t.args.fee_asset_item as usize; + let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); + let custom_xcm_on_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + beneficiary: t.args.beneficiary, + }, + ]), + ), + ); + ::PolkadotXcm::transfer_assets_using_type_and_then( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.assets.into()), + Box::new(TransferType::Teleport), + Box::new(fee.id.into()), + Box::new(TransferType::DestinationReserve), + Box::new(VersionedXcm::from(custom_xcm_on_dest)), + t.args.weight_limit, + ) + } + fn asset_hub_to_para_teleport_foreign_assets( + t: SystemParaToParaTest, + ) -> DispatchResult { + let fee_idx = t.args.fee_asset_item as usize; + let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); + let custom_xcm_on_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + beneficiary: t.args.beneficiary, + }, + ]), + ), + ); + ::PolkadotXcm::transfer_assets_using_type_and_then( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.assets.into()), + Box::new(TransferType::Teleport), + Box::new(fee.id.into()), + Box::new(TransferType::LocalReserve), + Box::new(VersionedXcm::from(custom_xcm_on_dest)), + t.args.weight_limit, + ) + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::hybrid_transfers::transfer_foreign_assets_from_asset_hub_to_para"] + pub const transfer_foreign_assets_from_asset_hub_to_para: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::hybrid_transfers::transfer_foreign_assets_from_asset_hub_to_para", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", + start_line: 156usize, + start_col: 4usize, + end_line: 156usize, + end_col: 50usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + transfer_foreign_assets_from_asset_hub_to_para(), + ), + ), + }; + /// Transfers of native asset plus bridged asset from AssetHub to some Parachain + /// while paying fees using native asset. + fn transfer_foreign_assets_from_asset_hub_to_para() { + let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); + let sender = AssetHubWestendSender::get(); + let native_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let native_asset_location = RelayLocation::get(); + let receiver = PenpalAReceiver::get(); + let assets_owner = PenpalAssetOwner::get(); + let foreign_amount_to_send = ASSET_HUB_WESTEND_ED * 10_000_000; + let roc_at_westend_parachains = Location::new( + 2, + [Junction::GlobalConsensus(NetworkId::Rococo)], + ); + PenpalA::execute_with(|| { + let is = ::System::set_storage( + ::RuntimeOrigin::root(), + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), + Location::new(2, [GlobalConsensus(Rococo)]).encode(), + ), + ]), + ), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + PenpalA::force_create_foreign_asset( + roc_at_westend_parachains.clone(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + AssetHubWestend::force_create_foreign_asset( + roc_at_westend_parachains.clone().try_into().unwrap(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + AssetHubWestend::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner), + roc_at_westend_parachains.clone().try_into().unwrap(), + sender.clone(), + foreign_amount_to_send * 2, + ); + let assets: Vec = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (Parent, native_amount_to_send).into(), + (roc_at_westend_parachains.clone(), foreign_amount_to_send).into(), + ]), + ); + let fee_asset_id = AssetId(Parent.into()); + let fee_asset_item = assets + .iter() + .position(|a| a.id == fee_asset_id) + .unwrap() as u32; + let test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination.clone(), + receiver.clone(), + native_amount_to_send, + assets.into(), + None, + fee_asset_item, + ), + }; + let mut test = SystemParaToParaTest::new(test_args); + let sender_balance_before = test.sender.balance; + let sender_rocs_before = AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &sender, + ) + }); + let receiver_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location.clone(), &receiver) + }); + let receiver_rocs_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.clone(), &receiver) + }); + test.set_assertion::(system_para_to_para_sender_assertions); + test.set_assertion::(system_para_to_para_receiver_assertions); + test.set_dispatchable::(ah_to_para_transfer_assets); + test.assert(); + let sender_balance_after = test.sender.balance; + let sender_rocs_after = AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &sender, + ) + }); + let receiver_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location, &receiver) + }); + let receiver_rocs_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains, &receiver) + }); + if !(sender_balance_after < sender_balance_before - native_amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_balance_after < sender_balance_before - native_amount_to_send", + ) + } + match (&sender_rocs_after, &(sender_rocs_before - foreign_amount_to_send)) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(receiver_assets_after > receiver_assets_before) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after > receiver_assets_before", + ) + } + if !(receiver_assets_after < receiver_assets_before + native_amount_to_send) + { + ::core::panicking::panic( + "assertion failed: receiver_assets_after < receiver_assets_before + native_amount_to_send", + ) + } + match ( + &receiver_rocs_after, + &(receiver_rocs_before + foreign_amount_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_asset_hub"] + pub const transfer_foreign_assets_from_para_to_asset_hub: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_asset_hub", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", + start_line: 285usize, + start_col: 4usize, + end_line: 285usize, + end_col: 50usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + transfer_foreign_assets_from_para_to_asset_hub(), + ), + ), + }; + /// Reserve Transfers of native asset from Parachain to System Parachain should work + /// Transfers of native asset plus bridged asset from some Parachain to AssetHub + /// while paying fees using native asset. + fn transfer_foreign_assets_from_para_to_asset_hub() { + let destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()); + let sender = PenpalASender::get(); + let native_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 10000; + let native_asset_location = RelayLocation::get(); + let assets_owner = PenpalAssetOwner::get(); + let foreign_amount_to_send = ASSET_HUB_WESTEND_ED * 10_000_000; + let roc_at_westend_parachains = Location::new( + 2, + [Junction::GlobalConsensus(NetworkId::Rococo)], + ); + PenpalA::execute_with(|| { + let is = ::System::set_storage( + ::RuntimeOrigin::root(), + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), + Location::new(2, [GlobalConsensus(Rococo)]).encode(), + ), + ]), + ), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + PenpalA::force_create_foreign_asset( + roc_at_westend_parachains.clone(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + AssetHubWestend::force_create_foreign_asset( + roc_at_westend_parachains.clone().try_into().unwrap(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner.clone()), + native_asset_location.clone(), + sender.clone(), + native_amount_to_send * 2, + ); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner.clone()), + roc_at_westend_parachains.clone(), + sender.clone(), + foreign_amount_to_send * 2, + ); + let receiver = AssetHubWestendReceiver::get(); + let penpal_location_as_seen_by_ahr = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + penpal_location_as_seen_by_ahr, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_penpal_on_ahr.clone().into(), native_amount_to_send * 2), + ]), + ), + ); + AssetHubWestend::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner), + roc_at_westend_parachains.clone().try_into().unwrap(), + sov_penpal_on_ahr, + foreign_amount_to_send * 2, + ); + let assets: Vec = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (Parent, native_amount_to_send).into(), + (roc_at_westend_parachains.clone(), foreign_amount_to_send).into(), + ]), + ); + let fee_asset_id = AssetId(Parent.into()); + let fee_asset_item = assets + .iter() + .position(|a| a.id == fee_asset_id) + .unwrap() as u32; + let test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination.clone(), + receiver.clone(), + native_amount_to_send, + assets.into(), + None, + fee_asset_item, + ), + }; + let mut test = ParaToSystemParaTest::new(test_args); + let sender_native_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location.clone(), &sender) + }); + let sender_rocs_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.clone(), &sender) + }); + let receiver_native_before = test.receiver.balance; + let receiver_rocs_before = AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &receiver, + ) + }); + test.set_assertion::(para_to_system_para_sender_assertions); + test.set_assertion::< + AssetHubWestend, + >(para_to_system_para_receiver_assertions); + test.set_dispatchable::(para_to_ah_transfer_assets); + test.assert(); + let sender_native_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location, &sender) + }); + let sender_rocs_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.clone(), &sender) + }); + let receiver_native_after = test.receiver.balance; + let receiver_rocs_after = AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.try_into().unwrap(), &receiver) + }); + if !(sender_native_after < sender_native_before - native_amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_native_after < sender_native_before - native_amount_to_send", + ) + } + match (&sender_rocs_after, &(sender_rocs_before - foreign_amount_to_send)) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(receiver_native_after > receiver_native_before) { + ::core::panicking::panic( + "assertion failed: receiver_native_after > receiver_native_before", + ) + } + if !(receiver_native_after < receiver_native_before + native_amount_to_send) + { + ::core::panicking::panic( + "assertion failed: receiver_native_after < receiver_native_before + native_amount_to_send", + ) + } + match ( + &receiver_rocs_after, + &(receiver_rocs_before + foreign_amount_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_para_through_asset_hub"] + pub const transfer_foreign_assets_from_para_to_para_through_asset_hub: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_para_through_asset_hub", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", + start_line: 440usize, + start_col: 4usize, + end_line: 440usize, + end_col: 63usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + transfer_foreign_assets_from_para_to_para_through_asset_hub(), + ), + ), + }; + /// Transfers of native asset plus bridged asset from Parachain to Parachain + /// (through AssetHub reserve) with fees paid using native asset. + fn transfer_foreign_assets_from_para_to_para_through_asset_hub() { + let destination = PenpalA::sibling_location_of(PenpalB::para_id()); + let sender = PenpalASender::get(); + let wnd_to_send: Balance = WESTEND_ED * 10000; + let assets_owner = PenpalAssetOwner::get(); + let wnd_location = RelayLocation::get(); + let sender_as_seen_by_ah = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_of_sender_on_ah = AssetHubWestend::sovereign_account_id_of( + sender_as_seen_by_ah, + ); + let receiver_as_seen_by_ah = AssetHubWestend::sibling_location_of( + PenpalB::para_id(), + ); + let sov_of_receiver_on_ah = AssetHubWestend::sovereign_account_id_of( + receiver_as_seen_by_ah, + ); + let roc_to_send = ASSET_HUB_WESTEND_ED * 10_000_000; + PenpalB::execute_with(|| { + let is = ::System::set_storage( + ::RuntimeOrigin::root(), + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), + Location::new(2, [GlobalConsensus(Rococo)]).encode(), + ), + ]), + ), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + let roc_at_westend_parachains = Location::new( + 2, + [Junction::GlobalConsensus(NetworkId::Rococo)], + ); + AssetHubWestend::force_create_foreign_asset( + roc_at_westend_parachains.clone().try_into().unwrap(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + PenpalA::force_create_foreign_asset( + roc_at_westend_parachains.clone(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + PenpalB::force_create_foreign_asset( + roc_at_westend_parachains.clone(), + assets_owner.clone(), + false, + ASSET_MIN_BALANCE, + ::alloc::vec::Vec::new(), + ); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner.clone()), + wnd_location.clone(), + sender.clone(), + wnd_to_send * 2, + ); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner.clone()), + roc_at_westend_parachains.clone(), + sender.clone(), + roc_to_send * 2, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_of_sender_on_ah.clone().into(), wnd_to_send * 2), + ]), + ), + ); + AssetHubWestend::mint_foreign_asset( + ::RuntimeOrigin::signed(assets_owner), + roc_at_westend_parachains.clone().try_into().unwrap(), + sov_of_sender_on_ah.clone(), + roc_to_send * 2, + ); + let receiver = PenpalBReceiver::get(); + let assets: Vec = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (wnd_location.clone(), wnd_to_send).into(), + (roc_at_westend_parachains.clone(), roc_to_send).into(), + ]), + ); + let fee_asset_id: AssetId = wnd_location.clone().into(); + let fee_asset_item = assets + .iter() + .position(|a| a.id == fee_asset_id) + .unwrap() as u32; + let test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination, + receiver.clone(), + wnd_to_send, + assets.into(), + None, + fee_asset_item, + ), + }; + let mut test = ParaToParaThroughAHTest::new(test_args); + let sender_wnds_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(wnd_location.clone(), &sender) + }); + let sender_rocs_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.clone(), &sender) + }); + let wnds_in_sender_reserve_on_ah_before = ::account_data_of( + sov_of_sender_on_ah.clone(), + ) + .free; + let rocs_in_sender_reserve_on_ah_before = AssetHubWestend::execute_with(|| { + type Assets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &sov_of_sender_on_ah, + ) + }); + let wnds_in_receiver_reserve_on_ah_before = ::account_data_of( + sov_of_receiver_on_ah.clone(), + ) + .free; + let rocs_in_receiver_reserve_on_ah_before = AssetHubWestend::execute_with(|| { + type Assets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &sov_of_receiver_on_ah, + ) + }); + let receiver_wnds_before = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(wnd_location.clone(), &receiver) + }); + let receiver_rocs_before = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.clone(), &receiver) + }); + test.set_assertion::(para_to_para_through_hop_sender_assertions); + test.set_assertion::(para_to_para_assethub_hop_assertions); + test.set_assertion::(para_to_para_through_hop_receiver_assertions); + test.set_dispatchable::(para_to_para_transfer_assets_through_ah); + test.assert(); + let sender_wnds_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(wnd_location.clone(), &sender) + }); + let sender_rocs_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.clone(), &sender) + }); + let rocs_in_sender_reserve_on_ah_after = AssetHubWestend::execute_with(|| { + type Assets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &sov_of_sender_on_ah, + ) + }); + let wnds_in_sender_reserve_on_ah_after = ::account_data_of( + sov_of_sender_on_ah, + ) + .free; + let rocs_in_receiver_reserve_on_ah_after = AssetHubWestend::execute_with(|| { + type Assets = ::ForeignAssets; + >::balance( + roc_at_westend_parachains.clone().try_into().unwrap(), + &sov_of_receiver_on_ah, + ) + }); + let wnds_in_receiver_reserve_on_ah_after = ::account_data_of( + sov_of_receiver_on_ah, + ) + .free; + let receiver_wnds_after = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(wnd_location, &receiver) + }); + let receiver_rocs_after = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains, &receiver) + }); + if !(sender_wnds_after < sender_wnds_before - wnd_to_send) { + ::core::panicking::panic( + "assertion failed: sender_wnds_after < sender_wnds_before - wnd_to_send", + ) + } + match (&sender_rocs_after, &(sender_rocs_before - roc_to_send)) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &wnds_in_sender_reserve_on_ah_after, + &(wnds_in_sender_reserve_on_ah_before - wnd_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &rocs_in_sender_reserve_on_ah_after, + &(rocs_in_sender_reserve_on_ah_before - roc_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(wnds_in_receiver_reserve_on_ah_after + > wnds_in_receiver_reserve_on_ah_before) + { + ::core::panicking::panic( + "assertion failed: wnds_in_receiver_reserve_on_ah_after > wnds_in_receiver_reserve_on_ah_before", + ) + } + match ( + &rocs_in_receiver_reserve_on_ah_after, + &(rocs_in_receiver_reserve_on_ah_before + roc_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(receiver_wnds_after > receiver_wnds_before) { + ::core::panicking::panic( + "assertion failed: receiver_wnds_after > receiver_wnds_before", + ) + } + match (&receiver_rocs_after, &(receiver_rocs_before + roc_to_send)) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::hybrid_transfers::bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types"] + pub const bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::hybrid_transfers::bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", + start_line: 644usize, + start_col: 4usize, + end_line: 644usize, + end_col: 97usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types(), + ), + ), + }; + /// Transfers of native asset plus teleportable foreign asset from Parachain to AssetHub and back + /// with fees paid using native asset. + fn bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types() { + do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt( + para_to_asset_hub_teleport_foreign_assets, + asset_hub_to_para_teleport_foreign_assets, + ); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::hybrid_transfers::transfer_native_asset_from_relay_to_para_through_asset_hub"] + pub const transfer_native_asset_from_relay_to_para_through_asset_hub: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::hybrid_transfers::transfer_native_asset_from_relay_to_para_through_asset_hub", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", + start_line: 658usize, + start_col: 4usize, + end_line: 658usize, + end_col: 62usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + transfer_native_asset_from_relay_to_para_through_asset_hub(), + ), + ), + }; + /// Transfers of native asset Relay to Parachain (using AssetHub reserve). Parachains want to avoid + /// managing SAs on all system chains, thus want all their DOT-in-reserve to be held in their + /// Sovereign Account on Asset Hub. + fn transfer_native_asset_from_relay_to_para_through_asset_hub() { + let destination = Westend::child_location_of(PenpalA::para_id()); + let sender = WestendSender::get(); + let amount_to_send: Balance = WESTEND_ED * 1000; + let relay_native_asset_location = RelayLocation::get(); + let receiver = PenpalAReceiver::get(); + let test_args = TestContext { + sender, + receiver: receiver.clone(), + args: TestArgs::new_relay( + destination.clone(), + receiver.clone(), + amount_to_send, + ), + }; + let mut test = RelayToParaThroughAHTest::new(test_args); + let sov_penpal_on_ah = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + let sender_balance_before = test.sender.balance; + let sov_penpal_on_ah_before = AssetHubWestend::execute_with(|| { + ::Balances::free_balance( + sov_penpal_on_ah.clone(), + ) + }); + let receiver_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &receiver) + }); + fn relay_assertions(t: RelayToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + Westend::assert_xcm_pallet_attempted_complete(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == t.sender.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *who == t.sender.account_id; + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who + == ::XcmPallet::check_account()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == ::XcmPallet::check_account()", + ), + ); + res + }); + } + meet_conditions + &= *who + == ::XcmPallet::check_account(); + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::hybrid_transfers", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn asset_hub_assertions(_: RelayToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_penpal_on_ah = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_on_ah) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_on_ah", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_on_ah; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::hybrid_transfers", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn penpal_assertions(t: RelayToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + let expected_id = t + .args + .assets + .into_inner() + .first() + .unwrap() + .id + .0 + .clone() + .try_into() + .unwrap(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == t.receiver.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::hybrid_transfers", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn transfer_assets_dispatchable( + t: RelayToParaThroughAHTest, + ) -> DispatchResult { + let fee_idx = t.args.fee_asset_item as usize; + let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); + let asset_hub_location = Westend::child_location_of( + AssetHubWestend::para_id(), + ); + let context = WestendUniversalLocation::get(); + let mut remote_fees = fee + .clone() + .reanchored(&t.args.dest, &context) + .unwrap(); + if let Fungible(ref mut amount) = remote_fees.fun { + *amount = *amount / 2; + } + let xcm_on_final_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + BuyExecution { + fees: remote_fees, + weight_limit: t.args.weight_limit.clone(), + }, + DepositAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + beneficiary: t.args.beneficiary, + }, + ]), + ), + ); + let mut dest = t.args.dest.clone(); + dest.reanchor(&asset_hub_location, &context).unwrap(); + let xcm_on_hop = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositReserveAsset { + assets: Wild(AllCounted(t.args.assets.len() as u32)), + dest, + xcm: xcm_on_final_dest, + }, + ]), + ), + ); + ::XcmPallet::transfer_assets_using_type_and_then( + t.signed_origin, + Box::new(asset_hub_location.into()), + Box::new(t.args.assets.into()), + Box::new(TransferType::Teleport), + Box::new(fee.id.into()), + Box::new(TransferType::Teleport), + Box::new(VersionedXcm::from(xcm_on_hop)), + t.args.weight_limit, + ) + } + test.set_assertion::(relay_assertions); + test.set_assertion::(asset_hub_assertions); + test.set_assertion::(penpal_assertions); + test.set_dispatchable::(transfer_assets_dispatchable); + test.assert(); + let sender_balance_after = test.sender.balance; + let sov_penpal_on_ah_after = AssetHubWestend::execute_with(|| { + ::Balances::free_balance( + sov_penpal_on_ah, + ) + }); + let receiver_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location, &receiver) + }); + if !(sender_balance_after < sender_balance_before - amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_balance_after < sender_balance_before - amount_to_send", + ) + } + if !(sov_penpal_on_ah_after > sov_penpal_on_ah_before) { + ::core::panicking::panic( + "assertion failed: sov_penpal_on_ah_after > sov_penpal_on_ah_before", + ) + } + if !(receiver_assets_after > receiver_assets_before) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after > receiver_assets_before", + ) + } + if !(receiver_assets_after < receiver_assets_before + amount_to_send) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after < receiver_assets_before + amount_to_send", + ) + } + } + } + mod reserve_transfer { + use crate::imports::*; + fn relay_to_para_sender_assertions(t: RelayToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + Westend::assert_xcm_pallet_attempted_complete( + Some(Weight::from_parts(864_610_000, 8_799)), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*from == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "*from == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *from == t.sender.account_id; + if !(*to + == Westend::sovereign_account_id_of(t.args.dest.clone())) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "*to == Westend::sovereign_account_id_of(t.args.dest.clone())", + ), + ); + res + }); + } + meet_conditions + &= *to + == Westend::sovereign_account_id_of(t.args.dest.clone()); + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn para_to_relay_sender_assertions(t: ParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + PenpalA::assert_xcm_pallet_attempted_complete( + Some(Weight::from_parts(864_610_000, 8_799)), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == RelayLocation::get()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == RelayLocation::get()", + ), + ); + res + }); + } + meet_conditions &= *asset_id == RelayLocation::get(); + if !(*owner == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if !(*balance == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *balance == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + pub fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcm_pallet_attempted_complete(None); + let sov_acc_of_dest = AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + ); + for (idx, asset) in t.args.assets.into_inner().into_iter().enumerate() { + let expected_id = asset.id.0.clone().try_into().unwrap(); + let asset_amount = if let Fungible(a) = asset.fun { + Some(a) + } else { + None + } + .unwrap(); + if idx == t.args.fee_asset_item as usize { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*from == t.sender.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "*from == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *from == t.sender.account_id; + if !(*to == sov_acc_of_dest) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "*to == sov_acc_of_dest", + ), + ); + res + }); + } + meet_conditions &= *to == sov_acc_of_dest; + if !(*amount == asset_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } else { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Transferred { + asset_id, + from, + to, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*from == t.sender.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "*from == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *from == t.sender.account_id; + if !(*to == sov_acc_of_dest) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "*to == sov_acc_of_dest", + ), + ); + res + }); + } + meet_conditions &= *to == sov_acc_of_dest; + if !(*amount == asset_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + } + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. }) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + AssetHubWestend::assert_xcm_pallet_sent(); + } + pub fn system_para_to_para_receiver_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + PenpalA::assert_xcmp_queue_success(None); + for asset in t.args.assets.into_inner().into_iter() { + let expected_id = asset.id.0.try_into().unwrap(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == t.receiver.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + } + pub fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + PenpalA::assert_xcm_pallet_attempted_complete(None); + for asset in t.args.assets.into_inner().into_iter() { + let expected_id = asset.id.0; + let asset_amount = if let Fungible(a) = asset.fun { + Some(a) + } else { + None + } + .unwrap(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == t.sender.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if !(*balance == asset_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == asset_amount", + ), + ); + res + }); + } + meet_conditions &= *balance == asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + } + fn para_to_relay_receiver_assertions(t: ParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_penpal_on_relay = Westend::sovereign_account_id_of( + Westend::child_location_of(PenpalA::para_id()), + ); + Westend::assert_ump_queue_processed( + true, + Some(PenpalA::para_id()), + Some(Weight::from_parts(306305000, 7_186)), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_on_relay.clone().into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_on_relay.clone().into()", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_on_relay.clone().into(); + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances(pallet_balances::Event::Minted { .. }) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + pub fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcmp_queue_success(None); + let sov_acc_of_penpal = AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + ); + for (idx, asset) in t.args.assets.into_inner().into_iter().enumerate() { + let expected_id = asset.id.0.clone().try_into().unwrap(); + let asset_amount = if let Fungible(a) = asset.fun { + Some(a) + } else { + None + } + .unwrap(); + if idx == t.args.fee_asset_item as usize { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_acc_of_penpal.clone().into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_acc_of_penpal.clone().into()", + ), + ); + res + }); + } + meet_conditions &= *who == sov_acc_of_penpal.clone().into(); + if !(*amount == asset_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == t.receiver.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *who == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } else { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == sov_acc_of_penpal) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == sov_acc_of_penpal", + ), + ); + res + }); + } + meet_conditions &= *owner == sov_acc_of_penpal; + if !(*balance == asset_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == asset_amount", + ), + ); + res + }); + } + meet_conditions &= *balance == asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == t.receiver.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if !(*amount == asset_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + } + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcm_pallet_attempted_complete( + Some(Weight::from_parts(864_610_000, 8799)), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Transferred { asset_id, from, to, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == RESERVABLE_ASSET_ID) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == RESERVABLE_ASSET_ID", + ), + ); + res + }); + } + meet_conditions &= *asset_id == RESERVABLE_ASSET_ID; + if !(*from == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "*from == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *from == t.sender.account_id; + if !(*to + == AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + )) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "*to == AssetHubWestend::sovereign_account_id_of(t.args.dest.clone())", + ), + ); + res + }); + } + meet_conditions + &= *to + == AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + ); + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who + == AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + )) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == AssetHubWestend::sovereign_account_id_of(t.args.dest.clone())", + ), + ); + res + }); + } + meet_conditions + &= *who + == AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + ); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. }) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn para_to_system_para_assets_sender_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let system_para_native_asset_location = RelayLocation::get(); + let reservable_asset_location = PenpalLocalReservableFromAssetHub::get(); + PenpalA::assert_xcm_pallet_attempted_complete( + Some(Weight::from_parts(864_610_000, 8799)), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == system_para_native_asset_location) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == system_para_native_asset_location", + ), + ); + res + }); + } + meet_conditions + &= *asset_id == system_para_native_asset_location; + if !(*owner == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == reservable_asset_location) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == reservable_asset_location", + ), + ); + res + }); + } + meet_conditions &= *asset_id == reservable_asset_location; + if !(*owner == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if !(*balance == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *balance == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. }) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn system_para_to_para_assets_receiver_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let system_para_asset_location = PenpalLocalReservableFromAssetHub::get(); + PenpalA::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == RelayLocation::get()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == RelayLocation::get()", + ), + ); + res + }); + } + meet_conditions &= *asset_id == RelayLocation::get(); + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == system_para_asset_location) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == system_para_asset_location", + ), + ); + res + }); + } + meet_conditions &= *asset_id == system_para_asset_location; + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn para_to_system_para_assets_receiver_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + AssetHubWestend::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == RESERVABLE_ASSET_ID) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == RESERVABLE_ASSET_ID", + ), + ); + res + }); + } + meet_conditions &= *asset_id == RESERVABLE_ASSET_ID; + if !(*owner == sov_penpal_on_ahr) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == sov_penpal_on_ahr", + ), + ); + res + }); + } + meet_conditions &= *owner == sov_penpal_on_ahr; + if !(*balance == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *balance == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_on_ahr) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_on_ahr", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_on_ahr; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Issued { asset_id, owner, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == RESERVABLE_ASSET_ID) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == RESERVABLE_ASSET_ID", + ), + ); + res + }); + } + meet_conditions &= *asset_id == RESERVABLE_ASSET_ID; + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == t.receiver.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *who == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn relay_to_para_assets_receiver_assertions(t: RelayToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == RelayLocation::get()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == RelayLocation::get()", + ), + ); + res + }); + } + meet_conditions &= *asset_id == RelayLocation::get(); + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + pub fn para_to_para_through_hop_sender_assertions( + t: Test, + ) { + type RuntimeEvent = ::RuntimeEvent; + PenpalA::assert_xcm_pallet_attempted_complete(None); + for asset in t.args.assets.into_inner() { + let expected_id = asset.id.0.clone().try_into().unwrap(); + let amount = if let Fungible(a) = asset.fun { Some(a) } else { None } + .unwrap(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == t.sender.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if !(*balance == amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == amount", + ), + ); + res + }); + } + meet_conditions &= *balance == amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + } + fn para_to_para_relay_hop_assertions(t: ParaToParaThroughRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_penpal_a_on_westend = Westend::sovereign_account_id_of( + Westend::child_location_of(PenpalA::para_id()), + ); + let sov_penpal_b_on_westend = Westend::sovereign_account_id_of( + Westend::child_location_of(PenpalB::para_id()), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_a_on_westend) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_a_on_westend", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_a_on_westend; + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_b_on_westend) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_b_on_westend", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_b_on_westend; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + pub fn para_to_para_through_hop_receiver_assertions( + t: Test, + ) { + type RuntimeEvent = ::RuntimeEvent; + PenpalB::assert_xcmp_queue_success(None); + for asset in t.args.assets.into_inner().into_iter() { + let expected_id = asset.id.0.try_into().unwrap(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_id; + if !(*owner == t.receiver.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalB", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalB", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalB", + "asset_hub_westend_integration_tests::tests::reserve_transfer", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + } + fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { + ::XcmPallet::limited_reserve_transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + fn para_to_relay_reserve_transfer_assets(t: ParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + fn system_para_to_para_reserve_transfer_assets( + t: SystemParaToParaTest, + ) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + fn para_to_system_para_reserve_transfer_assets( + t: ParaToSystemParaTest, + ) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + fn para_to_para_through_relay_limited_reserve_transfer_assets( + t: ParaToParaThroughRelayTest, + ) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_asset_hub_fails"] + pub const reserve_transfer_native_asset_from_relay_to_asset_hub_fails: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_asset_hub_fails", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 498usize, + start_col: 4usize, + end_line: 498usize, + end_col: 63usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_relay_to_asset_hub_fails(), + ), + ), + }; + /// Reserve Transfers of native asset from Relay Chain to the Asset Hub shouldn't work + fn reserve_transfer_native_asset_from_relay_to_asset_hub_fails() { + let signed_origin = ::RuntimeOrigin::signed( + WestendSender::get().into(), + ); + let destination = Westend::child_location_of(AssetHubWestend::para_id()); + let beneficiary: Location = AccountId32Junction { + network: None, + id: AssetHubWestendReceiver::get().into(), + } + .into(); + let amount_to_send: Balance = WESTEND_ED * 1000; + let assets: Assets = (Here, amount_to_send).into(); + let fee_asset_item = 0; + Westend::execute_with(|| { + let result = ::XcmPallet::limited_reserve_transfer_assets( + signed_origin, + Box::new(destination.into()), + Box::new(beneficiary.into()), + Box::new(assets.into()), + fee_asset_item, + WeightLimit::Unlimited, + ); + match ( + &result, + &Err( + DispatchError::Module(sp_runtime::ModuleError { + index: 99, + error: [2, 0, 0, 0], + message: Some("Filtered"), + }) + .into(), + ), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_relay_fails"] + pub const reserve_transfer_native_asset_from_asset_hub_to_relay_fails: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_relay_fails", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 531usize, + start_col: 4usize, + end_line: 531usize, + end_col: 63usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_asset_hub_to_relay_fails(), + ), + ), + }; + /// Reserve Transfers of native asset from Asset Hub to Relay Chain shouldn't work + fn reserve_transfer_native_asset_from_asset_hub_to_relay_fails() { + let signed_origin = ::RuntimeOrigin::signed( + AssetHubWestendSender::get().into(), + ); + let destination = AssetHubWestend::parent_location(); + let beneficiary_id = WestendReceiver::get(); + let beneficiary: Location = AccountId32Junction { + network: None, + id: beneficiary_id.into(), + } + .into(); + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let assets: Assets = (Parent, amount_to_send).into(); + let fee_asset_item = 0; + AssetHubWestend::execute_with(|| { + let result = ::PolkadotXcm::limited_reserve_transfer_assets( + signed_origin, + Box::new(destination.into()), + Box::new(beneficiary.into()), + Box::new(assets.into()), + fee_asset_item, + WeightLimit::Unlimited, + ); + match ( + &result, + &Err( + DispatchError::Module(sp_runtime::ModuleError { + index: 31, + error: [2, 0, 0, 0], + message: Some("Filtered"), + }) + .into(), + ), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_para"] + pub const reserve_transfer_native_asset_from_relay_to_para: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_para", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 571usize, + start_col: 4usize, + end_line: 571usize, + end_col: 52usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_relay_to_para(), + ), + ), + }; + /// Reserve Transfers of native asset from Relay to Parachain should work + fn reserve_transfer_native_asset_from_relay_to_para() { + let destination = Westend::child_location_of(PenpalA::para_id()); + let sender = WestendSender::get(); + let amount_to_send: Balance = WESTEND_ED * 1000; + let relay_native_asset_location = RelayLocation::get(); + let receiver = PenpalAReceiver::get(); + let test_args = TestContext { + sender, + receiver: receiver.clone(), + args: TestArgs::new_relay( + destination.clone(), + receiver.clone(), + amount_to_send, + ), + }; + let mut test = RelayToParaTest::new(test_args); + let sender_balance_before = test.sender.balance; + let receiver_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &receiver) + }); + test.set_assertion::(relay_to_para_sender_assertions); + test.set_assertion::(relay_to_para_assets_receiver_assertions); + test.set_dispatchable::(relay_to_para_reserve_transfer_assets); + test.assert(); + let sender_balance_after = test.sender.balance; + let receiver_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location, &receiver) + }); + if !(sender_balance_after < sender_balance_before - amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_balance_after < sender_balance_before - amount_to_send", + ) + } + if !(receiver_assets_after > receiver_assets_before) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after > receiver_assets_before", + ) + } + if !(receiver_assets_after < receiver_assets_before + amount_to_send) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after < receiver_assets_before + amount_to_send", + ) + } + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_relay"] + pub const reserve_transfer_native_asset_from_para_to_relay: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_relay", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 621usize, + start_col: 4usize, + end_line: 621usize, + end_col: 52usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_para_to_relay(), + ), + ), + }; + /// Reserve Transfers of native asset from Parachain to Relay should work + fn reserve_transfer_native_asset_from_para_to_relay() { + let destination = PenpalA::parent_location(); + let sender = PenpalASender::get(); + let amount_to_send: Balance = WESTEND_ED * 1000; + let assets: Assets = (Parent, amount_to_send).into(); + let asset_owner = PenpalAssetOwner::get(); + let relay_native_asset_location = RelayLocation::get(); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner), + relay_native_asset_location.clone(), + sender.clone(), + amount_to_send * 2, + ); + let receiver = WestendReceiver::get(); + let penpal_location_as_seen_by_relay = Westend::child_location_of( + PenpalA::para_id(), + ); + let sov_penpal_on_relay = Westend::sovereign_account_id_of( + penpal_location_as_seen_by_relay, + ); + Westend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_penpal_on_relay.into(), amount_to_send * 2), + ]), + ), + ); + let test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination.clone(), + receiver, + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let mut test = ParaToRelayTest::new(test_args); + let sender_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &sender) + }); + let receiver_balance_before = test.receiver.balance; + test.set_assertion::(para_to_relay_sender_assertions); + test.set_assertion::(para_to_relay_receiver_assertions); + test.set_dispatchable::(para_to_relay_reserve_transfer_assets); + test.assert(); + let sender_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location, &sender) + }); + let receiver_balance_after = test.receiver.balance; + if !(sender_assets_after < sender_assets_before - amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_assets_after < sender_assets_before - amount_to_send", + ) + } + if !(receiver_balance_after > receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: receiver_balance_after > receiver_balance_before", + ) + } + if !(receiver_balance_after < receiver_balance_before + amount_to_send) { + ::core::panicking::panic( + "assertion failed: receiver_balance_after < receiver_balance_before + amount_to_send", + ) + } + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_para"] + pub const reserve_transfer_native_asset_from_asset_hub_to_para: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_para", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 696usize, + start_col: 4usize, + end_line: 696usize, + end_col: 56usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_asset_hub_to_para(), + ), + ), + }; + /// Reserve Transfers of native asset from Asset Hub to Parachain should work + fn reserve_transfer_native_asset_from_asset_hub_to_para() { + let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); + let sender = AssetHubWestendSender::get(); + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 2000; + let assets: Assets = (Parent, amount_to_send).into(); + let system_para_native_asset_location = RelayLocation::get(); + let receiver = PenpalAReceiver::get(); + let test_args = TestContext { + sender, + receiver: receiver.clone(), + args: TestArgs::new_para( + destination.clone(), + receiver.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let mut test = SystemParaToParaTest::new(test_args); + let sender_balance_before = test.sender.balance; + let receiver_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location.clone(), &receiver) + }); + test.set_assertion::(system_para_to_para_sender_assertions); + test.set_assertion::(system_para_to_para_receiver_assertions); + test.set_dispatchable::< + AssetHubWestend, + >(system_para_to_para_reserve_transfer_assets); + test.assert(); + let sender_balance_after = test.sender.balance; + let receiver_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location, &receiver) + }); + if !(sender_balance_after < sender_balance_before - amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_balance_after < sender_balance_before - amount_to_send", + ) + } + if !(receiver_assets_after > receiver_assets_before) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after > receiver_assets_before", + ) + } + if !(receiver_assets_after < receiver_assets_before + amount_to_send) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after < receiver_assets_before + amount_to_send", + ) + } + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_asset_hub"] + pub const reserve_transfer_native_asset_from_para_to_asset_hub: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_asset_hub", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 754usize, + start_col: 4usize, + end_line: 754usize, + end_col: 56usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_para_to_asset_hub(), + ), + ), + }; + /// Reserve Transfers of native asset from Parachain to Asset Hub should work + fn reserve_transfer_native_asset_from_para_to_asset_hub() { + let destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()); + let sender = PenpalASender::get(); + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let assets: Assets = (Parent, amount_to_send).into(); + let system_para_native_asset_location = RelayLocation::get(); + let asset_owner = PenpalAssetOwner::get(); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner), + system_para_native_asset_location.clone(), + sender.clone(), + amount_to_send * 2, + ); + let receiver = AssetHubWestendReceiver::get(); + let penpal_location_as_seen_by_ahr = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + penpal_location_as_seen_by_ahr, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_penpal_on_ahr.into(), amount_to_send * 2), + ]), + ), + ); + let test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination.clone(), + receiver.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let mut test = ParaToSystemParaTest::new(test_args); + let sender_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location.clone(), &sender) + }); + let receiver_balance_before = test.receiver.balance; + test.set_assertion::(para_to_system_para_sender_assertions); + test.set_assertion::< + AssetHubWestend, + >(para_to_system_para_receiver_assertions); + test.set_dispatchable::< + PenpalA, + >(para_to_system_para_reserve_transfer_assets); + test.assert(); + let sender_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location, &sender) + }); + let receiver_balance_after = test.receiver.balance; + if !(sender_assets_after < sender_assets_before - amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_assets_after < sender_assets_before - amount_to_send", + ) + } + if !(receiver_balance_after > receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: receiver_balance_after > receiver_balance_before", + ) + } + if !(receiver_balance_after < receiver_balance_before + amount_to_send) { + ::core::panicking::panic( + "assertion failed: receiver_balance_after < receiver_balance_before + amount_to_send", + ) + } + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_multiple_assets_from_asset_hub_to_para"] + pub const reserve_transfer_multiple_assets_from_asset_hub_to_para: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_multiple_assets_from_asset_hub_to_para", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 831usize, + start_col: 4usize, + end_line: 831usize, + end_col: 59usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_multiple_assets_from_asset_hub_to_para(), + ), + ), + }; + /// Reserve Transfers of a local asset and native asset from Asset Hub to Parachain should + /// work + fn reserve_transfer_multiple_assets_from_asset_hub_to_para() { + let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + destination.clone(), + ); + let sender = AssetHubWestendSender::get(); + let fee_amount_to_send = ASSET_HUB_WESTEND_ED * 100; + let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100; + let asset_owner = AssetHubWestendAssetOwner::get(); + let asset_owner_signer = ::RuntimeOrigin::signed( + asset_owner.clone(), + ); + let assets: Assets = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (Parent, fee_amount_to_send).into(), + ( + [ + PalletInstance(ASSETS_PALLET_ID), + GeneralIndex(RESERVABLE_ASSET_ID.into()), + ], + asset_amount_to_send, + ) + .into(), + ]), + ) + .into(); + let fee_asset_index = assets + .inner() + .iter() + .position(|r| r == &(Parent, fee_amount_to_send).into()) + .unwrap() as u32; + AssetHubWestend::mint_asset( + asset_owner_signer, + RESERVABLE_ASSET_ID, + asset_owner, + asset_amount_to_send * 2, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_penpal_on_ahr.into(), ASSET_HUB_WESTEND_ED), + ]), + ), + ); + let receiver = PenpalAReceiver::get(); + let system_para_native_asset_location = RelayLocation::get(); + let system_para_foreign_asset_location = PenpalLocalReservableFromAssetHub::get(); + let para_test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination, + receiver.clone(), + asset_amount_to_send, + assets, + None, + fee_asset_index, + ), + }; + let mut test = SystemParaToParaTest::new(para_test_args); + let sender_balance_before = test.sender.balance; + let sender_assets_before = AssetHubWestend::execute_with(|| { + type Assets = ::Assets; + >::balance(RESERVABLE_ASSET_ID, &sender) + }); + let receiver_system_native_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location.clone(), &receiver) + }); + let receiver_foreign_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_foreign_asset_location.clone(), &receiver) + }); + test.set_assertion::< + AssetHubWestend, + >(system_para_to_para_assets_sender_assertions); + test.set_assertion::< + PenpalA, + >(system_para_to_para_assets_receiver_assertions); + test.set_dispatchable::< + AssetHubWestend, + >(system_para_to_para_reserve_transfer_assets); + test.assert(); + let sender_balance_after = test.sender.balance; + let sender_assets_after = AssetHubWestend::execute_with(|| { + type Assets = ::Assets; + >::balance(RESERVABLE_ASSET_ID, &sender) + }); + let receiver_system_native_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location, &receiver) + }); + let receiver_foreign_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_foreign_asset_location, &receiver) + }); + if !(sender_balance_after < sender_balance_before) { + ::core::panicking::panic( + "assertion failed: sender_balance_after < sender_balance_before", + ) + } + if !(receiver_foreign_assets_after > receiver_foreign_assets_before) { + ::core::panicking::panic( + "assertion failed: receiver_foreign_assets_after > receiver_foreign_assets_before", + ) + } + if !(receiver_system_native_assets_after + < receiver_system_native_assets_before + fee_amount_to_send) + { + ::core::panicking::panic( + "assertion failed: receiver_system_native_assets_after <\n receiver_system_native_assets_before + fee_amount_to_send", + ) + } + match ( + &(sender_assets_before - asset_amount_to_send), + &sender_assets_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &receiver_foreign_assets_after, + &(receiver_foreign_assets_before + asset_amount_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_multiple_assets_from_para_to_asset_hub"] + pub const reserve_transfer_multiple_assets_from_para_to_asset_hub: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_multiple_assets_from_para_to_asset_hub", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 948usize, + start_col: 4usize, + end_line: 948usize, + end_col: 59usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_multiple_assets_from_para_to_asset_hub(), + ), + ), + }; + /// Reserve Transfers of a random asset and native asset from Parachain to Asset Hub should work + /// Receiver is empty account to show deposit works as long as transfer includes enough DOT for ED. + /// Once we have https://github.com/paritytech/polkadot-sdk/issues/5298, + /// we should do equivalent test with USDT instead of DOT. + fn reserve_transfer_multiple_assets_from_para_to_asset_hub() { + let destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()); + let sender = PenpalASender::get(); + let fee_amount_to_send = ASSET_HUB_WESTEND_ED * 100; + let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100; + let penpal_asset_owner = PenpalAssetOwner::get(); + let penpal_asset_owner_signer = ::RuntimeOrigin::signed( + penpal_asset_owner, + ); + let asset_location_on_penpal = PenpalLocalReservableFromAssetHub::get(); + let system_asset_location_on_penpal = RelayLocation::get(); + let assets: Assets = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (Parent, fee_amount_to_send).into(), + (asset_location_on_penpal.clone(), asset_amount_to_send).into(), + ]), + ) + .into(); + let fee_asset_index = assets + .inner() + .iter() + .position(|r| r == &(Parent, fee_amount_to_send).into()) + .unwrap() as u32; + PenpalA::mint_foreign_asset( + penpal_asset_owner_signer.clone(), + asset_location_on_penpal.clone(), + sender.clone(), + asset_amount_to_send * 2, + ); + PenpalA::mint_foreign_asset( + penpal_asset_owner_signer, + system_asset_location_on_penpal.clone(), + sender.clone(), + fee_amount_to_send * 2, + ); + let receiver = get_account_id_from_seed::< + sp_runtime::testing::sr25519::Public, + >(DUMMY_EMPTY); + let penpal_location_as_seen_by_ahr = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + penpal_location_as_seen_by_ahr, + ); + let ah_asset_owner = AssetHubWestendAssetOwner::get(); + let ah_asset_owner_signer = ::RuntimeOrigin::signed( + ah_asset_owner, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_penpal_on_ahr.clone().into(), ASSET_HUB_WESTEND_ED * 1000), + ]), + ), + ); + AssetHubWestend::mint_asset( + ah_asset_owner_signer, + RESERVABLE_ASSET_ID, + sov_penpal_on_ahr, + asset_amount_to_send * 2, + ); + let para_test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination, + receiver.clone(), + asset_amount_to_send, + assets, + None, + fee_asset_index, + ), + }; + let mut test = ParaToSystemParaTest::new(para_test_args); + let sender_system_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_asset_location_on_penpal.clone(), &sender) + }); + let sender_foreign_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(asset_location_on_penpal.clone(), &sender) + }); + let receiver_balance_before = test.receiver.balance; + let receiver_assets_before = AssetHubWestend::execute_with(|| { + type Assets = ::Assets; + >::balance(RESERVABLE_ASSET_ID, &receiver) + }); + test.set_assertion::(para_to_system_para_assets_sender_assertions); + test.set_assertion::< + AssetHubWestend, + >(para_to_system_para_assets_receiver_assertions); + test.set_dispatchable::< + PenpalA, + >(para_to_system_para_reserve_transfer_assets); + test.assert(); + let sender_system_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_asset_location_on_penpal, &sender) + }); + let sender_foreign_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(asset_location_on_penpal, &sender) + }); + let receiver_balance_after = test.receiver.balance; + let receiver_assets_after = AssetHubWestend::execute_with(|| { + type Assets = ::Assets; + >::balance(RESERVABLE_ASSET_ID, &receiver) + }); + if !(sender_system_assets_after < sender_system_assets_before) { + ::core::panicking::panic( + "assertion failed: sender_system_assets_after < sender_system_assets_before", + ) + } + if !(receiver_balance_after > receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: receiver_balance_after > receiver_balance_before", + ) + } + if !(receiver_balance_after < receiver_balance_before + fee_amount_to_send) { + ::core::panicking::panic( + "assertion failed: receiver_balance_after < receiver_balance_before + fee_amount_to_send", + ) + } + match ( + &(sender_foreign_assets_before - asset_amount_to_send), + &sender_foreign_assets_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &receiver_assets_after, + &(receiver_assets_before + asset_amount_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_para_through_relay"] + pub const reserve_transfer_native_asset_from_para_to_para_through_relay: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_para_through_relay", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", + start_line: 1076usize, + start_col: 4usize, + end_line: 1076usize, + end_col: 65usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + reserve_transfer_native_asset_from_para_to_para_through_relay(), + ), + ), + }; + /// Reserve Transfers of native asset from Parachain to Parachain (through Relay reserve) should + /// work + fn reserve_transfer_native_asset_from_para_to_para_through_relay() { + let destination = PenpalA::sibling_location_of(PenpalB::para_id()); + let sender = PenpalASender::get(); + let amount_to_send: Balance = WESTEND_ED * 10000; + let asset_owner = PenpalAssetOwner::get(); + let assets = (Parent, amount_to_send).into(); + let relay_native_asset_location = RelayLocation::get(); + let sender_as_seen_by_relay = Westend::child_location_of(PenpalA::para_id()); + let sov_of_sender_on_relay = Westend::sovereign_account_id_of( + sender_as_seen_by_relay, + ); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner), + relay_native_asset_location.clone(), + sender.clone(), + amount_to_send * 2, + ); + Westend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_of_sender_on_relay.into(), amount_to_send * 2), + ]), + ), + ); + let receiver = PenpalBReceiver::get(); + let test_args = TestContext { + sender: sender.clone(), + receiver: receiver.clone(), + args: TestArgs::new_para( + destination, + receiver.clone(), + amount_to_send, + assets, + None, + 0, + ), + }; + let mut test = ParaToParaThroughRelayTest::new(test_args); + let sender_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &sender) + }); + let receiver_assets_before = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &receiver) + }); + test.set_assertion::(para_to_para_through_hop_sender_assertions); + test.set_assertion::(para_to_para_relay_hop_assertions); + test.set_assertion::(para_to_para_through_hop_receiver_assertions); + test.set_dispatchable::< + PenpalA, + >(para_to_para_through_relay_limited_reserve_transfer_assets); + test.assert(); + let sender_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &sender) + }); + let receiver_assets_after = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location, &receiver) + }); + if !(sender_assets_after < sender_assets_before - amount_to_send) { + ::core::panicking::panic( + "assertion failed: sender_assets_after < sender_assets_before - amount_to_send", + ) + } + if !(receiver_assets_after > receiver_assets_before) { + ::core::panicking::panic( + "assertion failed: receiver_assets_after > receiver_assets_before", + ) + } + } + } + mod send { + use crate::imports::*; + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::send::send_transact_as_superuser_from_relay_to_asset_hub_works"] + pub const send_transact_as_superuser_from_relay_to_asset_hub_works: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::send::send_transact_as_superuser_from_relay_to_asset_hub_works", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/send.rs", + start_line: 21usize, + start_col: 4usize, + end_line: 21usize, + end_col: 60usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + send_transact_as_superuser_from_relay_to_asset_hub_works(), + ), + ), + }; + /// Relay Chain should be able to execute `Transact` instructions in System Parachain + /// when `OriginKind::Superuser`. + fn send_transact_as_superuser_from_relay_to_asset_hub_works() { + AssetHubWestend::force_create_asset_from_relay_as_root( + ASSET_ID, + ASSET_MIN_BALANCE, + true, + AssetHubWestendSender::get().into(), + Some(Weight::from_parts(1_019_445_000, 200_000)), + ) + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset"] + pub const send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/send.rs", + start_line: 35usize, + start_col: 4usize, + end_line: 35usize, + end_col: 64usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset(), + ), + ), + }; + /// We tests two things here: + /// - Parachain should be able to send XCM paying its fee at Asset Hub using system asset + /// - Parachain should be able to create a new Foreign Asset at Asset Hub + fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() { + let para_sovereign_account = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + let asset_location_on_penpal = Location::new( + 0, + [ + Junction::PalletInstance(ASSETS_PALLET_ID), + Junction::GeneralIndex(ASSET_ID.into()), + ], + ); + let foreign_asset_at_asset_hub = Location::new( + 1, + [Junction::Parachain(PenpalA::para_id().into())], + ) + .appended_with(asset_location_on_penpal) + .unwrap(); + let call = AssetHubWestend::create_foreign_asset_call( + foreign_asset_at_asset_hub.clone(), + ASSET_MIN_BALANCE, + para_sovereign_account.clone(), + ); + let origin_kind = OriginKind::Xcm; + let fee_amount = ASSET_HUB_WESTEND_ED * 1000000; + let system_asset = (Parent, fee_amount).into(); + let root_origin = ::RuntimeOrigin::root(); + let system_para_destination = PenpalA::sibling_location_of( + AssetHubWestend::para_id(), + ) + .into(); + let xcm = xcm_transact_paid_execution( + call, + origin_kind, + system_asset, + para_sovereign_account.clone(), + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + para_sovereign_account.clone().into(), + ASSET_HUB_WESTEND_ED * 10000000000, + ), + ]), + ), + ); + PenpalA::execute_with(|| { + let is = ::PolkadotXcm::send( + root_origin, + Box::new(system_para_destination), + Box::new(xcm), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + PenpalA::assert_xcm_pallet_sent(); + }); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == para_sovereign_account) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == para_sovereign_account", + ), + ); + res + }); + } + meet_conditions &= *who == para_sovereign_account; + if !(*amount == fee_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == fee_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == fee_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Created { asset_id, creator, owner }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == foreign_asset_at_asset_hub) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == foreign_asset_at_asset_hub", + ), + ); + res + }); + } + meet_conditions &= *asset_id == foreign_asset_at_asset_hub; + if !(*creator == para_sovereign_account.clone()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "creator", + creator, + "*creator == para_sovereign_account.clone()", + ), + ); + res + }); + } + meet_conditions + &= *creator == para_sovereign_account.clone(); + if !(*owner == para_sovereign_account) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == para_sovereign_account", + ), + ); + res + }); + } + meet_conditions &= *owner == para_sovereign_account; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Created {\nasset_id, creator, owner })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Created {\nasset_id, creator, owner })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::send", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + type ForeignAssets = ::ForeignAssets; + if !ForeignAssets::asset_exists(foreign_asset_at_asset_hub) { + ::core::panicking::panic( + "assertion failed: ForeignAssets::asset_exists(foreign_asset_at_asset_hub)", + ) + } + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset"] + pub const send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/send.rs", + start_line: 113usize, + start_col: 4usize, + end_line: 113usize, + end_col: 68usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset(), + ), + ), + }; + /// We tests two things here: + /// - Parachain should be able to send XCM paying its fee at Asset Hub using sufficient asset + /// - Parachain should be able to create a new Asset at Asset Hub + fn send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset() { + let para_sovereign_account = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + AssetHubWestend::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + true, + para_sovereign_account.clone(), + Some(Weight::from_parts(1_019_445_000, 200_000)), + ASSET_MIN_BALANCE * 1000000000, + ); + let new_asset_id = ASSET_ID + 1; + let call = AssetHubWestend::create_asset_call( + new_asset_id, + ASSET_MIN_BALANCE, + para_sovereign_account.clone(), + ); + let origin_kind = OriginKind::SovereignAccount; + let fee_amount = ASSET_MIN_BALANCE * 1000000; + let asset = ( + [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], + fee_amount, + ) + .into(); + let root_origin = ::RuntimeOrigin::root(); + let system_para_destination = PenpalA::sibling_location_of( + AssetHubWestend::para_id(), + ) + .into(); + let xcm = xcm_transact_paid_execution( + call, + origin_kind, + asset, + para_sovereign_account.clone(), + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + para_sovereign_account.clone().into(), + ASSET_HUB_WESTEND_ED * 10000000000, + ), + ]), + ), + ); + PenpalA::execute_with(|| { + let is = ::PolkadotXcm::send( + root_origin, + Box::new(system_para_destination), + Box::new(xcm), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + PenpalA::assert_xcm_pallet_sent(); + }); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == ASSET_ID) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == ASSET_ID", + ), + ); + res + }); + } + meet_conditions &= *asset_id == ASSET_ID; + if !(*owner == para_sovereign_account) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == para_sovereign_account", + ), + ); + res + }); + } + meet_conditions &= *owner == para_sovereign_account; + if !(*balance == fee_amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == fee_amount", + ), + ); + res + }); + } + meet_conditions &= *balance == fee_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Created { asset_id, creator, owner }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == new_asset_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == new_asset_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == new_asset_id; + if !(*creator == para_sovereign_account.clone()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "creator", + creator, + "*creator == para_sovereign_account.clone()", + ), + ); + res + }); + } + meet_conditions + &= *creator == para_sovereign_account.clone(); + if !(*owner == para_sovereign_account) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == para_sovereign_account", + ), + ); + res + }); + } + meet_conditions &= *owner == para_sovereign_account; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Created { asset_id, creator, owner\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Created { asset_id, creator, owner\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::send", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + } + mod set_xcm_versions { + use crate::imports::*; + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::set_xcm_versions::relay_sets_system_para_xcm_supported_version"] + pub const relay_sets_system_para_xcm_supported_version: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::set_xcm_versions::relay_sets_system_para_xcm_supported_version", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_xcm_versions.rs", + start_line: 19usize, + start_col: 4usize, + end_line: 19usize, + end_col: 48usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + relay_sets_system_para_xcm_supported_version(), + ), + ), + }; + fn relay_sets_system_para_xcm_supported_version() { + let sudo_origin = ::RuntimeOrigin::root(); + let system_para_destination: Location = Westend::child_location_of( + AssetHubWestend::para_id(), + ); + Westend::execute_with(|| { + let is = ::XcmPallet::force_xcm_version( + sudo_origin, + Box::new(system_para_destination.clone()), + XCM_V3, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::XcmPallet( + pallet_xcm::Event::SupportedVersionChanged { + location, + version: XCM_V3, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*location == system_para_destination) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "location", + location, + "*location == system_para_destination", + ), + ); + res + }); + } + meet_conditions &= *location == system_para_destination; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::set_xcm_versions", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::set_xcm_versions::system_para_sets_relay_xcm_supported_version"] + pub const system_para_sets_relay_xcm_supported_version: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::set_xcm_versions::system_para_sets_relay_xcm_supported_version", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_xcm_versions.rs", + start_line: 47usize, + start_col: 4usize, + end_line: 47usize, + end_col: 48usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + system_para_sets_relay_xcm_supported_version(), + ), + ), + }; + fn system_para_sets_relay_xcm_supported_version() { + let parent_location = AssetHubWestend::parent_location(); + let force_xcm_version_call = ::RuntimeCall::PolkadotXcm(pallet_xcm::Call::< + ::Runtime, + >::force_xcm_version { + location: Box::new(parent_location.clone()), + version: XCM_V3, + }) + .encode() + .into(); + Westend::send_unpaid_transact_to_parachain_as_root( + AssetHubWestend::para_id(), + force_xcm_version_call, + ); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_dmp_queue_complete( + Some(Weight::from_parts(1_019_210_000, 200_000)), + ); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm( + pallet_xcm::Event::SupportedVersionChanged { + location, + version: XCM_V3, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*location == parent_location) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "location", + location, + "*location == parent_location", + ), + ); + res + }); + } + meet_conditions &= *location == parent_location; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::set_xcm_versions", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + } + mod swap { + use crate::imports::*; + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::swap::swap_locally_on_chain_using_local_assets"] + pub const swap_locally_on_chain_using_local_assets: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::swap::swap_locally_on_chain_using_local_assets", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", + start_line: 19usize, + start_col: 4usize, + end_line: 19usize, + end_col: 44usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(swap_locally_on_chain_using_local_assets()), + ), + }; + fn swap_locally_on_chain_using_local_assets() { + let asset_native = Box::new( + Location::try_from(RelayLocation::get()).expect("conversion works"), + ); + let asset_one = Box::new(Location { + parents: 0, + interior: [ + Junction::PalletInstance(ASSETS_PALLET_ID), + Junction::GeneralIndex(ASSET_ID.into()), + ] + .into(), + }); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + let is = ::Assets::create( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + ASSET_ID.into(), + AssetHubWestendSender::get().into(), + 1000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + if !::Assets::asset_exists( + ASSET_ID, + ) { + ::core::panicking::panic( + "assertion failed: ::Assets::asset_exists(ASSET_ID)", + ) + } + let is = ::Assets::mint( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + ASSET_ID.into(), + AssetHubWestendSender::get().into(), + 3_000_000_000_000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = ::AssetConversion::create_pool( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + asset_native.clone(), + asset_one.clone(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::PoolCreated { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let is = ::AssetConversion::add_liquidity( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + asset_native.clone(), + asset_one.clone(), + 1_000_000_000_000, + 2_000_000_000_000, + 0, + 0, + AssetHubWestendSender::get().into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::LiquidityAdded { + lp_token_minted, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*lp_token_minted == 1414213562273) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "lp_token_minted", + lp_token_minted, + "*lp_token_minted == 1414213562273", + ), + ); + res + }); + } + meet_conditions &= *lp_token_minted == 1414213562273; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let path = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([asset_native.clone(), asset_one.clone()]), + ); + let is = ::AssetConversion::swap_exact_tokens_for_tokens( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + path, + 100, + 1, + AssetHubWestendSender::get().into(), + true, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::SwapExecuted { + amount_in, + amount_out, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*amount_in == 100) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount_in", + amount_in, + "*amount_in == 100", + ), + ); + res + }); + } + meet_conditions &= *amount_in == 100; + if !(*amount_out == 199) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount_out", + amount_out, + "*amount_out == 199", + ), + ); + res + }); + } + meet_conditions &= *amount_out == 199; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let is = ::AssetConversion::remove_liquidity( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + asset_native.clone(), + asset_one.clone(), + 1414213562273 - 2_000_000_000, + 0, + 0, + AssetHubWestendSender::get().into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::swap::swap_locally_on_chain_using_foreign_assets"] + pub const swap_locally_on_chain_using_foreign_assets: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::swap::swap_locally_on_chain_using_foreign_assets", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", + start_line: 114usize, + start_col: 4usize, + end_line: 114usize, + end_col: 46usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(swap_locally_on_chain_using_foreign_assets()), + ), + }; + fn swap_locally_on_chain_using_foreign_assets() { + let asset_native = Box::new( + Location::try_from(RelayLocation::get()).unwrap(), + ); + let asset_location_on_penpal = Location::try_from( + PenpalLocalTeleportableToAssetHub::get(), + ) + .expect("conversion_works"); + let foreign_asset_at_asset_hub_westend = Location::new( + 1, + [Junction::Parachain(PenpalA::para_id().into())], + ) + .appended_with(asset_location_on_penpal) + .unwrap(); + let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + penpal_as_seen_by_ah, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + AssetHubWestendSender::get().into(), + 5_000_000 * ASSET_HUB_WESTEND_ED, + ), + ( + sov_penpal_on_ahr.clone().into(), + 100_000_000 * ASSET_HUB_WESTEND_ED, + ), + ]), + ), + ); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + let is = ::ForeignAssets::mint( + ::RuntimeOrigin::signed( + sov_penpal_on_ahr.clone().into(), + ), + foreign_asset_at_asset_hub_westend.clone(), + sov_penpal_on_ahr.clone().into(), + ASSET_HUB_WESTEND_ED * 3_000_000_000_000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let is = ::AssetConversion::create_pool( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + asset_native.clone(), + Box::new(foreign_asset_at_asset_hub_westend.clone()), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::PoolCreated { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let is = ::AssetConversion::add_liquidity( + ::RuntimeOrigin::signed( + sov_penpal_on_ahr.clone(), + ), + asset_native.clone(), + Box::new(foreign_asset_at_asset_hub_westend.clone()), + 1_000_000_000_000_000, + 2_000_000_000_000_000, + 0, + 0, + sov_penpal_on_ahr.clone().into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::LiquidityAdded { + lp_token_minted, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*lp_token_minted == 1414213562372995) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "lp_token_minted", + lp_token_minted, + "*lp_token_minted == 1414213562372995", + ), + ); + res + }); + } + meet_conditions &= *lp_token_minted == 1414213562372995; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let path = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + asset_native.clone(), + Box::new(foreign_asset_at_asset_hub_westend.clone()), + ]), + ); + let is = ::AssetConversion::swap_exact_tokens_for_tokens( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + path, + 100000 * ASSET_HUB_WESTEND_ED, + 1000 * ASSET_HUB_WESTEND_ED, + AssetHubWestendSender::get().into(), + true, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::SwapExecuted { + amount_in, + amount_out, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*amount_in == 100000000000000) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount_in", + amount_in, + "*amount_in == 100000000000000", + ), + ); + res + }); + } + meet_conditions &= *amount_in == 100000000000000; + if !(*amount_out == 181322178776029) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount_out", + amount_out, + "*amount_out == 181322178776029", + ), + ); + res + }); + } + meet_conditions &= *amount_out == 181322178776029; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let is = ::AssetConversion::remove_liquidity( + ::RuntimeOrigin::signed( + sov_penpal_on_ahr.clone(), + ), + asset_native.clone(), + Box::new(foreign_asset_at_asset_hub_westend), + 1414213562372995 - ASSET_HUB_WESTEND_ED * 2, + 0, + 0, + sov_penpal_on_ahr.clone().into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::swap::cannot_create_pool_from_pool_assets"] + pub const cannot_create_pool_from_pool_assets: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::swap::cannot_create_pool_from_pool_assets", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", + start_line: 229usize, + start_col: 4usize, + end_line: 229usize, + end_col: 39usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(cannot_create_pool_from_pool_assets()), + ), + }; + fn cannot_create_pool_from_pool_assets() { + let asset_native = RelayLocation::get(); + let mut asset_one = ahw_xcm_config::PoolAssetsPalletLocation::get(); + asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets"); + AssetHubWestend::execute_with(|| { + let pool_owner_account_id = AssetHubWestendAssetConversionOrigin::get(); + let is = ::PoolAssets::create( + ::RuntimeOrigin::signed( + pool_owner_account_id.clone(), + ), + ASSET_ID.into(), + pool_owner_account_id.clone().into(), + 1000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + if !::PoolAssets::asset_exists( + ASSET_ID, + ) { + ::core::panicking::panic( + "assertion failed: ::PoolAssets::asset_exists(ASSET_ID)", + ) + } + let is = ::PoolAssets::mint( + ::RuntimeOrigin::signed( + pool_owner_account_id, + ), + ASSET_ID.into(), + AssetHubWestendSender::get().into(), + 3_000_000_000_000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + match ::AssetConversion::create_pool( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + Box::new( + Location::try_from(asset_native).expect("conversion works"), + ), + Box::new(Location::try_from(asset_one).expect("conversion works")), + ) { + Err( + DispatchError::Module( + ModuleError { index: _, error: _, message }, + ), + ) => { + match (&message, &Some("Unknown")) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + } + } + ref e => { + ::std::rt::panic_fmt( + format_args!( + "assertion failed: `{0:?}` does not match `{1}`", + e, + "Err(DispatchError::Module(ModuleError { index: _, error: _, message }))", + ), + ); + } + }; + }); + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::swap::pay_xcm_fee_with_some_asset_swapped_for_native"] + pub const pay_xcm_fee_with_some_asset_swapped_for_native: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::swap::pay_xcm_fee_with_some_asset_swapped_for_native", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", + start_line: 264usize, + start_col: 4usize, + end_line: 264usize, + end_col: 50usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + pay_xcm_fee_with_some_asset_swapped_for_native(), + ), + ), + }; + fn pay_xcm_fee_with_some_asset_swapped_for_native() { + let asset_native = Location::try_from(RelayLocation::get()) + .expect("conversion works"); + let asset_one = Location { + parents: 0, + interior: [ + Junction::PalletInstance(ASSETS_PALLET_ID), + Junction::GeneralIndex(ASSET_ID.into()), + ] + .into(), + }; + let penpal = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + let is = ::Assets::create( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + ASSET_ID.into(), + AssetHubWestendSender::get().into(), + ASSET_MIN_BALANCE, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + if !::Assets::asset_exists( + ASSET_ID, + ) { + ::core::panicking::panic( + "assertion failed: ::Assets::asset_exists(ASSET_ID)", + ) + } + let is = ::Assets::mint( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + ASSET_ID.into(), + AssetHubWestendSender::get().into(), + 3_000_000_000_000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = ::AssetConversion::create_pool( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + Box::new(asset_native.clone()), + Box::new(asset_one.clone()), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::PoolCreated { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + let is = ::AssetConversion::add_liquidity( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + Box::new(asset_native), + Box::new(asset_one), + 1_000_000_000_000, + 2_000_000_000_000, + 0, + 0, + AssetHubWestendSender::get().into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::LiquidityAdded { + lp_token_minted, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*lp_token_minted == 1414213562273) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "lp_token_minted", + lp_token_minted, + "*lp_token_minted == 1414213562273", + ), + ); + res + }); + } + meet_conditions &= *lp_token_minted == 1414213562273; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + match ( + &::Balances::free_balance( + penpal.clone(), + ), + &0, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + let is = ::Assets::touch_other( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + ASSET_ID.into(), + penpal.clone().into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = ::Assets::mint( + ::RuntimeOrigin::signed( + AssetHubWestendSender::get(), + ), + ASSET_ID.into(), + penpal.clone().into(), + 10_000_000_000_000, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + PenpalA::execute_with(|| { + let call = AssetHubWestend::force_create_asset_call( + ASSET_ID + 1000, + penpal.clone(), + true, + ASSET_MIN_BALANCE, + ); + let penpal_root = ::RuntimeOrigin::root(); + let fee_amount = 4_000_000_000_000u128; + let asset_one = ( + [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], + fee_amount, + ) + .into(); + let asset_hub_location = PenpalA::sibling_location_of( + AssetHubWestend::para_id(), + ) + .into(); + let xcm = xcm_transact_paid_execution( + call, + OriginKind::SovereignAccount, + asset_one, + penpal.clone(), + ); + let is = ::PolkadotXcm::send( + penpal_root, + Box::new(asset_hub_location), + Box::new(xcm), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + PenpalA::assert_xcm_pallet_sent(); + }); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::AssetConversion( + pallet_asset_conversion::Event::SwapCreditExecuted { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapCreditExecuted {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapCreditExecuted {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::swap", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + } + mod teleport { + use crate::imports::*; + fn relay_dest_assertions_fail(_t: SystemParaToRelayTest) { + Westend::assert_ump_queue_processed( + false, + Some(AssetHubWestend::para_id()), + Some(Weight::from_parts(157_718_000, 3_593)), + ); + } + fn para_origin_assertions(t: SystemParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcm_pallet_attempted_complete( + Some(Weight::from_parts(720_053_000, 7_203)), + ); + AssetHubWestend::assert_parachain_system_ump_sent(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *who == t.sender.account_id; + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn penpal_to_ah_foreign_assets_sender_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let system_para_native_asset_location = RelayLocation::get(); + let expected_asset_id = t.args.asset_id.unwrap(); + let (_, expected_asset_amount) = non_fee_asset( + &t.args.assets, + t.args.fee_asset_item as usize, + ) + .unwrap(); + PenpalA::assert_xcm_pallet_attempted_complete(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == system_para_native_asset_location) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == system_para_native_asset_location", + ), + ); + res + }); + } + meet_conditions + &= *asset_id == system_para_native_asset_location; + if !(*owner == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_asset_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_asset_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_asset_id; + if !(*owner == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if !(*balance == expected_asset_amount) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == expected_asset_amount", + ), + ); + res + }); + } + meet_conditions &= *balance == expected_asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalA::para_id()), + ); + let (expected_foreign_asset_id, expected_foreign_asset_amount) = non_fee_asset( + &t.args.assets, + t.args.fee_asset_item as usize, + ) + .unwrap(); + AssetHubWestend::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == sov_penpal_on_ahr.clone().into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == sov_penpal_on_ahr.clone().into()", + ), + ); + res + }); + } + meet_conditions &= *who == sov_penpal_on_ahr.clone().into(); + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Minted { who, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*who == t.receiver.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "who", + who, + "*who == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *who == t.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_foreign_asset_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_foreign_asset_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_foreign_asset_id; + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if !(*amount == expected_foreign_asset_amount) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == expected_foreign_asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == expected_foreign_asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn ah_to_penpal_foreign_assets_sender_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcm_pallet_attempted_complete(None); + let (expected_foreign_asset_id, expected_foreign_asset_amount) = non_fee_asset( + &t.args.assets, + t.args.fee_asset_item as usize, + ) + .unwrap(); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*from == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "*from == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *from == t.sender.account_id; + if !(*to + == AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + )) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "*to == AssetHubWestend::sovereign_account_id_of(t.args.dest.clone())", + ), + ); + res + }); + } + meet_conditions + &= *to + == AssetHubWestend::sovereign_account_id_of( + t.args.dest.clone(), + ); + if !(*amount == t.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == t.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == t.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_foreign_asset_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_foreign_asset_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_foreign_asset_id; + if !(*owner == t.sender.account_id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.sender.account_id; + if !(*balance == expected_foreign_asset_amount) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == expected_foreign_asset_amount", + ), + ); + res + }); + } + meet_conditions &= *balance == expected_foreign_asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn ah_to_penpal_foreign_assets_receiver_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + let expected_asset_id = t.args.asset_id.unwrap(); + let (_, expected_asset_amount) = non_fee_asset( + &t.args.assets, + t.args.fee_asset_item as usize, + ) + .unwrap(); + let checking_account = ::PolkadotXcm::check_account(); + let system_para_native_asset_location = RelayLocation::get(); + PenpalA::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_asset_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_asset_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_asset_id; + if !(*owner == checking_account) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == checking_account", + ), + ); + res + }); + } + meet_conditions &= *owner == checking_account; + if !(*balance == expected_asset_amount) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == expected_asset_amount", + ), + ); + res + }); + } + meet_conditions &= *balance == expected_asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Issued { asset_id, owner, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == expected_asset_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == expected_asset_id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == expected_asset_id; + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if !(*amount == expected_asset_amount) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == expected_asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == expected_asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, amount }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == system_para_native_asset_location) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == system_para_native_asset_location", + ), + ); + res + }); + } + meet_conditions + &= *asset_id == system_para_native_asset_location; + if !(*owner == t.receiver.account_id) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == t.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == t.receiver.account_id; + if !(*amount == expected_asset_amount) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == expected_asset_amount", + ), + ); + res + }); + } + meet_conditions &= *amount == expected_asset_amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn system_para_limited_teleport_assets( + t: SystemParaToRelayTest, + ) -> DispatchResult { + ::PolkadotXcm::limited_teleport_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + fn para_to_system_para_transfer_assets( + t: ParaToSystemParaTest, + ) -> DispatchResult { + ::PolkadotXcm::transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + fn system_para_to_para_transfer_assets( + t: SystemParaToParaTest, + ) -> DispatchResult { + ::PolkadotXcm::transfer_assets( + t.signed_origin, + Box::new(t.args.dest.into()), + Box::new(t.args.beneficiary.into()), + Box::new(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::teleport::teleport_to_other_system_parachains_works"] + pub const teleport_to_other_system_parachains_works: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::teleport::teleport_to_other_system_parachains_works", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", + start_line: 204usize, + start_col: 4usize, + end_line: 204usize, + end_col: 45usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(teleport_to_other_system_parachains_works()), + ), + }; + fn teleport_to_other_system_parachains_works() { + let amount = ASSET_HUB_WESTEND_ED * 100; + let native_asset: Assets = (Parent, amount).into(); + let sender = AssetHubWestendSender::get(); + let mut para_sender_balance_before = ::account_data_of( + sender.clone(), + ) + .free; + let origin = ::RuntimeOrigin::signed( + sender.clone(), + ); + let fee_asset_item = 0; + let weight_limit = ::emulated_integration_tests_common::macros::WeightLimit::Unlimited; + { + let receiver = BridgeHubWestendReceiver::get(); + let para_receiver_balance_before = ::account_data_of( + receiver.clone(), + ) + .free; + let para_destination = ::sibling_location_of( + ::para_id(), + ); + let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { + network: None, + id: receiver.clone().into(), + } + .into(); + ::execute_with(|| { + let is = ::PolkadotXcm::limited_teleport_assets( + origin.clone(), + Box::new(para_destination.clone().into()), + Box::new(beneficiary.clone().into()), + Box::new(native_asset.clone().into()), + fee_asset_item, + weight_limit.clone(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted { + outcome: Outcome::Complete { .. }, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::XcmpQueue( + ::emulated_integration_tests_common::macros::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::XcmpQueue(::emulated_integration_tests_common::macros::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::XcmpQueue(::emulated_integration_tests_common::macros::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + ::emulated_integration_tests_common::macros::pallet_balances::Event::Burned { + who: sender, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + ::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + ::emulated_integration_tests_common::macros::pallet_balances::Event::Minted { + who: receiver, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "BridgeHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "BridgeHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + ::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed { + success: true, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "BridgeHubWestend", + "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "BridgeHubWestend", + "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::BridgeHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + let para_sender_balance_after = ::account_data_of( + sender.clone(), + ) + .free; + let para_receiver_balance_after = ::account_data_of( + receiver.clone(), + ) + .free; + let delivery_fees = ::execute_with(|| { + ::emulated_integration_tests_common::macros::asset_test_utils::xcm_helpers::teleport_assets_delivery_fees::< + ::XcmSender, + >( + native_asset.clone(), + fee_asset_item, + weight_limit.clone(), + beneficiary, + para_destination, + ) + }); + match ( + &(para_sender_balance_before - amount - delivery_fees), + ¶_sender_balance_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(para_receiver_balance_after > para_receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: para_receiver_balance_after > para_receiver_balance_before", + ) + } + para_sender_balance_before = ::account_data_of( + sender.clone(), + ) + .free; + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::teleport::teleport_from_and_to_relay"] + pub const teleport_from_and_to_relay: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::teleport::teleport_from_and_to_relay", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", + start_line: 217usize, + start_col: 4usize, + end_line: 217usize, + end_col: 30usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(teleport_from_and_to_relay()), + ), + }; + fn teleport_from_and_to_relay() { + let amount = WESTEND_ED * 100; + let native_asset: Assets = (Here, amount).into(); + let sender = WestendSender::get(); + let mut relay_sender_balance_before = ::account_data_of( + sender.clone(), + ) + .free; + let origin = ::RuntimeOrigin::signed( + sender.clone(), + ); + let fee_asset_item = 0; + let weight_limit = ::emulated_integration_tests_common::macros::WeightLimit::Unlimited; + { + let receiver = AssetHubWestendReceiver::get(); + let para_receiver_balance_before = ::account_data_of( + receiver.clone(), + ) + .free; + let para_destination = ::child_location_of( + ::para_id(), + ); + let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { + network: None, + id: receiver.clone().into(), + } + .into(); + ::execute_with(|| { + let is = ::XcmPallet::limited_teleport_assets( + origin.clone(), + Box::new(para_destination.clone().into()), + Box::new(beneficiary.clone().into()), + Box::new(native_asset.clone().into()), + fee_asset_item, + weight_limit.clone(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::XcmPallet( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted { + outcome: Outcome::Complete { .. }, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + ::emulated_integration_tests_common::macros::pallet_balances::Event::Burned { + who: sender, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::XcmPallet( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + ::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + ::emulated_integration_tests_common::macros::pallet_balances::Event::Minted { + who: receiver, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + ::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed { + success: true, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + let relay_sender_balance_after = ::account_data_of( + sender.clone(), + ) + .free; + let para_receiver_balance_after = ::account_data_of( + receiver.clone(), + ) + .free; + let delivery_fees = ::execute_with(|| { + ::emulated_integration_tests_common::macros::asset_test_utils::xcm_helpers::teleport_assets_delivery_fees::< + ::XcmSender, + >( + native_asset.clone(), + fee_asset_item, + weight_limit.clone(), + beneficiary, + para_destination, + ) + }); + match ( + &(relay_sender_balance_before - amount - delivery_fees), + &relay_sender_balance_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(para_receiver_balance_after > para_receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: para_receiver_balance_after > para_receiver_balance_before", + ) + } + relay_sender_balance_before = ::account_data_of( + sender.clone(), + ) + .free; + }; + let sender = AssetHubWestendSender::get(); + let para_sender_balance_before = ::account_data_of( + sender.clone(), + ) + .free; + let origin = ::RuntimeOrigin::signed( + sender.clone(), + ); + let assets: Assets = (Parent, amount).into(); + let fee_asset_item = 0; + let weight_limit = ::emulated_integration_tests_common::macros::WeightLimit::Unlimited; + let receiver = WestendReceiver::get(); + let relay_receiver_balance_before = ::account_data_of( + receiver.clone(), + ) + .free; + let relay_destination: Location = Parent.into(); + let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { + network: None, + id: receiver.clone().into(), + } + .into(); + ::execute_with(|| { + let is = ::PolkadotXcm::limited_teleport_assets( + origin.clone(), + Box::new(relay_destination.clone().into()), + Box::new(beneficiary.clone().into()), + Box::new(assets.clone().into()), + fee_asset_item, + weight_limit.clone(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted { + outcome: Outcome::Complete { .. }, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + ::emulated_integration_tests_common::macros::pallet_balances::Event::Burned { + who: sender, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::PolkadotXcm( + ::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + ::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + ::emulated_integration_tests_common::macros::pallet_balances::Event::Minted { + who: receiver, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + ::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed { + success: true, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::teleport", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + let para_sender_balance_after = ::account_data_of( + sender.clone(), + ) + .free; + let relay_receiver_balance_after = ::account_data_of( + receiver.clone(), + ) + .free; + let delivery_fees = ::execute_with(|| { + ::emulated_integration_tests_common::macros::asset_test_utils::xcm_helpers::teleport_assets_delivery_fees::< + ::XcmSender, + >( + assets, + fee_asset_item, + weight_limit.clone(), + beneficiary, + relay_destination, + ) + }); + match ( + &(para_sender_balance_before - amount - delivery_fees), + ¶_sender_balance_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + if !(relay_receiver_balance_after > relay_receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: relay_receiver_balance_after > relay_receiver_balance_before", + ) + } + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::teleport::limited_teleport_native_assets_from_system_para_to_relay_fails"] + pub const limited_teleport_native_assets_from_system_para_to_relay_fails: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::teleport::limited_teleport_native_assets_from_system_para_to_relay_fails", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", + start_line: 239usize, + start_col: 4usize, + end_line: 239usize, + end_col: 66usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + limited_teleport_native_assets_from_system_para_to_relay_fails(), + ), + ), + }; + /// Limited Teleport of native asset from System Parachain to Relay Chain + /// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` + fn limited_teleport_native_assets_from_system_para_to_relay_fails() { + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let destination = AssetHubWestend::parent_location().into(); + let beneficiary_id = WestendReceiver::get().into(); + let assets = (Parent, amount_to_send).into(); + let test_args = TestContext { + sender: AssetHubWestendSender::get(), + receiver: WestendReceiver::get(), + args: TestArgs::new_para( + destination, + beneficiary_id, + amount_to_send, + assets, + None, + 0, + ), + }; + let mut test = SystemParaToRelayTest::new(test_args); + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + test.set_assertion::(para_origin_assertions); + test.set_assertion::(relay_dest_assertions_fail); + test.set_dispatchable::< + AssetHubWestend, + >(system_para_limited_teleport_assets); + test.assert(); + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + let delivery_fees = AssetHubWestend::execute_with(|| { + xcm_helpers::teleport_assets_delivery_fees::< + ::XcmSender, + >( + test.args.assets.clone(), + 0, + test.args.weight_limit, + test.args.beneficiary, + test.args.dest, + ) + }); + match ( + &(sender_balance_before - amount_to_send - delivery_fees), + &sender_balance_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match (&receiver_balance_after, &receiver_balance_before) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + /// Bidirectional teleports of local Penpal assets to Asset Hub as foreign assets while paying + /// fees using (reserve transferred) native asset. + pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt( + para_to_ah_dispatchable: fn(ParaToSystemParaTest) -> DispatchResult, + ah_to_para_dispatchable: fn(SystemParaToParaTest) -> DispatchResult, + ) { + let fee_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 100; + let asset_location_on_penpal = PenpalLocalTeleportableToAssetHub::get(); + let asset_id_on_penpal = match asset_location_on_penpal.last() { + Some(Junction::GeneralIndex(id)) => *id as u32, + _ => ::core::panicking::panic("internal error: entered unreachable code"), + }; + let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100; + let asset_owner = PenpalAssetOwner::get(); + let system_para_native_asset_location = RelayLocation::get(); + let sender = PenpalASender::get(); + let penpal_check_account = ::PolkadotXcm::check_account(); + let ah_as_seen_by_penpal = PenpalA::sibling_location_of( + AssetHubWestend::para_id(), + ); + let penpal_assets: Assets = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (Parent, fee_amount_to_send).into(), + (asset_location_on_penpal.clone(), asset_amount_to_send).into(), + ]), + ) + .into(); + let fee_asset_index = penpal_assets + .inner() + .iter() + .position(|r| r == &(Parent, fee_amount_to_send).into()) + .unwrap() as u32; + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner.clone()), + system_para_native_asset_location.clone(), + sender.clone(), + fee_amount_to_send * 2, + ); + PenpalA::mint_asset( + ::RuntimeOrigin::signed(asset_owner.clone()), + asset_id_on_penpal, + sender.clone(), + asset_amount_to_send, + ); + PenpalA::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + penpal_check_account.clone().into(), + ASSET_HUB_WESTEND_ED * 1000, + ), + ]), + ), + ); + let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_penpal_on_ah = AssetHubWestend::sovereign_account_id_of( + penpal_as_seen_by_ah, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + sov_penpal_on_ah.clone().into(), + ASSET_HUB_WESTEND_ED * 100_000_000_000, + ), + ]), + ), + ); + let foreign_asset_at_asset_hub_westend = Location::new( + 1, + [Junction::Parachain(PenpalA::para_id().into())], + ) + .appended_with(asset_location_on_penpal) + .unwrap(); + let penpal_to_ah_beneficiary_id = AssetHubWestendReceiver::get(); + let penpal_to_ah_test_args = TestContext { + sender: PenpalASender::get(), + receiver: AssetHubWestendReceiver::get(), + args: TestArgs::new_para( + ah_as_seen_by_penpal, + penpal_to_ah_beneficiary_id, + asset_amount_to_send, + penpal_assets, + Some(asset_id_on_penpal), + fee_asset_index, + ), + }; + let mut penpal_to_ah = ParaToSystemParaTest::new(penpal_to_ah_test_args); + let penpal_sender_balance_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + system_para_native_asset_location.clone(), + &PenpalASender::get(), + ) + }); + let ah_receiver_balance_before = penpal_to_ah.receiver.balance; + let penpal_sender_assets_before = PenpalA::execute_with(|| { + type Assets = ::Assets; + >::balance(asset_id_on_penpal, &PenpalASender::get()) + }); + let ah_receiver_assets_before = AssetHubWestend::execute_with(|| { + type Assets = ::ForeignAssets; + >::balance( + foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), + &AssetHubWestendReceiver::get(), + ) + }); + penpal_to_ah + .set_assertion::(penpal_to_ah_foreign_assets_sender_assertions); + penpal_to_ah + .set_assertion::< + AssetHubWestend, + >(penpal_to_ah_foreign_assets_receiver_assertions); + penpal_to_ah.set_dispatchable::(para_to_ah_dispatchable); + penpal_to_ah.assert(); + let penpal_sender_balance_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + system_para_native_asset_location.clone(), + &PenpalASender::get(), + ) + }); + let ah_receiver_balance_after = penpal_to_ah.receiver.balance; + let penpal_sender_assets_after = PenpalA::execute_with(|| { + type Assets = ::Assets; + >::balance(asset_id_on_penpal, &PenpalASender::get()) + }); + let ah_receiver_assets_after = AssetHubWestend::execute_with(|| { + type Assets = ::ForeignAssets; + >::balance( + foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), + &AssetHubWestendReceiver::get(), + ) + }); + if !(penpal_sender_balance_after < penpal_sender_balance_before) { + ::core::panicking::panic( + "assertion failed: penpal_sender_balance_after < penpal_sender_balance_before", + ) + } + if !(ah_receiver_balance_after > ah_receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: ah_receiver_balance_after > ah_receiver_balance_before", + ) + } + if !(ah_receiver_balance_after + < ah_receiver_balance_before + fee_amount_to_send) + { + ::core::panicking::panic( + "assertion failed: ah_receiver_balance_after < ah_receiver_balance_before + fee_amount_to_send", + ) + } + match ( + &(penpal_sender_assets_before - asset_amount_to_send), + &penpal_sender_assets_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &ah_receiver_assets_after, + &(ah_receiver_assets_before + asset_amount_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + let is = ForeignAssets::transfer( + ::RuntimeOrigin::signed( + AssetHubWestendReceiver::get(), + ), + foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), + AssetHubWestendSender::get().into(), + asset_amount_to_send, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + let ah_to_penpal_beneficiary_id = PenpalAReceiver::get(); + let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let ah_assets: Assets = <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (Parent, fee_amount_to_send).into(), + ( + foreign_asset_at_asset_hub_westend.clone(), + asset_amount_to_send, + ) + .into(), + ]), + ) + .into(); + let fee_asset_index = ah_assets + .inner() + .iter() + .position(|r| r == &(Parent, fee_amount_to_send).into()) + .unwrap() as u32; + let ah_to_penpal_test_args = TestContext { + sender: AssetHubWestendSender::get(), + receiver: PenpalAReceiver::get(), + args: TestArgs::new_para( + penpal_as_seen_by_ah, + ah_to_penpal_beneficiary_id, + asset_amount_to_send, + ah_assets, + Some(asset_id_on_penpal), + fee_asset_index, + ), + }; + let mut ah_to_penpal = SystemParaToParaTest::new(ah_to_penpal_test_args); + let ah_sender_balance_before = ah_to_penpal.sender.balance; + let penpal_receiver_balance_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + system_para_native_asset_location.clone(), + &PenpalAReceiver::get(), + ) + }); + let ah_sender_assets_before = AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), + &AssetHubWestendSender::get(), + ) + }); + let penpal_receiver_assets_before = PenpalA::execute_with(|| { + type Assets = ::Assets; + >::balance(asset_id_on_penpal, &PenpalAReceiver::get()) + }); + ah_to_penpal + .set_assertion::< + AssetHubWestend, + >(ah_to_penpal_foreign_assets_sender_assertions); + ah_to_penpal + .set_assertion::< + PenpalA, + >(ah_to_penpal_foreign_assets_receiver_assertions); + ah_to_penpal.set_dispatchable::(ah_to_para_dispatchable); + ah_to_penpal.assert(); + let ah_sender_balance_after = ah_to_penpal.sender.balance; + let penpal_receiver_balance_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(system_para_native_asset_location, &PenpalAReceiver::get()) + }); + let ah_sender_assets_after = AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance( + foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), + &AssetHubWestendSender::get(), + ) + }); + let penpal_receiver_assets_after = PenpalA::execute_with(|| { + type Assets = ::Assets; + >::balance(asset_id_on_penpal, &PenpalAReceiver::get()) + }); + if !(ah_sender_balance_after < ah_sender_balance_before) { + ::core::panicking::panic( + "assertion failed: ah_sender_balance_after < ah_sender_balance_before", + ) + } + if !(penpal_receiver_balance_after > penpal_receiver_balance_before) { + ::core::panicking::panic( + "assertion failed: penpal_receiver_balance_after > penpal_receiver_balance_before", + ) + } + if !(penpal_receiver_balance_after + < penpal_receiver_balance_before + fee_amount_to_send) + { + ::core::panicking::panic( + "assertion failed: penpal_receiver_balance_after <\n penpal_receiver_balance_before + fee_amount_to_send", + ) + } + match ( + &(ah_sender_assets_before - asset_amount_to_send), + &ah_sender_assets_after, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &penpal_receiver_assets_after, + &(penpal_receiver_assets_before + asset_amount_to_send), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::teleport::bidirectional_teleport_foreign_assets_between_para_and_asset_hub"] + pub const bidirectional_teleport_foreign_assets_between_para_and_asset_hub: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::teleport::bidirectional_teleport_foreign_assets_between_para_and_asset_hub", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", + start_line: 527usize, + start_col: 4usize, + end_line: 527usize, + end_col: 68usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result( + bidirectional_teleport_foreign_assets_between_para_and_asset_hub(), + ), + ), + }; + /// Bidirectional teleports of local Penpal assets to Asset Hub as foreign assets should work + /// (using native reserve-based transfer for fees) + fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() { + do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt( + para_to_system_para_transfer_assets, + system_para_to_para_transfer_assets, + ); + } + } + mod treasury { + use crate::imports::*; + use emulated_integration_tests_common::{ + accounts::{ALICE, BOB}, + USDT_ID, + }; + use frame_support::traits::fungibles::{Inspect, Mutate}; + use polkadot_runtime_common::impls::VersionedLocatableAsset; + use xcm_executor::traits::ConvertLocation; + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::treasury::create_and_claim_treasury_spend"] + pub const create_and_claim_treasury_spend: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName( + "tests::treasury::create_and_claim_treasury_spend", + ), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs", + start_line: 26usize, + start_col: 4usize, + end_line: 26usize, + end_col: 35usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(create_and_claim_treasury_spend()), + ), + }; + fn create_and_claim_treasury_spend() { + const SPEND_AMOUNT: u128 = 1_000_000_000; + let treasury_location: Location = Location::new(1, PalletInstance(37)); + let treasury_account = ahw_xcm_config::LocationToAccountId::convert_location( + &treasury_location, + ) + .unwrap(); + let asset_hub_location = Location::new( + 0, + Parachain(AssetHubWestend::para_id().into()), + ); + let root = ::RuntimeOrigin::root(); + let asset_kind = VersionedLocatableAsset::V5 { + location: asset_hub_location, + asset_id: AssetId( + [PalletInstance(50), GeneralIndex(USDT_ID.into())].into(), + ), + }; + let alice: AccountId = Westend::account_id_of(ALICE); + let bob: AccountId = Westend::account_id_of(BOB); + let bob_signed = ::RuntimeOrigin::signed(bob.clone()); + AssetHubWestend::execute_with(|| { + type Assets = ::Assets; + let is = >::mint_into(USDT_ID, &treasury_account, SPEND_AMOUNT * 4); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + match (&>::balance(USDT_ID, &alice), &0u128) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + Westend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type Treasury = ::Treasury; + type AssetRate = ::AssetRate; + let is = AssetRate::create( + root.clone(), + Box::new(asset_kind.clone()), + 2.into(), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = Treasury::spend( + root, + Box::new(asset_kind), + SPEND_AMOUNT, + Box::new( + Location::new(0, Into::<[u8; 32]>::into(alice.clone())).into(), + ), + None, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let is = Treasury::payout(bob_signed.clone(), 0); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. }) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::treasury", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type Assets = ::Assets; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Assets( + pallet_assets::Event::Transferred { + asset_id: id, + from, + to, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(id == &USDT_ID) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "id", + id, + "id == &USDT_ID", + ), + ); + res + }); + } + meet_conditions &= id == &USDT_ID; + if !(from == &treasury_account) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "from", + from, + "from == &treasury_account", + ), + ); + res + }); + } + meet_conditions &= from == &treasury_account; + if !(to == &alice) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "to", + to, + "to == &alice", + ), + ); + res + }); + } + meet_conditions &= to == &alice; + if !(amount == &SPEND_AMOUNT) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "amount == &SPEND_AMOUNT", + ), + ); + res + }); + } + meet_conditions &= amount == &SPEND_AMOUNT; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ParachainSystem( + cumulus_pallet_parachain_system::Event::UpwardMessageSent { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::ParachainSystem(cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::ParachainSystem(cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::treasury", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + match ( + &>::balance(USDT_ID, &alice), + &SPEND_AMOUNT, + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + }); + Westend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type Treasury = ::Treasury; + let is = Treasury::check_status(bob_signed, 0); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Treasury( + pallet_treasury::Event::SpendProcessed { .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Westend", + "RuntimeEvent::Treasury(pallet_treasury::Event::SpendProcessed { .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Westend", + "RuntimeEvent::Treasury(pallet_treasury::Event::SpendProcessed { .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Westend", + "asset_hub_westend_integration_tests::tests::treasury", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display( + arg: &T, + ) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + } + mod xcm_fee_estimation { + //! Tests to ensure correct XCM fee estimation for cross-chain asset transfers. + use crate::imports::*; + use frame_support::{ + dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, + }; + use xcm_runtime_apis::{ + dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, + fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, + }; + fn sender_assertions(test: ParaToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + PenpalA::assert_xcm_pallet_attempted_complete(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == Location::new(1, [])) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == Location::new(1, [])", + ), + ); + res + }); + } + meet_conditions &= *asset_id == Location::new(1, []); + if !(*owner == test.sender.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == test.sender.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == test.sender.account_id; + if !(*balance == test.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "balance", + balance, + "*balance == test.args.amount", + ), + ); + res + }); + } + meet_conditions &= *balance == test.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalA", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "asset_hub_westend_integration_tests::tests::xcm_fee_estimation", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn hop_assertions(test: ParaToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + AssetHubWestend::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::Balances( + pallet_balances::Event::Burned { amount, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*amount == test.args.amount) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == test.args.amount", + ), + ); + res + }); + } + meet_conditions &= *amount == test.args.amount; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { amount, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "AssetHubWestend", + "RuntimeEvent::Balances(pallet_balances::Event::Burned { amount, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::AssetHubWestend", + "asset_hub_westend_integration_tests::tests::xcm_fee_estimation", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn receiver_assertions(test: ParaToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + PenpalB::assert_xcmp_queue_success(None); + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Issued { asset_id, owner, .. }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == Location::new(1, [])) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == Location::new(1, [])", + ), + ); + res + }); + } + meet_conditions &= *asset_id == Location::new(1, []); + if !(*owner == test.receiver.account_id) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == test.receiver.account_id", + ), + ); + res + }); + } + meet_conditions &= *owner == test.receiver.account_id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "PenpalB", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "PenpalB", + "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalB", + "asset_hub_westend_integration_tests::tests::xcm_fee_estimation", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + fn transfer_assets_para_to_para_through_ah_dispatchable( + test: ParaToParaThroughAHTest, + ) -> DispatchResult { + let call = transfer_assets_para_to_para_through_ah_call(test.clone()); + match call.dispatch(test.signed_origin) { + Ok(_) => Ok(()), + Err(error_with_post_info) => Err(error_with_post_info.error), + } + } + fn transfer_assets_para_to_para_through_ah_call( + test: ParaToParaThroughAHTest, + ) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; + let asset_hub_location: Location = PenpalB::sibling_location_of( + AssetHubWestend::para_id(), + ); + let custom_xcm_on_dest = Xcm::< + (), + >( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + DepositAsset { + assets: Wild(AllCounted(test.args.assets.len() as u32)), + beneficiary: test.args.beneficiary, + }, + ]), + ), + ); + RuntimeCall::PolkadotXcm(pallet_xcm::Call::transfer_assets_using_type_and_then { + dest: Box::new(test.args.dest.into()), + assets: Box::new(test.args.assets.clone().into()), + assets_transfer_type: Box::new( + TransferType::RemoteReserve(asset_hub_location.clone().into()), + ), + remote_fees_id: Box::new( + VersionedAssetId::V5(AssetId(Location::new(1, []))), + ), + fees_transfer_type: Box::new( + TransferType::RemoteReserve(asset_hub_location.into()), + ), + custom_xcm_on_dest: Box::new(VersionedXcm::from(custom_xcm_on_dest)), + weight_limit: test.args.weight_limit, + }) + } + extern crate test; + #[cfg(test)] + #[rustc_test_marker = "tests::xcm_fee_estimation::multi_hop_works"] + pub const multi_hop_works: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("tests::xcm_fee_estimation::multi_hop_works"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs", + start_line: 115usize, + start_col: 4usize, + end_line: 115usize, + end_col: 19usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::UnitTest, + }, + testfn: test::StaticTestFn( + #[coverage(off)] + || test::assert_test_result(multi_hop_works()), + ), + }; + /// We are able to dry-run and estimate the fees for a multi-hop XCM journey. + /// Scenario: Alice on PenpalA has some WND and wants to send them to PenpalB. + /// We want to know the fees using the `DryRunApi` and `XcmPaymentApi`. + fn multi_hop_works() { + let destination = PenpalA::sibling_location_of(PenpalB::para_id()); + let sender = PenpalASender::get(); + let amount_to_send = 1_000_000_000_000; + let asset_owner = PenpalAssetOwner::get(); + let assets: Assets = (Parent, amount_to_send).into(); + let relay_native_asset_location = Location::parent(); + let sender_as_seen_by_ah = AssetHubWestend::sibling_location_of( + PenpalA::para_id(), + ); + let sov_of_sender_on_ah = AssetHubWestend::sovereign_account_id_of( + sender_as_seen_by_ah.clone(), + ); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner.clone()), + relay_native_asset_location.clone(), + sender.clone(), + amount_to_send * 2, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (sov_of_sender_on_ah.clone(), amount_to_send * 2), + ]), + ), + ); + let beneficiary_id = PenpalBReceiver::get(); + let test_args = TestContext { + sender: PenpalASender::get(), + receiver: PenpalBReceiver::get(), + args: TestArgs::new_para( + destination, + beneficiary_id.clone(), + amount_to_send, + assets, + None, + 0, + ), + }; + let mut test = ParaToParaThroughAHTest::new(test_args); + let mut delivery_fees_amount = 0; + let mut remote_message = VersionedXcm::V5(Xcm(Vec::new())); + ::execute_with(|| { + type Runtime = ::Runtime; + type OriginCaller = ::OriginCaller; + let call = transfer_assets_para_to_para_through_ah_call(test.clone()); + let origin = OriginCaller::system(RawOrigin::Signed(sender.clone())); + let result = Runtime::dry_run_call(origin, call).unwrap(); + let (destination_to_query, messages_to_query) = &result + .forwarded_xcms + .iter() + .find(|(destination, _)| { + *destination + == VersionedLocation::V5(Location::new(1, [Parachain(1000)])) + }) + .unwrap(); + match (&messages_to_query.len(), &1) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + remote_message = messages_to_query[0].clone(); + let delivery_fees = Runtime::query_delivery_fees( + destination_to_query.clone(), + remote_message.clone(), + ) + .unwrap(); + delivery_fees_amount = get_amount_from_versioned_assets(delivery_fees); + }); + let mut intermediate_execution_fees = 0; + let mut intermediate_delivery_fees_amount = 0; + let mut intermediate_remote_message = VersionedXcm::V5( + Xcm::<()>(Vec::new()), + ); + ::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + let weight = Runtime::query_xcm_weight(remote_message.clone()).unwrap(); + intermediate_execution_fees = Runtime::query_weight_to_asset_fee( + weight, + VersionedAssetId::V5(Location::new(1, []).into()), + ) + .unwrap(); + let xcm_program = VersionedXcm::V5( + Xcm::::from(remote_message.clone().try_into().unwrap()), + ); + let result = Runtime::dry_run_xcm( + sender_as_seen_by_ah.clone().into(), + xcm_program, + ) + .unwrap(); + let (destination_to_query, messages_to_query) = &result + .forwarded_xcms + .iter() + .find(|(destination, _)| { + *destination + == VersionedLocation::V5(Location::new(1, [Parachain(2001)])) + }) + .unwrap(); + intermediate_remote_message = messages_to_query[0].clone(); + let delivery_fees = Runtime::query_delivery_fees( + destination_to_query.clone(), + intermediate_remote_message.clone(), + ) + .unwrap(); + intermediate_delivery_fees_amount = get_amount_from_versioned_assets( + delivery_fees, + ); + }); + let mut final_execution_fees = 0; + ::execute_with(|| { + type Runtime = ::Runtime; + let weight = Runtime::query_xcm_weight( + intermediate_remote_message.clone(), + ) + .unwrap(); + final_execution_fees = Runtime::query_weight_to_asset_fee( + weight, + VersionedAssetId::V5(Parent.into()), + ) + .unwrap(); + }); + PenpalA::reset_ext(); + AssetHubWestend::reset_ext(); + PenpalB::reset_ext(); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner), + relay_native_asset_location.clone(), + sender.clone(), + amount_to_send * 2, + ); + AssetHubWestend::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([(sov_of_sender_on_ah, amount_to_send * 2)]), + ), + ); + let sender_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &sender) + }); + let receiver_assets_before = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &beneficiary_id) + }); + test.set_assertion::(sender_assertions); + test.set_assertion::(hop_assertions); + test.set_assertion::(receiver_assertions); + test.set_dispatchable::< + PenpalA, + >(transfer_assets_para_to_para_through_ah_dispatchable); + test.assert(); + let sender_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location.clone(), &sender) + }); + let receiver_assets_after = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(relay_native_asset_location, &beneficiary_id) + }); + match ( + &sender_assets_after, + &(sender_assets_before - amount_to_send - delivery_fees_amount), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + match ( + &receiver_assets_after, + &(receiver_assets_before + amount_to_send - intermediate_execution_fees + - intermediate_delivery_fees_amount - final_execution_fees), + ) { + (left_val, right_val) => { + if !(*left_val == *right_val) { + let kind = ::core::panicking::AssertKind::Eq; + ::core::panicking::assert_failed( + kind, + &*left_val, + &*right_val, + ::core::option::Option::None, + ); + } + } + }; + } + } +} +#[rustc_main] +#[coverage(off)] +pub fn main() -> () { + extern crate test; + test::test_main_static( + &[ + &assets_can_be_claimed, + &create_and_claim_treasury_spend, + &bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types, + &transfer_foreign_assets_from_asset_hub_to_para, + &transfer_foreign_assets_from_para_to_asset_hub, + &transfer_foreign_assets_from_para_to_para_through_asset_hub, + &transfer_native_asset_from_relay_to_para_through_asset_hub, + &reserve_transfer_multiple_assets_from_asset_hub_to_para, + &reserve_transfer_multiple_assets_from_para_to_asset_hub, + &reserve_transfer_native_asset_from_asset_hub_to_para, + &reserve_transfer_native_asset_from_asset_hub_to_relay_fails, + &reserve_transfer_native_asset_from_para_to_asset_hub, + &reserve_transfer_native_asset_from_para_to_para_through_relay, + &reserve_transfer_native_asset_from_para_to_relay, + &reserve_transfer_native_asset_from_relay_to_asset_hub_fails, + &reserve_transfer_native_asset_from_relay_to_para, + &send_transact_as_superuser_from_relay_to_asset_hub_works, + &send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset, + &send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset, + &relay_sets_system_para_xcm_supported_version, + &system_para_sets_relay_xcm_supported_version, + &cannot_create_pool_from_pool_assets, + &pay_xcm_fee_with_some_asset_swapped_for_native, + &swap_locally_on_chain_using_foreign_assets, + &swap_locally_on_chain_using_local_assets, + &bidirectional_teleport_foreign_assets_between_para_and_asset_hub, + &limited_teleport_native_assets_from_system_para_to_relay_fails, + &teleport_from_and_to_relay, + &teleport_to_other_system_parachains_works, + &create_and_claim_treasury_spend, + &multi_hop_works, + ], + ) +} diff --git a/polkadot/runtime/westend/src/weights/xcm/mod.rs b/polkadot/runtime/westend/src/weights/xcm/mod.rs index 8035439e8892..aebf287ca578 100644 --- a/polkadot/runtime/westend/src/weights/xcm/mod.rs +++ b/polkadot/runtime/westend/src/weights/xcm/mod.rs @@ -187,6 +187,11 @@ impl XcmWeightInfo for WestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } + + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } + fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } @@ -272,6 +277,10 @@ impl XcmWeightInfo for WestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } #[test] From aff5fd4421a7afa2c38d21c6002f1a60e689083d Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 28 Aug 2024 20:39:00 +0300 Subject: [PATCH 102/151] Implemented pay_fees for the testnets --- .../runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs | 2 +- polkadot/runtime/westend/src/weights/xcm/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index e6c376ebc90a..be4aa3e989bf 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -238,6 +238,6 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { } fn pay_fees(asset: &Asset) -> Weight { - todo!() + XcmGeneric::::pay_fees() } } diff --git a/polkadot/runtime/westend/src/weights/xcm/mod.rs b/polkadot/runtime/westend/src/weights/xcm/mod.rs index aebf287ca578..b664c1714b18 100644 --- a/polkadot/runtime/westend/src/weights/xcm/mod.rs +++ b/polkadot/runtime/westend/src/weights/xcm/mod.rs @@ -279,7 +279,7 @@ impl XcmWeightInfo for WestendXcmWeight { } fn pay_fees(asset: &Asset) -> Weight { - todo!() + XcmGeneric::::pay_fees() } } From 13b561932ce31f5e465bcadcf4fd99de45837783 Mon Sep 17 00:00:00 2001 From: ndk Date: Fri, 30 Aug 2024 13:54:58 +0300 Subject: [PATCH 103/151] WIP e2e tests - claimAssets step --- .../src/tests/set_asset_claimer.rs | 126 +++++++++++++----- .../asset-hub-westend/src/weights/xcm/mod.rs | 4 - .../bridge-hub-rococo/src/weights/xcm/mod.rs | 4 + .../bridge-hub-westend/src/weights/xcm/mod.rs | 4 - .../coretime-westend/src/weights/xcm/mod.rs | 4 - .../people-rococo/src/weights/xcm/mod.rs | 3 + .../people-westend/src/weights/xcm/mod.rs | 4 - .../runtime/rococo/src/weights/xcm/mod.rs | 4 + .../runtime/westend/src/weights/xcm/mod.rs | 4 - 9 files changed, 100 insertions(+), 57 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 7a053388d741..2e3feac13b38 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -15,7 +15,10 @@ //! Tests related to claiming assets trapped during XCM execution. -use crate::imports::*; +use emulated_integration_tests_common::accounts::BOB; +use crate::{ + imports::*, +}; use frame_support::{ dispatch::RawOrigin, @@ -30,77 +33,126 @@ use xcm_runtime_apis::{ #[test] fn azs() { - let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); let destination = PenpalA::sibling_location_of(PenpalB::para_id()); let sender = PenpalASender::get(); - let beneficiary_id = PenpalBReceiver::get(); - let amount_to_send = 1_000_000_000_000; + + let amount_to_send = 16_000_000_000_000; + let asset_owner = PenpalAssetOwner::get(); + let native_asset_location = RelayLocation::get(); let assets: Assets = (Parent, amount_to_send).into(); - // Fund accounts again. + + + let bob_account: AccountId = PenpalA::account_id_of(BOB); + let bob_location: Location = + [Junction::AccountId32 { network: None, id: PenpalA::account_id_of(BOB).into() }] + .into(); + + + + // Fund accounts. + let relay_native_asset_location = Location::parent(); PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(PenpalAssetOwner::get()), - Location::parent().clone(), + ::RuntimeOrigin::signed(asset_owner), + relay_native_asset_location.clone(), sender.clone(), amount_to_send * 2, ); + let sender_assets_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location.clone(), &sender) + }); + + dbg!(sender_assets_before); + + // Init values for Parachain Destination + let beneficiary_id = PenpalBReceiver::get(); + let test_args = TestContext { + sender: PenpalASender::get(), + receiver: PenpalBReceiver::get(), + args: TestArgs::new_para( + destination.clone(), + beneficiary_id.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let mut test = ParaToParaThroughAHTest::new(test_args); + let call = transfer_assets(test.clone(), bob_location.clone()); + PenpalA::execute_with(|| { + assert!(call.dispatch(test.signed_origin).is_ok()); + }); + + let sender_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location.clone(), &sender) + }); + + dbg!(sender_assets_after); + let test_args = TestContext { - sender: PenpalASender::get(), // Bob in PenpalB. - receiver: PenpalBReceiver::get(), // Alice. + sender: PenpalASender::get(), + receiver: PenpalBReceiver::get(), args: TestArgs::new_para( - destination, + destination.clone(), beneficiary_id.clone(), amount_to_send, - assets, + assets.clone(), None, 0, ), }; let mut test = ParaToParaThroughAHTest::new(test_args); - transfer_assets(test.clone(), bob.clone()); - // let call = transfer_assets(test.clone(), bob.clone()); + let call = claim_assets(test.clone(), bob_location.clone()); + call.dispatch(::RuntimeOrigin::signed(bob_account.clone())); + // PenpalA::execute_with(|| { + // assert!(call.dispatch(test.signed_origin).is_ok()); + // }); + let bob_assets_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(native_asset_location.clone(), &bob_account) + }); - // test.set_assertion::(sender_assertions); - // test.set_call(call); - // test.assert(); + dbg!(bob_assets_after); } -fn transfer_assets( +fn claim_assets( test: ParaToParaThroughAHTest, claimer: Location ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; + let local_xcm = Xcm::::builder_unsafe() + .claim_asset(test.args.assets.clone(), Here) + .deposit_asset(AllCounted(test.args.assets.len() as u32), claimer) + .pay_fees((Parent, 10u128)) + .build(); + + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(4_000_000_000_000, 300_000), + }) +} +fn transfer_assets( + test: ParaToParaThroughAHTest, + claimer: Location +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; let local_xcm = Xcm::::builder_unsafe() - .clear_origin() .set_asset_claimer(claimer.clone()) .withdraw_asset(test.args.assets.clone()) - .pay_fees((Parent, 0)) + .clear_origin() + // .pay_fees((Parent, 4_000_000_000_000u128)) .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { message: bx!(VersionedXcm::from(local_xcm)), - max_weight: Weight::from_parts(3_000_000_000, 200_000), + max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) -} - -fn sender_assertions(test: ParaToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - // PenpalA::assert_xcm_pallet_attempted_complete(None); - assert_expected_events!( - PenpalA, - vec![ - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance } - ) => { - asset_id: *asset_id == Location::new(1, []), - owner: *owner == test.sender.account_id, - balance: *balance == test.args.amount, - }, - ] - ); } \ No newline at end of file diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 1a1746feadc2..3a1a498a7f80 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -236,8 +236,4 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs index bc1c9980e140..5e5cdf624656 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs @@ -234,4 +234,8 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index 83209d11aeaa..86e9de516df9 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -240,8 +240,4 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs index f6292ff9f6c2..443f9007898c 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs @@ -237,8 +237,4 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs index 09e3b3732206..7ba4b17ebc70 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs @@ -231,4 +231,7 @@ impl XcmWeightInfo for PeopleRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs index 1dd5dc3cd742..b9e1f9a4a735 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs @@ -236,8 +236,4 @@ impl XcmWeightInfo for PeopleWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/polkadot/runtime/rococo/src/weights/xcm/mod.rs b/polkadot/runtime/rococo/src/weights/xcm/mod.rs index 0c4b7e7c1596..4e8d403f757d 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/mod.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/mod.rs @@ -269,6 +269,10 @@ impl XcmWeightInfo for RococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn set_asset_claimer(location: &Location) -> Weight { + todo!() + } } #[test] diff --git a/polkadot/runtime/westend/src/weights/xcm/mod.rs b/polkadot/runtime/westend/src/weights/xcm/mod.rs index b664c1714b18..f978df67ad2b 100644 --- a/polkadot/runtime/westend/src/weights/xcm/mod.rs +++ b/polkadot/runtime/westend/src/weights/xcm/mod.rs @@ -277,10 +277,6 @@ impl XcmWeightInfo for WestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - XcmGeneric::::pay_fees() - } } #[test] From 129d8cba9ca3e7617ba598b65ffcbd94e195bb0b Mon Sep 17 00:00:00 2001 From: ndk Date: Fri, 30 Aug 2024 14:01:40 +0300 Subject: [PATCH 104/151] Fixed dispatch --- .../asset-hub-westend/src/tests/set_asset_claimer.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 2e3feac13b38..9f64c16be213 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -107,10 +107,11 @@ fn azs() { }; let mut test = ParaToParaThroughAHTest::new(test_args); let call = claim_assets(test.clone(), bob_location.clone()); - call.dispatch(::RuntimeOrigin::signed(bob_account.clone())); - // PenpalA::execute_with(|| { - // assert!(call.dispatch(test.signed_origin).is_ok()); - // }); + // call.dispatch(::RuntimeOrigin::signed(bob_account.clone())); + PenpalA::execute_with(|| { + assert!(call.dispatch(::RuntimeOrigin::signed(bob_account.clone())).is_ok()); + // assert!(call.dispatch(test.signed_origin).is_ok()); + }); let bob_assets_after = PenpalA::execute_with(|| { type ForeignAssets = ::ForeignAssets; From 737943cf1a62fa362680b2547d432eaee2ddcd45 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 2 Sep 2024 13:16:30 +0300 Subject: [PATCH 105/151] finished first SAC e2e single chain test --- .../src/tests/set_asset_claimer.rs | 124 ++++++++---------- 1 file changed, 57 insertions(+), 67 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 9f64c16be213..cf751e4ed49b 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -15,7 +15,8 @@ //! Tests related to claiming assets trapped during XCM execution. -use emulated_integration_tests_common::accounts::BOB; +use emulated_integration_tests_common::accounts::{ALICE, BOB, CHARLIE}; +use emulated_integration_tests_common::impls::AccountId32; use crate::{ imports::*, }; @@ -24,56 +25,28 @@ use frame_support::{ dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, }; -use emulated_integration_tests_common::test_chain_can_claim_assets; -use xcm_executor::traits::DropAssets; -use xcm_runtime_apis::{ - dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, - fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, -}; #[test] -fn azs() { - let destination = PenpalA::sibling_location_of(PenpalB::para_id()); - let sender = PenpalASender::get(); +fn test_set_asset_claimer_within_a_chain() { + let (alice_account, alice_location) = account_and_location(ALICE); + let (bob_account, bob_location) = account_and_location(BOB); let amount_to_send = 16_000_000_000_000; - let asset_owner = PenpalAssetOwner::get(); let native_asset_location = RelayLocation::get(); let assets: Assets = (Parent, amount_to_send).into(); - - - let bob_account: AccountId = PenpalA::account_id_of(BOB); - let bob_location: Location = - [Junction::AccountId32 { network: None, id: PenpalA::account_id_of(BOB).into() }] - .into(); - - - // Fund accounts. - let relay_native_asset_location = Location::parent(); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - relay_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); + fund_account(&alice_account, amount_to_send * 2); - let sender_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location.clone(), &sender) - }); - - dbg!(sender_assets_before); + let alice_assets_before = query_balance(&alice_account, &native_asset_location); + assert_eq!(alice_assets_before, amount_to_send * 2); - // Init values for Parachain Destination - let beneficiary_id = PenpalBReceiver::get(); let test_args = TestContext { - sender: PenpalASender::get(), - receiver: PenpalBReceiver::get(), + sender: alice_account.clone(), + receiver: bob_account.clone(), args: TestArgs::new_para( - destination.clone(), - beneficiary_id.clone(), + bob_location.clone(), + bob_account.clone(), amount_to_send, assets.clone(), None, @@ -81,24 +54,17 @@ fn azs() { ), }; let mut test = ParaToParaThroughAHTest::new(test_args); - let call = transfer_assets(test.clone(), bob_location.clone()); - PenpalA::execute_with(|| { - assert!(call.dispatch(test.signed_origin).is_ok()); - }); + execute_test(test.clone(), bob_location.clone(), transfer_assets); - let sender_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location.clone(), &sender) - }); - - dbg!(sender_assets_after); + let alice_assets_after = query_balance(&alice_account, &native_asset_location); + assert_eq!(alice_assets_after, amount_to_send); let test_args = TestContext { - sender: PenpalASender::get(), - receiver: PenpalBReceiver::get(), + sender: bob_account.clone(), + receiver: alice_account.clone(), args: TestArgs::new_para( - destination.clone(), - beneficiary_id.clone(), + alice_location.clone(), + alice_account.clone(), amount_to_send, assets.clone(), None, @@ -106,19 +72,45 @@ fn azs() { ), }; let mut test = ParaToParaThroughAHTest::new(test_args); - let call = claim_assets(test.clone(), bob_location.clone()); - // call.dispatch(::RuntimeOrigin::signed(bob_account.clone())); - PenpalA::execute_with(|| { - assert!(call.dispatch(::RuntimeOrigin::signed(bob_account.clone())).is_ok()); - // assert!(call.dispatch(test.signed_origin).is_ok()); - }); + execute_test(test.clone(), bob_location.clone(), claim_assets); - let bob_assets_after = PenpalA::execute_with(|| { + let bob_assets_after = query_balance(&bob_account, &native_asset_location); + assert_eq!(bob_assets_after, amount_to_send); +} + +fn account_and_location(account: &str) -> (AccountId32, Location) { + let account_id = PenpalA::account_id_of(account); + let clone = account_id.clone(); + let location: Location = [Junction::AccountId32 { network: Some(Rococo), id: account_id.into() }].into(); + (clone, location) +} + +fn fund_account(account: &AccountId, amount: u128) { + let asset_owner = PenpalAssetOwner::get(); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner), + Location::parent(), + account.clone(), + amount, + ); +} + +fn query_balance(account: &AccountId, asset_location: &Location) -> u128 { + PenpalA::execute_with(|| { type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location.clone(), &bob_account) - }); + >::balance(asset_location.clone(), account) + }) +} - dbg!(bob_assets_after); +fn execute_test( + test: ParaToParaThroughAHTest, + location: Location, + xcm_fn: impl Fn(ParaToParaThroughAHTest, Location) -> ::RuntimeCall, +) { + let call = xcm_fn(test.clone(), location.clone()); + PenpalA::execute_with(|| { + assert!(call.dispatch(test.signed_origin).is_ok()); + }); } fn claim_assets( @@ -126,11 +118,10 @@ fn claim_assets( claimer: Location ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; - + let local_xcm = Xcm::::builder_unsafe() .claim_asset(test.args.assets.clone(), Here) .deposit_asset(AllCounted(test.args.assets.len() as u32), claimer) - .pay_fees((Parent, 10u128)) .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { @@ -144,12 +135,11 @@ fn transfer_assets( claimer: Location ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; - + let local_xcm = Xcm::::builder_unsafe() .set_asset_claimer(claimer.clone()) .withdraw_asset(test.args.assets.clone()) .clear_origin() - // .pay_fees((Parent, 4_000_000_000_000u128)) .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { From 465bd7e0d80f2b3f7c2bd8c7896d011c753f3d20 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 2 Sep 2024 18:56:42 +0300 Subject: [PATCH 106/151] benchmarks initial commit --- .../src/tests/set_asset_claimer.rs | 20 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 374 ++---------------- .../bridge-hub-rococo/src/weights/xcm/mod.rs | 2 +- .../src/generic/benchmarking.rs | 14 + .../src/migrations/v1/weights.rs | 2 +- 5 files changed, 62 insertions(+), 350 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index cf751e4ed49b..966971f80eab 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -113,15 +113,16 @@ fn execute_test( }); } -fn claim_assets( +fn transfer_assets( test: ParaToParaThroughAHTest, claimer: Location ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; - + let local_xcm = Xcm::::builder_unsafe() - .claim_asset(test.args.assets.clone(), Here) - .deposit_asset(AllCounted(test.args.assets.len() as u32), claimer) + .set_asset_claimer(claimer.clone()) + .withdraw_asset(test.args.assets.clone()) + .clear_origin() .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { @@ -130,20 +131,19 @@ fn claim_assets( }) } -fn transfer_assets( +fn claim_assets( test: ParaToParaThroughAHTest, claimer: Location ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; - + let local_xcm = Xcm::::builder_unsafe() - .set_asset_claimer(claimer.clone()) - .withdraw_asset(test.args.assets.clone()) - .clear_origin() + .claim_asset(test.args.assets.clone(), Here) + .deposit_asset(AllCounted(test.args.assets.len() as u32), claimer) .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { message: bx!(VersionedXcm::from(local_xcm)), max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) -} \ No newline at end of file +} diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 6a960e1a073e..66b2a0bc5e7f 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -1,362 +1,60 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.0 +//! DATE: 2024-09-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 +//! HOSTNAME: `PAR03612`, CPU: `` +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: -// target/production/polkadot-parachain +// frame-omni-bencher +// v1 // benchmark // pallet -// --steps=50 -// --repeat=20 -// --extrinsic=* -// --wasm-execution=compiled -// --heap-pages=4096 -// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json -// --pallet=pallet_xcm_benchmarks::generic -// --chain=asset-hub-westend-dev -// --header=./cumulus/file_header.txt -// --template=./cumulus/templates/xcm-bench-template.hbs -// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ +// --runtime +// target/release/wbuild/asset-hub-westend-runtime/asset_hub_westend_runtime.compact.compressed.wasm +// --pallet +// pallet_xcm_benchmarks::generic +// --extrinsic +// pay_fees +// --template +// substrate/.maintain/frame-weight-template.hbs +// --output +// cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] -use frame_support::{traits::Get, weights::Weight}; +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; -/// Weights for `pallet_xcm_benchmarks::generic`. -pub struct WeightInfo(PhantomData); -impl WeightInfo { - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn report_holding() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 97_854_000 picoseconds. - Weight::from_parts(100_164_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - pub fn buy_execution() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 723_000 picoseconds. - Weight::from_parts(769_000, 0) - } - pub fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_933_000 picoseconds. - Weight::from_parts(4_168_000, 0) - } - // Storage: `PolkadotXcm::Queries` (r:1 w:0) - // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn query_response() -> Weight { - // Proof Size summary in bytes: - // Measured: `103` - // Estimated: `3568` - // Minimum execution time: 8_228_000 picoseconds. - Weight::from_parts(8_428_000, 3568) - .saturating_add(T::DbWeight::get().reads(1)) - } - pub fn transact() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 7_123_000 picoseconds. - Weight::from_parts(7_371_000, 0) - } - pub fn refund_surplus() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_718_000 picoseconds. - Weight::from_parts(2_877_000, 0) - } - pub fn set_error_handler() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 737_000 picoseconds. - Weight::from_parts(769_000, 0) - } - pub fn set_appendix() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 705_000 picoseconds. - Weight::from_parts(766_000, 0) - } - pub fn clear_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 688_000 picoseconds. - Weight::from_parts(742_000, 0) - } - pub fn descend_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 736_000 picoseconds. - Weight::from_parts(800_000, 0) - } - pub fn clear_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 698_000 picoseconds. - Weight::from_parts(730_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn report_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 65_608_000 picoseconds. - Weight::from_parts(67_828_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) - // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn claim_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `160` - // Estimated: `3625` - // Minimum execution time: 12_895_000 picoseconds. - Weight::from_parts(13_134_000, 3625) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - pub fn trap() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 705_000 picoseconds. - Weight::from_parts(741_000, 0) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn subscribe_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 27_604_000 picoseconds. - Weight::from_parts(28_364_000, 3610) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:0 w:1) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn unsubscribe_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_584_000 picoseconds. - Weight::from_parts(2_706_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - pub fn burn_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 22_537_000 picoseconds. - Weight::from_parts(22_881_000, 0) - } - pub fn expect_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 6_248_000 picoseconds. - Weight::from_parts(6_464_000, 0) - } - pub fn expect_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 734_000 picoseconds. - Weight::from_parts(780_000, 0) - } - pub fn expect_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 684_000 picoseconds. - Weight::from_parts(741_000, 0) - } - pub fn expect_transact_status() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 863_000 picoseconds. - Weight::from_parts(930_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn query_pallet() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 71_041_000 picoseconds. - Weight::from_parts(72_948_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - pub fn expect_pallet() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 4_267_000 picoseconds. - Weight::from_parts(4_557_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn report_transact_status() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 65_605_000 picoseconds. - Weight::from_parts(67_382_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - pub fn clear_transact_status() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 743_000 picoseconds. - Weight::from_parts(791_000, 0) - } - pub fn set_topic() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 711_000 picoseconds. - Weight::from_parts(751_000, 0) - } - pub fn clear_topic() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 722_000 picoseconds. - Weight::from_parts(753_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - pub fn universal_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `1489` - // Minimum execution time: 2_653_000 picoseconds. - Weight::from_parts(2_720_000, 1489) - .saturating_add(T::DbWeight::get().reads(1)) - } - pub fn set_fees_mode() -> Weight { +/// Weight functions needed for `pallet_xcm_benchmarks::generic`. +pub trait WeightInfo { + fn pay_fees() -> Weight; +} + +/// Weights for `pallet_xcm_benchmarks::generic` using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 668_000 picoseconds. - Weight::from_parts(695_000, 0) + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) } - pub fn unpaid_execution() -> Weight { +} + +// For backwards compatibility and tests. +impl WeightInfo for () { + fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 742_000 picoseconds. - Weight::from_parts(773_000, 0) + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 0) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs index 5e5cdf624656..2337e3ca1e70 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs @@ -236,6 +236,6 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight { } fn set_asset_claimer(location: &Location) -> Weight { - todo!() + XcmGeneric::::set_asset_claimer() } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index cf2312b61c25..9edbabb7677f 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -113,6 +113,20 @@ benchmarks! { executor.bench_process(xcm)?; } verify {} + set_asset_claimer { + let mut executor = new_executor::(Default::default()); + let (sender_account, sender_location) = account_and_location::(1); + + executor.set_asset_claimer(sender_location.clone()); + let instruction = Instruction::SetAssetClaimer{ location: Some(sender_location.clone()) }; + + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } verify { + assert_eq!(executor.asset_claimer(), sender_location.clone()); + } + query_response { let mut executor = new_executor::(Default::default()); let (query_id, response) = T::worst_case_response(); diff --git a/substrate/frame/examples/multi-block-migrations/src/migrations/v1/weights.rs b/substrate/frame/examples/multi-block-migrations/src/migrations/v1/weights.rs index 6a5cf2ac5936..a436d6a8ab40 100644 --- a/substrate/frame/examples/multi-block-migrations/src/migrations/v1/weights.rs +++ b/substrate/frame/examples/multi-block-migrations/src/migrations/v1/weights.rs @@ -33,7 +33,7 @@ // --pallet // pallet_example_mbm // --extrinsic -// +// // --template // substrate/.maintain/frame-weight-template.hbs // --output From 80d7e6e967f84d32814e2a3955e4a232d2088282 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 12:19:17 +0300 Subject: [PATCH 107/151] Reverted cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs --- .../xcm/pallet_xcm_benchmarks_generic.rs | 374 ++++++++++++++++-- 1 file changed, 338 insertions(+), 36 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 66b2a0bc5e7f..6a960e1a073e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -1,60 +1,362 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.0 -//! DATE: 2024-09-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `PAR03612`, CPU: `` -//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: -// frame-omni-bencher -// v1 +// target/production/polkadot-parachain // benchmark // pallet -// --runtime -// target/release/wbuild/asset-hub-westend-runtime/asset_hub_westend_runtime.compact.compressed.wasm -// --pallet -// pallet_xcm_benchmarks::generic -// --extrinsic -// pay_fees -// --template -// substrate/.maintain/frame-weight-template.hbs -// --output -// cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_xcm_benchmarks::generic +// --chain=asset-hub-westend-dev +// --header=./cumulus/file_header.txt +// --template=./cumulus/templates/xcm-bench-template.hbs +// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] -#![allow(missing_docs)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::Weight}; use core::marker::PhantomData; -/// Weight functions needed for `pallet_xcm_benchmarks::generic`. -pub trait WeightInfo { - fn pay_fees() -> Weight; -} - -/// Weights for `pallet_xcm_benchmarks::generic` using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - fn pay_fees() -> Weight { +/// Weights for `pallet_xcm_benchmarks::generic`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn report_holding() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 97_854_000 picoseconds. + Weight::from_parts(100_164_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + pub fn buy_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(5_000_000, 0) + // Minimum execution time: 723_000 picoseconds. + Weight::from_parts(769_000, 0) } -} - -// For backwards compatibility and tests. -impl WeightInfo for () { - fn pay_fees() -> Weight { + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_933_000 picoseconds. + Weight::from_parts(4_168_000, 0) + } + // Storage: `PolkadotXcm::Queries` (r:1 w:0) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn query_response() -> Weight { + // Proof Size summary in bytes: + // Measured: `103` + // Estimated: `3568` + // Minimum execution time: 8_228_000 picoseconds. + Weight::from_parts(8_428_000, 3568) + .saturating_add(T::DbWeight::get().reads(1)) + } + pub fn transact() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_123_000 picoseconds. + Weight::from_parts(7_371_000, 0) + } + pub fn refund_surplus() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_718_000 picoseconds. + Weight::from_parts(2_877_000, 0) + } + pub fn set_error_handler() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 737_000 picoseconds. + Weight::from_parts(769_000, 0) + } + pub fn set_appendix() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 705_000 picoseconds. + Weight::from_parts(766_000, 0) + } + pub fn clear_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 688_000 picoseconds. + Weight::from_parts(742_000, 0) + } + pub fn descend_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 736_000 picoseconds. + Weight::from_parts(800_000, 0) + } + pub fn clear_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 698_000 picoseconds. + Weight::from_parts(730_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn report_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 65_608_000 picoseconds. + Weight::from_parts(67_828_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) + // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn claim_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `160` + // Estimated: `3625` + // Minimum execution time: 12_895_000 picoseconds. + Weight::from_parts(13_134_000, 3625) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + pub fn trap() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 705_000 picoseconds. + Weight::from_parts(741_000, 0) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn subscribe_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3610` + // Minimum execution time: 27_604_000 picoseconds. + Weight::from_parts(28_364_000, 3610) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:0 w:1) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn unsubscribe_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_584_000 picoseconds. + Weight::from_parts(2_706_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + pub fn burn_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 22_537_000 picoseconds. + Weight::from_parts(22_881_000, 0) + } + pub fn expect_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_248_000 picoseconds. + Weight::from_parts(6_464_000, 0) + } + pub fn expect_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 734_000 picoseconds. + Weight::from_parts(780_000, 0) + } + pub fn expect_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 684_000 picoseconds. + Weight::from_parts(741_000, 0) + } + pub fn expect_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 863_000 picoseconds. + Weight::from_parts(930_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn query_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 71_041_000 picoseconds. + Weight::from_parts(72_948_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + pub fn expect_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_267_000 picoseconds. + Weight::from_parts(4_557_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn report_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 65_605_000 picoseconds. + Weight::from_parts(67_382_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + pub fn clear_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 743_000 picoseconds. + Weight::from_parts(791_000, 0) + } + pub fn set_topic() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 711_000 picoseconds. + Weight::from_parts(751_000, 0) + } + pub fn clear_topic() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 722_000 picoseconds. + Weight::from_parts(753_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + pub fn universal_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1489` + // Minimum execution time: 2_653_000 picoseconds. + Weight::from_parts(2_720_000, 1489) + .saturating_add(T::DbWeight::get().reads(1)) + } + pub fn set_fees_mode() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 668_000 picoseconds. + Weight::from_parts(695_000, 0) + } + pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_000_000 picoseconds. - Weight::from_parts(5_000_000, 0) + // Minimum execution time: 742_000 picoseconds. + Weight::from_parts(773_000, 0) } } From 1754578bb05dca3fe284031bff21e54636d5f701 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 14:22:02 +0300 Subject: [PATCH 108/151] add made-up benchmarks to all runtimes --- .../asset-hub-rococo/src/weights/xcm/mod.rs | 4 - .../asset-hub-westend/src/weights/xcm/mod.rs | 3 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 374 ++---------------- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../bridge-hub-westend/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../coretime-rococo/src/weights/xcm/mod.rs | 3 + .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../coretime-westend/src/weights/xcm/mod.rs | 4 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../people-rococo/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../people-westend/src/weights/xcm/mod.rs | 8 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../runtime/rococo/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../runtime/westend/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + .../src/generic/benchmarking.rs | 6 +- 19 files changed, 75 insertions(+), 359 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index be4aa3e989bf..31dcbfaf5b7c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -236,8 +236,4 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - XcmGeneric::::pay_fees() - } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 3a1a498a7f80..758f024cbb9e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -154,8 +154,7 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { XcmGeneric::::clear_error() } fn set_asset_claimer(location: &Location) -> Weight { - // TODO: implement - todo!() + XcmGeneric::::set_asset_claimer() } fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 6a960e1a073e..12ae69f62c7a 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -1,362 +1,60 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.0 +//! DATE: 2024-09-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 +//! HOSTNAME: `PAR03612`, CPU: `` +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: -// target/production/polkadot-parachain +// frame-omni-bencher +// v1 // benchmark // pallet -// --steps=50 -// --repeat=20 -// --extrinsic=* -// --wasm-execution=compiled -// --heap-pages=4096 -// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json -// --pallet=pallet_xcm_benchmarks::generic -// --chain=asset-hub-westend-dev -// --header=./cumulus/file_header.txt -// --template=./cumulus/templates/xcm-bench-template.hbs -// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ +// --runtime +// target/release/wbuild/asset-hub-westend-runtime/asset_hub_westend_runtime.compact.compressed.wasm +// --pallet +// pallet_xcm_benchmarks::generic +// --extrinsic +// set_asset_claimer +// --template +// substrate/.maintain/frame-weight-template.hbs +// --output +// cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] -use frame_support::{traits::Get, weights::Weight}; +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; -/// Weights for `pallet_xcm_benchmarks::generic`. -pub struct WeightInfo(PhantomData); -impl WeightInfo { - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn report_holding() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 97_854_000 picoseconds. - Weight::from_parts(100_164_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - pub fn buy_execution() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 723_000 picoseconds. - Weight::from_parts(769_000, 0) - } - pub fn pay_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 3_933_000 picoseconds. - Weight::from_parts(4_168_000, 0) - } - // Storage: `PolkadotXcm::Queries` (r:1 w:0) - // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn query_response() -> Weight { - // Proof Size summary in bytes: - // Measured: `103` - // Estimated: `3568` - // Minimum execution time: 8_228_000 picoseconds. - Weight::from_parts(8_428_000, 3568) - .saturating_add(T::DbWeight::get().reads(1)) - } - pub fn transact() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 7_123_000 picoseconds. - Weight::from_parts(7_371_000, 0) - } - pub fn refund_surplus() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_718_000 picoseconds. - Weight::from_parts(2_877_000, 0) - } - pub fn set_error_handler() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 737_000 picoseconds. - Weight::from_parts(769_000, 0) - } - pub fn set_appendix() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 705_000 picoseconds. - Weight::from_parts(766_000, 0) - } - pub fn clear_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 688_000 picoseconds. - Weight::from_parts(742_000, 0) - } - pub fn descend_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 736_000 picoseconds. - Weight::from_parts(800_000, 0) - } - pub fn clear_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 698_000 picoseconds. - Weight::from_parts(730_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn report_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 65_608_000 picoseconds. - Weight::from_parts(67_828_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) - // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn claim_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `160` - // Estimated: `3625` - // Minimum execution time: 12_895_000 picoseconds. - Weight::from_parts(13_134_000, 3625) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - pub fn trap() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 705_000 picoseconds. - Weight::from_parts(741_000, 0) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn subscribe_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 27_604_000 picoseconds. - Weight::from_parts(28_364_000, 3610) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:0 w:1) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn unsubscribe_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_584_000 picoseconds. - Weight::from_parts(2_706_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - pub fn burn_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 22_537_000 picoseconds. - Weight::from_parts(22_881_000, 0) - } - pub fn expect_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 6_248_000 picoseconds. - Weight::from_parts(6_464_000, 0) - } - pub fn expect_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 734_000 picoseconds. - Weight::from_parts(780_000, 0) - } - pub fn expect_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 684_000 picoseconds. - Weight::from_parts(741_000, 0) - } - pub fn expect_transact_status() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 863_000 picoseconds. - Weight::from_parts(930_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn query_pallet() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 71_041_000 picoseconds. - Weight::from_parts(72_948_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - pub fn expect_pallet() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 4_267_000 picoseconds. - Weight::from_parts(4_557_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn report_transact_status() -> Weight { - // Proof Size summary in bytes: - // Measured: `246` - // Estimated: `6196` - // Minimum execution time: 65_605_000 picoseconds. - Weight::from_parts(67_382_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - pub fn clear_transact_status() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 743_000 picoseconds. - Weight::from_parts(791_000, 0) - } - pub fn set_topic() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 711_000 picoseconds. - Weight::from_parts(751_000, 0) - } - pub fn clear_topic() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 722_000 picoseconds. - Weight::from_parts(753_000, 0) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - pub fn universal_origin() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `1489` - // Minimum execution time: 2_653_000 picoseconds. - Weight::from_parts(2_720_000, 1489) - .saturating_add(T::DbWeight::get().reads(1)) - } - pub fn set_fees_mode() -> Weight { +/// Weight functions needed for `pallet_xcm_benchmarks::generic`. +pub trait WeightInfo { + fn set_asset_claimer() -> Weight; +} + +/// Weights for `pallet_xcm_benchmarks::generic` using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn set_asset_claimer() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 668_000 picoseconds. - Weight::from_parts(695_000, 0) + // Minimum execution time: 0_000 picoseconds. + Weight::from_parts(1_000_000, 0) } - pub fn unpaid_execution() -> Weight { +} + +// For backwards compatibility and tests. +impl WeightInfo for () { + fn set_asset_claimer() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 742_000 picoseconds. - Weight::from_parts(773_000, 0) + // Minimum execution time: 0_000 picoseconds. + Weight::from_parts(1_000_000, 0) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 3dd636c32a4e..282914840087 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -373,4 +373,7 @@ impl WeightInfo { // Minimum execution time: 1_085_000 picoseconds. Weight::from_parts(1_161_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index 86e9de516df9..35a9bdd908a9 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -157,7 +157,7 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { } fn set_asset_claimer(location: &Location) -> Weight { - todo!() + XcmGeneric::::set_asset_claimer() } fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 893d991958e1..ddbfb3ebfee3 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -373,4 +373,7 @@ impl WeightInfo { // Minimum execution time: 995_000 picoseconds. Weight::from_parts(1_060_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs index 9983aaf4c0ed..31ff0440fd9a 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs @@ -232,4 +232,7 @@ impl XcmWeightInfo for CoretimeRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + fn set_asset_claimer(location: &Location) -> Weight { + XcmGeneric::::set_asset_claimer() + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 3a93c80766de..40321fa0261b 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -331,4 +331,7 @@ impl WeightInfo { // Minimum execution time: 650_000 picoseconds. Weight::from_parts(673_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs index 443f9007898c..ccaffc946b2c 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs @@ -153,11 +153,9 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } - fn set_asset_claimer(location: &Location) -> Weight { - todo!() + XcmGeneric::::set_asset_claimer() } - fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index c8ba2d8b4ce7..98f31390c666 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -331,4 +331,7 @@ impl WeightInfo { // Minimum execution time: 624_000 picoseconds. Weight::from_parts(659_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs index 7ba4b17ebc70..2b4b1e367f16 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs @@ -232,6 +232,6 @@ impl XcmWeightInfo for PeopleRococoXcmWeight { XcmGeneric::::unpaid_execution() } fn set_asset_claimer(location: &Location) -> Weight { - todo!() + XcmGeneric::::set_asset_claimer() } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index e4f103e25370..a03267080c12 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -331,4 +331,7 @@ impl WeightInfo { // Minimum execution time: 685_000 picoseconds. Weight::from_parts(757_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs index b9e1f9a4a735..19cc8e3f1061 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs @@ -152,11 +152,6 @@ impl XcmWeightInfo for PeopleWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } - - fn set_asset_claimer(location: &Location) -> Weight { - todo!() - } - fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } @@ -236,4 +231,7 @@ impl XcmWeightInfo for PeopleWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + fn set_asset_claimer(location: &Location) -> Weight { + XcmGeneric::::set_asset_claimer() + } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 818c2e23a2e9..b4f067dbe9b8 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -331,4 +331,7 @@ impl WeightInfo { // Minimum execution time: 598_000 picoseconds. Weight::from_parts(655_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/polkadot/runtime/rococo/src/weights/xcm/mod.rs b/polkadot/runtime/rococo/src/weights/xcm/mod.rs index 4e8d403f757d..0d2cc309d6d9 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/mod.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/mod.rs @@ -271,7 +271,7 @@ impl XcmWeightInfo for RococoXcmWeight { } fn set_asset_claimer(location: &Location) -> Weight { - todo!() + XcmGeneric::::set_asset_claimer() } } diff --git a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 53d42a0e5c47..84a9a7ce5851 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -322,4 +322,7 @@ impl WeightInfo { // Minimum execution time: 798_000 picoseconds. Weight::from_parts(845_000, 0) } + pub(crate) fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/polkadot/runtime/westend/src/weights/xcm/mod.rs b/polkadot/runtime/westend/src/weights/xcm/mod.rs index f978df67ad2b..4ad9df20b83d 100644 --- a/polkadot/runtime/westend/src/weights/xcm/mod.rs +++ b/polkadot/runtime/westend/src/weights/xcm/mod.rs @@ -189,7 +189,7 @@ impl XcmWeightInfo for WestendXcmWeight { } fn set_asset_claimer(location: &Location) -> Weight { - todo!() + XcmGeneric::::set_asset_claimer() } fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { diff --git a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 4cc979959483..f178d56cc375 100644 --- a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -322,4 +322,7 @@ impl WeightInfo { // Minimum execution time: 735_000 picoseconds. Weight::from_parts(811_000, 0) } + pub(crate) fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 9edbabb7677f..cc41d5a93e32 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -117,14 +117,14 @@ benchmarks! { let mut executor = new_executor::(Default::default()); let (sender_account, sender_location) = account_and_location::(1); - executor.set_asset_claimer(sender_location.clone()); - let instruction = Instruction::SetAssetClaimer{ location: Some(sender_location.clone()) }; + // executor.set_asset_claimer(sender_location.clone()); + let instruction = Instruction::SetAssetClaimer{ location:sender_location.clone() }; let xcm = Xcm(vec![instruction]); }: { executor.bench_process(xcm)?; } verify { - assert_eq!(executor.asset_claimer(), sender_location.clone()); + assert_eq!(executor.asset_claimer(), Some(sender_location.clone())); } query_response { From c0081aec400db6861b6a199d16b52ea3dba27404 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 14:24:02 +0300 Subject: [PATCH 109/151] removed commented instruction --- polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index cc41d5a93e32..ece7a95ab7b7 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -116,8 +116,7 @@ benchmarks! { set_asset_claimer { let mut executor = new_executor::(Default::default()); let (sender_account, sender_location) = account_and_location::(1); - - // executor.set_asset_claimer(sender_location.clone()); + let instruction = Instruction::SetAssetClaimer{ location:sender_location.clone() }; let xcm = Xcm(vec![instruction]); From 0db627d663b5be7bc5378a29a80658b85e6337ee Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 17:38:32 +0300 Subject: [PATCH 110/151] added set_asset_claimer to pallet_xcm WeightInfo trait and implemented it on WestHub --- .../bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs | 1 - polkadot/runtime/westend/src/weights/pallet_xcm.rs | 7 +++++++ .../xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 2 +- polkadot/xcm/pallet-xcm/src/lib.rs | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs index 2337e3ca1e70..2493d93bc2bf 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs @@ -234,7 +234,6 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - fn set_asset_claimer(location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } diff --git a/polkadot/runtime/westend/src/weights/pallet_xcm.rs b/polkadot/runtime/westend/src/weights/pallet_xcm.rs index 10725cecf249..63c60fe51915 100644 --- a/polkadot/runtime/westend/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/westend/src/weights/pallet_xcm.rs @@ -348,4 +348,11 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(35_299_000, 0) + .saturating_add(Weight::from_parts(0, 3488)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index ece7a95ab7b7..5d1d643d828c 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -116,7 +116,7 @@ benchmarks! { set_asset_claimer { let mut executor = new_executor::(Default::default()); let (sender_account, sender_location) = account_and_location::(1); - + let instruction = Instruction::SetAssetClaimer{ location:sender_location.clone() }; let xcm = Xcm(vec![instruction]); diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 6451901279b1..2587f3d0c02f 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -96,6 +96,7 @@ pub trait WeightInfo { fn new_query() -> Weight; fn take_response() -> Weight; fn claim_assets() -> Weight; + fn set_asset_claimer() -> Weight; } /// fallback implementation @@ -180,6 +181,8 @@ impl WeightInfo for TestWeightInfo { fn claim_assets() -> Weight { Weight::from_parts(100_000_000, 0) } + + fn set_asset_claimer() -> Weight { Weight::from_parts(100_000_000, 0) } } #[frame_support::pallet] From 89a8ee2a68610d063a43bc29bc7811c0b28c8c95 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 17:56:53 +0300 Subject: [PATCH 111/151] resolved merge conflicts --- polkadot/xcm/src/v5/mod.rs | 1 - polkadot/xcm/xcm-executor/src/lib.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/polkadot/xcm/src/v5/mod.rs b/polkadot/xcm/src/v5/mod.rs index 63aae405c395..04e4f5d7d966 100644 --- a/polkadot/xcm/src/v5/mod.rs +++ b/polkadot/xcm/src/v5/mod.rs @@ -747,7 +747,6 @@ pub enum Instruction { /// /// Errors: None. SetAssetClaimer { location: Location }, - /// Create some assets which are being held on behalf of the origin. /// /// - `assets`: The assets which are to be claimed. This must match exactly with the assets diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 4313ea8c561a..d5ffb26ddb57 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -29,7 +29,7 @@ use frame_support::{ use sp_core::defer; use sp_io::hashing::blake2_128; use sp_weights::Weight; -use xcm::latest::prelude::*; +use xcm::{latest::prelude::*, v3::MultiLocation}; pub mod traits; use traits::{ From 7a487a05e72e94fd7bcfeaf84bf0418567368392 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 26 Aug 2024 18:33:27 +0300 Subject: [PATCH 112/151] Added unit test for SetAssetClaimer --- .../runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index 31dcbfaf5b7c..e6c376ebc90a 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -236,4 +236,8 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } From fdd45afaf333db1f6fca5d08b4b2bb5461a1e159 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 18:00:47 +0300 Subject: [PATCH 113/151] resolved merge conflicts[3] --- .../src/tests/set_asset_claimer.rs | 84 +++++++++++++++++++ .../asset-hub-westend/src/weights/xcm/mod.rs | 4 + .../bridge-hub-westend/src/weights/xcm/mod.rs | 4 + .../coretime-westend/src/weights/xcm/mod.rs | 4 + .../runtime/westend/src/weights/xcm/mod.rs | 2 +- 5 files changed, 97 insertions(+), 1 deletion(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 966971f80eab..22e02a23414b 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -15,16 +15,21 @@ //! Tests related to claiming assets trapped during XCM execution. +<<<<<<< HEAD use emulated_integration_tests_common::accounts::{ALICE, BOB, CHARLIE}; use emulated_integration_tests_common::impls::AccountId32; use crate::{ imports::*, }; +======= +use crate::imports::*; +>>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) use frame_support::{ dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, }; +<<<<<<< HEAD #[test] fn test_set_asset_claimer_within_a_chain() { @@ -111,6 +116,52 @@ fn execute_test( PenpalA::execute_with(|| { assert!(call.dispatch(test.signed_origin).is_ok()); }); +======= +use emulated_integration_tests_common::test_chain_can_claim_assets; +use xcm_executor::traits::DropAssets; +use xcm_runtime_apis::{ + dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, + fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, +}; + +#[test] +fn azs() { + let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); + let destination = PenpalA::sibling_location_of(PenpalB::para_id()); + let sender = PenpalASender::get(); + let beneficiary_id = PenpalBReceiver::get(); + let amount_to_send = 1_000_000_000_000; + let assets: Assets = (Parent, amount_to_send).into(); + + // Fund accounts again. + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(PenpalAssetOwner::get()), + Location::parent().clone(), + sender.clone(), + amount_to_send * 2, + ); + + let test_args = TestContext { + sender: PenpalASender::get(), // Bob in PenpalB. + receiver: PenpalBReceiver::get(), // Alice. + args: TestArgs::new_para( + destination, + beneficiary_id.clone(), + amount_to_send, + assets, + None, + 0, + ), + }; + let mut test = ParaToParaThroughAHTest::new(test_args); + transfer_assets(test.clone(), bob.clone()); + // let call = transfer_assets(test.clone(), bob.clone()); + + + // test.set_assertion::(sender_assertions); + // test.set_call(call); + // test.assert(); +>>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) } fn transfer_assets( @@ -119,14 +170,25 @@ fn transfer_assets( ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; +<<<<<<< HEAD let local_xcm = Xcm::::builder_unsafe() .set_asset_claimer(claimer.clone()) .withdraw_asset(test.args.assets.clone()) .clear_origin() +======= + + + let local_xcm = Xcm::::builder_unsafe() + .clear_origin() + .set_asset_claimer(claimer.clone()) + .withdraw_asset(test.args.assets.clone()) + .pay_fees((Parent, 0)) +>>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { message: bx!(VersionedXcm::from(local_xcm)), +<<<<<<< HEAD max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) } @@ -147,3 +209,25 @@ fn claim_assets( max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) } +======= + max_weight: Weight::from_parts(3_000_000_000, 200_000), + }) +} + +fn sender_assertions(test: ParaToParaThroughAHTest) { + type RuntimeEvent = ::RuntimeEvent; + // PenpalA::assert_xcm_pallet_attempted_complete(None); + assert_expected_events!( + PenpalA, + vec![ + RuntimeEvent::ForeignAssets( + pallet_assets::Event::Burned { asset_id, owner, balance } + ) => { + asset_id: *asset_id == Location::new(1, []), + owner: *owner == test.sender.account_id, + balance: *balance == test.args.amount, + }, + ] + ); +} +>>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 758f024cbb9e..f440308a5c4c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -235,4 +235,8 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index 35a9bdd908a9..a33f54e96744 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -240,4 +240,8 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs index ccaffc946b2c..a0878d52ea0e 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs @@ -235,4 +235,8 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } + + fn pay_fees(asset: &Asset) -> Weight { + todo!() + } } diff --git a/polkadot/runtime/westend/src/weights/xcm/mod.rs b/polkadot/runtime/westend/src/weights/xcm/mod.rs index 4ad9df20b83d..b0f7c18fee35 100644 --- a/polkadot/runtime/westend/src/weights/xcm/mod.rs +++ b/polkadot/runtime/westend/src/weights/xcm/mod.rs @@ -189,7 +189,7 @@ impl XcmWeightInfo for WestendXcmWeight { } fn set_asset_claimer(location: &Location) -> Weight { - XcmGeneric::::set_asset_claimer() + XcmGeneric::::set_asset_claimer() } fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { From e467e4ad11937d2e9f3ecfb07de1b4418686748e Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 18:40:25 +0300 Subject: [PATCH 114/151] resolved merge conflicts[4] --- .../src/tests/set_asset_claimer.rs | 85 ------------------- 1 file changed, 85 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 22e02a23414b..01ba9ca9d0f7 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -15,22 +15,16 @@ //! Tests related to claiming assets trapped during XCM execution. -<<<<<<< HEAD use emulated_integration_tests_common::accounts::{ALICE, BOB, CHARLIE}; use emulated_integration_tests_common::impls::AccountId32; use crate::{ imports::*, }; -======= -use crate::imports::*; ->>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) use frame_support::{ dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, }; -<<<<<<< HEAD - #[test] fn test_set_asset_claimer_within_a_chain() { let (alice_account, alice_location) = account_and_location(ALICE); @@ -116,52 +110,6 @@ fn execute_test( PenpalA::execute_with(|| { assert!(call.dispatch(test.signed_origin).is_ok()); }); -======= -use emulated_integration_tests_common::test_chain_can_claim_assets; -use xcm_executor::traits::DropAssets; -use xcm_runtime_apis::{ - dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, - fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, -}; - -#[test] -fn azs() { - let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); - let destination = PenpalA::sibling_location_of(PenpalB::para_id()); - let sender = PenpalASender::get(); - let beneficiary_id = PenpalBReceiver::get(); - let amount_to_send = 1_000_000_000_000; - let assets: Assets = (Parent, amount_to_send).into(); - - // Fund accounts again. - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(PenpalAssetOwner::get()), - Location::parent().clone(), - sender.clone(), - amount_to_send * 2, - ); - - let test_args = TestContext { - sender: PenpalASender::get(), // Bob in PenpalB. - receiver: PenpalBReceiver::get(), // Alice. - args: TestArgs::new_para( - destination, - beneficiary_id.clone(), - amount_to_send, - assets, - None, - 0, - ), - }; - let mut test = ParaToParaThroughAHTest::new(test_args); - transfer_assets(test.clone(), bob.clone()); - // let call = transfer_assets(test.clone(), bob.clone()); - - - // test.set_assertion::(sender_assertions); - // test.set_call(call); - // test.assert(); ->>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) } fn transfer_assets( @@ -170,25 +118,14 @@ fn transfer_assets( ) -> ::RuntimeCall { type RuntimeCall = ::RuntimeCall; -<<<<<<< HEAD let local_xcm = Xcm::::builder_unsafe() .set_asset_claimer(claimer.clone()) .withdraw_asset(test.args.assets.clone()) .clear_origin() -======= - - - let local_xcm = Xcm::::builder_unsafe() - .clear_origin() - .set_asset_claimer(claimer.clone()) - .withdraw_asset(test.args.assets.clone()) - .pay_fees((Parent, 0)) ->>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) .build(); RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { message: bx!(VersionedXcm::from(local_xcm)), -<<<<<<< HEAD max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) } @@ -209,25 +146,3 @@ fn claim_assets( max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) } -======= - max_weight: Weight::from_parts(3_000_000_000, 200_000), - }) -} - -fn sender_assertions(test: ParaToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - // PenpalA::assert_xcm_pallet_attempted_complete(None); - assert_expected_events!( - PenpalA, - vec![ - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance } - ) => { - asset_id: *asset_id == Location::new(1, []), - owner: *owner == test.sender.account_id, - balance: *balance == test.args.amount, - }, - ] - ); -} ->>>>>>> 0290e0057fa ([WIP] set_asset_claimer e2e test) From 145de1ed9857cda6f9746009aacc4b8db78cd7e7 Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 19:01:01 +0300 Subject: [PATCH 115/151] reverted cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs --- .../asset-hub-rococo/src/weights/xcm/mod.rs | 4 - .../asset-hub-westend/src/weights/xcm/mod.rs | 4 - .../xcm/pallet_xcm_benchmarks_generic.rs | 374 ++++++++++++++++-- .../bridge-hub-westend/src/weights/xcm/mod.rs | 4 - .../coretime-westend/src/weights/xcm/mod.rs | 4 - polkadot/xcm/pallet-xcm/src/lib.rs | 3 - 6 files changed, 338 insertions(+), 55 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index e6c376ebc90a..31dcbfaf5b7c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -236,8 +236,4 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index f440308a5c4c..758f024cbb9e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -235,8 +235,4 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 12ae69f62c7a..6a960e1a073e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -1,60 +1,362 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.0 -//! DATE: 2024-09-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-08-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `PAR03612`, CPU: `` -//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: -// frame-omni-bencher -// v1 +// target/production/polkadot-parachain // benchmark // pallet -// --runtime -// target/release/wbuild/asset-hub-westend-runtime/asset_hub_westend_runtime.compact.compressed.wasm -// --pallet -// pallet_xcm_benchmarks::generic -// --extrinsic -// set_asset_claimer -// --template -// substrate/.maintain/frame-weight-template.hbs -// --output -// cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_xcm_benchmarks::generic +// --chain=asset-hub-westend-dev +// --header=./cumulus/file_header.txt +// --template=./cumulus/templates/xcm-bench-template.hbs +// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] -#![allow(missing_docs)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::Weight}; use core::marker::PhantomData; -/// Weight functions needed for `pallet_xcm_benchmarks::generic`. -pub trait WeightInfo { - fn set_asset_claimer() -> Weight; -} - -/// Weights for `pallet_xcm_benchmarks::generic` using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - fn set_asset_claimer() -> Weight { +/// Weights for `pallet_xcm_benchmarks::generic`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn report_holding() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 97_854_000 picoseconds. + Weight::from_parts(100_164_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + pub fn buy_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 0_000 picoseconds. - Weight::from_parts(1_000_000, 0) + // Minimum execution time: 723_000 picoseconds. + Weight::from_parts(769_000, 0) } -} - -// For backwards compatibility and tests. -impl WeightInfo for () { - fn set_asset_claimer() -> Weight { + pub fn pay_fees() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_933_000 picoseconds. + Weight::from_parts(4_168_000, 0) + } + // Storage: `PolkadotXcm::Queries` (r:1 w:0) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn query_response() -> Weight { + // Proof Size summary in bytes: + // Measured: `103` + // Estimated: `3568` + // Minimum execution time: 8_228_000 picoseconds. + Weight::from_parts(8_428_000, 3568) + .saturating_add(T::DbWeight::get().reads(1)) + } + pub fn transact() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_123_000 picoseconds. + Weight::from_parts(7_371_000, 0) + } + pub fn refund_surplus() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_718_000 picoseconds. + Weight::from_parts(2_877_000, 0) + } + pub fn set_error_handler() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 737_000 picoseconds. + Weight::from_parts(769_000, 0) + } + pub fn set_appendix() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 705_000 picoseconds. + Weight::from_parts(766_000, 0) + } + pub fn clear_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 688_000 picoseconds. + Weight::from_parts(742_000, 0) + } + pub fn descend_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 736_000 picoseconds. + Weight::from_parts(800_000, 0) + } + pub fn clear_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 698_000 picoseconds. + Weight::from_parts(730_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn report_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 65_608_000 picoseconds. + Weight::from_parts(67_828_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) + // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn claim_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `160` + // Estimated: `3625` + // Minimum execution time: 12_895_000 picoseconds. + Weight::from_parts(13_134_000, 3625) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + pub fn trap() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 705_000 picoseconds. + Weight::from_parts(741_000, 0) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn subscribe_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3610` + // Minimum execution time: 27_604_000 picoseconds. + Weight::from_parts(28_364_000, 3610) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:0 w:1) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn unsubscribe_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_584_000 picoseconds. + Weight::from_parts(2_706_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + pub fn burn_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 22_537_000 picoseconds. + Weight::from_parts(22_881_000, 0) + } + pub fn expect_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_248_000 picoseconds. + Weight::from_parts(6_464_000, 0) + } + pub fn expect_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 734_000 picoseconds. + Weight::from_parts(780_000, 0) + } + pub fn expect_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 684_000 picoseconds. + Weight::from_parts(741_000, 0) + } + pub fn expect_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 863_000 picoseconds. + Weight::from_parts(930_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn query_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 71_041_000 picoseconds. + Weight::from_parts(72_948_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + pub fn expect_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_267_000 picoseconds. + Weight::from_parts(4_557_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn report_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `6196` + // Minimum execution time: 65_605_000 picoseconds. + Weight::from_parts(67_382_000, 6196) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } + pub fn clear_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 743_000 picoseconds. + Weight::from_parts(791_000, 0) + } + pub fn set_topic() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 711_000 picoseconds. + Weight::from_parts(751_000, 0) + } + pub fn clear_topic() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 722_000 picoseconds. + Weight::from_parts(753_000, 0) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + pub fn universal_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1489` + // Minimum execution time: 2_653_000 picoseconds. + Weight::from_parts(2_720_000, 1489) + .saturating_add(T::DbWeight::get().reads(1)) + } + pub fn set_fees_mode() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 668_000 picoseconds. + Weight::from_parts(695_000, 0) + } + pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 0_000 picoseconds. - Weight::from_parts(1_000_000, 0) + // Minimum execution time: 742_000 picoseconds. + Weight::from_parts(773_000, 0) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index a33f54e96744..35a9bdd908a9 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -240,8 +240,4 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs index a0878d52ea0e..ccaffc946b2c 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs @@ -235,8 +235,4 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - - fn pay_fees(asset: &Asset) -> Weight { - todo!() - } } diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 2587f3d0c02f..6451901279b1 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -96,7 +96,6 @@ pub trait WeightInfo { fn new_query() -> Weight; fn take_response() -> Weight; fn claim_assets() -> Weight; - fn set_asset_claimer() -> Weight; } /// fallback implementation @@ -181,8 +180,6 @@ impl WeightInfo for TestWeightInfo { fn claim_assets() -> Weight { Weight::from_parts(100_000_000, 0) } - - fn set_asset_claimer() -> Weight { Weight::from_parts(100_000_000, 0) } } #[frame_support::pallet] From 571510cb9ad13d9a383ee8b1f794db215b4b908f Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 3 Sep 2024 19:03:59 +0300 Subject: [PATCH 116/151] fixed benchmark --- .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 6a960e1a073e..8f03695c0d1e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -359,4 +359,7 @@ impl WeightInfo { // Minimum execution time: 742_000 picoseconds. Weight::from_parts(773_000, 0) } + pub fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } From 97b2e5103b9876b6809a7e0fae49535a58d9f54d Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 4 Sep 2024 13:43:59 +0300 Subject: [PATCH 117/151] removed unused file and import --- expansion.rs | 14961 ------------------------- polkadot/xcm/xcm-executor/src/lib.rs | 2 +- 2 files changed, 1 insertion(+), 14962 deletions(-) delete mode 100644 expansion.rs diff --git a/expansion.rs b/expansion.rs deleted file mode 100644 index 7be4f19597a3..000000000000 --- a/expansion.rs +++ /dev/null @@ -1,14961 +0,0 @@ -#![feature(prelude_import)] -#[prelude_import] -use std::prelude::rust_2021::*; -#[macro_use] -extern crate std; -#[cfg(test)] -mod imports { - pub use codec::Encode; - pub use frame_support::{ - assert_err, assert_ok, pallet_prelude::Weight, - sp_runtime::{DispatchError, DispatchResult, ModuleError}, - traits::fungibles::Inspect, - }; - pub use xcm::prelude::{AccountId32 as AccountId32Junction, *}; - pub use xcm_executor::traits::TransferType; - pub use asset_test_utils::xcm_helpers; - pub use emulated_integration_tests_common::{ - accounts::DUMMY_EMPTY, get_account_id_from_seed, - test_parachain_is_trusted_teleporter, - test_parachain_is_trusted_teleporter_for_relay, test_relay_is_trusted_teleporter, - xcm_emulator::{ - assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, - Test, TestArgs, TestContext, TestExt, - }, - xcm_helpers::{ - get_amount_from_versioned_assets, non_fee_asset, xcm_transact_paid_execution, - }, - ASSETS_PALLET_ID, RESERVABLE_ASSET_ID, XCM_V3, - }; - pub use parachains_common::{AccountId, Balance}; - pub use westend_system_emulated_network::{ - asset_hub_westend_emulated_chain::{ - asset_hub_westend_runtime::{ - xcm_config::{ - self as ahw_xcm_config, WestendLocation as RelayLocation, - XcmConfig as AssetHubWestendXcmConfig, - }, - AssetConversionOrigin as AssetHubWestendAssetConversionOrigin, - ExistentialDeposit as AssetHubWestendExistentialDeposit, - }, - genesis::{AssetHubWestendAssetOwner, ED as ASSET_HUB_WESTEND_ED}, - AssetHubWestendParaPallet as AssetHubWestendPallet, - }, - collectives_westend_emulated_chain::CollectivesWestendParaPallet as CollectivesWestendPallet, - penpal_emulated_chain::{ - penpal_runtime::xcm_config::{ - CustomizableAssetFromSystemAssetHub as PenpalCustomizableAssetFromSystemAssetHub, - LocalReservableFromAssetHub as PenpalLocalReservableFromAssetHub, - LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub, - }, - PenpalAParaPallet as PenpalAPallet, PenpalAssetOwner, - PenpalBParaPallet as PenpalBPallet, - }, - westend_emulated_chain::{ - genesis::ED as WESTEND_ED, - westend_runtime::xcm_config::{ - UniversalLocation as WestendUniversalLocation, - XcmConfig as WestendXcmConfig, - }, - WestendRelayPallet as WestendPallet, - }, - AssetHubWestendPara as AssetHubWestend, - AssetHubWestendParaReceiver as AssetHubWestendReceiver, - AssetHubWestendParaSender as AssetHubWestendSender, - BridgeHubWestendPara as BridgeHubWestend, - BridgeHubWestendParaReceiver as BridgeHubWestendReceiver, - CollectivesWestendPara as CollectivesWestend, PenpalAPara as PenpalA, - PenpalAParaReceiver as PenpalAReceiver, PenpalAParaSender as PenpalASender, - PenpalBPara as PenpalB, PenpalBParaReceiver as PenpalBReceiver, - WestendRelay as Westend, WestendRelayReceiver as WestendReceiver, - WestendRelaySender as WestendSender, - }; - pub const ASSET_ID: u32 = 3; - pub const ASSET_MIN_BALANCE: u128 = 1000; - pub type RelayToParaTest = Test; - pub type ParaToRelayTest = Test; - pub type SystemParaToRelayTest = Test; - pub type SystemParaToParaTest = Test; - pub type ParaToSystemParaTest = Test; - pub type ParaToParaThroughRelayTest = Test; - pub type ParaToParaThroughAHTest = Test; - pub type RelayToParaThroughAHTest = Test; -} -#[cfg(test)] -mod tests { - mod claim_assets { - //! Tests related to claiming assets trapped during XCM execution. - use crate::imports::*; - use frame_support::{ - dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, - }; - use emulated_integration_tests_common::test_chain_can_claim_assets; - use xcm_executor::traits::DropAssets; - use xcm_runtime_apis::{ - dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, - fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, - }; - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::claim_assets::assets_can_be_claimed"] - pub const assets_can_be_claimed: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName("tests::claim_assets::assets_can_be_claimed"), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/claim_assets.rs", - start_line: 32usize, - start_col: 4usize, - end_line: 32usize, - end_col: 25usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(assets_can_be_claimed()), - ), - }; - fn assets_can_be_claimed() { - let amount = AssetHubWestendExistentialDeposit::get(); - let assets: Assets = (Parent, amount).into(); - let sender = AssetHubWestendSender::get(); - let origin = ::RuntimeOrigin::signed( - sender.clone(), - ); - let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { - network: Some(NetworkId::Westend), - id: sender.clone().into(), - } - .into(); - let versioned_assets: ::emulated_integration_tests_common::macros::VersionedAssets = assets - .clone() - .into(); - ::execute_with(|| { - ::PolkadotXcm::drop_assets( - &beneficiary, - assets.clone().into(), - &XcmContext { - origin: None, - message_id: [0u8; 32], - topic: None, - }, - ); - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsTrapped { - origin: beneficiary, - assets: versioned_assets, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsTrapped {\norigin: beneficiary, assets: versioned_assets, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsTrapped {\norigin: beneficiary, assets: versioned_assets, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::claim_assets", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let balance_before = ::Balances::free_balance( - &sender, - ); - let other_origin = ::RuntimeOrigin::signed( - AssetHubWestendReceiver::get(), - ); - if !::PolkadotXcm::claim_assets( - other_origin, - Box::new(versioned_assets.clone().into()), - Box::new(beneficiary.clone().into()), - ) - .is_err() - { - ::core::panicking::panic( - "assertion failed: ::PolkadotXcm::claim_assets(other_origin,\n bx!(versioned_assets.clone().into()),\n bx!(beneficiary.clone().into())).is_err()", - ) - } - let other_versioned_assets: ::emulated_integration_tests_common::macros::VersionedAssets = Assets::new() - .into(); - if !::PolkadotXcm::claim_assets( - origin.clone(), - Box::new(other_versioned_assets.into()), - Box::new(beneficiary.clone().into()), - ) - .is_err() - { - ::core::panicking::panic( - "assertion failed: ::PolkadotXcm::claim_assets(origin.clone(),\n bx!(other_versioned_assets.into()),\n bx!(beneficiary.clone().into())).is_err()", - ) - } - let is = ::PolkadotXcm::claim_assets( - origin.clone(), - Box::new(versioned_assets.clone().into()), - Box::new(beneficiary.clone().into()), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsClaimed { - origin: beneficiary, - assets: versioned_assets, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsClaimed {\norigin: beneficiary, assets: versioned_assets, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::AssetsClaimed {\norigin: beneficiary, assets: versioned_assets, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::claim_assets", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let balance_after = ::Balances::free_balance( - &sender, - ); - match (&balance_after, &(balance_before + amount)) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !::PolkadotXcm::claim_assets( - origin.clone(), - Box::new(versioned_assets.clone().into()), - Box::new(beneficiary.clone().into()), - ) - .is_err() - { - ::core::panicking::panic( - "assertion failed: ::PolkadotXcm::claim_assets(origin.clone(),\n bx!(versioned_assets.clone().into()),\n bx!(beneficiary.clone().into())).is_err()", - ) - } - let balance = ::Balances::free_balance( - &sender, - ); - match (&balance, &balance_after) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - ::PolkadotXcm::drop_assets( - &beneficiary, - assets.clone().into(), - &XcmContext { - origin: None, - message_id: [0u8; 32], - topic: None, - }, - ); - let receiver = AssetHubWestendReceiver::get(); - let other_beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { - network: Some(NetworkId::Westend), - id: receiver.clone().into(), - } - .into(); - let balance_before = ::Balances::free_balance( - &receiver, - ); - let is = ::PolkadotXcm::claim_assets( - origin.clone(), - Box::new(versioned_assets.clone().into()), - Box::new(other_beneficiary.clone().into()), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let balance_after = ::Balances::free_balance( - &receiver, - ); - match (&balance_after, &(balance_before + amount)) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - } - } - mod fellowship_treasury { - use crate::imports::*; - use emulated_integration_tests_common::{ - accounts::{ALICE, BOB}, - USDT_ID, - }; - use frame_support::traits::fungibles::{Inspect, Mutate}; - use polkadot_runtime_common::impls::VersionedLocatableAsset; - use xcm_executor::traits::ConvertLocation; - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::fellowship_treasury::create_and_claim_treasury_spend"] - pub const create_and_claim_treasury_spend: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::fellowship_treasury::create_and_claim_treasury_spend", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/fellowship_treasury.rs", - start_line: 26usize, - start_col: 4usize, - end_line: 26usize, - end_col: 35usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(create_and_claim_treasury_spend()), - ), - }; - fn create_and_claim_treasury_spend() { - const SPEND_AMOUNT: u128 = 1_000_000_000; - let treasury_location: Location = Location::new( - 1, - [Parachain(CollectivesWestend::para_id().into()), PalletInstance(65)], - ); - let treasury_account = ahw_xcm_config::LocationToAccountId::convert_location( - &treasury_location, - ) - .unwrap(); - let asset_hub_location = Location::new( - 1, - [Parachain(AssetHubWestend::para_id().into())], - ); - let root = ::RuntimeOrigin::root(); - let asset_kind = VersionedLocatableAsset::V5 { - location: asset_hub_location, - asset_id: AssetId( - (PalletInstance(50), GeneralIndex(USDT_ID.into())).into(), - ), - }; - let alice: AccountId = Westend::account_id_of(ALICE); - let bob: AccountId = CollectivesWestend::account_id_of(BOB); - let bob_signed = ::RuntimeOrigin::signed( - bob.clone(), - ); - AssetHubWestend::execute_with(|| { - type Assets = ::Assets; - let is = >::mint_into(USDT_ID, &treasury_account, SPEND_AMOUNT * 4); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - match (&>::balance(USDT_ID, &alice), &0u128) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - CollectivesWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type FellowshipTreasury = ::FellowshipTreasury; - type AssetRate = ::AssetRate; - let is = AssetRate::create( - root.clone(), - Box::new(asset_kind.clone()), - 2.into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = FellowshipTreasury::spend( - root, - Box::new(asset_kind), - SPEND_AMOUNT, - Box::new( - Location::new(0, Into::<[u8; 32]>::into(alice.clone())).into(), - ), - None, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = FellowshipTreasury::payout(bob_signed.clone(), 0); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::FellowshipTreasury( - pallet_treasury::Event::Paid { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "CollectivesWestend", - "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::Paid { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "CollectivesWestend", - "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::Paid { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::CollectivesWestend", - "asset_hub_westend_integration_tests::tests::fellowship_treasury", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type Assets = ::Assets; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Transferred { - asset_id: id, - from, - to, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(id == &USDT_ID) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "id", - id, - "id == &USDT_ID", - ), - ); - res - }); - } - meet_conditions &= id == &USDT_ID; - if !(from == &treasury_account) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "from == &treasury_account", - ), - ); - res - }); - } - meet_conditions &= from == &treasury_account; - if !(to == &alice) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "to == &alice", - ), - ); - res - }); - } - meet_conditions &= to == &alice; - if !(amount == &SPEND_AMOUNT) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "amount == &SPEND_AMOUNT", - ), - ); - res - }); - } - meet_conditions &= amount == &SPEND_AMOUNT; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::XcmpQueue( - cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::fellowship_treasury", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - match ( - &>::balance(USDT_ID, &alice), - &SPEND_AMOUNT, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - CollectivesWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type FellowshipTreasury = ::FellowshipTreasury; - let is = FellowshipTreasury::check_status(bob_signed, 0); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::FellowshipTreasury( - pallet_treasury::Event::SpendProcessed { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "CollectivesWestend", - "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::SpendProcessed { ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "CollectivesWestend", - "RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::SpendProcessed { ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::CollectivesWestend", - "asset_hub_westend_integration_tests::tests::fellowship_treasury", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - } - mod hybrid_transfers { - use super::reserve_transfer::*; - use crate::{ - imports::*, - tests::teleport::do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt, - }; - fn para_to_para_assethub_hop_assertions(t: ParaToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_penpal_a_on_ah = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - let sov_penpal_b_on_ah = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalB::para_id()), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_a_on_ah) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_a_on_ah", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_a_on_ah; - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_b_on_ah) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_b_on_ah", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_b_on_ah; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::hybrid_transfers", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn ah_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { - let fee_idx = t.args.fee_asset_item as usize; - let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); - let custom_xcm_on_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - beneficiary: t.args.beneficiary, - }, - ]), - ), - ); - ::PolkadotXcm::transfer_assets_using_type_and_then( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.assets.into()), - Box::new(TransferType::LocalReserve), - Box::new(fee.id.into()), - Box::new(TransferType::LocalReserve), - Box::new(VersionedXcm::from(custom_xcm_on_dest)), - t.args.weight_limit, - ) - } - fn para_to_ah_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult { - let fee_idx = t.args.fee_asset_item as usize; - let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); - let custom_xcm_on_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - beneficiary: t.args.beneficiary, - }, - ]), - ), - ); - ::PolkadotXcm::transfer_assets_using_type_and_then( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.assets.into()), - Box::new(TransferType::DestinationReserve), - Box::new(fee.id.into()), - Box::new(TransferType::DestinationReserve), - Box::new(VersionedXcm::from(custom_xcm_on_dest)), - t.args.weight_limit, - ) - } - fn para_to_para_transfer_assets_through_ah( - t: ParaToParaThroughAHTest, - ) -> DispatchResult { - let fee_idx = t.args.fee_asset_item as usize; - let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); - let asset_hub_location: Location = PenpalA::sibling_location_of( - AssetHubWestend::para_id(), - ); - let custom_xcm_on_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - beneficiary: t.args.beneficiary, - }, - ]), - ), - ); - ::PolkadotXcm::transfer_assets_using_type_and_then( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.assets.into()), - Box::new(TransferType::RemoteReserve(asset_hub_location.clone().into())), - Box::new(fee.id.into()), - Box::new(TransferType::RemoteReserve(asset_hub_location.into())), - Box::new(VersionedXcm::from(custom_xcm_on_dest)), - t.args.weight_limit, - ) - } - fn para_to_asset_hub_teleport_foreign_assets( - t: ParaToSystemParaTest, - ) -> DispatchResult { - let fee_idx = t.args.fee_asset_item as usize; - let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); - let custom_xcm_on_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - beneficiary: t.args.beneficiary, - }, - ]), - ), - ); - ::PolkadotXcm::transfer_assets_using_type_and_then( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.assets.into()), - Box::new(TransferType::Teleport), - Box::new(fee.id.into()), - Box::new(TransferType::DestinationReserve), - Box::new(VersionedXcm::from(custom_xcm_on_dest)), - t.args.weight_limit, - ) - } - fn asset_hub_to_para_teleport_foreign_assets( - t: SystemParaToParaTest, - ) -> DispatchResult { - let fee_idx = t.args.fee_asset_item as usize; - let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); - let custom_xcm_on_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - beneficiary: t.args.beneficiary, - }, - ]), - ), - ); - ::PolkadotXcm::transfer_assets_using_type_and_then( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.assets.into()), - Box::new(TransferType::Teleport), - Box::new(fee.id.into()), - Box::new(TransferType::LocalReserve), - Box::new(VersionedXcm::from(custom_xcm_on_dest)), - t.args.weight_limit, - ) - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::hybrid_transfers::transfer_foreign_assets_from_asset_hub_to_para"] - pub const transfer_foreign_assets_from_asset_hub_to_para: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::hybrid_transfers::transfer_foreign_assets_from_asset_hub_to_para", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", - start_line: 156usize, - start_col: 4usize, - end_line: 156usize, - end_col: 50usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - transfer_foreign_assets_from_asset_hub_to_para(), - ), - ), - }; - /// Transfers of native asset plus bridged asset from AssetHub to some Parachain - /// while paying fees using native asset. - fn transfer_foreign_assets_from_asset_hub_to_para() { - let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); - let sender = AssetHubWestendSender::get(); - let native_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let native_asset_location = RelayLocation::get(); - let receiver = PenpalAReceiver::get(); - let assets_owner = PenpalAssetOwner::get(); - let foreign_amount_to_send = ASSET_HUB_WESTEND_ED * 10_000_000; - let roc_at_westend_parachains = Location::new( - 2, - [Junction::GlobalConsensus(NetworkId::Rococo)], - ); - PenpalA::execute_with(|| { - let is = ::System::set_storage( - ::RuntimeOrigin::root(), - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), - Location::new(2, [GlobalConsensus(Rococo)]).encode(), - ), - ]), - ), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - PenpalA::force_create_foreign_asset( - roc_at_westend_parachains.clone(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - AssetHubWestend::force_create_foreign_asset( - roc_at_westend_parachains.clone().try_into().unwrap(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - AssetHubWestend::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner), - roc_at_westend_parachains.clone().try_into().unwrap(), - sender.clone(), - foreign_amount_to_send * 2, - ); - let assets: Vec = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (Parent, native_amount_to_send).into(), - (roc_at_westend_parachains.clone(), foreign_amount_to_send).into(), - ]), - ); - let fee_asset_id = AssetId(Parent.into()); - let fee_asset_item = assets - .iter() - .position(|a| a.id == fee_asset_id) - .unwrap() as u32; - let test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination.clone(), - receiver.clone(), - native_amount_to_send, - assets.into(), - None, - fee_asset_item, - ), - }; - let mut test = SystemParaToParaTest::new(test_args); - let sender_balance_before = test.sender.balance; - let sender_rocs_before = AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &sender, - ) - }); - let receiver_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location.clone(), &receiver) - }); - let receiver_rocs_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.clone(), &receiver) - }); - test.set_assertion::(system_para_to_para_sender_assertions); - test.set_assertion::(system_para_to_para_receiver_assertions); - test.set_dispatchable::(ah_to_para_transfer_assets); - test.assert(); - let sender_balance_after = test.sender.balance; - let sender_rocs_after = AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &sender, - ) - }); - let receiver_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location, &receiver) - }); - let receiver_rocs_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains, &receiver) - }); - if !(sender_balance_after < sender_balance_before - native_amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_balance_after < sender_balance_before - native_amount_to_send", - ) - } - match (&sender_rocs_after, &(sender_rocs_before - foreign_amount_to_send)) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(receiver_assets_after > receiver_assets_before) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after > receiver_assets_before", - ) - } - if !(receiver_assets_after < receiver_assets_before + native_amount_to_send) - { - ::core::panicking::panic( - "assertion failed: receiver_assets_after < receiver_assets_before + native_amount_to_send", - ) - } - match ( - &receiver_rocs_after, - &(receiver_rocs_before + foreign_amount_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_asset_hub"] - pub const transfer_foreign_assets_from_para_to_asset_hub: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_asset_hub", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", - start_line: 285usize, - start_col: 4usize, - end_line: 285usize, - end_col: 50usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - transfer_foreign_assets_from_para_to_asset_hub(), - ), - ), - }; - /// Reserve Transfers of native asset from Parachain to System Parachain should work - /// Transfers of native asset plus bridged asset from some Parachain to AssetHub - /// while paying fees using native asset. - fn transfer_foreign_assets_from_para_to_asset_hub() { - let destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()); - let sender = PenpalASender::get(); - let native_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 10000; - let native_asset_location = RelayLocation::get(); - let assets_owner = PenpalAssetOwner::get(); - let foreign_amount_to_send = ASSET_HUB_WESTEND_ED * 10_000_000; - let roc_at_westend_parachains = Location::new( - 2, - [Junction::GlobalConsensus(NetworkId::Rococo)], - ); - PenpalA::execute_with(|| { - let is = ::System::set_storage( - ::RuntimeOrigin::root(), - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), - Location::new(2, [GlobalConsensus(Rococo)]).encode(), - ), - ]), - ), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - PenpalA::force_create_foreign_asset( - roc_at_westend_parachains.clone(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - AssetHubWestend::force_create_foreign_asset( - roc_at_westend_parachains.clone().try_into().unwrap(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner.clone()), - native_asset_location.clone(), - sender.clone(), - native_amount_to_send * 2, - ); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner.clone()), - roc_at_westend_parachains.clone(), - sender.clone(), - foreign_amount_to_send * 2, - ); - let receiver = AssetHubWestendReceiver::get(); - let penpal_location_as_seen_by_ahr = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - penpal_location_as_seen_by_ahr, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_penpal_on_ahr.clone().into(), native_amount_to_send * 2), - ]), - ), - ); - AssetHubWestend::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner), - roc_at_westend_parachains.clone().try_into().unwrap(), - sov_penpal_on_ahr, - foreign_amount_to_send * 2, - ); - let assets: Vec = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (Parent, native_amount_to_send).into(), - (roc_at_westend_parachains.clone(), foreign_amount_to_send).into(), - ]), - ); - let fee_asset_id = AssetId(Parent.into()); - let fee_asset_item = assets - .iter() - .position(|a| a.id == fee_asset_id) - .unwrap() as u32; - let test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination.clone(), - receiver.clone(), - native_amount_to_send, - assets.into(), - None, - fee_asset_item, - ), - }; - let mut test = ParaToSystemParaTest::new(test_args); - let sender_native_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location.clone(), &sender) - }); - let sender_rocs_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.clone(), &sender) - }); - let receiver_native_before = test.receiver.balance; - let receiver_rocs_before = AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &receiver, - ) - }); - test.set_assertion::(para_to_system_para_sender_assertions); - test.set_assertion::< - AssetHubWestend, - >(para_to_system_para_receiver_assertions); - test.set_dispatchable::(para_to_ah_transfer_assets); - test.assert(); - let sender_native_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(native_asset_location, &sender) - }); - let sender_rocs_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.clone(), &sender) - }); - let receiver_native_after = test.receiver.balance; - let receiver_rocs_after = AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.try_into().unwrap(), &receiver) - }); - if !(sender_native_after < sender_native_before - native_amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_native_after < sender_native_before - native_amount_to_send", - ) - } - match (&sender_rocs_after, &(sender_rocs_before - foreign_amount_to_send)) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(receiver_native_after > receiver_native_before) { - ::core::panicking::panic( - "assertion failed: receiver_native_after > receiver_native_before", - ) - } - if !(receiver_native_after < receiver_native_before + native_amount_to_send) - { - ::core::panicking::panic( - "assertion failed: receiver_native_after < receiver_native_before + native_amount_to_send", - ) - } - match ( - &receiver_rocs_after, - &(receiver_rocs_before + foreign_amount_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_para_through_asset_hub"] - pub const transfer_foreign_assets_from_para_to_para_through_asset_hub: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::hybrid_transfers::transfer_foreign_assets_from_para_to_para_through_asset_hub", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", - start_line: 440usize, - start_col: 4usize, - end_line: 440usize, - end_col: 63usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - transfer_foreign_assets_from_para_to_para_through_asset_hub(), - ), - ), - }; - /// Transfers of native asset plus bridged asset from Parachain to Parachain - /// (through AssetHub reserve) with fees paid using native asset. - fn transfer_foreign_assets_from_para_to_para_through_asset_hub() { - let destination = PenpalA::sibling_location_of(PenpalB::para_id()); - let sender = PenpalASender::get(); - let wnd_to_send: Balance = WESTEND_ED * 10000; - let assets_owner = PenpalAssetOwner::get(); - let wnd_location = RelayLocation::get(); - let sender_as_seen_by_ah = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_of_sender_on_ah = AssetHubWestend::sovereign_account_id_of( - sender_as_seen_by_ah, - ); - let receiver_as_seen_by_ah = AssetHubWestend::sibling_location_of( - PenpalB::para_id(), - ); - let sov_of_receiver_on_ah = AssetHubWestend::sovereign_account_id_of( - receiver_as_seen_by_ah, - ); - let roc_to_send = ASSET_HUB_WESTEND_ED * 10_000_000; - PenpalB::execute_with(|| { - let is = ::System::set_storage( - ::RuntimeOrigin::root(), - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), - Location::new(2, [GlobalConsensus(Rococo)]).encode(), - ), - ]), - ), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - let roc_at_westend_parachains = Location::new( - 2, - [Junction::GlobalConsensus(NetworkId::Rococo)], - ); - AssetHubWestend::force_create_foreign_asset( - roc_at_westend_parachains.clone().try_into().unwrap(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - PenpalA::force_create_foreign_asset( - roc_at_westend_parachains.clone(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - PenpalB::force_create_foreign_asset( - roc_at_westend_parachains.clone(), - assets_owner.clone(), - false, - ASSET_MIN_BALANCE, - ::alloc::vec::Vec::new(), - ); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner.clone()), - wnd_location.clone(), - sender.clone(), - wnd_to_send * 2, - ); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner.clone()), - roc_at_westend_parachains.clone(), - sender.clone(), - roc_to_send * 2, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_of_sender_on_ah.clone().into(), wnd_to_send * 2), - ]), - ), - ); - AssetHubWestend::mint_foreign_asset( - ::RuntimeOrigin::signed(assets_owner), - roc_at_westend_parachains.clone().try_into().unwrap(), - sov_of_sender_on_ah.clone(), - roc_to_send * 2, - ); - let receiver = PenpalBReceiver::get(); - let assets: Vec = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (wnd_location.clone(), wnd_to_send).into(), - (roc_at_westend_parachains.clone(), roc_to_send).into(), - ]), - ); - let fee_asset_id: AssetId = wnd_location.clone().into(); - let fee_asset_item = assets - .iter() - .position(|a| a.id == fee_asset_id) - .unwrap() as u32; - let test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination, - receiver.clone(), - wnd_to_send, - assets.into(), - None, - fee_asset_item, - ), - }; - let mut test = ParaToParaThroughAHTest::new(test_args); - let sender_wnds_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(wnd_location.clone(), &sender) - }); - let sender_rocs_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.clone(), &sender) - }); - let wnds_in_sender_reserve_on_ah_before = ::account_data_of( - sov_of_sender_on_ah.clone(), - ) - .free; - let rocs_in_sender_reserve_on_ah_before = AssetHubWestend::execute_with(|| { - type Assets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &sov_of_sender_on_ah, - ) - }); - let wnds_in_receiver_reserve_on_ah_before = ::account_data_of( - sov_of_receiver_on_ah.clone(), - ) - .free; - let rocs_in_receiver_reserve_on_ah_before = AssetHubWestend::execute_with(|| { - type Assets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &sov_of_receiver_on_ah, - ) - }); - let receiver_wnds_before = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(wnd_location.clone(), &receiver) - }); - let receiver_rocs_before = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.clone(), &receiver) - }); - test.set_assertion::(para_to_para_through_hop_sender_assertions); - test.set_assertion::(para_to_para_assethub_hop_assertions); - test.set_assertion::(para_to_para_through_hop_receiver_assertions); - test.set_dispatchable::(para_to_para_transfer_assets_through_ah); - test.assert(); - let sender_wnds_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(wnd_location.clone(), &sender) - }); - let sender_rocs_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains.clone(), &sender) - }); - let rocs_in_sender_reserve_on_ah_after = AssetHubWestend::execute_with(|| { - type Assets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &sov_of_sender_on_ah, - ) - }); - let wnds_in_sender_reserve_on_ah_after = ::account_data_of( - sov_of_sender_on_ah, - ) - .free; - let rocs_in_receiver_reserve_on_ah_after = AssetHubWestend::execute_with(|| { - type Assets = ::ForeignAssets; - >::balance( - roc_at_westend_parachains.clone().try_into().unwrap(), - &sov_of_receiver_on_ah, - ) - }); - let wnds_in_receiver_reserve_on_ah_after = ::account_data_of( - sov_of_receiver_on_ah, - ) - .free; - let receiver_wnds_after = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(wnd_location, &receiver) - }); - let receiver_rocs_after = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(roc_at_westend_parachains, &receiver) - }); - if !(sender_wnds_after < sender_wnds_before - wnd_to_send) { - ::core::panicking::panic( - "assertion failed: sender_wnds_after < sender_wnds_before - wnd_to_send", - ) - } - match (&sender_rocs_after, &(sender_rocs_before - roc_to_send)) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &wnds_in_sender_reserve_on_ah_after, - &(wnds_in_sender_reserve_on_ah_before - wnd_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &rocs_in_sender_reserve_on_ah_after, - &(rocs_in_sender_reserve_on_ah_before - roc_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(wnds_in_receiver_reserve_on_ah_after - > wnds_in_receiver_reserve_on_ah_before) - { - ::core::panicking::panic( - "assertion failed: wnds_in_receiver_reserve_on_ah_after > wnds_in_receiver_reserve_on_ah_before", - ) - } - match ( - &rocs_in_receiver_reserve_on_ah_after, - &(rocs_in_receiver_reserve_on_ah_before + roc_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(receiver_wnds_after > receiver_wnds_before) { - ::core::panicking::panic( - "assertion failed: receiver_wnds_after > receiver_wnds_before", - ) - } - match (&receiver_rocs_after, &(receiver_rocs_before + roc_to_send)) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::hybrid_transfers::bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types"] - pub const bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::hybrid_transfers::bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", - start_line: 644usize, - start_col: 4usize, - end_line: 644usize, - end_col: 97usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types(), - ), - ), - }; - /// Transfers of native asset plus teleportable foreign asset from Parachain to AssetHub and back - /// with fees paid using native asset. - fn bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types() { - do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt( - para_to_asset_hub_teleport_foreign_assets, - asset_hub_to_para_teleport_foreign_assets, - ); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::hybrid_transfers::transfer_native_asset_from_relay_to_para_through_asset_hub"] - pub const transfer_native_asset_from_relay_to_para_through_asset_hub: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::hybrid_transfers::transfer_native_asset_from_relay_to_para_through_asset_hub", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs", - start_line: 658usize, - start_col: 4usize, - end_line: 658usize, - end_col: 62usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - transfer_native_asset_from_relay_to_para_through_asset_hub(), - ), - ), - }; - /// Transfers of native asset Relay to Parachain (using AssetHub reserve). Parachains want to avoid - /// managing SAs on all system chains, thus want all their DOT-in-reserve to be held in their - /// Sovereign Account on Asset Hub. - fn transfer_native_asset_from_relay_to_para_through_asset_hub() { - let destination = Westend::child_location_of(PenpalA::para_id()); - let sender = WestendSender::get(); - let amount_to_send: Balance = WESTEND_ED * 1000; - let relay_native_asset_location = RelayLocation::get(); - let receiver = PenpalAReceiver::get(); - let test_args = TestContext { - sender, - receiver: receiver.clone(), - args: TestArgs::new_relay( - destination.clone(), - receiver.clone(), - amount_to_send, - ), - }; - let mut test = RelayToParaThroughAHTest::new(test_args); - let sov_penpal_on_ah = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - let sender_balance_before = test.sender.balance; - let sov_penpal_on_ah_before = AssetHubWestend::execute_with(|| { - ::Balances::free_balance( - sov_penpal_on_ah.clone(), - ) - }); - let receiver_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &receiver) - }); - fn relay_assertions(t: RelayToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - Westend::assert_xcm_pallet_attempted_complete(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == t.sender.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *who == t.sender.account_id; - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who - == ::XcmPallet::check_account()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == ::XcmPallet::check_account()", - ), - ); - res - }); - } - meet_conditions - &= *who - == ::XcmPallet::check_account(); - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::hybrid_transfers", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn asset_hub_assertions(_: RelayToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_penpal_on_ah = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_on_ah) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_on_ah", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_on_ah; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::hybrid_transfers", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn penpal_assertions(t: RelayToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - let expected_id = t - .args - .assets - .into_inner() - .first() - .unwrap() - .id - .0 - .clone() - .try_into() - .unwrap(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == t.receiver.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::hybrid_transfers", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn transfer_assets_dispatchable( - t: RelayToParaThroughAHTest, - ) -> DispatchResult { - let fee_idx = t.args.fee_asset_item as usize; - let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap(); - let asset_hub_location = Westend::child_location_of( - AssetHubWestend::para_id(), - ); - let context = WestendUniversalLocation::get(); - let mut remote_fees = fee - .clone() - .reanchored(&t.args.dest, &context) - .unwrap(); - if let Fungible(ref mut amount) = remote_fees.fun { - *amount = *amount / 2; - } - let xcm_on_final_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - BuyExecution { - fees: remote_fees, - weight_limit: t.args.weight_limit.clone(), - }, - DepositAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - beneficiary: t.args.beneficiary, - }, - ]), - ), - ); - let mut dest = t.args.dest.clone(); - dest.reanchor(&asset_hub_location, &context).unwrap(); - let xcm_on_hop = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositReserveAsset { - assets: Wild(AllCounted(t.args.assets.len() as u32)), - dest, - xcm: xcm_on_final_dest, - }, - ]), - ), - ); - ::XcmPallet::transfer_assets_using_type_and_then( - t.signed_origin, - Box::new(asset_hub_location.into()), - Box::new(t.args.assets.into()), - Box::new(TransferType::Teleport), - Box::new(fee.id.into()), - Box::new(TransferType::Teleport), - Box::new(VersionedXcm::from(xcm_on_hop)), - t.args.weight_limit, - ) - } - test.set_assertion::(relay_assertions); - test.set_assertion::(asset_hub_assertions); - test.set_assertion::(penpal_assertions); - test.set_dispatchable::(transfer_assets_dispatchable); - test.assert(); - let sender_balance_after = test.sender.balance; - let sov_penpal_on_ah_after = AssetHubWestend::execute_with(|| { - ::Balances::free_balance( - sov_penpal_on_ah, - ) - }); - let receiver_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location, &receiver) - }); - if !(sender_balance_after < sender_balance_before - amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_balance_after < sender_balance_before - amount_to_send", - ) - } - if !(sov_penpal_on_ah_after > sov_penpal_on_ah_before) { - ::core::panicking::panic( - "assertion failed: sov_penpal_on_ah_after > sov_penpal_on_ah_before", - ) - } - if !(receiver_assets_after > receiver_assets_before) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after > receiver_assets_before", - ) - } - if !(receiver_assets_after < receiver_assets_before + amount_to_send) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after < receiver_assets_before + amount_to_send", - ) - } - } - } - mod reserve_transfer { - use crate::imports::*; - fn relay_to_para_sender_assertions(t: RelayToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - Westend::assert_xcm_pallet_attempted_complete( - Some(Weight::from_parts(864_610_000, 8_799)), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from, to, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*from == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "*from == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *from == t.sender.account_id; - if !(*to - == Westend::sovereign_account_id_of(t.args.dest.clone())) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "*to == Westend::sovereign_account_id_of(t.args.dest.clone())", - ), - ); - res - }); - } - meet_conditions - &= *to - == Westend::sovereign_account_id_of(t.args.dest.clone()); - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn para_to_relay_sender_assertions(t: ParaToRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - PenpalA::assert_xcm_pallet_attempted_complete( - Some(Weight::from_parts(864_610_000, 8_799)), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == RelayLocation::get()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == RelayLocation::get()", - ), - ); - res - }); - } - meet_conditions &= *asset_id == RelayLocation::get(); - if !(*owner == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if !(*balance == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *balance == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - pub fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcm_pallet_attempted_complete(None); - let sov_acc_of_dest = AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - ); - for (idx, asset) in t.args.assets.into_inner().into_iter().enumerate() { - let expected_id = asset.id.0.clone().try_into().unwrap(); - let asset_amount = if let Fungible(a) = asset.fun { - Some(a) - } else { - None - } - .unwrap(); - if idx == t.args.fee_asset_item as usize { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from, to, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*from == t.sender.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "*from == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *from == t.sender.account_id; - if !(*to == sov_acc_of_dest) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "*to == sov_acc_of_dest", - ), - ); - res - }); - } - meet_conditions &= *to == sov_acc_of_dest; - if !(*amount == asset_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } else { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Transferred { - asset_id, - from, - to, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*from == t.sender.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "*from == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *from == t.sender.account_id; - if !(*to == sov_acc_of_dest) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "*to == sov_acc_of_dest", - ), - ); - res - }); - } - meet_conditions &= *to == sov_acc_of_dest; - if !(*amount == asset_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - } - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. }) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - AssetHubWestend::assert_xcm_pallet_sent(); - } - pub fn system_para_to_para_receiver_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - PenpalA::assert_xcmp_queue_success(None); - for asset in t.args.assets.into_inner().into_iter() { - let expected_id = asset.id.0.try_into().unwrap(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == t.receiver.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - } - pub fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - PenpalA::assert_xcm_pallet_attempted_complete(None); - for asset in t.args.assets.into_inner().into_iter() { - let expected_id = asset.id.0; - let asset_amount = if let Fungible(a) = asset.fun { - Some(a) - } else { - None - } - .unwrap(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == t.sender.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if !(*balance == asset_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == asset_amount", - ), - ); - res - }); - } - meet_conditions &= *balance == asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - } - fn para_to_relay_receiver_assertions(t: ParaToRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_penpal_on_relay = Westend::sovereign_account_id_of( - Westend::child_location_of(PenpalA::para_id()), - ); - Westend::assert_ump_queue_processed( - true, - Some(PenpalA::para_id()), - Some(Weight::from_parts(306305000, 7_186)), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_on_relay.clone().into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_on_relay.clone().into()", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_on_relay.clone().into(); - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances(pallet_balances::Event::Minted { .. }) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - pub fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcmp_queue_success(None); - let sov_acc_of_penpal = AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - ); - for (idx, asset) in t.args.assets.into_inner().into_iter().enumerate() { - let expected_id = asset.id.0.clone().try_into().unwrap(); - let asset_amount = if let Fungible(a) = asset.fun { - Some(a) - } else { - None - } - .unwrap(); - if idx == t.args.fee_asset_item as usize { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_acc_of_penpal.clone().into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_acc_of_penpal.clone().into()", - ), - ); - res - }); - } - meet_conditions &= *who == sov_acc_of_penpal.clone().into(); - if !(*amount == asset_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == t.receiver.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *who == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } else { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == sov_acc_of_penpal) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == sov_acc_of_penpal", - ), - ); - res - }); - } - meet_conditions &= *owner == sov_acc_of_penpal; - if !(*balance == asset_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == asset_amount", - ), - ); - res - }); - } - meet_conditions &= *balance == asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == t.receiver.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if !(*amount == asset_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - } - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcm_pallet_attempted_complete( - Some(Weight::from_parts(864_610_000, 8799)), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Transferred { asset_id, from, to, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == RESERVABLE_ASSET_ID) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == RESERVABLE_ASSET_ID", - ), - ); - res - }); - } - meet_conditions &= *asset_id == RESERVABLE_ASSET_ID; - if !(*from == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "*from == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *from == t.sender.account_id; - if !(*to - == AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - )) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "*to == AssetHubWestend::sovereign_account_id_of(t.args.dest.clone())", - ), - ); - res - }); - } - meet_conditions - &= *to - == AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - ); - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id, from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who - == AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - )) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == AssetHubWestend::sovereign_account_id_of(t.args.dest.clone())", - ), - ); - res - }); - } - meet_conditions - &= *who - == AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - ); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. }) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn para_to_system_para_assets_sender_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let system_para_native_asset_location = RelayLocation::get(); - let reservable_asset_location = PenpalLocalReservableFromAssetHub::get(); - PenpalA::assert_xcm_pallet_attempted_complete( - Some(Weight::from_parts(864_610_000, 8799)), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == system_para_native_asset_location) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == system_para_native_asset_location", - ), - ); - res - }); - } - meet_conditions - &= *asset_id == system_para_native_asset_location; - if !(*owner == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == reservable_asset_location) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == reservable_asset_location", - ), - ); - res - }); - } - meet_conditions &= *asset_id == reservable_asset_location; - if !(*owner == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if !(*balance == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *balance == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. }) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::FeesPaid { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn system_para_to_para_assets_receiver_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let system_para_asset_location = PenpalLocalReservableFromAssetHub::get(); - PenpalA::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == RelayLocation::get()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == RelayLocation::get()", - ), - ); - res - }); - } - meet_conditions &= *asset_id == RelayLocation::get(); - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == system_para_asset_location) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == system_para_asset_location", - ), - ); - res - }); - } - meet_conditions &= *asset_id == system_para_asset_location; - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn para_to_system_para_assets_receiver_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - AssetHubWestend::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == RESERVABLE_ASSET_ID) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == RESERVABLE_ASSET_ID", - ), - ); - res - }); - } - meet_conditions &= *asset_id == RESERVABLE_ASSET_ID; - if !(*owner == sov_penpal_on_ahr) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == sov_penpal_on_ahr", - ), - ); - res - }); - } - meet_conditions &= *owner == sov_penpal_on_ahr; - if !(*balance == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *balance == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_on_ahr) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_on_ahr", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_on_ahr; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Issued { asset_id, owner, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == RESERVABLE_ASSET_ID) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == RESERVABLE_ASSET_ID", - ), - ); - res - }); - } - meet_conditions &= *asset_id == RESERVABLE_ASSET_ID; - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == t.receiver.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *who == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn relay_to_para_assets_receiver_assertions(t: RelayToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == RelayLocation::get()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == RelayLocation::get()", - ), - ); - res - }); - } - meet_conditions &= *asset_id == RelayLocation::get(); - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - pub fn para_to_para_through_hop_sender_assertions( - t: Test, - ) { - type RuntimeEvent = ::RuntimeEvent; - PenpalA::assert_xcm_pallet_attempted_complete(None); - for asset in t.args.assets.into_inner() { - let expected_id = asset.id.0.clone().try_into().unwrap(); - let amount = if let Fungible(a) = asset.fun { Some(a) } else { None } - .unwrap(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == t.sender.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if !(*balance == amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == amount", - ), - ); - res - }); - } - meet_conditions &= *balance == amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - } - fn para_to_para_relay_hop_assertions(t: ParaToParaThroughRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_penpal_a_on_westend = Westend::sovereign_account_id_of( - Westend::child_location_of(PenpalA::para_id()), - ); - let sov_penpal_b_on_westend = Westend::sovereign_account_id_of( - Westend::child_location_of(PenpalB::para_id()), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_a_on_westend) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_a_on_westend", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_a_on_westend; - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_b_on_westend) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_b_on_westend", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_b_on_westend; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - pub fn para_to_para_through_hop_receiver_assertions( - t: Test, - ) { - type RuntimeEvent = ::RuntimeEvent; - PenpalB::assert_xcmp_queue_success(None); - for asset in t.args.assets.into_inner().into_iter() { - let expected_id = asset.id.0.try_into().unwrap(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_id; - if !(*owner == t.receiver.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalB", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalB", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalB", - "asset_hub_westend_integration_tests::tests::reserve_transfer", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - } - fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult { - ::XcmPallet::limited_reserve_transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - fn para_to_relay_reserve_transfer_assets(t: ParaToRelayTest) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - fn system_para_to_para_reserve_transfer_assets( - t: SystemParaToParaTest, - ) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - fn para_to_system_para_reserve_transfer_assets( - t: ParaToSystemParaTest, - ) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - fn para_to_para_through_relay_limited_reserve_transfer_assets( - t: ParaToParaThroughRelayTest, - ) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_asset_hub_fails"] - pub const reserve_transfer_native_asset_from_relay_to_asset_hub_fails: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_asset_hub_fails", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 498usize, - start_col: 4usize, - end_line: 498usize, - end_col: 63usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_relay_to_asset_hub_fails(), - ), - ), - }; - /// Reserve Transfers of native asset from Relay Chain to the Asset Hub shouldn't work - fn reserve_transfer_native_asset_from_relay_to_asset_hub_fails() { - let signed_origin = ::RuntimeOrigin::signed( - WestendSender::get().into(), - ); - let destination = Westend::child_location_of(AssetHubWestend::para_id()); - let beneficiary: Location = AccountId32Junction { - network: None, - id: AssetHubWestendReceiver::get().into(), - } - .into(); - let amount_to_send: Balance = WESTEND_ED * 1000; - let assets: Assets = (Here, amount_to_send).into(); - let fee_asset_item = 0; - Westend::execute_with(|| { - let result = ::XcmPallet::limited_reserve_transfer_assets( - signed_origin, - Box::new(destination.into()), - Box::new(beneficiary.into()), - Box::new(assets.into()), - fee_asset_item, - WeightLimit::Unlimited, - ); - match ( - &result, - &Err( - DispatchError::Module(sp_runtime::ModuleError { - index: 99, - error: [2, 0, 0, 0], - message: Some("Filtered"), - }) - .into(), - ), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_relay_fails"] - pub const reserve_transfer_native_asset_from_asset_hub_to_relay_fails: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_relay_fails", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 531usize, - start_col: 4usize, - end_line: 531usize, - end_col: 63usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_asset_hub_to_relay_fails(), - ), - ), - }; - /// Reserve Transfers of native asset from Asset Hub to Relay Chain shouldn't work - fn reserve_transfer_native_asset_from_asset_hub_to_relay_fails() { - let signed_origin = ::RuntimeOrigin::signed( - AssetHubWestendSender::get().into(), - ); - let destination = AssetHubWestend::parent_location(); - let beneficiary_id = WestendReceiver::get(); - let beneficiary: Location = AccountId32Junction { - network: None, - id: beneficiary_id.into(), - } - .into(); - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let assets: Assets = (Parent, amount_to_send).into(); - let fee_asset_item = 0; - AssetHubWestend::execute_with(|| { - let result = ::PolkadotXcm::limited_reserve_transfer_assets( - signed_origin, - Box::new(destination.into()), - Box::new(beneficiary.into()), - Box::new(assets.into()), - fee_asset_item, - WeightLimit::Unlimited, - ); - match ( - &result, - &Err( - DispatchError::Module(sp_runtime::ModuleError { - index: 31, - error: [2, 0, 0, 0], - message: Some("Filtered"), - }) - .into(), - ), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_para"] - pub const reserve_transfer_native_asset_from_relay_to_para: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_relay_to_para", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 571usize, - start_col: 4usize, - end_line: 571usize, - end_col: 52usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_relay_to_para(), - ), - ), - }; - /// Reserve Transfers of native asset from Relay to Parachain should work - fn reserve_transfer_native_asset_from_relay_to_para() { - let destination = Westend::child_location_of(PenpalA::para_id()); - let sender = WestendSender::get(); - let amount_to_send: Balance = WESTEND_ED * 1000; - let relay_native_asset_location = RelayLocation::get(); - let receiver = PenpalAReceiver::get(); - let test_args = TestContext { - sender, - receiver: receiver.clone(), - args: TestArgs::new_relay( - destination.clone(), - receiver.clone(), - amount_to_send, - ), - }; - let mut test = RelayToParaTest::new(test_args); - let sender_balance_before = test.sender.balance; - let receiver_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &receiver) - }); - test.set_assertion::(relay_to_para_sender_assertions); - test.set_assertion::(relay_to_para_assets_receiver_assertions); - test.set_dispatchable::(relay_to_para_reserve_transfer_assets); - test.assert(); - let sender_balance_after = test.sender.balance; - let receiver_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location, &receiver) - }); - if !(sender_balance_after < sender_balance_before - amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_balance_after < sender_balance_before - amount_to_send", - ) - } - if !(receiver_assets_after > receiver_assets_before) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after > receiver_assets_before", - ) - } - if !(receiver_assets_after < receiver_assets_before + amount_to_send) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after < receiver_assets_before + amount_to_send", - ) - } - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_relay"] - pub const reserve_transfer_native_asset_from_para_to_relay: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_relay", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 621usize, - start_col: 4usize, - end_line: 621usize, - end_col: 52usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_para_to_relay(), - ), - ), - }; - /// Reserve Transfers of native asset from Parachain to Relay should work - fn reserve_transfer_native_asset_from_para_to_relay() { - let destination = PenpalA::parent_location(); - let sender = PenpalASender::get(); - let amount_to_send: Balance = WESTEND_ED * 1000; - let assets: Assets = (Parent, amount_to_send).into(); - let asset_owner = PenpalAssetOwner::get(); - let relay_native_asset_location = RelayLocation::get(); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - relay_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); - let receiver = WestendReceiver::get(); - let penpal_location_as_seen_by_relay = Westend::child_location_of( - PenpalA::para_id(), - ); - let sov_penpal_on_relay = Westend::sovereign_account_id_of( - penpal_location_as_seen_by_relay, - ); - Westend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_penpal_on_relay.into(), amount_to_send * 2), - ]), - ), - ); - let test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination.clone(), - receiver, - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let mut test = ParaToRelayTest::new(test_args); - let sender_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &sender) - }); - let receiver_balance_before = test.receiver.balance; - test.set_assertion::(para_to_relay_sender_assertions); - test.set_assertion::(para_to_relay_receiver_assertions); - test.set_dispatchable::(para_to_relay_reserve_transfer_assets); - test.assert(); - let sender_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location, &sender) - }); - let receiver_balance_after = test.receiver.balance; - if !(sender_assets_after < sender_assets_before - amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_assets_after < sender_assets_before - amount_to_send", - ) - } - if !(receiver_balance_after > receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: receiver_balance_after > receiver_balance_before", - ) - } - if !(receiver_balance_after < receiver_balance_before + amount_to_send) { - ::core::panicking::panic( - "assertion failed: receiver_balance_after < receiver_balance_before + amount_to_send", - ) - } - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_para"] - pub const reserve_transfer_native_asset_from_asset_hub_to_para: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_asset_hub_to_para", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 696usize, - start_col: 4usize, - end_line: 696usize, - end_col: 56usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_asset_hub_to_para(), - ), - ), - }; - /// Reserve Transfers of native asset from Asset Hub to Parachain should work - fn reserve_transfer_native_asset_from_asset_hub_to_para() { - let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); - let sender = AssetHubWestendSender::get(); - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 2000; - let assets: Assets = (Parent, amount_to_send).into(); - let system_para_native_asset_location = RelayLocation::get(); - let receiver = PenpalAReceiver::get(); - let test_args = TestContext { - sender, - receiver: receiver.clone(), - args: TestArgs::new_para( - destination.clone(), - receiver.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let mut test = SystemParaToParaTest::new(test_args); - let sender_balance_before = test.sender.balance; - let receiver_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location.clone(), &receiver) - }); - test.set_assertion::(system_para_to_para_sender_assertions); - test.set_assertion::(system_para_to_para_receiver_assertions); - test.set_dispatchable::< - AssetHubWestend, - >(system_para_to_para_reserve_transfer_assets); - test.assert(); - let sender_balance_after = test.sender.balance; - let receiver_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location, &receiver) - }); - if !(sender_balance_after < sender_balance_before - amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_balance_after < sender_balance_before - amount_to_send", - ) - } - if !(receiver_assets_after > receiver_assets_before) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after > receiver_assets_before", - ) - } - if !(receiver_assets_after < receiver_assets_before + amount_to_send) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after < receiver_assets_before + amount_to_send", - ) - } - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_asset_hub"] - pub const reserve_transfer_native_asset_from_para_to_asset_hub: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_asset_hub", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 754usize, - start_col: 4usize, - end_line: 754usize, - end_col: 56usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_para_to_asset_hub(), - ), - ), - }; - /// Reserve Transfers of native asset from Parachain to Asset Hub should work - fn reserve_transfer_native_asset_from_para_to_asset_hub() { - let destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()); - let sender = PenpalASender::get(); - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let assets: Assets = (Parent, amount_to_send).into(); - let system_para_native_asset_location = RelayLocation::get(); - let asset_owner = PenpalAssetOwner::get(); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - system_para_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); - let receiver = AssetHubWestendReceiver::get(); - let penpal_location_as_seen_by_ahr = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - penpal_location_as_seen_by_ahr, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_penpal_on_ahr.into(), amount_to_send * 2), - ]), - ), - ); - let test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination.clone(), - receiver.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let mut test = ParaToSystemParaTest::new(test_args); - let sender_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location.clone(), &sender) - }); - let receiver_balance_before = test.receiver.balance; - test.set_assertion::(para_to_system_para_sender_assertions); - test.set_assertion::< - AssetHubWestend, - >(para_to_system_para_receiver_assertions); - test.set_dispatchable::< - PenpalA, - >(para_to_system_para_reserve_transfer_assets); - test.assert(); - let sender_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location, &sender) - }); - let receiver_balance_after = test.receiver.balance; - if !(sender_assets_after < sender_assets_before - amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_assets_after < sender_assets_before - amount_to_send", - ) - } - if !(receiver_balance_after > receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: receiver_balance_after > receiver_balance_before", - ) - } - if !(receiver_balance_after < receiver_balance_before + amount_to_send) { - ::core::panicking::panic( - "assertion failed: receiver_balance_after < receiver_balance_before + amount_to_send", - ) - } - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_multiple_assets_from_asset_hub_to_para"] - pub const reserve_transfer_multiple_assets_from_asset_hub_to_para: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_multiple_assets_from_asset_hub_to_para", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 831usize, - start_col: 4usize, - end_line: 831usize, - end_col: 59usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_multiple_assets_from_asset_hub_to_para(), - ), - ), - }; - /// Reserve Transfers of a local asset and native asset from Asset Hub to Parachain should - /// work - fn reserve_transfer_multiple_assets_from_asset_hub_to_para() { - let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - destination.clone(), - ); - let sender = AssetHubWestendSender::get(); - let fee_amount_to_send = ASSET_HUB_WESTEND_ED * 100; - let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100; - let asset_owner = AssetHubWestendAssetOwner::get(); - let asset_owner_signer = ::RuntimeOrigin::signed( - asset_owner.clone(), - ); - let assets: Assets = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (Parent, fee_amount_to_send).into(), - ( - [ - PalletInstance(ASSETS_PALLET_ID), - GeneralIndex(RESERVABLE_ASSET_ID.into()), - ], - asset_amount_to_send, - ) - .into(), - ]), - ) - .into(); - let fee_asset_index = assets - .inner() - .iter() - .position(|r| r == &(Parent, fee_amount_to_send).into()) - .unwrap() as u32; - AssetHubWestend::mint_asset( - asset_owner_signer, - RESERVABLE_ASSET_ID, - asset_owner, - asset_amount_to_send * 2, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_penpal_on_ahr.into(), ASSET_HUB_WESTEND_ED), - ]), - ), - ); - let receiver = PenpalAReceiver::get(); - let system_para_native_asset_location = RelayLocation::get(); - let system_para_foreign_asset_location = PenpalLocalReservableFromAssetHub::get(); - let para_test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination, - receiver.clone(), - asset_amount_to_send, - assets, - None, - fee_asset_index, - ), - }; - let mut test = SystemParaToParaTest::new(para_test_args); - let sender_balance_before = test.sender.balance; - let sender_assets_before = AssetHubWestend::execute_with(|| { - type Assets = ::Assets; - >::balance(RESERVABLE_ASSET_ID, &sender) - }); - let receiver_system_native_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location.clone(), &receiver) - }); - let receiver_foreign_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_foreign_asset_location.clone(), &receiver) - }); - test.set_assertion::< - AssetHubWestend, - >(system_para_to_para_assets_sender_assertions); - test.set_assertion::< - PenpalA, - >(system_para_to_para_assets_receiver_assertions); - test.set_dispatchable::< - AssetHubWestend, - >(system_para_to_para_reserve_transfer_assets); - test.assert(); - let sender_balance_after = test.sender.balance; - let sender_assets_after = AssetHubWestend::execute_with(|| { - type Assets = ::Assets; - >::balance(RESERVABLE_ASSET_ID, &sender) - }); - let receiver_system_native_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location, &receiver) - }); - let receiver_foreign_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_foreign_asset_location, &receiver) - }); - if !(sender_balance_after < sender_balance_before) { - ::core::panicking::panic( - "assertion failed: sender_balance_after < sender_balance_before", - ) - } - if !(receiver_foreign_assets_after > receiver_foreign_assets_before) { - ::core::panicking::panic( - "assertion failed: receiver_foreign_assets_after > receiver_foreign_assets_before", - ) - } - if !(receiver_system_native_assets_after - < receiver_system_native_assets_before + fee_amount_to_send) - { - ::core::panicking::panic( - "assertion failed: receiver_system_native_assets_after <\n receiver_system_native_assets_before + fee_amount_to_send", - ) - } - match ( - &(sender_assets_before - asset_amount_to_send), - &sender_assets_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &receiver_foreign_assets_after, - &(receiver_foreign_assets_before + asset_amount_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_multiple_assets_from_para_to_asset_hub"] - pub const reserve_transfer_multiple_assets_from_para_to_asset_hub: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_multiple_assets_from_para_to_asset_hub", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 948usize, - start_col: 4usize, - end_line: 948usize, - end_col: 59usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_multiple_assets_from_para_to_asset_hub(), - ), - ), - }; - /// Reserve Transfers of a random asset and native asset from Parachain to Asset Hub should work - /// Receiver is empty account to show deposit works as long as transfer includes enough DOT for ED. - /// Once we have https://github.com/paritytech/polkadot-sdk/issues/5298, - /// we should do equivalent test with USDT instead of DOT. - fn reserve_transfer_multiple_assets_from_para_to_asset_hub() { - let destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()); - let sender = PenpalASender::get(); - let fee_amount_to_send = ASSET_HUB_WESTEND_ED * 100; - let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100; - let penpal_asset_owner = PenpalAssetOwner::get(); - let penpal_asset_owner_signer = ::RuntimeOrigin::signed( - penpal_asset_owner, - ); - let asset_location_on_penpal = PenpalLocalReservableFromAssetHub::get(); - let system_asset_location_on_penpal = RelayLocation::get(); - let assets: Assets = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (Parent, fee_amount_to_send).into(), - (asset_location_on_penpal.clone(), asset_amount_to_send).into(), - ]), - ) - .into(); - let fee_asset_index = assets - .inner() - .iter() - .position(|r| r == &(Parent, fee_amount_to_send).into()) - .unwrap() as u32; - PenpalA::mint_foreign_asset( - penpal_asset_owner_signer.clone(), - asset_location_on_penpal.clone(), - sender.clone(), - asset_amount_to_send * 2, - ); - PenpalA::mint_foreign_asset( - penpal_asset_owner_signer, - system_asset_location_on_penpal.clone(), - sender.clone(), - fee_amount_to_send * 2, - ); - let receiver = get_account_id_from_seed::< - sp_runtime::testing::sr25519::Public, - >(DUMMY_EMPTY); - let penpal_location_as_seen_by_ahr = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - penpal_location_as_seen_by_ahr, - ); - let ah_asset_owner = AssetHubWestendAssetOwner::get(); - let ah_asset_owner_signer = ::RuntimeOrigin::signed( - ah_asset_owner, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_penpal_on_ahr.clone().into(), ASSET_HUB_WESTEND_ED * 1000), - ]), - ), - ); - AssetHubWestend::mint_asset( - ah_asset_owner_signer, - RESERVABLE_ASSET_ID, - sov_penpal_on_ahr, - asset_amount_to_send * 2, - ); - let para_test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination, - receiver.clone(), - asset_amount_to_send, - assets, - None, - fee_asset_index, - ), - }; - let mut test = ParaToSystemParaTest::new(para_test_args); - let sender_system_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_asset_location_on_penpal.clone(), &sender) - }); - let sender_foreign_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(asset_location_on_penpal.clone(), &sender) - }); - let receiver_balance_before = test.receiver.balance; - let receiver_assets_before = AssetHubWestend::execute_with(|| { - type Assets = ::Assets; - >::balance(RESERVABLE_ASSET_ID, &receiver) - }); - test.set_assertion::(para_to_system_para_assets_sender_assertions); - test.set_assertion::< - AssetHubWestend, - >(para_to_system_para_assets_receiver_assertions); - test.set_dispatchable::< - PenpalA, - >(para_to_system_para_reserve_transfer_assets); - test.assert(); - let sender_system_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_asset_location_on_penpal, &sender) - }); - let sender_foreign_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(asset_location_on_penpal, &sender) - }); - let receiver_balance_after = test.receiver.balance; - let receiver_assets_after = AssetHubWestend::execute_with(|| { - type Assets = ::Assets; - >::balance(RESERVABLE_ASSET_ID, &receiver) - }); - if !(sender_system_assets_after < sender_system_assets_before) { - ::core::panicking::panic( - "assertion failed: sender_system_assets_after < sender_system_assets_before", - ) - } - if !(receiver_balance_after > receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: receiver_balance_after > receiver_balance_before", - ) - } - if !(receiver_balance_after < receiver_balance_before + fee_amount_to_send) { - ::core::panicking::panic( - "assertion failed: receiver_balance_after < receiver_balance_before + fee_amount_to_send", - ) - } - match ( - &(sender_foreign_assets_before - asset_amount_to_send), - &sender_foreign_assets_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &receiver_assets_after, - &(receiver_assets_before + asset_amount_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_para_through_relay"] - pub const reserve_transfer_native_asset_from_para_to_para_through_relay: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::reserve_transfer::reserve_transfer_native_asset_from_para_to_para_through_relay", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs", - start_line: 1076usize, - start_col: 4usize, - end_line: 1076usize, - end_col: 65usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - reserve_transfer_native_asset_from_para_to_para_through_relay(), - ), - ), - }; - /// Reserve Transfers of native asset from Parachain to Parachain (through Relay reserve) should - /// work - fn reserve_transfer_native_asset_from_para_to_para_through_relay() { - let destination = PenpalA::sibling_location_of(PenpalB::para_id()); - let sender = PenpalASender::get(); - let amount_to_send: Balance = WESTEND_ED * 10000; - let asset_owner = PenpalAssetOwner::get(); - let assets = (Parent, amount_to_send).into(); - let relay_native_asset_location = RelayLocation::get(); - let sender_as_seen_by_relay = Westend::child_location_of(PenpalA::para_id()); - let sov_of_sender_on_relay = Westend::sovereign_account_id_of( - sender_as_seen_by_relay, - ); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - relay_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); - Westend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_of_sender_on_relay.into(), amount_to_send * 2), - ]), - ), - ); - let receiver = PenpalBReceiver::get(); - let test_args = TestContext { - sender: sender.clone(), - receiver: receiver.clone(), - args: TestArgs::new_para( - destination, - receiver.clone(), - amount_to_send, - assets, - None, - 0, - ), - }; - let mut test = ParaToParaThroughRelayTest::new(test_args); - let sender_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &sender) - }); - let receiver_assets_before = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &receiver) - }); - test.set_assertion::(para_to_para_through_hop_sender_assertions); - test.set_assertion::(para_to_para_relay_hop_assertions); - test.set_assertion::(para_to_para_through_hop_receiver_assertions); - test.set_dispatchable::< - PenpalA, - >(para_to_para_through_relay_limited_reserve_transfer_assets); - test.assert(); - let sender_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &sender) - }); - let receiver_assets_after = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location, &receiver) - }); - if !(sender_assets_after < sender_assets_before - amount_to_send) { - ::core::panicking::panic( - "assertion failed: sender_assets_after < sender_assets_before - amount_to_send", - ) - } - if !(receiver_assets_after > receiver_assets_before) { - ::core::panicking::panic( - "assertion failed: receiver_assets_after > receiver_assets_before", - ) - } - } - } - mod send { - use crate::imports::*; - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::send::send_transact_as_superuser_from_relay_to_asset_hub_works"] - pub const send_transact_as_superuser_from_relay_to_asset_hub_works: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::send::send_transact_as_superuser_from_relay_to_asset_hub_works", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/send.rs", - start_line: 21usize, - start_col: 4usize, - end_line: 21usize, - end_col: 60usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - send_transact_as_superuser_from_relay_to_asset_hub_works(), - ), - ), - }; - /// Relay Chain should be able to execute `Transact` instructions in System Parachain - /// when `OriginKind::Superuser`. - fn send_transact_as_superuser_from_relay_to_asset_hub_works() { - AssetHubWestend::force_create_asset_from_relay_as_root( - ASSET_ID, - ASSET_MIN_BALANCE, - true, - AssetHubWestendSender::get().into(), - Some(Weight::from_parts(1_019_445_000, 200_000)), - ) - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset"] - pub const send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/send.rs", - start_line: 35usize, - start_col: 4usize, - end_line: 35usize, - end_col: 64usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset(), - ), - ), - }; - /// We tests two things here: - /// - Parachain should be able to send XCM paying its fee at Asset Hub using system asset - /// - Parachain should be able to create a new Foreign Asset at Asset Hub - fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() { - let para_sovereign_account = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - let asset_location_on_penpal = Location::new( - 0, - [ - Junction::PalletInstance(ASSETS_PALLET_ID), - Junction::GeneralIndex(ASSET_ID.into()), - ], - ); - let foreign_asset_at_asset_hub = Location::new( - 1, - [Junction::Parachain(PenpalA::para_id().into())], - ) - .appended_with(asset_location_on_penpal) - .unwrap(); - let call = AssetHubWestend::create_foreign_asset_call( - foreign_asset_at_asset_hub.clone(), - ASSET_MIN_BALANCE, - para_sovereign_account.clone(), - ); - let origin_kind = OriginKind::Xcm; - let fee_amount = ASSET_HUB_WESTEND_ED * 1000000; - let system_asset = (Parent, fee_amount).into(); - let root_origin = ::RuntimeOrigin::root(); - let system_para_destination = PenpalA::sibling_location_of( - AssetHubWestend::para_id(), - ) - .into(); - let xcm = xcm_transact_paid_execution( - call, - origin_kind, - system_asset, - para_sovereign_account.clone(), - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - para_sovereign_account.clone().into(), - ASSET_HUB_WESTEND_ED * 10000000000, - ), - ]), - ), - ); - PenpalA::execute_with(|| { - let is = ::PolkadotXcm::send( - root_origin, - Box::new(system_para_destination), - Box::new(xcm), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - PenpalA::assert_xcm_pallet_sent(); - }); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == para_sovereign_account) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == para_sovereign_account", - ), - ); - res - }); - } - meet_conditions &= *who == para_sovereign_account; - if !(*amount == fee_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == fee_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == fee_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Created { asset_id, creator, owner }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == foreign_asset_at_asset_hub) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == foreign_asset_at_asset_hub", - ), - ); - res - }); - } - meet_conditions &= *asset_id == foreign_asset_at_asset_hub; - if !(*creator == para_sovereign_account.clone()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "creator", - creator, - "*creator == para_sovereign_account.clone()", - ), - ); - res - }); - } - meet_conditions - &= *creator == para_sovereign_account.clone(); - if !(*owner == para_sovereign_account) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == para_sovereign_account", - ), - ); - res - }); - } - meet_conditions &= *owner == para_sovereign_account; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Created {\nasset_id, creator, owner })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Created {\nasset_id, creator, owner })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::send", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - type ForeignAssets = ::ForeignAssets; - if !ForeignAssets::asset_exists(foreign_asset_at_asset_hub) { - ::core::panicking::panic( - "assertion failed: ForeignAssets::asset_exists(foreign_asset_at_asset_hub)", - ) - } - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset"] - pub const send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::send::send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/send.rs", - start_line: 113usize, - start_col: 4usize, - end_line: 113usize, - end_col: 68usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset(), - ), - ), - }; - /// We tests two things here: - /// - Parachain should be able to send XCM paying its fee at Asset Hub using sufficient asset - /// - Parachain should be able to create a new Asset at Asset Hub - fn send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset() { - let para_sovereign_account = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - AssetHubWestend::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - true, - para_sovereign_account.clone(), - Some(Weight::from_parts(1_019_445_000, 200_000)), - ASSET_MIN_BALANCE * 1000000000, - ); - let new_asset_id = ASSET_ID + 1; - let call = AssetHubWestend::create_asset_call( - new_asset_id, - ASSET_MIN_BALANCE, - para_sovereign_account.clone(), - ); - let origin_kind = OriginKind::SovereignAccount; - let fee_amount = ASSET_MIN_BALANCE * 1000000; - let asset = ( - [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], - fee_amount, - ) - .into(); - let root_origin = ::RuntimeOrigin::root(); - let system_para_destination = PenpalA::sibling_location_of( - AssetHubWestend::para_id(), - ) - .into(); - let xcm = xcm_transact_paid_execution( - call, - origin_kind, - asset, - para_sovereign_account.clone(), - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - para_sovereign_account.clone().into(), - ASSET_HUB_WESTEND_ED * 10000000000, - ), - ]), - ), - ); - PenpalA::execute_with(|| { - let is = ::PolkadotXcm::send( - root_origin, - Box::new(system_para_destination), - Box::new(xcm), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - PenpalA::assert_xcm_pallet_sent(); - }); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == ASSET_ID) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == ASSET_ID", - ), - ); - res - }); - } - meet_conditions &= *asset_id == ASSET_ID; - if !(*owner == para_sovereign_account) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == para_sovereign_account", - ), - ); - res - }); - } - meet_conditions &= *owner == para_sovereign_account; - if !(*balance == fee_amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == fee_amount", - ), - ); - res - }); - } - meet_conditions &= *balance == fee_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Created { asset_id, creator, owner }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == new_asset_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == new_asset_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == new_asset_id; - if !(*creator == para_sovereign_account.clone()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "creator", - creator, - "*creator == para_sovereign_account.clone()", - ), - ); - res - }); - } - meet_conditions - &= *creator == para_sovereign_account.clone(); - if !(*owner == para_sovereign_account) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == para_sovereign_account", - ), - ); - res - }); - } - meet_conditions &= *owner == para_sovereign_account; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Created { asset_id, creator, owner\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Created { asset_id, creator, owner\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::send", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - } - mod set_xcm_versions { - use crate::imports::*; - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::set_xcm_versions::relay_sets_system_para_xcm_supported_version"] - pub const relay_sets_system_para_xcm_supported_version: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::set_xcm_versions::relay_sets_system_para_xcm_supported_version", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_xcm_versions.rs", - start_line: 19usize, - start_col: 4usize, - end_line: 19usize, - end_col: 48usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - relay_sets_system_para_xcm_supported_version(), - ), - ), - }; - fn relay_sets_system_para_xcm_supported_version() { - let sudo_origin = ::RuntimeOrigin::root(); - let system_para_destination: Location = Westend::child_location_of( - AssetHubWestend::para_id(), - ); - Westend::execute_with(|| { - let is = ::XcmPallet::force_xcm_version( - sudo_origin, - Box::new(system_para_destination.clone()), - XCM_V3, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::XcmPallet( - pallet_xcm::Event::SupportedVersionChanged { - location, - version: XCM_V3, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*location == system_para_destination) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "location", - location, - "*location == system_para_destination", - ), - ); - res - }); - } - meet_conditions &= *location == system_para_destination; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::set_xcm_versions", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::set_xcm_versions::system_para_sets_relay_xcm_supported_version"] - pub const system_para_sets_relay_xcm_supported_version: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::set_xcm_versions::system_para_sets_relay_xcm_supported_version", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_xcm_versions.rs", - start_line: 47usize, - start_col: 4usize, - end_line: 47usize, - end_col: 48usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - system_para_sets_relay_xcm_supported_version(), - ), - ), - }; - fn system_para_sets_relay_xcm_supported_version() { - let parent_location = AssetHubWestend::parent_location(); - let force_xcm_version_call = ::RuntimeCall::PolkadotXcm(pallet_xcm::Call::< - ::Runtime, - >::force_xcm_version { - location: Box::new(parent_location.clone()), - version: XCM_V3, - }) - .encode() - .into(); - Westend::send_unpaid_transact_to_parachain_as_root( - AssetHubWestend::para_id(), - force_xcm_version_call, - ); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_dmp_queue_complete( - Some(Weight::from_parts(1_019_210_000, 200_000)), - ); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm( - pallet_xcm::Event::SupportedVersionChanged { - location, - version: XCM_V3, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*location == parent_location) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "location", - location, - "*location == parent_location", - ), - ); - res - }); - } - meet_conditions &= *location == parent_location; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged {\nlocation, version: XCM_V3 })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::set_xcm_versions", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - } - mod swap { - use crate::imports::*; - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::swap::swap_locally_on_chain_using_local_assets"] - pub const swap_locally_on_chain_using_local_assets: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::swap::swap_locally_on_chain_using_local_assets", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", - start_line: 19usize, - start_col: 4usize, - end_line: 19usize, - end_col: 44usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(swap_locally_on_chain_using_local_assets()), - ), - }; - fn swap_locally_on_chain_using_local_assets() { - let asset_native = Box::new( - Location::try_from(RelayLocation::get()).expect("conversion works"), - ); - let asset_one = Box::new(Location { - parents: 0, - interior: [ - Junction::PalletInstance(ASSETS_PALLET_ID), - Junction::GeneralIndex(ASSET_ID.into()), - ] - .into(), - }); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - let is = ::Assets::create( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - ASSET_ID.into(), - AssetHubWestendSender::get().into(), - 1000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - if !::Assets::asset_exists( - ASSET_ID, - ) { - ::core::panicking::panic( - "assertion failed: ::Assets::asset_exists(ASSET_ID)", - ) - } - let is = ::Assets::mint( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - ASSET_ID.into(), - AssetHubWestendSender::get().into(), - 3_000_000_000_000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = ::AssetConversion::create_pool( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - asset_native.clone(), - asset_one.clone(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::PoolCreated { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let is = ::AssetConversion::add_liquidity( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - asset_native.clone(), - asset_one.clone(), - 1_000_000_000_000, - 2_000_000_000_000, - 0, - 0, - AssetHubWestendSender::get().into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::LiquidityAdded { - lp_token_minted, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*lp_token_minted == 1414213562273) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "lp_token_minted", - lp_token_minted, - "*lp_token_minted == 1414213562273", - ), - ); - res - }); - } - meet_conditions &= *lp_token_minted == 1414213562273; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let path = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([asset_native.clone(), asset_one.clone()]), - ); - let is = ::AssetConversion::swap_exact_tokens_for_tokens( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - path, - 100, - 1, - AssetHubWestendSender::get().into(), - true, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::SwapExecuted { - amount_in, - amount_out, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*amount_in == 100) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount_in", - amount_in, - "*amount_in == 100", - ), - ); - res - }); - } - meet_conditions &= *amount_in == 100; - if !(*amount_out == 199) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount_out", - amount_out, - "*amount_out == 199", - ), - ); - res - }); - } - meet_conditions &= *amount_out == 199; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let is = ::AssetConversion::remove_liquidity( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - asset_native.clone(), - asset_one.clone(), - 1414213562273 - 2_000_000_000, - 0, - 0, - AssetHubWestendSender::get().into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::swap::swap_locally_on_chain_using_foreign_assets"] - pub const swap_locally_on_chain_using_foreign_assets: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::swap::swap_locally_on_chain_using_foreign_assets", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", - start_line: 114usize, - start_col: 4usize, - end_line: 114usize, - end_col: 46usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(swap_locally_on_chain_using_foreign_assets()), - ), - }; - fn swap_locally_on_chain_using_foreign_assets() { - let asset_native = Box::new( - Location::try_from(RelayLocation::get()).unwrap(), - ); - let asset_location_on_penpal = Location::try_from( - PenpalLocalTeleportableToAssetHub::get(), - ) - .expect("conversion_works"); - let foreign_asset_at_asset_hub_westend = Location::new( - 1, - [Junction::Parachain(PenpalA::para_id().into())], - ) - .appended_with(asset_location_on_penpal) - .unwrap(); - let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - penpal_as_seen_by_ah, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - AssetHubWestendSender::get().into(), - 5_000_000 * ASSET_HUB_WESTEND_ED, - ), - ( - sov_penpal_on_ahr.clone().into(), - 100_000_000 * ASSET_HUB_WESTEND_ED, - ), - ]), - ), - ); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - let is = ::ForeignAssets::mint( - ::RuntimeOrigin::signed( - sov_penpal_on_ahr.clone().into(), - ), - foreign_asset_at_asset_hub_westend.clone(), - sov_penpal_on_ahr.clone().into(), - ASSET_HUB_WESTEND_ED * 3_000_000_000_000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let is = ::AssetConversion::create_pool( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - asset_native.clone(), - Box::new(foreign_asset_at_asset_hub_westend.clone()), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::PoolCreated { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let is = ::AssetConversion::add_liquidity( - ::RuntimeOrigin::signed( - sov_penpal_on_ahr.clone(), - ), - asset_native.clone(), - Box::new(foreign_asset_at_asset_hub_westend.clone()), - 1_000_000_000_000_000, - 2_000_000_000_000_000, - 0, - 0, - sov_penpal_on_ahr.clone().into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::LiquidityAdded { - lp_token_minted, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*lp_token_minted == 1414213562372995) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "lp_token_minted", - lp_token_minted, - "*lp_token_minted == 1414213562372995", - ), - ); - res - }); - } - meet_conditions &= *lp_token_minted == 1414213562372995; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let path = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - asset_native.clone(), - Box::new(foreign_asset_at_asset_hub_westend.clone()), - ]), - ); - let is = ::AssetConversion::swap_exact_tokens_for_tokens( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - path, - 100000 * ASSET_HUB_WESTEND_ED, - 1000 * ASSET_HUB_WESTEND_ED, - AssetHubWestendSender::get().into(), - true, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::SwapExecuted { - amount_in, - amount_out, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*amount_in == 100000000000000) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount_in", - amount_in, - "*amount_in == 100000000000000", - ), - ); - res - }); - } - meet_conditions &= *amount_in == 100000000000000; - if !(*amount_out == 181322178776029) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount_out", - amount_out, - "*amount_out == 181322178776029", - ), - ); - res - }); - } - meet_conditions &= *amount_out == 181322178776029; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted {\namount_in, amount_out, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let is = ::AssetConversion::remove_liquidity( - ::RuntimeOrigin::signed( - sov_penpal_on_ahr.clone(), - ), - asset_native.clone(), - Box::new(foreign_asset_at_asset_hub_westend), - 1414213562372995 - ASSET_HUB_WESTEND_ED * 2, - 0, - 0, - sov_penpal_on_ahr.clone().into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::swap::cannot_create_pool_from_pool_assets"] - pub const cannot_create_pool_from_pool_assets: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::swap::cannot_create_pool_from_pool_assets", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", - start_line: 229usize, - start_col: 4usize, - end_line: 229usize, - end_col: 39usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(cannot_create_pool_from_pool_assets()), - ), - }; - fn cannot_create_pool_from_pool_assets() { - let asset_native = RelayLocation::get(); - let mut asset_one = ahw_xcm_config::PoolAssetsPalletLocation::get(); - asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets"); - AssetHubWestend::execute_with(|| { - let pool_owner_account_id = AssetHubWestendAssetConversionOrigin::get(); - let is = ::PoolAssets::create( - ::RuntimeOrigin::signed( - pool_owner_account_id.clone(), - ), - ASSET_ID.into(), - pool_owner_account_id.clone().into(), - 1000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - if !::PoolAssets::asset_exists( - ASSET_ID, - ) { - ::core::panicking::panic( - "assertion failed: ::PoolAssets::asset_exists(ASSET_ID)", - ) - } - let is = ::PoolAssets::mint( - ::RuntimeOrigin::signed( - pool_owner_account_id, - ), - ASSET_ID.into(), - AssetHubWestendSender::get().into(), - 3_000_000_000_000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - match ::AssetConversion::create_pool( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - Box::new( - Location::try_from(asset_native).expect("conversion works"), - ), - Box::new(Location::try_from(asset_one).expect("conversion works")), - ) { - Err( - DispatchError::Module( - ModuleError { index: _, error: _, message }, - ), - ) => { - match (&message, &Some("Unknown")) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - } - } - ref e => { - ::std::rt::panic_fmt( - format_args!( - "assertion failed: `{0:?}` does not match `{1}`", - e, - "Err(DispatchError::Module(ModuleError { index: _, error: _, message }))", - ), - ); - } - }; - }); - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::swap::pay_xcm_fee_with_some_asset_swapped_for_native"] - pub const pay_xcm_fee_with_some_asset_swapped_for_native: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::swap::pay_xcm_fee_with_some_asset_swapped_for_native", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs", - start_line: 264usize, - start_col: 4usize, - end_line: 264usize, - end_col: 50usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - pay_xcm_fee_with_some_asset_swapped_for_native(), - ), - ), - }; - fn pay_xcm_fee_with_some_asset_swapped_for_native() { - let asset_native = Location::try_from(RelayLocation::get()) - .expect("conversion works"); - let asset_one = Location { - parents: 0, - interior: [ - Junction::PalletInstance(ASSETS_PALLET_ID), - Junction::GeneralIndex(ASSET_ID.into()), - ] - .into(), - }; - let penpal = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - let is = ::Assets::create( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - ASSET_ID.into(), - AssetHubWestendSender::get().into(), - ASSET_MIN_BALANCE, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - if !::Assets::asset_exists( - ASSET_ID, - ) { - ::core::panicking::panic( - "assertion failed: ::Assets::asset_exists(ASSET_ID)", - ) - } - let is = ::Assets::mint( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - ASSET_ID.into(), - AssetHubWestendSender::get().into(), - 3_000_000_000_000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = ::AssetConversion::create_pool( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - Box::new(asset_native.clone()), - Box::new(asset_one.clone()), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::PoolCreated { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - let is = ::AssetConversion::add_liquidity( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - Box::new(asset_native), - Box::new(asset_one), - 1_000_000_000_000, - 2_000_000_000_000, - 0, - 0, - AssetHubWestendSender::get().into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::LiquidityAdded { - lp_token_minted, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*lp_token_minted == 1414213562273) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "lp_token_minted", - lp_token_minted, - "*lp_token_minted == 1414213562273", - ), - ); - res - }); - } - meet_conditions &= *lp_token_minted == 1414213562273; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {\nlp_token_minted, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - match ( - &::Balances::free_balance( - penpal.clone(), - ), - &0, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - let is = ::Assets::touch_other( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - ASSET_ID.into(), - penpal.clone().into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = ::Assets::mint( - ::RuntimeOrigin::signed( - AssetHubWestendSender::get(), - ), - ASSET_ID.into(), - penpal.clone().into(), - 10_000_000_000_000, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - PenpalA::execute_with(|| { - let call = AssetHubWestend::force_create_asset_call( - ASSET_ID + 1000, - penpal.clone(), - true, - ASSET_MIN_BALANCE, - ); - let penpal_root = ::RuntimeOrigin::root(); - let fee_amount = 4_000_000_000_000u128; - let asset_one = ( - [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], - fee_amount, - ) - .into(); - let asset_hub_location = PenpalA::sibling_location_of( - AssetHubWestend::para_id(), - ) - .into(); - let xcm = xcm_transact_paid_execution( - call, - OriginKind::SovereignAccount, - asset_one, - penpal.clone(), - ); - let is = ::PolkadotXcm::send( - penpal_root, - Box::new(asset_hub_location), - Box::new(xcm), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - PenpalA::assert_xcm_pallet_sent(); - }); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::AssetConversion( - pallet_asset_conversion::Event::SwapCreditExecuted { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapCreditExecuted {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapCreditExecuted {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::swap", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - } - mod teleport { - use crate::imports::*; - fn relay_dest_assertions_fail(_t: SystemParaToRelayTest) { - Westend::assert_ump_queue_processed( - false, - Some(AssetHubWestend::para_id()), - Some(Weight::from_parts(157_718_000, 3_593)), - ); - } - fn para_origin_assertions(t: SystemParaToRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcm_pallet_attempted_complete( - Some(Weight::from_parts(720_053_000, 7_203)), - ); - AssetHubWestend::assert_parachain_system_ump_sent(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *who == t.sender.account_id; - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn penpal_to_ah_foreign_assets_sender_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let system_para_native_asset_location = RelayLocation::get(); - let expected_asset_id = t.args.asset_id.unwrap(); - let (_, expected_asset_amount) = non_fee_asset( - &t.args.assets, - t.args.fee_asset_item as usize, - ) - .unwrap(); - PenpalA::assert_xcm_pallet_attempted_complete(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == system_para_native_asset_location) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == system_para_native_asset_location", - ), - ); - res - }); - } - meet_conditions - &= *asset_id == system_para_native_asset_location; - if !(*owner == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_asset_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_asset_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_asset_id; - if !(*owner == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if !(*balance == expected_asset_amount) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == expected_asset_amount", - ), - ); - res - }); - } - meet_conditions &= *balance == expected_asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalA::para_id()), - ); - let (expected_foreign_asset_id, expected_foreign_asset_amount) = non_fee_asset( - &t.args.assets, - t.args.fee_asset_item as usize, - ) - .unwrap(); - AssetHubWestend::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == sov_penpal_on_ahr.clone().into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == sov_penpal_on_ahr.clone().into()", - ), - ); - res - }); - } - meet_conditions &= *who == sov_penpal_on_ahr.clone().into(); - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { who, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Minted { who, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*who == t.receiver.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "who", - who, - "*who == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *who == t.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_foreign_asset_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_foreign_asset_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_foreign_asset_id; - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if !(*amount == expected_foreign_asset_amount) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == expected_foreign_asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == expected_foreign_asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn ah_to_penpal_foreign_assets_sender_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcm_pallet_attempted_complete(None); - let (expected_foreign_asset_id, expected_foreign_asset_amount) = non_fee_asset( - &t.args.assets, - t.args.fee_asset_item as usize, - ) - .unwrap(); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from, to, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*from == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "*from == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *from == t.sender.account_id; - if !(*to - == AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - )) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "*to == AssetHubWestend::sovereign_account_id_of(t.args.dest.clone())", - ), - ); - res - }); - } - meet_conditions - &= *to - == AssetHubWestend::sovereign_account_id_of( - t.args.dest.clone(), - ); - if !(*amount == t.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == t.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == t.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_foreign_asset_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_foreign_asset_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_foreign_asset_id; - if !(*owner == t.sender.account_id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.sender.account_id; - if !(*balance == expected_foreign_asset_amount) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == expected_foreign_asset_amount", - ), - ); - res - }); - } - meet_conditions &= *balance == expected_foreign_asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn ah_to_penpal_foreign_assets_receiver_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - let expected_asset_id = t.args.asset_id.unwrap(); - let (_, expected_asset_amount) = non_fee_asset( - &t.args.assets, - t.args.fee_asset_item as usize, - ) - .unwrap(); - let checking_account = ::PolkadotXcm::check_account(); - let system_para_native_asset_location = RelayLocation::get(); - PenpalA::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_asset_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_asset_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_asset_id; - if !(*owner == checking_account) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == checking_account", - ), - ); - res - }); - } - meet_conditions &= *owner == checking_account; - if !(*balance == expected_asset_amount) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == expected_asset_amount", - ), - ); - res - }); - } - meet_conditions &= *balance == expected_asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Issued { asset_id, owner, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == expected_asset_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == expected_asset_id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == expected_asset_id; - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if !(*amount == expected_asset_amount) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == expected_asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == expected_asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, amount }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == system_para_native_asset_location) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == system_para_native_asset_location", - ), - ); - res - }); - } - meet_conditions - &= *asset_id == system_para_native_asset_location; - if !(*owner == t.receiver.account_id) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == t.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == t.receiver.account_id; - if !(*amount == expected_asset_amount) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == expected_asset_amount", - ), - ); - res - }); - } - meet_conditions &= *amount == expected_asset_amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued {\nasset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn system_para_limited_teleport_assets( - t: SystemParaToRelayTest, - ) -> DispatchResult { - ::PolkadotXcm::limited_teleport_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - fn para_to_system_para_transfer_assets( - t: ParaToSystemParaTest, - ) -> DispatchResult { - ::PolkadotXcm::transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - fn system_para_to_para_transfer_assets( - t: SystemParaToParaTest, - ) -> DispatchResult { - ::PolkadotXcm::transfer_assets( - t.signed_origin, - Box::new(t.args.dest.into()), - Box::new(t.args.beneficiary.into()), - Box::new(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::teleport::teleport_to_other_system_parachains_works"] - pub const teleport_to_other_system_parachains_works: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::teleport::teleport_to_other_system_parachains_works", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", - start_line: 204usize, - start_col: 4usize, - end_line: 204usize, - end_col: 45usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(teleport_to_other_system_parachains_works()), - ), - }; - fn teleport_to_other_system_parachains_works() { - let amount = ASSET_HUB_WESTEND_ED * 100; - let native_asset: Assets = (Parent, amount).into(); - let sender = AssetHubWestendSender::get(); - let mut para_sender_balance_before = ::account_data_of( - sender.clone(), - ) - .free; - let origin = ::RuntimeOrigin::signed( - sender.clone(), - ); - let fee_asset_item = 0; - let weight_limit = ::emulated_integration_tests_common::macros::WeightLimit::Unlimited; - { - let receiver = BridgeHubWestendReceiver::get(); - let para_receiver_balance_before = ::account_data_of( - receiver.clone(), - ) - .free; - let para_destination = ::sibling_location_of( - ::para_id(), - ); - let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { - network: None, - id: receiver.clone().into(), - } - .into(); - ::execute_with(|| { - let is = ::PolkadotXcm::limited_teleport_assets( - origin.clone(), - Box::new(para_destination.clone().into()), - Box::new(beneficiary.clone().into()), - Box::new(native_asset.clone().into()), - fee_asset_item, - weight_limit.clone(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted { - outcome: Outcome::Complete { .. }, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::XcmpQueue( - ::emulated_integration_tests_common::macros::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::XcmpQueue(::emulated_integration_tests_common::macros::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::XcmpQueue(::emulated_integration_tests_common::macros::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - ::emulated_integration_tests_common::macros::pallet_balances::Event::Burned { - who: sender, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - ::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - ::emulated_integration_tests_common::macros::pallet_balances::Event::Minted { - who: receiver, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "BridgeHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "BridgeHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - ::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed { - success: true, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "BridgeHubWestend", - "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "BridgeHubWestend", - "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::BridgeHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - let para_sender_balance_after = ::account_data_of( - sender.clone(), - ) - .free; - let para_receiver_balance_after = ::account_data_of( - receiver.clone(), - ) - .free; - let delivery_fees = ::execute_with(|| { - ::emulated_integration_tests_common::macros::asset_test_utils::xcm_helpers::teleport_assets_delivery_fees::< - ::XcmSender, - >( - native_asset.clone(), - fee_asset_item, - weight_limit.clone(), - beneficiary, - para_destination, - ) - }); - match ( - &(para_sender_balance_before - amount - delivery_fees), - ¶_sender_balance_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(para_receiver_balance_after > para_receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: para_receiver_balance_after > para_receiver_balance_before", - ) - } - para_sender_balance_before = ::account_data_of( - sender.clone(), - ) - .free; - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::teleport::teleport_from_and_to_relay"] - pub const teleport_from_and_to_relay: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::teleport::teleport_from_and_to_relay", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", - start_line: 217usize, - start_col: 4usize, - end_line: 217usize, - end_col: 30usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(teleport_from_and_to_relay()), - ), - }; - fn teleport_from_and_to_relay() { - let amount = WESTEND_ED * 100; - let native_asset: Assets = (Here, amount).into(); - let sender = WestendSender::get(); - let mut relay_sender_balance_before = ::account_data_of( - sender.clone(), - ) - .free; - let origin = ::RuntimeOrigin::signed( - sender.clone(), - ); - let fee_asset_item = 0; - let weight_limit = ::emulated_integration_tests_common::macros::WeightLimit::Unlimited; - { - let receiver = AssetHubWestendReceiver::get(); - let para_receiver_balance_before = ::account_data_of( - receiver.clone(), - ) - .free; - let para_destination = ::child_location_of( - ::para_id(), - ); - let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { - network: None, - id: receiver.clone().into(), - } - .into(); - ::execute_with(|| { - let is = ::XcmPallet::limited_teleport_assets( - origin.clone(), - Box::new(para_destination.clone().into()), - Box::new(beneficiary.clone().into()), - Box::new(native_asset.clone().into()), - fee_asset_item, - weight_limit.clone(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::XcmPallet( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted { - outcome: Outcome::Complete { .. }, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - ::emulated_integration_tests_common::macros::pallet_balances::Event::Burned { - who: sender, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::XcmPallet( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::XcmPallet(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - ::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - ::emulated_integration_tests_common::macros::pallet_balances::Event::Minted { - who: receiver, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - ::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed { - success: true, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - let relay_sender_balance_after = ::account_data_of( - sender.clone(), - ) - .free; - let para_receiver_balance_after = ::account_data_of( - receiver.clone(), - ) - .free; - let delivery_fees = ::execute_with(|| { - ::emulated_integration_tests_common::macros::asset_test_utils::xcm_helpers::teleport_assets_delivery_fees::< - ::XcmSender, - >( - native_asset.clone(), - fee_asset_item, - weight_limit.clone(), - beneficiary, - para_destination, - ) - }); - match ( - &(relay_sender_balance_before - amount - delivery_fees), - &relay_sender_balance_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(para_receiver_balance_after > para_receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: para_receiver_balance_after > para_receiver_balance_before", - ) - } - relay_sender_balance_before = ::account_data_of( - sender.clone(), - ) - .free; - }; - let sender = AssetHubWestendSender::get(); - let para_sender_balance_before = ::account_data_of( - sender.clone(), - ) - .free; - let origin = ::RuntimeOrigin::signed( - sender.clone(), - ); - let assets: Assets = (Parent, amount).into(); - let fee_asset_item = 0; - let weight_limit = ::emulated_integration_tests_common::macros::WeightLimit::Unlimited; - let receiver = WestendReceiver::get(); - let relay_receiver_balance_before = ::account_data_of( - receiver.clone(), - ) - .free; - let relay_destination: Location = Parent.into(); - let beneficiary: Location = ::emulated_integration_tests_common::macros::AccountId32 { - network: None, - id: receiver.clone().into(), - } - .into(); - ::execute_with(|| { - let is = ::PolkadotXcm::limited_teleport_assets( - origin.clone(), - Box::new(relay_destination.clone().into()), - Box::new(beneficiary.clone().into()), - Box::new(assets.clone().into()), - fee_asset_item, - weight_limit.clone(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted { - outcome: Outcome::Complete { .. }, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Attempted {\noutcome: Outcome::Complete { .. } })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - ::emulated_integration_tests_common::macros::pallet_balances::Event::Burned { - who: sender, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Burned {\nwho: sender, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::PolkadotXcm( - ::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::PolkadotXcm(::emulated_integration_tests_common::macros::pallet_xcm::Event::Sent {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - ::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - ::emulated_integration_tests_common::macros::pallet_balances::Event::Minted { - who: receiver, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Balances(::emulated_integration_tests_common::macros::pallet_balances::Event::Minted {\nwho: receiver, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - ::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed { - success: true, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::MessageQueue(::emulated_integration_tests_common::macros::pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::teleport", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - let para_sender_balance_after = ::account_data_of( - sender.clone(), - ) - .free; - let relay_receiver_balance_after = ::account_data_of( - receiver.clone(), - ) - .free; - let delivery_fees = ::execute_with(|| { - ::emulated_integration_tests_common::macros::asset_test_utils::xcm_helpers::teleport_assets_delivery_fees::< - ::XcmSender, - >( - assets, - fee_asset_item, - weight_limit.clone(), - beneficiary, - relay_destination, - ) - }); - match ( - &(para_sender_balance_before - amount - delivery_fees), - ¶_sender_balance_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(relay_receiver_balance_after > relay_receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: relay_receiver_balance_after > relay_receiver_balance_before", - ) - } - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::teleport::limited_teleport_native_assets_from_system_para_to_relay_fails"] - pub const limited_teleport_native_assets_from_system_para_to_relay_fails: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::teleport::limited_teleport_native_assets_from_system_para_to_relay_fails", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", - start_line: 239usize, - start_col: 4usize, - end_line: 239usize, - end_col: 66usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - limited_teleport_native_assets_from_system_para_to_relay_fails(), - ), - ), - }; - /// Limited Teleport of native asset from System Parachain to Relay Chain - /// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` - fn limited_teleport_native_assets_from_system_para_to_relay_fails() { - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let destination = AssetHubWestend::parent_location().into(); - let beneficiary_id = WestendReceiver::get().into(); - let assets = (Parent, amount_to_send).into(); - let test_args = TestContext { - sender: AssetHubWestendSender::get(), - receiver: WestendReceiver::get(), - args: TestArgs::new_para( - destination, - beneficiary_id, - amount_to_send, - assets, - None, - 0, - ), - }; - let mut test = SystemParaToRelayTest::new(test_args); - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - test.set_assertion::(para_origin_assertions); - test.set_assertion::(relay_dest_assertions_fail); - test.set_dispatchable::< - AssetHubWestend, - >(system_para_limited_teleport_assets); - test.assert(); - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - let delivery_fees = AssetHubWestend::execute_with(|| { - xcm_helpers::teleport_assets_delivery_fees::< - ::XcmSender, - >( - test.args.assets.clone(), - 0, - test.args.weight_limit, - test.args.beneficiary, - test.args.dest, - ) - }); - match ( - &(sender_balance_before - amount_to_send - delivery_fees), - &sender_balance_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match (&receiver_balance_after, &receiver_balance_before) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - /// Bidirectional teleports of local Penpal assets to Asset Hub as foreign assets while paying - /// fees using (reserve transferred) native asset. - pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt( - para_to_ah_dispatchable: fn(ParaToSystemParaTest) -> DispatchResult, - ah_to_para_dispatchable: fn(SystemParaToParaTest) -> DispatchResult, - ) { - let fee_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 100; - let asset_location_on_penpal = PenpalLocalTeleportableToAssetHub::get(); - let asset_id_on_penpal = match asset_location_on_penpal.last() { - Some(Junction::GeneralIndex(id)) => *id as u32, - _ => ::core::panicking::panic("internal error: entered unreachable code"), - }; - let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100; - let asset_owner = PenpalAssetOwner::get(); - let system_para_native_asset_location = RelayLocation::get(); - let sender = PenpalASender::get(); - let penpal_check_account = ::PolkadotXcm::check_account(); - let ah_as_seen_by_penpal = PenpalA::sibling_location_of( - AssetHubWestend::para_id(), - ); - let penpal_assets: Assets = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (Parent, fee_amount_to_send).into(), - (asset_location_on_penpal.clone(), asset_amount_to_send).into(), - ]), - ) - .into(); - let fee_asset_index = penpal_assets - .inner() - .iter() - .position(|r| r == &(Parent, fee_amount_to_send).into()) - .unwrap() as u32; - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner.clone()), - system_para_native_asset_location.clone(), - sender.clone(), - fee_amount_to_send * 2, - ); - PenpalA::mint_asset( - ::RuntimeOrigin::signed(asset_owner.clone()), - asset_id_on_penpal, - sender.clone(), - asset_amount_to_send, - ); - PenpalA::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - penpal_check_account.clone().into(), - ASSET_HUB_WESTEND_ED * 1000, - ), - ]), - ), - ); - let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_penpal_on_ah = AssetHubWestend::sovereign_account_id_of( - penpal_as_seen_by_ah, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - sov_penpal_on_ah.clone().into(), - ASSET_HUB_WESTEND_ED * 100_000_000_000, - ), - ]), - ), - ); - let foreign_asset_at_asset_hub_westend = Location::new( - 1, - [Junction::Parachain(PenpalA::para_id().into())], - ) - .appended_with(asset_location_on_penpal) - .unwrap(); - let penpal_to_ah_beneficiary_id = AssetHubWestendReceiver::get(); - let penpal_to_ah_test_args = TestContext { - sender: PenpalASender::get(), - receiver: AssetHubWestendReceiver::get(), - args: TestArgs::new_para( - ah_as_seen_by_penpal, - penpal_to_ah_beneficiary_id, - asset_amount_to_send, - penpal_assets, - Some(asset_id_on_penpal), - fee_asset_index, - ), - }; - let mut penpal_to_ah = ParaToSystemParaTest::new(penpal_to_ah_test_args); - let penpal_sender_balance_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - system_para_native_asset_location.clone(), - &PenpalASender::get(), - ) - }); - let ah_receiver_balance_before = penpal_to_ah.receiver.balance; - let penpal_sender_assets_before = PenpalA::execute_with(|| { - type Assets = ::Assets; - >::balance(asset_id_on_penpal, &PenpalASender::get()) - }); - let ah_receiver_assets_before = AssetHubWestend::execute_with(|| { - type Assets = ::ForeignAssets; - >::balance( - foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), - &AssetHubWestendReceiver::get(), - ) - }); - penpal_to_ah - .set_assertion::(penpal_to_ah_foreign_assets_sender_assertions); - penpal_to_ah - .set_assertion::< - AssetHubWestend, - >(penpal_to_ah_foreign_assets_receiver_assertions); - penpal_to_ah.set_dispatchable::(para_to_ah_dispatchable); - penpal_to_ah.assert(); - let penpal_sender_balance_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - system_para_native_asset_location.clone(), - &PenpalASender::get(), - ) - }); - let ah_receiver_balance_after = penpal_to_ah.receiver.balance; - let penpal_sender_assets_after = PenpalA::execute_with(|| { - type Assets = ::Assets; - >::balance(asset_id_on_penpal, &PenpalASender::get()) - }); - let ah_receiver_assets_after = AssetHubWestend::execute_with(|| { - type Assets = ::ForeignAssets; - >::balance( - foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), - &AssetHubWestendReceiver::get(), - ) - }); - if !(penpal_sender_balance_after < penpal_sender_balance_before) { - ::core::panicking::panic( - "assertion failed: penpal_sender_balance_after < penpal_sender_balance_before", - ) - } - if !(ah_receiver_balance_after > ah_receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: ah_receiver_balance_after > ah_receiver_balance_before", - ) - } - if !(ah_receiver_balance_after - < ah_receiver_balance_before + fee_amount_to_send) - { - ::core::panicking::panic( - "assertion failed: ah_receiver_balance_after < ah_receiver_balance_before + fee_amount_to_send", - ) - } - match ( - &(penpal_sender_assets_before - asset_amount_to_send), - &penpal_sender_assets_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &ah_receiver_assets_after, - &(ah_receiver_assets_before + asset_amount_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - let is = ForeignAssets::transfer( - ::RuntimeOrigin::signed( - AssetHubWestendReceiver::get(), - ), - foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), - AssetHubWestendSender::get().into(), - asset_amount_to_send, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - let ah_to_penpal_beneficiary_id = PenpalAReceiver::get(); - let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let ah_assets: Assets = <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (Parent, fee_amount_to_send).into(), - ( - foreign_asset_at_asset_hub_westend.clone(), - asset_amount_to_send, - ) - .into(), - ]), - ) - .into(); - let fee_asset_index = ah_assets - .inner() - .iter() - .position(|r| r == &(Parent, fee_amount_to_send).into()) - .unwrap() as u32; - let ah_to_penpal_test_args = TestContext { - sender: AssetHubWestendSender::get(), - receiver: PenpalAReceiver::get(), - args: TestArgs::new_para( - penpal_as_seen_by_ah, - ah_to_penpal_beneficiary_id, - asset_amount_to_send, - ah_assets, - Some(asset_id_on_penpal), - fee_asset_index, - ), - }; - let mut ah_to_penpal = SystemParaToParaTest::new(ah_to_penpal_test_args); - let ah_sender_balance_before = ah_to_penpal.sender.balance; - let penpal_receiver_balance_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - system_para_native_asset_location.clone(), - &PenpalAReceiver::get(), - ) - }); - let ah_sender_assets_before = AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), - &AssetHubWestendSender::get(), - ) - }); - let penpal_receiver_assets_before = PenpalA::execute_with(|| { - type Assets = ::Assets; - >::balance(asset_id_on_penpal, &PenpalAReceiver::get()) - }); - ah_to_penpal - .set_assertion::< - AssetHubWestend, - >(ah_to_penpal_foreign_assets_sender_assertions); - ah_to_penpal - .set_assertion::< - PenpalA, - >(ah_to_penpal_foreign_assets_receiver_assertions); - ah_to_penpal.set_dispatchable::(ah_to_para_dispatchable); - ah_to_penpal.assert(); - let ah_sender_balance_after = ah_to_penpal.sender.balance; - let penpal_receiver_balance_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(system_para_native_asset_location, &PenpalAReceiver::get()) - }); - let ah_sender_assets_after = AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance( - foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(), - &AssetHubWestendSender::get(), - ) - }); - let penpal_receiver_assets_after = PenpalA::execute_with(|| { - type Assets = ::Assets; - >::balance(asset_id_on_penpal, &PenpalAReceiver::get()) - }); - if !(ah_sender_balance_after < ah_sender_balance_before) { - ::core::panicking::panic( - "assertion failed: ah_sender_balance_after < ah_sender_balance_before", - ) - } - if !(penpal_receiver_balance_after > penpal_receiver_balance_before) { - ::core::panicking::panic( - "assertion failed: penpal_receiver_balance_after > penpal_receiver_balance_before", - ) - } - if !(penpal_receiver_balance_after - < penpal_receiver_balance_before + fee_amount_to_send) - { - ::core::panicking::panic( - "assertion failed: penpal_receiver_balance_after <\n penpal_receiver_balance_before + fee_amount_to_send", - ) - } - match ( - &(ah_sender_assets_before - asset_amount_to_send), - &ah_sender_assets_after, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &penpal_receiver_assets_after, - &(penpal_receiver_assets_before + asset_amount_to_send), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::teleport::bidirectional_teleport_foreign_assets_between_para_and_asset_hub"] - pub const bidirectional_teleport_foreign_assets_between_para_and_asset_hub: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::teleport::bidirectional_teleport_foreign_assets_between_para_and_asset_hub", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs", - start_line: 527usize, - start_col: 4usize, - end_line: 527usize, - end_col: 68usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result( - bidirectional_teleport_foreign_assets_between_para_and_asset_hub(), - ), - ), - }; - /// Bidirectional teleports of local Penpal assets to Asset Hub as foreign assets should work - /// (using native reserve-based transfer for fees) - fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() { - do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt( - para_to_system_para_transfer_assets, - system_para_to_para_transfer_assets, - ); - } - } - mod treasury { - use crate::imports::*; - use emulated_integration_tests_common::{ - accounts::{ALICE, BOB}, - USDT_ID, - }; - use frame_support::traits::fungibles::{Inspect, Mutate}; - use polkadot_runtime_common::impls::VersionedLocatableAsset; - use xcm_executor::traits::ConvertLocation; - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::treasury::create_and_claim_treasury_spend"] - pub const create_and_claim_treasury_spend: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName( - "tests::treasury::create_and_claim_treasury_spend", - ), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs", - start_line: 26usize, - start_col: 4usize, - end_line: 26usize, - end_col: 35usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(create_and_claim_treasury_spend()), - ), - }; - fn create_and_claim_treasury_spend() { - const SPEND_AMOUNT: u128 = 1_000_000_000; - let treasury_location: Location = Location::new(1, PalletInstance(37)); - let treasury_account = ahw_xcm_config::LocationToAccountId::convert_location( - &treasury_location, - ) - .unwrap(); - let asset_hub_location = Location::new( - 0, - Parachain(AssetHubWestend::para_id().into()), - ); - let root = ::RuntimeOrigin::root(); - let asset_kind = VersionedLocatableAsset::V5 { - location: asset_hub_location, - asset_id: AssetId( - [PalletInstance(50), GeneralIndex(USDT_ID.into())].into(), - ), - }; - let alice: AccountId = Westend::account_id_of(ALICE); - let bob: AccountId = Westend::account_id_of(BOB); - let bob_signed = ::RuntimeOrigin::signed(bob.clone()); - AssetHubWestend::execute_with(|| { - type Assets = ::Assets; - let is = >::mint_into(USDT_ID, &treasury_account, SPEND_AMOUNT * 4); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - match (&>::balance(USDT_ID, &alice), &0u128) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - Westend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type Treasury = ::Treasury; - type AssetRate = ::AssetRate; - let is = AssetRate::create( - root.clone(), - Box::new(asset_kind.clone()), - 2.into(), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = Treasury::spend( - root, - Box::new(asset_kind), - SPEND_AMOUNT, - Box::new( - Location::new(0, Into::<[u8; 32]>::into(alice.clone())).into(), - ), - None, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let is = Treasury::payout(bob_signed.clone(), 0); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. }) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::treasury", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type Assets = ::Assets; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Assets( - pallet_assets::Event::Transferred { - asset_id: id, - from, - to, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(id == &USDT_ID) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "id", - id, - "id == &USDT_ID", - ), - ); - res - }); - } - meet_conditions &= id == &USDT_ID; - if !(from == &treasury_account) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "from", - from, - "from == &treasury_account", - ), - ); - res - }); - } - meet_conditions &= from == &treasury_account; - if !(to == &alice) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "to", - to, - "to == &alice", - ), - ); - res - }); - } - meet_conditions &= to == &alice; - if !(amount == &SPEND_AMOUNT) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "amount == &SPEND_AMOUNT", - ), - ); - res - }); - } - meet_conditions &= amount == &SPEND_AMOUNT; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Assets(pallet_assets::Event::Transferred {\nasset_id: id, from, to, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ParachainSystem( - cumulus_pallet_parachain_system::Event::UpwardMessageSent { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::ParachainSystem(cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::ParachainSystem(cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::MessageQueue( - pallet_message_queue::Event::Processed { success: true, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {\nsuccess: true, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::treasury", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - match ( - &>::balance(USDT_ID, &alice), - &SPEND_AMOUNT, - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - }); - Westend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type Treasury = ::Treasury; - let is = Treasury::check_status(bob_signed, 0); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Treasury( - pallet_treasury::Event::SpendProcessed { .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Westend", - "RuntimeEvent::Treasury(pallet_treasury::Event::SpendProcessed { .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Westend", - "RuntimeEvent::Treasury(pallet_treasury::Event::SpendProcessed { .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Westend", - "asset_hub_westend_integration_tests::tests::treasury", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display( - arg: &T, - ) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - } - mod xcm_fee_estimation { - //! Tests to ensure correct XCM fee estimation for cross-chain asset transfers. - use crate::imports::*; - use frame_support::{ - dispatch::RawOrigin, sp_runtime::{traits::Dispatchable, DispatchResult}, - }; - use xcm_runtime_apis::{ - dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, - fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, - }; - fn sender_assertions(test: ParaToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - PenpalA::assert_xcm_pallet_attempted_complete(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Burned { asset_id, owner, balance }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == Location::new(1, [])) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == Location::new(1, [])", - ), - ); - res - }); - } - meet_conditions &= *asset_id == Location::new(1, []); - if !(*owner == test.sender.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == test.sender.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == test.sender.account_id; - if !(*balance == test.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "balance", - balance, - "*balance == test.args.amount", - ), - ); - res - }); - } - meet_conditions &= *balance == test.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalA", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned {\nasset_id, owner, balance })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "asset_hub_westend_integration_tests::tests::xcm_fee_estimation", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn hop_assertions(test: ParaToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - AssetHubWestend::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::Balances( - pallet_balances::Event::Burned { amount, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*amount == test.args.amount) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == test.args.amount", - ), - ); - res - }); - } - meet_conditions &= *amount == test.args.amount; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { amount, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "AssetHubWestend", - "RuntimeEvent::Balances(pallet_balances::Event::Burned { amount, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::AssetHubWestend", - "asset_hub_westend_integration_tests::tests::xcm_fee_estimation", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn receiver_assertions(test: ParaToParaThroughAHTest) { - type RuntimeEvent = ::RuntimeEvent; - PenpalB::assert_xcmp_queue_success(None); - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::ForeignAssets( - pallet_assets::Event::Issued { asset_id, owner, .. }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == Location::new(1, [])) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == Location::new(1, [])", - ), - ); - res - }); - } - meet_conditions &= *asset_id == Location::new(1, []); - if !(*owner == test.receiver.account_id) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == test.receiver.account_id", - ), - ); - res - }); - } - meet_conditions &= *owner == test.receiver.account_id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "PenpalB", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "PenpalB", - "RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, ..\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalB", - "asset_hub_westend_integration_tests::tests::xcm_fee_estimation", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - fn transfer_assets_para_to_para_through_ah_dispatchable( - test: ParaToParaThroughAHTest, - ) -> DispatchResult { - let call = transfer_assets_para_to_para_through_ah_call(test.clone()); - match call.dispatch(test.signed_origin) { - Ok(_) => Ok(()), - Err(error_with_post_info) => Err(error_with_post_info.error), - } - } - fn transfer_assets_para_to_para_through_ah_call( - test: ParaToParaThroughAHTest, - ) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; - let asset_hub_location: Location = PenpalB::sibling_location_of( - AssetHubWestend::para_id(), - ); - let custom_xcm_on_dest = Xcm::< - (), - >( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - DepositAsset { - assets: Wild(AllCounted(test.args.assets.len() as u32)), - beneficiary: test.args.beneficiary, - }, - ]), - ), - ); - RuntimeCall::PolkadotXcm(pallet_xcm::Call::transfer_assets_using_type_and_then { - dest: Box::new(test.args.dest.into()), - assets: Box::new(test.args.assets.clone().into()), - assets_transfer_type: Box::new( - TransferType::RemoteReserve(asset_hub_location.clone().into()), - ), - remote_fees_id: Box::new( - VersionedAssetId::V5(AssetId(Location::new(1, []))), - ), - fees_transfer_type: Box::new( - TransferType::RemoteReserve(asset_hub_location.into()), - ), - custom_xcm_on_dest: Box::new(VersionedXcm::from(custom_xcm_on_dest)), - weight_limit: test.args.weight_limit, - }) - } - extern crate test; - #[cfg(test)] - #[rustc_test_marker = "tests::xcm_fee_estimation::multi_hop_works"] - pub const multi_hop_works: test::TestDescAndFn = test::TestDescAndFn { - desc: test::TestDesc { - name: test::StaticTestName("tests::xcm_fee_estimation::multi_hop_works"), - ignore: false, - ignore_message: ::core::option::Option::None, - source_file: "cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs", - start_line: 115usize, - start_col: 4usize, - end_line: 115usize, - end_col: 19usize, - compile_fail: false, - no_run: false, - should_panic: test::ShouldPanic::No, - test_type: test::TestType::UnitTest, - }, - testfn: test::StaticTestFn( - #[coverage(off)] - || test::assert_test_result(multi_hop_works()), - ), - }; - /// We are able to dry-run and estimate the fees for a multi-hop XCM journey. - /// Scenario: Alice on PenpalA has some WND and wants to send them to PenpalB. - /// We want to know the fees using the `DryRunApi` and `XcmPaymentApi`. - fn multi_hop_works() { - let destination = PenpalA::sibling_location_of(PenpalB::para_id()); - let sender = PenpalASender::get(); - let amount_to_send = 1_000_000_000_000; - let asset_owner = PenpalAssetOwner::get(); - let assets: Assets = (Parent, amount_to_send).into(); - let relay_native_asset_location = Location::parent(); - let sender_as_seen_by_ah = AssetHubWestend::sibling_location_of( - PenpalA::para_id(), - ); - let sov_of_sender_on_ah = AssetHubWestend::sovereign_account_id_of( - sender_as_seen_by_ah.clone(), - ); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner.clone()), - relay_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (sov_of_sender_on_ah.clone(), amount_to_send * 2), - ]), - ), - ); - let beneficiary_id = PenpalBReceiver::get(); - let test_args = TestContext { - sender: PenpalASender::get(), - receiver: PenpalBReceiver::get(), - args: TestArgs::new_para( - destination, - beneficiary_id.clone(), - amount_to_send, - assets, - None, - 0, - ), - }; - let mut test = ParaToParaThroughAHTest::new(test_args); - let mut delivery_fees_amount = 0; - let mut remote_message = VersionedXcm::V5(Xcm(Vec::new())); - ::execute_with(|| { - type Runtime = ::Runtime; - type OriginCaller = ::OriginCaller; - let call = transfer_assets_para_to_para_through_ah_call(test.clone()); - let origin = OriginCaller::system(RawOrigin::Signed(sender.clone())); - let result = Runtime::dry_run_call(origin, call).unwrap(); - let (destination_to_query, messages_to_query) = &result - .forwarded_xcms - .iter() - .find(|(destination, _)| { - *destination - == VersionedLocation::V5(Location::new(1, [Parachain(1000)])) - }) - .unwrap(); - match (&messages_to_query.len(), &1) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - remote_message = messages_to_query[0].clone(); - let delivery_fees = Runtime::query_delivery_fees( - destination_to_query.clone(), - remote_message.clone(), - ) - .unwrap(); - delivery_fees_amount = get_amount_from_versioned_assets(delivery_fees); - }); - let mut intermediate_execution_fees = 0; - let mut intermediate_delivery_fees_amount = 0; - let mut intermediate_remote_message = VersionedXcm::V5( - Xcm::<()>(Vec::new()), - ); - ::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - let weight = Runtime::query_xcm_weight(remote_message.clone()).unwrap(); - intermediate_execution_fees = Runtime::query_weight_to_asset_fee( - weight, - VersionedAssetId::V5(Location::new(1, []).into()), - ) - .unwrap(); - let xcm_program = VersionedXcm::V5( - Xcm::::from(remote_message.clone().try_into().unwrap()), - ); - let result = Runtime::dry_run_xcm( - sender_as_seen_by_ah.clone().into(), - xcm_program, - ) - .unwrap(); - let (destination_to_query, messages_to_query) = &result - .forwarded_xcms - .iter() - .find(|(destination, _)| { - *destination - == VersionedLocation::V5(Location::new(1, [Parachain(2001)])) - }) - .unwrap(); - intermediate_remote_message = messages_to_query[0].clone(); - let delivery_fees = Runtime::query_delivery_fees( - destination_to_query.clone(), - intermediate_remote_message.clone(), - ) - .unwrap(); - intermediate_delivery_fees_amount = get_amount_from_versioned_assets( - delivery_fees, - ); - }); - let mut final_execution_fees = 0; - ::execute_with(|| { - type Runtime = ::Runtime; - let weight = Runtime::query_xcm_weight( - intermediate_remote_message.clone(), - ) - .unwrap(); - final_execution_fees = Runtime::query_weight_to_asset_fee( - weight, - VersionedAssetId::V5(Parent.into()), - ) - .unwrap(); - }); - PenpalA::reset_ext(); - AssetHubWestend::reset_ext(); - PenpalB::reset_ext(); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - relay_native_asset_location.clone(), - sender.clone(), - amount_to_send * 2, - ); - AssetHubWestend::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([(sov_of_sender_on_ah, amount_to_send * 2)]), - ), - ); - let sender_assets_before = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &sender) - }); - let receiver_assets_before = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &beneficiary_id) - }); - test.set_assertion::(sender_assertions); - test.set_assertion::(hop_assertions); - test.set_assertion::(receiver_assertions); - test.set_dispatchable::< - PenpalA, - >(transfer_assets_para_to_para_through_ah_dispatchable); - test.assert(); - let sender_assets_after = PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location.clone(), &sender) - }); - let receiver_assets_after = PenpalB::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(relay_native_asset_location, &beneficiary_id) - }); - match ( - &sender_assets_after, - &(sender_assets_before - amount_to_send - delivery_fees_amount), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - match ( - &receiver_assets_after, - &(receiver_assets_before + amount_to_send - intermediate_execution_fees - - intermediate_delivery_fees_amount - final_execution_fees), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - } - } -} -#[rustc_main] -#[coverage(off)] -pub fn main() -> () { - extern crate test; - test::test_main_static( - &[ - &assets_can_be_claimed, - &create_and_claim_treasury_spend, - &bidirectional_teleport_foreign_asset_between_para_and_asset_hub_using_explicit_transfer_types, - &transfer_foreign_assets_from_asset_hub_to_para, - &transfer_foreign_assets_from_para_to_asset_hub, - &transfer_foreign_assets_from_para_to_para_through_asset_hub, - &transfer_native_asset_from_relay_to_para_through_asset_hub, - &reserve_transfer_multiple_assets_from_asset_hub_to_para, - &reserve_transfer_multiple_assets_from_para_to_asset_hub, - &reserve_transfer_native_asset_from_asset_hub_to_para, - &reserve_transfer_native_asset_from_asset_hub_to_relay_fails, - &reserve_transfer_native_asset_from_para_to_asset_hub, - &reserve_transfer_native_asset_from_para_to_para_through_relay, - &reserve_transfer_native_asset_from_para_to_relay, - &reserve_transfer_native_asset_from_relay_to_asset_hub_fails, - &reserve_transfer_native_asset_from_relay_to_para, - &send_transact_as_superuser_from_relay_to_asset_hub_works, - &send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset, - &send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset, - &relay_sets_system_para_xcm_supported_version, - &system_para_sets_relay_xcm_supported_version, - &cannot_create_pool_from_pool_assets, - &pay_xcm_fee_with_some_asset_swapped_for_native, - &swap_locally_on_chain_using_foreign_assets, - &swap_locally_on_chain_using_local_assets, - &bidirectional_teleport_foreign_assets_between_para_and_asset_hub, - &limited_teleport_native_assets_from_system_para_to_relay_fails, - &teleport_from_and_to_relay, - &teleport_to_other_system_parachains_works, - &create_and_claim_treasury_spend, - &multi_hop_works, - ], - ) -} diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index d5ffb26ddb57..4313ea8c561a 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -29,7 +29,7 @@ use frame_support::{ use sp_core::defer; use sp_io::hashing::blake2_128; use sp_weights::Weight; -use xcm::{latest::prelude::*, v3::MultiLocation}; +use xcm::latest::prelude::*; pub mod traits; use traits::{ From d8c4651c1787c3f02c78d1de2f7afc3f42f3e5f5 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 10:02:18 +0300 Subject: [PATCH 118/151] added missing fn definition to trait --- polkadot/xcm/pallet-xcm/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 6451901279b1..b10cc223aacf 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -96,6 +96,7 @@ pub trait WeightInfo { fn new_query() -> Weight; fn take_response() -> Weight; fn claim_assets() -> Weight; + fn set_asset_claimer() -> Weight; } /// fallback implementation From c44584f7853bae5c4ac7ba4960fc86d46bd7c8f5 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 10:13:01 +0300 Subject: [PATCH 119/151] added westhub sac weights --- .../assets/asset-hub-westend/src/weights/pallet_xcm.rs | 4 ++++ polkadot/xcm/pallet-xcm/src/lib.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs index be3d7661ab3c..c67b4896df0b 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs @@ -393,4 +393,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index b10cc223aacf..1543279059b4 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -181,6 +181,10 @@ impl WeightInfo for TestWeightInfo { fn claim_assets() -> Weight { Weight::from_parts(100_000_000, 0) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } #[frame_support::pallet] From 7d1c21fcbe4ef79cd6da0227830776fc04a74b15 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 10:27:29 +0300 Subject: [PATCH 120/151] removed unused sender_account --- polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 5d1d643d828c..ffa0a7c302c1 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -115,7 +115,7 @@ benchmarks! { set_asset_claimer { let mut executor = new_executor::(Default::default()); - let (sender_account, sender_location) = account_and_location::(1); + let (_, sender_location) = account_and_location::(1); let instruction = Instruction::SetAssetClaimer{ location:sender_location.clone() }; From 9920ddf0a78eb8f760f8b2fe77d3b9193b87008d Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 10:41:39 +0300 Subject: [PATCH 121/151] added sac to people-westend --- .../runtimes/people/people-westend/src/weights/pallet_xcm.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs index c337289243b7..3edcdbd5c4db 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs @@ -343,4 +343,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } From fc997ecb32d6b04cf7b8ece5dc1fe44bb0dd04b6 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 10:51:55 +0300 Subject: [PATCH 122/151] added sac to runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs --- .../collectives/collectives-westend/src/weights/pallet_xcm.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs index 5d427d850046..9206943997c1 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs @@ -373,4 +373,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } From 2135b589b59b20230810782d436cc42ef172cb48 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 10:57:54 +0300 Subject: [PATCH 123/151] added sac to rococo runtime --- polkadot/runtime/rococo/src/weights/pallet_xcm.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs index 5544ca44658c..b40725240b02 100644 --- a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs @@ -346,4 +346,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } From 687271afca2844cabd41ea6a9c925e099261fbc1 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 11:15:06 +0300 Subject: [PATCH 124/151] added sac to all the weights/xcm_pallet --- .../assets/asset-hub-rococo/src/weights/pallet_xcm.rs | 4 ++++ .../bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs | 4 ++++ .../bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs | 4 ++++ .../coretime/coretime-rococo/src/weights/pallet_xcm.rs | 4 ++++ .../coretime/coretime-westend/src/weights/pallet_xcm.rs | 4 ++++ .../runtimes/people/people-rococo/src/weights/pallet_xcm.rs | 4 ++++ polkadot/runtime/rococo/src/weights/pallet_xcm.rs | 5 ++++- 7 files changed, 28 insertions(+), 1 deletion(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs index 51b6543bae82..ca96284b5c52 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs @@ -395,4 +395,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs index a732e1a57343..e37ec773deef 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs @@ -373,4 +373,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs index a78ff2355efa..722ebe3443ba 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs @@ -373,4 +373,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs index 7fb492173dad..24baf0b9ff0e 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs @@ -361,4 +361,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs index fa588e982f09..3736dc14c623 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs @@ -361,4 +361,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs index fabce29b5fd9..dfbbec08ee8f 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs @@ -343,4 +343,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_asset_claimer() -> Weight { + Weight::from_parts(2_176_000, 0) + } } diff --git a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs index b40725240b02..a8049ab13252 100644 --- a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs @@ -348,6 +348,9 @@ impl pallet_xcm::WeightInfo for WeightInfo { } fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + Weight::from_parts(35_299_000, 0) + .saturating_add(Weight::from_parts(0, 3488)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } } From 582a397fdaae4e866379a95fd786dd2603d1d615 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 11:39:13 +0300 Subject: [PATCH 125/151] added _ to all the unused location --- .../runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs | 2 +- .../runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs | 2 +- .../bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs | 2 +- .../bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs | 2 +- .../runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs | 2 +- .../runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs | 2 +- .../runtimes/people/people-rococo/src/weights/xcm/mod.rs | 2 +- .../runtimes/people/people-westend/src/weights/xcm/mod.rs | 2 +- polkadot/runtime/rococo/src/weights/xcm/mod.rs | 2 +- polkadot/runtime/westend/src/weights/xcm/mod.rs | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index 31dcbfaf5b7c..83261140b01d 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -153,7 +153,7 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } - fn set_asset_claimer(location: &Location) -> Weight { + fn set_asset_claimer(_location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 758f024cbb9e..68995d76adb9 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -153,7 +153,7 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } - fn set_asset_claimer(location: &Location) -> Weight { + fn set_asset_claimer(_location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs index 2493d93bc2bf..5706f23f74e1 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs @@ -234,7 +234,7 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - fn set_asset_claimer(location: &Location) -> Weight { + fn set_asset_claimer(_location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index 35a9bdd908a9..84d9263d6432 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -156,7 +156,7 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { XcmGeneric::::clear_error() } - fn set_asset_claimer(location: &Location) -> Weight { + fn set_asset_claimer(_location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs index 31ff0440fd9a..d174942e0a8c 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs @@ -232,7 +232,7 @@ impl XcmWeightInfo for CoretimeRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - fn set_asset_claimer(location: &Location) -> Weight { + fn set_asset_claimer(_location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs index ccaffc946b2c..16e2e2e1c45f 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs @@ -153,7 +153,7 @@ impl XcmWeightInfo for CoretimeWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } - fn set_asset_claimer(location: &Location) -> Weight { + fn set_asset_claimer(_location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs index 2b4b1e367f16..c8b231df8c49 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs @@ -231,7 +231,7 @@ impl XcmWeightInfo for PeopleRococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - fn set_asset_claimer(location: &Location) -> Weight { + fn set_asset_claimer(_location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs index 19cc8e3f1061..bdf1e58d7b4b 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs @@ -231,7 +231,7 @@ impl XcmWeightInfo for PeopleWestendXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - fn set_asset_claimer(location: &Location) -> Weight { + fn set_asset_claimer(_location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } } diff --git a/polkadot/runtime/rococo/src/weights/xcm/mod.rs b/polkadot/runtime/rococo/src/weights/xcm/mod.rs index 0d2cc309d6d9..128e07a49824 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/mod.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/mod.rs @@ -270,7 +270,7 @@ impl XcmWeightInfo for RococoXcmWeight { XcmGeneric::::unpaid_execution() } - fn set_asset_claimer(location: &Location) -> Weight { + fn set_asset_claimer(_location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } } diff --git a/polkadot/runtime/westend/src/weights/xcm/mod.rs b/polkadot/runtime/westend/src/weights/xcm/mod.rs index b0f7c18fee35..93e8227df77c 100644 --- a/polkadot/runtime/westend/src/weights/xcm/mod.rs +++ b/polkadot/runtime/westend/src/weights/xcm/mod.rs @@ -188,7 +188,7 @@ impl XcmWeightInfo for WestendXcmWeight { XcmGeneric::::clear_error() } - fn set_asset_claimer(location: &Location) -> Weight { + fn set_asset_claimer(_location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } From 9ad82b7e2e3c7f018f82bd3a59782aef93f7089a Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Thu, 5 Sep 2024 09:38:48 +0000 Subject: [PATCH 126/151] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=westend --target_dir=polkadot --pallet=pallet_xcm_benchmarks::generic --- .../xcm/pallet_xcm_benchmarks_generic.rs | 120 +++++++++--------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index f35636a79a4f..2ad1cd6359a6 100644 --- a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -63,8 +63,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6196` - // Minimum execution time: 67_863_000 picoseconds. - Weight::from_parts(70_014_000, 6196) + // Minimum execution time: 67_813_000 picoseconds. + Weight::from_parts(69_357_000, 6196) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -72,22 +72,22 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 695_000 picoseconds. - Weight::from_parts(755_000, 0) + // Minimum execution time: 716_000 picoseconds. + Weight::from_parts(780_000, 0) } pub(crate) fn pay_fees() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_703_000 picoseconds. - Weight::from_parts(1_839_000, 0) + // Minimum execution time: 1_601_000 picoseconds. + Weight::from_parts(1_680_000, 0) } pub(crate) fn set_asset_claimer() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 678_000 picoseconds. - Weight::from_parts(712_000, 0) + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } /// Storage: `XcmPallet::Queries` (r:1 w:0) /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -95,58 +95,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3465` - // Minimum execution time: 6_470_000 picoseconds. - Weight::from_parts(6_722_000, 3465) + // Minimum execution time: 6_574_000 picoseconds. + Weight::from_parts(6_790_000, 3465) .saturating_add(T::DbWeight::get().reads(1)) } pub(crate) fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_178_000 picoseconds. - Weight::from_parts(7_447_000, 0) + // Minimum execution time: 7_232_000 picoseconds. + Weight::from_parts(7_422_000, 0) } pub(crate) fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_236_000 picoseconds. - Weight::from_parts(1_326_000, 0) + // Minimum execution time: 1_180_000 picoseconds. + Weight::from_parts(1_250_000, 0) } pub(crate) fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 704_000 picoseconds. - Weight::from_parts(746_000, 0) + // Minimum execution time: 702_000 picoseconds. + Weight::from_parts(766_000, 0) } pub(crate) fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 729_000 picoseconds. - Weight::from_parts(768_000, 0) + // Minimum execution time: 700_000 picoseconds. + Weight::from_parts(757_000, 0) } pub(crate) fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 685_000 picoseconds. - Weight::from_parts(738_000, 0) + // Minimum execution time: 686_000 picoseconds. + Weight::from_parts(751_000, 0) } pub(crate) fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 736_000 picoseconds. - Weight::from_parts(776_000, 0) + // Minimum execution time: 705_000 picoseconds. + Weight::from_parts(765_000, 0) } pub(crate) fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 700_000 picoseconds. - Weight::from_parts(756_000, 0) + // Minimum execution time: 687_000 picoseconds. + Weight::from_parts(741_000, 0) } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -162,8 +162,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6196` - // Minimum execution time: 65_431_000 picoseconds. - Weight::from_parts(66_937_000, 6196) + // Minimum execution time: 65_398_000 picoseconds. + Weight::from_parts(67_140_000, 6196) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -173,8 +173,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `23` // Estimated: `3488` - // Minimum execution time: 9_667_000 picoseconds. - Weight::from_parts(10_074_000, 3488) + // Minimum execution time: 9_653_000 picoseconds. + Weight::from_parts(9_944_000, 3488) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -182,8 +182,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 684_000 picoseconds. - Weight::from_parts(719_000, 0) + // Minimum execution time: 698_000 picoseconds. + Weight::from_parts(759_000, 0) } /// Storage: `XcmPallet::VersionNotifyTargets` (r:1 w:1) /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -199,8 +199,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `147` // Estimated: `3612` - // Minimum execution time: 30_607_000 picoseconds. - Weight::from_parts(31_576_000, 3612) + // Minimum execution time: 31_300_000 picoseconds. + Weight::from_parts(31_989_000, 3612) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -210,44 +210,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_833_000 picoseconds. - Weight::from_parts(2_989_000, 0) + // Minimum execution time: 2_863_000 picoseconds. + Weight::from_parts(3_027_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub(crate) fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_131_000 picoseconds. - Weight::from_parts(1_205_000, 0) + // Minimum execution time: 1_046_000 picoseconds. + Weight::from_parts(1_125_000, 0) } pub(crate) fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 845_000 picoseconds. - Weight::from_parts(887_000, 0) + // Minimum execution time: 811_000 picoseconds. + Weight::from_parts(871_000, 0) } pub(crate) fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 713_000 picoseconds. - Weight::from_parts(753_000, 0) + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(741_000, 0) } pub(crate) fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 705_000 picoseconds. - Weight::from_parts(742_000, 0) + // Minimum execution time: 687_000 picoseconds. + Weight::from_parts(741_000, 0) } pub(crate) fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 876_000 picoseconds. - Weight::from_parts(920_000, 0) + // Minimum execution time: 861_000 picoseconds. + Weight::from_parts(931_000, 0) } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -263,8 +263,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6196` - // Minimum execution time: 74_354_000 picoseconds. - Weight::from_parts(76_278_000, 6196) + // Minimum execution time: 74_622_000 picoseconds. + Weight::from_parts(77_059_000, 6196) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -272,8 +272,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_316_000 picoseconds. - Weight::from_parts(7_553_000, 0) + // Minimum execution time: 7_603_000 picoseconds. + Weight::from_parts(7_871_000, 0) } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -289,8 +289,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6196` - // Minimum execution time: 65_391_000 picoseconds. - Weight::from_parts(67_302_000, 6196) + // Minimum execution time: 65_617_000 picoseconds. + Weight::from_parts(66_719_000, 6196) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -298,35 +298,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 728_000 picoseconds. - Weight::from_parts(790_000, 0) + // Minimum execution time: 738_000 picoseconds. + Weight::from_parts(779_000, 0) } pub(crate) fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 671_000 picoseconds. - Weight::from_parts(715_000, 0) + // Minimum execution time: 688_000 picoseconds. + Weight::from_parts(755_000, 0) } pub(crate) fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 670_000 picoseconds. - Weight::from_parts(725_000, 0) + // Minimum execution time: 684_000 picoseconds. + Weight::from_parts(722_000, 0) } pub(crate) fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 677_000 picoseconds. - Weight::from_parts(739_000, 0) + // Minimum execution time: 694_000 picoseconds. + Weight::from_parts(738_000, 0) } pub(crate) fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 705_000 picoseconds. - Weight::from_parts(770_000, 0) + // Minimum execution time: 713_000 picoseconds. + Weight::from_parts(776_000, 0) } } From b02c831a32574bca730c813c942def39770e890b Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 13:06:18 +0300 Subject: [PATCH 127/151] fixed e2e tests --- .../asset-hub-westend/src/tests/set_asset_claimer.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 01ba9ca9d0f7..9742bb8b5c75 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -15,15 +15,14 @@ //! Tests related to claiming assets trapped during XCM execution. -use emulated_integration_tests_common::accounts::{ALICE, BOB, CHARLIE}; +use emulated_integration_tests_common::accounts::{ALICE, BOB}; use emulated_integration_tests_common::impls::AccountId32; use crate::{ imports::*, }; use frame_support::{ - dispatch::RawOrigin, - sp_runtime::{traits::Dispatchable, DispatchResult}, + sp_runtime::{traits::Dispatchable}, }; #[test] fn test_set_asset_claimer_within_a_chain() { @@ -52,7 +51,7 @@ fn test_set_asset_claimer_within_a_chain() { 0, ), }; - let mut test = ParaToParaThroughAHTest::new(test_args); + let test = ParaToParaThroughAHTest::new(test_args); execute_test(test.clone(), bob_location.clone(), transfer_assets); let alice_assets_after = query_balance(&alice_account, &native_asset_location); @@ -70,7 +69,7 @@ fn test_set_asset_claimer_within_a_chain() { 0, ), }; - let mut test = ParaToParaThroughAHTest::new(test_args); + let test = ParaToParaThroughAHTest::new(test_args); execute_test(test.clone(), bob_location.clone(), claim_assets); let bob_assets_after = query_balance(&bob_account, &native_asset_location); From 660cfcc148c94aaa29b57e03c51b929ea53d7a52 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 5 Sep 2024 13:39:55 +0300 Subject: [PATCH 128/151] changed benchmark values for all the set_asset_claimers --- .../assets/asset-hub-rococo/src/weights/pallet_xcm.rs | 6 +++++- .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 6 +++++- .../assets/asset-hub-westend/src/weights/pallet_xcm.rs | 6 +++++- .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 6 +++++- .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 6 +++++- .../bridge-hub-westend/src/weights/pallet_xcm.rs | 6 +++++- .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 6 +++++- .../collectives-westend/src/weights/pallet_xcm.rs | 6 +++++- .../coretime/coretime-rococo/src/weights/pallet_xcm.rs | 6 +++++- .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 6 +++++- .../coretime/coretime-westend/src/weights/pallet_xcm.rs | 6 +++++- .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 6 +++++- .../runtimes/people/people-rococo/src/weights/pallet_xcm.rs | 6 +++++- .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 6 +++++- .../people/people-westend/src/weights/pallet_xcm.rs | 6 +++++- .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 6 +++++- .../rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 6 +++++- 17 files changed, 85 insertions(+), 17 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs index ca96284b5c52..1870bd223fb8 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs @@ -397,6 +397,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { } fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index b20dba8a8ab9..dffba55523a2 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -147,7 +147,11 @@ impl WeightInfo { Weight::from_parts(780_000, 0) } pub fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs index c67b4896df0b..1f4e39db7c9d 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs @@ -395,6 +395,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { } fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 8f03695c0d1e..8651fd4e4217 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -360,6 +360,10 @@ impl WeightInfo { Weight::from_parts(773_000, 0) } pub fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 282914840087..b8bd4c4e2d44 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -374,6 +374,10 @@ impl WeightInfo { Weight::from_parts(1_161_000, 0) } pub fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs index 722ebe3443ba..47ce66716ef0 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs @@ -375,6 +375,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { } fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index ddbfb3ebfee3..849456af9255 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -374,6 +374,10 @@ impl WeightInfo { Weight::from_parts(1_060_000, 0) } pub fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs index 9206943997c1..c95698ba4a73 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs @@ -375,6 +375,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { } fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs index 24baf0b9ff0e..7fcf795fa4b3 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs @@ -363,6 +363,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { } fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 40321fa0261b..229dafb7c5ed 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -332,6 +332,10 @@ impl WeightInfo { Weight::from_parts(673_000, 0) } pub fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs index 3736dc14c623..ed1f303da6c9 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs @@ -363,6 +363,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { } fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 98f31390c666..bd70bc4f4bd9 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -332,6 +332,10 @@ impl WeightInfo { Weight::from_parts(659_000, 0) } pub fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs index dfbbec08ee8f..8ceb4c57a9b7 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs @@ -345,6 +345,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { } fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index a03267080c12..30e28fac7e57 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -332,6 +332,10 @@ impl WeightInfo { Weight::from_parts(757_000, 0) } pub fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs index 3edcdbd5c4db..6b2f86551543 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs @@ -345,6 +345,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { } fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index b4f067dbe9b8..3c539902abc8 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -332,6 +332,10 @@ impl WeightInfo { Weight::from_parts(655_000, 0) } pub fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } diff --git a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 84a9a7ce5851..677640b45331 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -323,6 +323,10 @@ impl WeightInfo { Weight::from_parts(845_000, 0) } pub(crate) fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 707_000 picoseconds. + Weight::from_parts(749_000, 0) } } From 5ac4e7efca4936858b6ede34e30486855a944c5d Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 18 Sep 2024 11:05:04 +0200 Subject: [PATCH 129/151] WIP: multi-chain set asset claimer test --- .../parachains/testing/penpal/src/lib.rs | 1 + .../tests/assets/asset-hub-westend/src/lib.rs | 2 + .../assets/asset-hub-westend/src/tests/mod.rs | 1 + .../src/tests/set_asset_claimer.rs | 287 +- .../src/tests/set_asset_claimer_multichain.rs | 317 ++ .../bridge-hub-westend/src/xcm_config.rs | 13 +- .../runtimes/testing/penpal/src/xcm_config.rs | 2 +- expansion.rs | 4772 +++++++++++++++++ polkadot/xcm/xcm-executor/src/lib.rs | 3 - 9 files changed, 5376 insertions(+), 22 deletions(-) create mode 100644 cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer_multichain.rs create mode 100644 expansion.rs diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs index 92dfa30f2e83..b7364856f21a 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs @@ -50,6 +50,7 @@ decl_test_parachains! { MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, }, pallets = { + System: penpal_runtime::System, PolkadotXcm: penpal_runtime::PolkadotXcm, Assets: penpal_runtime::Assets, ForeignAssets: penpal_runtime::ForeignAssets, diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs index f568fb4101db..b02deb456eef 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs @@ -98,6 +98,8 @@ mod imports { pub type ParaToParaThroughRelayTest = Test; pub type ParaToParaThroughAHTest = Test; pub type RelayToParaThroughAHTest = Test; + pub type BridgeToAssetHubTest = Test; + pub type AssetHubToBridgeHubTest = Test; } #[cfg(test)] diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs index 089f899696bb..8ab45abc373e 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs @@ -24,3 +24,4 @@ mod teleport; mod treasury; mod xcm_fee_estimation; mod set_asset_claimer; +mod set_asset_claimer_multichain; diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 9742bb8b5c75..794133ba6e5e 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -15,20 +15,33 @@ //! Tests related to claiming assets trapped during XCM execution. -use emulated_integration_tests_common::accounts::{ALICE, BOB}; +use emulated_integration_tests_common::accounts::{ALICE, BOB, CHARLIE}; use emulated_integration_tests_common::impls::AccountId32; +use emulated_integration_tests_common::xcm_emulator::log; use crate::{ imports::*, }; -use frame_support::{ - sp_runtime::{traits::Dispatchable}, -}; +use frame_support::{sp_runtime::{traits::Dispatchable}, assert_ok, LOG_TARGET}; +use westend_system_emulated_network::penpal_emulated_chain::penpal_runtime; +use westend_system_emulated_network::asset_hub_westend_emulated_chain::asset_hub_westend_runtime; +use westend_system_emulated_network::westend_emulated_chain::westend_runtime::xcm_config::AssetHub; +use crate::imports::ahw_xcm_config::UniversalLocation; + #[test] fn test_set_asset_claimer_within_a_chain() { let (alice_account, alice_location) = account_and_location(ALICE); let (bob_account, bob_location) = account_and_location(BOB); + PenpalA::execute_with(|| { + type System = ::System; + type RuntimeOrigin = ::RuntimeOrigin; + assert_ok!(System::set_storage( + RuntimeOrigin::root(), + vec![(penpal_runtime::xcm_config::RelayNetworkId::key().to_vec(), NetworkId::Westend.encode())] + )); + }); + let amount_to_send = 16_000_000_000_000; let native_asset_location = RelayLocation::get(); let assets: Assets = (Parent, amount_to_send).into(); @@ -76,13 +89,251 @@ fn test_set_asset_claimer_within_a_chain() { assert_eq!(bob_assets_after, amount_to_send); } -fn account_and_location(account: &str) -> (AccountId32, Location) { - let account_id = PenpalA::account_id_of(account); +fn transfer_assets_ah( + test: SystemParaToParaTest, + claimer: Location +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; + + let local_xcm = Xcm::::builder_unsafe() + .set_asset_claimer(claimer.clone()) + .withdraw_asset(test.args.assets.clone()) + .clear_origin() + .build(); + + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(4_000_000_000_000, 300_000), + }) +} + +#[test] +fn test_set_asset_claimer_on_ah() { + log::error!("anything_error"); + println!("printlined_error"); + + let alice = AssetHubWestend::account_id_of(ALICE); + let alice_location = Location::new(0, Junction::AccountId32 { network: None, id: alice.clone().into() }); + let assets: Assets = (Parent, 1000u128).into(); + // let alice_on_asset_hub = Location::new(1, [Parachain(1000), Junction::AccountId32 { id: [67u8; 32], network: Some(Westend) }]); + + + let bob_on_penpal = Location::new( + 1, + [ + Parachain(PenpalA::para_id().into()), + Junction::AccountId32 { + network: None, + id: PenpalA::account_id_of(BOB).into()}], + ); + println!("PenpalA:: sender is {:?}", PenpalASender::get()); + println!("BOB on PenpalA: {:?}", bob_on_penpal); + // let bob_acc = AssetHubWestend::sovereign_account_id_of(PenpalASender::); + + let amount_to_send = 16_000_000_000_000u128; + let alice_acc = AssetHubWestend::account_id_of(ALICE); + AssetHubWestend::fund_accounts(vec![( + alice_acc.clone(), + amount_to_send * 2, + )]); + + let balance = ::account_data_of(alice_acc.clone()).free; + println!("alice balance {:?}", balance); + + let test_args = TestContext { + sender: alice_acc.clone(), + receiver: alice_acc.clone(), + args: TestArgs::new_para( + alice_location.clone(), + alice_acc.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let test = SystemParaToParaTest::new(test_args); + execute_ah_test(test.clone(), bob_on_penpal.clone(), transfer_assets_ah); + + + + let balance = ::account_data_of(alice_acc.clone()).free; + println!("alice balance after {:?}", balance); + + + + + // let bob_ah_from_bh = BridgeHubWestend::sovereign_account_id_of(Location::new( + // 1, + // [Parachain(AssetHubWestend::para_id().into()), Junction::AccountId32 {network: Some(Westend), id: AssetHubWestend::account_id_of(BOB).into()}], + // )); + // let alice_sov_account_on_bridge_hub = BridgeHubWestend::sovereign_account_id_of(alice_on_asset_hub); + // println!("alice_sov_account_on_bridge_hub {:?}", alice_sov_account_on_bridge_hub); + + // let (alice_account, alice_location) = account_and_location_ah(ALICE); + // let (bob_account, bob_location) = account_and_location_ah(BOB); + + + + + // PenpalA::execute_with(|| { + // type System = ::System; + // type RuntimeOrigin = ::RuntimeOrigin; + // assert_ok!(System::set_storage( + // RuntimeOrigin::root(), + // vec![(penpal_runtime::xcm_config::RelayNetworkId::key().to_vec(), NetworkId::Westend.encode())] + // )); + // }); + // + + // log::trace!("alice account: {}" , alice_account); + + let amount_to_send = 16_000_000_000_000u128; + let alice_acc = ::account_id_of(ALICE); + // Fund accounts. + AssetHubWestend::fund_accounts(vec![( + alice_acc.clone(), + amount_to_send * 2, + )]); + let balance = ::account_data_of(alice_acc.clone()).free; + println!("alice balance {:?}", balance); + // AssetHubWestend::execute_with(||{ + // }); + + let assets: Assets = (Parent, amount_to_send).into(); + let alice: AccountId = AssetHubWestend::account_id_of(ALICE); + + + let alice_signed = ::RuntimeOrigin::signed(alice.clone()); + // let bridge_hub = AssetHubWestend::sibling_location_of(BridgeHubWestend::para_id()).into(); + let xcm = Xcm::<()>::builder_unsafe() + .claim_asset(assets.clone(), Here) + .pay_fees(Asset { id: AssetId(Location::new(1, [])), fun: Fungibility::Fungible(1_000_000u128) }) + .build(); + // let bridge_hub = Location::new(1, Parachain(1002)); + + let bob_acc = ::account_id_of(BOB); + let bob_location = Location::new(0, Junction::AccountId32 { network: None, id: bob_acc.clone().into() }); + + + + // let xcm = Xcm::<()>::builder_unsafe() + // .buy_execution((Parent, 100u128), WeightLimit::Unlimited) + // // .pay_fees(Asset { id: AssetId(Location::new(1, [])), fun: Fungibility::Fungible(1_000u128) }) + // // .set_asset_claimer(bob_location) + // .build(); + + // AssetHubWestend::execute_with(|| { + // assert_ok!(::PolkadotXcm::send( + // alice_signed, + // bx!(bridge_hub), + // bx!(VersionedXcm::from(xcm)), + // )); + // // AssetHubWestend::assert_xcm_pallet_sent(); + // }); + + + + // BridgeHubWestend::execute_with(|| { + // type Balances = ::Balances; + // + // dbg!(&Balances::free_balance(&alice_sov_account_on_bridge_hub)); + // }); + // // let bob_account = BridgeHubWestend::sibling_location_of(AssetHubWestend::account_id_of(BOB)).into(); + // + // BridgeHubWestend::fund_accounts(vec![( + // alice_from_bh.clone(), + // amount_to_send * 2, + // )]); + + + + // BH + // 1. add assets to AccountId {parent 1, Chainid (1002 or 1000) Alice + + // let native_asset_location = RelayLocation::get(); + // let alice_assets_before = query_ah_balance(&alice_account, &native_asset_location); + // assert_eq!(alice_assets_before, amount_to_send * 2); + // log::debug!("{}" ,alice_assets_before); + + // let test_args = TestContext { + // sender: alice_account.clone(), + // receiver: bob_account.clone(), + // args: TestArgs::new_para( + // bob_location.clone(), + // bob_account.clone(), + // amount_to_send, + // assets.clone(), + // None, + // 0, + // ), + // }; + // let test = ParaToParaThroughAHTest::new(test_args); + // execute_test(test.clone(), bob_location.clone(), transfer_assets_to_ah); + + // let alice_assets_after = query_balance(&alice_account, &native_asset_location); + // assert_eq!(alice_assets_after, amount_to_send); + + + // let test_args = TestContext { + // sender: bob_account.clone(), + // receiver: alice_account.clone(), + // args: TestArgs::new_para( + // alice_location.clone(), + // alice_account.clone(), + // amount_to_send, + // assets.clone(), + // None, + // 0, + // ), + // }; + // let test = ParaToParaThroughAHTest::new(test_args); + // execute_test(test.clone(), bob_location.clone(), claim_assets); + // + // let bob_assets_after = query_balance(&bob_account, &native_asset_location); + // assert_eq!(bob_assets_after, amount_to_send); +} + +fn transfer_assets_to_ah( + test: ParaToParaThroughAHTest, + claimer: Location +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; + + + let xcm_in_reserve = Xcm::::builder_unsafe() + .set_asset_claimer(claimer.clone()) + .withdraw_asset(test.args.assets) + .build(); + + let fee_asset: Asset = (Location::parent(), 1_000_000u128).into(); + + + // let local_xcm = Xcm::::builder_unsafe() + // .set_asset_claimer(claimer.clone()) + // .initiate_reserve_withdraw(fee_asset.clone(), Location::parent(), xcm_in_reserve) + // .build(); + + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(xcm_in_reserve)), + max_weight: Weight::from_parts(4_000_000_000_000, 300_000), + }) +} + +fn account_and_location_ah(account: &str) -> (AccountId32, Location) { + let account_id = AssetHubWestend::account_id_of(account); let clone = account_id.clone(); - let location: Location = [Junction::AccountId32 { network: Some(Rococo), id: account_id.into() }].into(); + let location: Location = [Junction::AccountId32 { network: Some(Westend), id: account_id.into() }].into(); (clone, location) } +fn account_and_location(account: &str) -> (AccountId32, Location) { + let account_id = PenpalA::account_id_of(account); + let account_clone = account_id.clone(); + let location: Location = [Junction::AccountId32 { network: Some(Westend), id: account_id.into() }].into(); + (account_clone, location) +} + fn fund_account(account: &AccountId, amount: u128) { let asset_owner = PenpalAssetOwner::get(); PenpalA::mint_foreign_asset( @@ -93,6 +344,13 @@ fn fund_account(account: &AccountId, amount: u128) { ); } +fn query_ah_balance(account: &AccountId, asset_location: &Location) -> u128 { + AssetHubWestend::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(asset_location.clone(), account) + }) +} + fn query_balance(account: &AccountId, asset_location: &Location) -> u128 { PenpalA::execute_with(|| { type ForeignAssets = ::ForeignAssets; @@ -100,12 +358,23 @@ fn query_balance(account: &AccountId, asset_location: &Location) -> u128 { }) } +fn execute_ah_test( + test: SystemParaToParaTest, + claimer: Location, + xcm_fn: impl Fn(SystemParaToParaTest, Location) -> ::RuntimeCall, +) { + let call = xcm_fn(test.clone(), claimer.clone()); + AssetHubWestend::execute_with(|| { + assert!(call.dispatch(test.signed_origin).is_ok()); + }); +} + fn execute_test( test: ParaToParaThroughAHTest, - location: Location, + claimer: Location, xcm_fn: impl Fn(ParaToParaThroughAHTest, Location) -> ::RuntimeCall, ) { - let call = xcm_fn(test.clone(), location.clone()); + let call = xcm_fn(test.clone(), claimer.clone()); PenpalA::execute_with(|| { assert!(call.dispatch(test.signed_origin).is_ok()); }); diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer_multichain.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer_multichain.rs new file mode 100644 index 000000000000..c6fba3d041fb --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer_multichain.rs @@ -0,0 +1,317 @@ +use emulated_integration_tests_common::accounts::{ALICE, BOB, CHARLIE}; +use emulated_integration_tests_common::impls::AccountId32; +use emulated_integration_tests_common::xcm_emulator::log; +use crate::{ + imports::*, +}; + +use frame_support::{sp_runtime::{traits::Dispatchable}, assert_ok, LOG_TARGET}; +use westend_system_emulated_network::asset_hub_westend_emulated_chain::asset_hub_westend_runtime; +use westend_system_emulated_network::bridge_hub_westend_emulated_chain::BridgeHubWestendParaPallet; +use westend_system_emulated_network::westend_emulated_chain::westend_runtime::xcm_config::AssetHub; +use crate::imports::ahw_xcm_config::UniversalLocation; + +#[test] +fn test_set_asset_claimer_on_multiverse() { + println!("printlined_error"); + + let alice = AssetHubWestend::account_id_of(ALICE); + let bob = BridgeHubWestend::account_id_of(BOB); + let destination = BridgeHubWestend::sibling_location_of(AssetHubWestend::para_id()); + let alice_location = Location::new(0, Junction::AccountId32 { network: None, id: alice.clone().into() }); + let assets: Assets = (Parent, 12300456000u128).into(); + // let alice_on_asset_hub = Location::new(1, [Parachain(1000), Junction::AccountId32 { id: [67u8; 32], network: Some(Westend) }]); + + + let bob_on_bh = Location::new( + 1, + [ + Parachain(BridgeHubWestend::para_id().into()), + Junction::AccountId32 { + network: Some(Westend), + id: bob.clone().into()}], + ); + println!("BOB on BridgeHub: {:?}", bob_on_bh); + // let bob_acc = AssetHubWestend::sovereign_account_id_of(PenpalASender::); + + let amount_to_send = 16_000_000_000_000u128; + let alice_acc = AssetHubWestend::account_id_of(ALICE); + AssetHubWestend::fund_accounts(vec![( + alice_acc.clone(), + amount_to_send * 2, + )]); + + let balance = ::account_data_of(alice_acc.clone()).free; + println!("alice balance {:?}", balance); + + + let test_args = TestContext { + sender: alice_acc.clone(), + receiver: alice_acc.clone(), + args: TestArgs::new_para( + alice_location.clone(), + alice_acc.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let test = SystemParaToParaTest::new(test_args); + execute_ah_test(test.clone(), bob_on_bh.clone(), trap_assets_ah); + + let balance = ::account_data_of(alice_acc.clone()).free; + println!("ali balance {:?}", balance); + + + + // SECOND PART OF THE TEST + + BridgeHubWestend::fund_accounts(vec![( + bob.clone(), + amount_to_send * 20000, + )]); + + let balance = ::account_data_of(bob.clone()).free; + println!("bob balance {:?}", balance); + + let test_args = TestContext { + sender: bob.clone(), + receiver: alice.clone(), + args: TestArgs::new_para( + destination.clone(), + alice_acc.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let test = BridgeToAssetHubTest::new(test_args); + let asset_hub = BridgeHubWestend::sibling_location_of( + AssetHubWestend::para_id() + ).into(); + let xcm_there = Xcm::<()>::builder_unsafe() + .claim_asset(test.args.assets.clone(), Here) + .pay_fees((Parent, 40_000_000_000u128)) + .deposit_asset(AllCounted(1), bob_on_bh.clone()) + .build(); + + BridgeHubWestend::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + test.signed_origin, + bx!(asset_hub), + bx!(VersionedXcm::from(xcm_there)), + )); + }); + + // execute_bh_test(test.clone(), bob_on_bh.clone(), transfer_assets_from_bh); +} + +fn execute_bh_test( + test: BridgeToAssetHubTest, + claimer: Location, + xcm_fn: impl Fn(BridgeToAssetHubTest, Location) -> ::RuntimeCall, +) { + let call = xcm_fn(test.clone(), claimer.clone()); + BridgeHubWestend::execute_with(|| { + assert!(call.dispatch(test.signed_origin).is_ok()); + }); +} + +fn transfer_assets_from_bh( + test: BridgeToAssetHubTest, + claimer: Location +) -> ::RuntimeCall { + + let xcm_there = Xcm::<()>::builder_unsafe() + .pay_fees((Parent, 40_000_000_000u128)) + .claim_asset(test.args.assets.clone(), Here) + .deposit_asset(AllCounted(1), claimer) + .build(); + + let xcm_here = Xcm::::builder_unsafe() + .withdraw_asset((Parent, 200_000_000_000u128)) + .pay_fees((Parent, 40_000_000_000u128)) + .export_message( + Westend, + Parachain(1000), + xcm_there + ) + // .transfer_reserve_asset( + // (Parent, 60_000_000_000u128), + // test.args.dest.clone(), xcm_there) + // .initiate_teleport( + // Definite((Parent, 60_000_000_000u128).into()), + // test.args.dest.clone(), xcm_there) + .build(); + + type RuntimeCall = ::RuntimeCall; + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(xcm_here)), + max_weight: Weight::from_parts(4_000_000_000_000, 300_000), + }) + + + // .transfer_reserve_asset(test.args.assets.clone(), bob_on_ah, xcm_there) + // .withdraw_asset(test.args.assets.clone()) + // .transfer_reserve_asset(test.args.assets.clone(), bob_on_ah, xcm_there) + // .deposit_reserve_asset(test.args.assets.clone(), test.args.dest.clone(), xcm_there) + // let al_ac = AssetHubWestend::account_id_of(ALICE); + // let bob_on_ah = Location::new( + // 1, + // [ + // Parachain(AssetHubWestend::para_id().into()), + // Junction::AccountId32 { + // network: None, + // id: al_ac.clone().into()} + // ], + // ); + // let fee_asset = Asset { id: AssetId(Location::new(0, [])), fun: Fungibility::Fungible(1_000_000_000u128) }; + // let asset_hub = BridgeHubWestend::sibling_location_of(AssetHubWestend::para_id());a +} + + +fn execute_ah_test( + test: SystemParaToParaTest, + claimer: Location, + xcm_fn: impl Fn(SystemParaToParaTest, Location) -> ::RuntimeCall, +) { + let call = xcm_fn(test.clone(), claimer.clone()); + AssetHubWestend::execute_with(|| { + assert!(call.dispatch(test.signed_origin).is_ok()); + }); +} + +fn trap_assets_ah( + test: SystemParaToParaTest, + claimer: Location +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; + + let local_xcm = Xcm::::builder_unsafe() + .set_asset_claimer(claimer.clone()) + .withdraw_asset(test.args.assets.clone()) + .clear_origin() + .build(); + + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(4_000_000_000_000, 300_000), + }) +} + + +#[test] +fn test_sac_ah_to_bh() { + let alice = AssetHubWestend::account_id_of(ALICE); + let bob = BridgeHubWestend::account_id_of(BOB); + let destination = AssetHubWestend::sibling_location_of(BridgeHubWestend::para_id()); + let bob_location = Location::new(0, Junction::AccountId32 { network: Some(Westend), id: bob.clone().into() }); + + let amount_to_send = 16_000_000_000_000u128; + BridgeHubWestend::fund_accounts(vec![( + bob.clone(), + amount_to_send * 2, + )]); + let balance = ::account_data_of(bob.clone()).free; + println!("[BH] Bob balance before {:?}", balance); + + let assets: Assets = (Parent, amount_to_send).into(); + let test_args = TestContext { + sender: bob.clone(), + receiver: alice.clone(), + args: TestArgs::new_para( + bob_location.clone(), + bob.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let test = BridgeToAssetHubTest::new(test_args); + let alice_on_ah = Location::new( + 1, + [ + Parachain(1000), + Junction::AccountId32 { + network: Some(Westend), + id: alice.clone().into()}], + ); + + execute_bob_bh_test(test.clone(), alice_on_ah.clone(), trap_assets_bh); + + let balance = ::account_data_of(bob.clone()).free; + println!("[BH] Bob balance after {:?}", balance); + + + let amount_to_send = 16_000_000_000_000u128; + AssetHubWestend::fund_accounts(vec![( + alice.clone(), + amount_to_send * 2, + )]); + + let balance = ::account_data_of(alice.clone()).free; + println!("[AH] Alice balance before {:?}", balance); + + let test_args = TestContext { + sender: alice.clone(), + receiver: bob.clone(), + args: TestArgs::new_para( + destination.clone(), + bob.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let test = AssetHubToBridgeHubTest::new(test_args); + let bridge_hub = AssetHubWestend::sibling_location_of( + BridgeHubWestend::para_id() + ).into(); + let xcm_there = Xcm::<()>::builder_unsafe() + .claim_asset(test.args.assets.clone(), Here) + .pay_fees((Parent, 15_000_000_000_000u128)) + .deposit_asset(All, alice_on_ah) + .build(); + // sign does not work bc of BadOrigin + AssetHubWestend::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + test.signed_origin, + bx!(bridge_hub), + bx!(VersionedXcm::from(xcm_there)), + )); + }); + +} + +fn execute_bob_bh_test( + test: BridgeToAssetHubTest, + claimer: Location, + xcm_fn: impl Fn(BridgeToAssetHubTest, Location) -> ::RuntimeCall, +) { + let call = xcm_fn(test.clone(), claimer.clone()); + BridgeHubWestend::execute_with(|| { + assert!(call.dispatch(test.signed_origin).is_ok()); + }); +} + +fn trap_assets_bh( + test: BridgeToAssetHubTest, + claimer: Location +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; + + let local_xcm = Xcm::::builder_unsafe() + .set_asset_claimer(claimer.clone()) + .withdraw_asset(test.args.assets.clone()) + .clear_origin() + .build(); + + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(4_000_000_000_000, 700_000), + }) +} diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs index e07d50c6fc48..deb2bb047659 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs @@ -40,15 +40,7 @@ use sp_runtime::traits::AccountIdConversion; use sp_std::marker::PhantomData; use testnet_parachains_constants::westend::snowbridge::EthereumNetwork; use xcm::latest::prelude::*; -use xcm_builder::{ - AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, - AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, - DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FrameTransactionalProcessor, - FungibleAdapter, HandleFee, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, - SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, -}; +use xcm_builder::{AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, GlobalConsensusParachainConvertsFor, HandleFee, HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic}; use xcm_executor::{ traits::{FeeManager, FeeReason, FeeReason::Export}, XcmExecutor, @@ -76,6 +68,9 @@ pub type LocationToAccountId = ( SiblingParachainConvertsVia, // Straight up local `AccountId32` origins just alias directly to `AccountId`. AccountId32Aliases, + // Foreign chain account alias into local accounts according to a hash of their standard + // description. + HashedDescription>, ); /// Means for transacting the native currency on this chain. diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index 99aadb33b840..bd479f101793 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -65,7 +65,7 @@ parameter_types! { pub const PenpalNativeCurrency: Location = Location::here(); // The Penpal runtime is utilized for testing with various environment setups. // This storage item allows us to customize the `NetworkId` where Penpal is deployed. - // By default, it is set to `NetworkId::Rococo` and can be changed using `System::set_storage`. + // By default, it is set to `NetworkId::Westend` and can be changed using `System::set_storage`. pub storage RelayNetworkId: NetworkId = NetworkId::Westend; pub RelayNetwork: Option = Some(RelayNetworkId::get()); pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); diff --git a/expansion.rs b/expansion.rs new file mode 100644 index 000000000000..c7136479719b --- /dev/null +++ b/expansion.rs @@ -0,0 +1,4772 @@ +#![feature(prelude_import)] +#[prelude_import] +use std::prelude::rust_2021::*; +#[macro_use] +extern crate std; +pub use penpal_runtime::{self, xcm_config::RelayNetworkId as PenpalRelayNetworkId}; +mod genesis { + use frame_support::parameter_types; + use sp_core::{sr25519, storage::Storage}; + use emulated_integration_tests_common::{ + accounts, build_genesis_storage, collators, get_account_id_from_seed, + SAFE_XCM_VERSION, + }; + use parachains_common::{AccountId, Balance}; + use penpal_runtime::xcm_config::{ + LocalReservableFromAssetHub, RelayLocation, UsdtFromAssetHub, + }; + pub const PARA_ID_A: u32 = 2000; + pub const PARA_ID_B: u32 = 2001; + pub const ED: Balance = penpal_runtime::EXISTENTIAL_DEPOSIT; + pub const USDT_ED: Balance = 70_000; + pub struct PenpalSudoAccount; + impl PenpalSudoAccount { + /// Returns the value of this parameter type. + pub fn get() -> AccountId { + get_account_id_from_seed::("Alice") + } + } + impl<_I: From> ::frame_support::traits::Get<_I> for PenpalSudoAccount { + fn get() -> _I { + _I::from(Self::get()) + } + } + impl ::frame_support::traits::TypedGet for PenpalSudoAccount { + type Type = AccountId; + fn get() -> AccountId { + Self::get() + } + } + pub struct PenpalAssetOwner; + impl PenpalAssetOwner { + /// Returns the value of this parameter type. + pub fn get() -> AccountId { + PenpalSudoAccount::get() + } + } + impl<_I: From> ::frame_support::traits::Get<_I> for PenpalAssetOwner { + fn get() -> _I { + _I::from(Self::get()) + } + } + impl ::frame_support::traits::TypedGet for PenpalAssetOwner { + type Type = AccountId; + fn get() -> AccountId { + Self::get() + } + } + pub fn genesis(para_id: u32) -> Storage { + let genesis_config = penpal_runtime::RuntimeGenesisConfig { + system: penpal_runtime::SystemConfig::default(), + balances: penpal_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: penpal_runtime::ParachainInfoConfig { + parachain_id: para_id.into(), + ..Default::default() + }, + collator_selection: penpal_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: penpal_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), + acc, + penpal_runtime::SessionKeys { + aura, + }, + ) + }) + .collect(), + ..Default::default() + }, + polkadot_xcm: penpal_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + sudo: penpal_runtime::SudoConfig { + key: Some(PenpalSudoAccount::get()), + }, + assets: penpal_runtime::AssetsConfig { + assets: <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + penpal_runtime::xcm_config::TELEPORTABLE_ASSET_ID, + PenpalAssetOwner::get(), + false, + ED, + ), + ]), + ), + ..Default::default() + }, + foreign_assets: penpal_runtime::ForeignAssetsConfig { + assets: <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (RelayLocation::get(), PenpalAssetOwner::get(), true, ED), + ( + LocalReservableFromAssetHub::get(), + PenpalAssetOwner::get(), + true, + ED, + ), + (UsdtFromAssetHub::get(), PenpalAssetOwner::get(), true, USDT_ED), + ]), + ), + ..Default::default() + }, + ..Default::default() + }; + build_genesis_storage( + &genesis_config, + penpal_runtime::WASM_BINARY + .expect("WASM binary was not built, please build it!"), + ) + } +} +pub use genesis::{ + genesis, PenpalAssetOwner, PenpalSudoAccount, ED, PARA_ID_A, PARA_ID_B, +}; +use frame_support::traits::OnInitialize; +use sp_core::Encode; +use emulated_integration_tests_common::{ + impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, + impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain, + impl_xcm_helpers_for_parachain, impls::{NetworkId, Parachain}, + xcm_emulator::decl_test_parachains, +}; +pub struct PenpalA(::xcm_emulator::PhantomData); +#[automatically_derived] +impl ::core::clone::Clone for PenpalA { + #[inline] + fn clone(&self) -> PenpalA { + PenpalA(::core::clone::Clone::clone(&self.0)) + } +} +impl ::xcm_emulator::Chain for PenpalA { + type Runtime = penpal_runtime::Runtime; + type RuntimeCall = penpal_runtime::RuntimeCall; + type RuntimeOrigin = penpal_runtime::RuntimeOrigin; + type RuntimeEvent = penpal_runtime::RuntimeEvent; + type System = ::xcm_emulator::SystemPallet; + type OriginCaller = penpal_runtime::OriginCaller; + type Network = N; + fn account_data_of( + account: ::xcm_emulator::AccountIdOf, + ) -> ::xcm_emulator::AccountData<::xcm_emulator::Balance> { + ::ext_wrapper(|| { + ::xcm_emulator::SystemPallet::::account(account).data.into() + }) + } + fn events() -> Vec<::RuntimeEvent> { + Self::System::events().iter().map(|record| record.event.clone()).collect() + } +} +impl ::xcm_emulator::Parachain for PenpalA { + type XcmpMessageHandler = penpal_runtime::XcmpQueue; + type LocationToAccountId = penpal_runtime::xcm_config::LocationToAccountId; + type ParachainSystem = ::xcm_emulator::ParachainSystemPallet< + ::Runtime, + >; + type ParachainInfo = penpal_runtime::ParachainInfo; + type MessageProcessor = ::xcm_emulator::DefaultParaMessageProcessor< + PenpalA, + cumulus_primitives_core::AggregateMessageOrigin, + >; + fn init() { + use ::xcm_emulator::{ + Chain, HeadData, Network, Hooks, Encode, Parachain, TestExt, + }; + LOCAL_EXT_PENPALA + .with(|v| *v.borrow_mut() = Self::build_new_ext(genesis(PARA_ID_A))); + Self::set_last_head(); + Self::new_block(); + Self::finalize_block(); + } + fn new_block() { + use ::xcm_emulator::{ + Chain, HeadData, Network, Hooks, Encode, Parachain, TestExt, + }; + let para_id = Self::para_id().into(); + Self::ext_wrapper(|| { + let mut relay_block_number = N::relay_block_number(); + relay_block_number += 1; + N::set_relay_block_number(relay_block_number); + let mut block_number = ::System::block_number(); + block_number += 1; + let parent_head_data = ::xcm_emulator::LAST_HEAD + .with(|b| { + b + .borrow_mut() + .get_mut(N::name()) + .expect("network not initialized?") + .get(¶_id) + .expect("network not initialized?") + .clone() + }); + ::System::initialize( + &block_number, + &parent_head_data.hash(), + &Default::default(), + ); + <::ParachainSystem as Hooks< + ::xcm_emulator::BlockNumberFor, + >>::on_initialize(block_number); + let _ = ::ParachainSystem::set_validation_data( + ::RuntimeOrigin::none(), + N::hrmp_channel_parachain_inherent_data( + para_id, + relay_block_number, + parent_head_data, + ), + ); + }); + } + fn finalize_block() { + use ::xcm_emulator::{Chain, Encode, Hooks, Network, Parachain, TestExt}; + Self::ext_wrapper(|| { + let block_number = ::System::block_number(); + ::ParachainSystem::on_finalize(block_number); + }); + Self::set_last_head(); + } + fn set_last_head() { + use ::xcm_emulator::{Chain, Encode, HeadData, Network, Parachain, TestExt}; + let para_id = Self::para_id().into(); + Self::ext_wrapper(|| { + let created_header = ::System::finalize(); + ::xcm_emulator::LAST_HEAD + .with(|b| { + b + .borrow_mut() + .get_mut(N::name()) + .expect("network not initialized?") + .insert(para_id, HeadData(created_header.encode())) + }); + }); + } +} +pub trait PenpalAParaPallet { + type System; + type PolkadotXcm; + type Assets; + type ForeignAssets; + type AssetConversion; + type Balances; +} +impl PenpalAParaPallet for PenpalA { + type System = penpal_runtime::System; + type PolkadotXcm = penpal_runtime::PolkadotXcm; + type Assets = penpal_runtime::Assets; + type ForeignAssets = penpal_runtime::ForeignAssets; + type AssetConversion = penpal_runtime::AssetConversion; + type Balances = penpal_runtime::Balances; +} +pub const LOCAL_EXT_PENPALA: ::std::thread::LocalKey< + ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, +> = { + #[inline] + fn __init() -> ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities> { + ::xcm_emulator::RefCell::new( + ::xcm_emulator::TestExternalities::new(genesis(PARA_ID_A)), + ) + } + unsafe { + use ::std::mem::needs_drop; + use ::std::thread::LocalKey; + use ::std::thread::local_impl::LazyStorage; + LocalKey::new(const { + if needs_drop::< + ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, + >() { + |init| { + #[thread_local] + static VAL: LazyStorage< + ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, + (), + > = LazyStorage::new(); + VAL.get_or_init(init, __init) + } + } else { + |init| { + #[thread_local] + static VAL: LazyStorage< + ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, + !, + > = LazyStorage::new(); + VAL.get_or_init(init, __init) + } + } + }) + } +}; +#[allow(missing_copy_implementations)] +#[allow(non_camel_case_types)] +#[allow(dead_code)] +pub struct GLOBAL_EXT_PENPALA { + __private_field: (), +} +#[doc(hidden)] +pub static GLOBAL_EXT_PENPALA: GLOBAL_EXT_PENPALA = GLOBAL_EXT_PENPALA { + __private_field: (), +}; +impl ::lazy_static::__Deref for GLOBAL_EXT_PENPALA { + type Target = ::xcm_emulator::Mutex< + ::xcm_emulator::RefCell< + ::xcm_emulator::HashMap, + >, + >; + fn deref( + &self, + ) -> &::xcm_emulator::Mutex< + ::xcm_emulator::RefCell< + ::xcm_emulator::HashMap, + >, + > { + #[inline(always)] + fn __static_ref_initialize() -> ::xcm_emulator::Mutex< + ::xcm_emulator::RefCell< + ::xcm_emulator::HashMap, + >, + > { + ::xcm_emulator::Mutex::new( + ::xcm_emulator::RefCell::new(::xcm_emulator::HashMap::new()), + ) + } + #[inline(always)] + fn __stability() -> &'static ::xcm_emulator::Mutex< + ::xcm_emulator::RefCell< + ::xcm_emulator::HashMap, + >, + > { + static LAZY: ::lazy_static::lazy::Lazy< + ::xcm_emulator::Mutex< + ::xcm_emulator::RefCell< + ::xcm_emulator::HashMap< + String, + ::xcm_emulator::TestExternalities, + >, + >, + >, + > = ::lazy_static::lazy::Lazy::INIT; + LAZY.get(__static_ref_initialize) + } + __stability() + } +} +impl ::lazy_static::LazyStatic for GLOBAL_EXT_PENPALA { + fn initialize(lazy: &Self) { + let _ = &**lazy; + } +} +impl ::xcm_emulator::TestExt for PenpalA { + fn build_new_ext( + storage: ::xcm_emulator::Storage, + ) -> ::xcm_emulator::TestExternalities { + let mut ext = ::xcm_emulator::TestExternalities::new(storage); + ext.execute_with(|| { + #[allow(clippy::no_effect)] + { + penpal_runtime::AuraExt::on_initialize(1); + let is = penpal_runtime::System::set_storage( + penpal_runtime::RuntimeOrigin::root(), + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + PenpalRelayNetworkId::key().to_vec(), + NetworkId::Rococo.encode(), + ), + ]), + ), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }; + ::xcm_emulator::sp_tracing::try_init_simple(); + let mut block_number = ::System::block_number(); + block_number = std::cmp::max(1, block_number); + ::System::set_block_number(block_number); + }); + ext + } + fn new_ext() -> ::xcm_emulator::TestExternalities { + Self::build_new_ext(genesis(PARA_ID_A)) + } + fn move_ext_out(id: &'static str) { + use ::xcm_emulator::Deref; + let local_ext = LOCAL_EXT_PENPALA.with(|v| { v.take() }); + let global_ext_guard = GLOBAL_EXT_PENPALA.lock().unwrap(); + global_ext_guard.deref().borrow_mut().insert(id.to_string(), local_ext); + } + fn move_ext_in(id: &'static str) { + use ::xcm_emulator::Deref; + let mut global_ext_unlocked = false; + while !global_ext_unlocked { + let global_ext_result = GLOBAL_EXT_PENPALA.try_lock(); + if let Ok(global_ext_guard) = global_ext_result { + if !global_ext_guard.deref().borrow().contains_key(id) { + drop(global_ext_guard); + } else { + global_ext_unlocked = true; + } + } + } + let mut global_ext_guard = GLOBAL_EXT_PENPALA.lock().unwrap(); + let global_ext = global_ext_guard.deref(); + LOCAL_EXT_PENPALA + .with(|v| { + v.replace(global_ext.take().remove(id).unwrap()); + }); + } + fn reset_ext() { + LOCAL_EXT_PENPALA + .with(|v| *v.borrow_mut() = Self::build_new_ext(genesis(PARA_ID_A))); + } + fn execute_with(execute: impl FnOnce() -> R) -> R { + use ::xcm_emulator::{Chain, Get, Hooks, Network, Parachain, Encode}; + ::init(); + Self::new_block(); + let r = LOCAL_EXT_PENPALA.with(|v| v.borrow_mut().execute_with(execute)); + Self::finalize_block(); + let para_id = Self::para_id().into(); + LOCAL_EXT_PENPALA + .with(|v| { + v.borrow_mut() + .execute_with(|| { + let mock_header = ::xcm_emulator::HeaderT::new( + 0, + Default::default(), + Default::default(), + Default::default(), + Default::default(), + ); + let collation_info = ::ParachainSystem::collect_collation_info( + &mock_header, + ); + let relay_block_number = ::relay_block_number(); + for msg in collation_info.upward_messages.clone() { + ::send_upward_message(para_id, msg); + } + for msg in collation_info.horizontal_messages { + ::send_horizontal_messages( + msg.recipient.into(), + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (para_id.into(), relay_block_number, msg.data), + ]), + ) + .into_iter(), + ); + } + type NetworkBridge = ::Bridge; + let bridge_messages = < as ::xcm_emulator::Bridge>::Handler as ::xcm_emulator::BridgeMessageHandler>::get_source_outbound_messages(); + for msg in bridge_messages { + ::send_bridged_messages(msg); + } + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalA", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + ::System::reset_events(); + }) + }); + ::process_messages(); + r + } + fn ext_wrapper(func: impl FnOnce() -> R) -> R { + LOCAL_EXT_PENPALA.with(|v| { v.borrow_mut().execute_with(|| { func() }) }) + } +} +impl< + N, + Origin, + Destination, + Hops, + Args, +> ::xcm_emulator::CheckAssertion for PenpalA +where + N: ::xcm_emulator::Network, + Origin: ::xcm_emulator::Chain + Clone, + Destination: ::xcm_emulator::Chain + Clone, + Origin::RuntimeOrigin: ::xcm_emulator::OriginTrait< + AccountId = ::xcm_emulator::AccountIdOf, + > + Clone, + Destination::RuntimeOrigin: ::xcm_emulator::OriginTrait< + AccountId = ::xcm_emulator::AccountIdOf, + > + Clone, + Hops: Clone, + Args: Clone, +{ + fn check_assertion(test: ::xcm_emulator::Test) { + use ::xcm_emulator::{Dispatchable, TestExt}; + let chain_name = std::any::type_name::>(); + >::execute_with(|| { + if let Some(dispatchable) = test.hops_dispatchable.get(chain_name) { + let is = dispatchable(test.clone()); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + } + if let Some(call) = test.hops_calls.get(chain_name) { + let is = match call.clone().dispatch(test.signed_origin.clone()) { + Ok(_) => Ok(()), + Err(error_with_post_info) => Err(error_with_post_info.error), + }; + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + } + if let Some(assertion) = test.hops_assertion.get(chain_name) { + assertion(test); + } + }); + } +} +pub struct PenpalB(::xcm_emulator::PhantomData); +#[automatically_derived] +impl ::core::clone::Clone for PenpalB { + #[inline] + fn clone(&self) -> PenpalB { + PenpalB(::core::clone::Clone::clone(&self.0)) + } +} +impl ::xcm_emulator::Chain for PenpalB { + type Runtime = penpal_runtime::Runtime; + type RuntimeCall = penpal_runtime::RuntimeCall; + type RuntimeOrigin = penpal_runtime::RuntimeOrigin; + type RuntimeEvent = penpal_runtime::RuntimeEvent; + type System = ::xcm_emulator::SystemPallet; + type OriginCaller = penpal_runtime::OriginCaller; + type Network = N; + fn account_data_of( + account: ::xcm_emulator::AccountIdOf, + ) -> ::xcm_emulator::AccountData<::xcm_emulator::Balance> { + ::ext_wrapper(|| { + ::xcm_emulator::SystemPallet::::account(account).data.into() + }) + } + fn events() -> Vec<::RuntimeEvent> { + Self::System::events().iter().map(|record| record.event.clone()).collect() + } +} +impl ::xcm_emulator::Parachain for PenpalB { + type XcmpMessageHandler = penpal_runtime::XcmpQueue; + type LocationToAccountId = penpal_runtime::xcm_config::LocationToAccountId; + type ParachainSystem = ::xcm_emulator::ParachainSystemPallet< + ::Runtime, + >; + type ParachainInfo = penpal_runtime::ParachainInfo; + type MessageProcessor = ::xcm_emulator::DefaultParaMessageProcessor< + PenpalB, + cumulus_primitives_core::AggregateMessageOrigin, + >; + fn init() { + use ::xcm_emulator::{ + Chain, HeadData, Network, Hooks, Encode, Parachain, TestExt, + }; + LOCAL_EXT_PENPALB + .with(|v| *v.borrow_mut() = Self::build_new_ext(genesis(PARA_ID_B))); + Self::set_last_head(); + Self::new_block(); + Self::finalize_block(); + } + fn new_block() { + use ::xcm_emulator::{ + Chain, HeadData, Network, Hooks, Encode, Parachain, TestExt, + }; + let para_id = Self::para_id().into(); + Self::ext_wrapper(|| { + let mut relay_block_number = N::relay_block_number(); + relay_block_number += 1; + N::set_relay_block_number(relay_block_number); + let mut block_number = ::System::block_number(); + block_number += 1; + let parent_head_data = ::xcm_emulator::LAST_HEAD + .with(|b| { + b + .borrow_mut() + .get_mut(N::name()) + .expect("network not initialized?") + .get(¶_id) + .expect("network not initialized?") + .clone() + }); + ::System::initialize( + &block_number, + &parent_head_data.hash(), + &Default::default(), + ); + <::ParachainSystem as Hooks< + ::xcm_emulator::BlockNumberFor, + >>::on_initialize(block_number); + let _ = ::ParachainSystem::set_validation_data( + ::RuntimeOrigin::none(), + N::hrmp_channel_parachain_inherent_data( + para_id, + relay_block_number, + parent_head_data, + ), + ); + }); + } + fn finalize_block() { + use ::xcm_emulator::{Chain, Encode, Hooks, Network, Parachain, TestExt}; + Self::ext_wrapper(|| { + let block_number = ::System::block_number(); + ::ParachainSystem::on_finalize(block_number); + }); + Self::set_last_head(); + } + fn set_last_head() { + use ::xcm_emulator::{Chain, Encode, HeadData, Network, Parachain, TestExt}; + let para_id = Self::para_id().into(); + Self::ext_wrapper(|| { + let created_header = ::System::finalize(); + ::xcm_emulator::LAST_HEAD + .with(|b| { + b + .borrow_mut() + .get_mut(N::name()) + .expect("network not initialized?") + .insert(para_id, HeadData(created_header.encode())) + }); + }); + } +} +pub trait PenpalBParaPallet { + type PolkadotXcm; + type Assets; + type ForeignAssets; + type AssetConversion; + type Balances; +} +impl PenpalBParaPallet for PenpalB { + type PolkadotXcm = penpal_runtime::PolkadotXcm; + type Assets = penpal_runtime::Assets; + type ForeignAssets = penpal_runtime::ForeignAssets; + type AssetConversion = penpal_runtime::AssetConversion; + type Balances = penpal_runtime::Balances; +} +pub const LOCAL_EXT_PENPALB: ::std::thread::LocalKey< + ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, +> = { + #[inline] + fn __init() -> ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities> { + ::xcm_emulator::RefCell::new( + ::xcm_emulator::TestExternalities::new(genesis(PARA_ID_B)), + ) + } + unsafe { + use ::std::mem::needs_drop; + use ::std::thread::LocalKey; + use ::std::thread::local_impl::LazyStorage; + LocalKey::new(const { + if needs_drop::< + ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, + >() { + |init| { + #[thread_local] + static VAL: LazyStorage< + ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, + (), + > = LazyStorage::new(); + VAL.get_or_init(init, __init) + } + } else { + |init| { + #[thread_local] + static VAL: LazyStorage< + ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, + !, + > = LazyStorage::new(); + VAL.get_or_init(init, __init) + } + } + }) + } +}; +#[allow(missing_copy_implementations)] +#[allow(non_camel_case_types)] +#[allow(dead_code)] +pub struct GLOBAL_EXT_PENPALB { + __private_field: (), +} +#[doc(hidden)] +pub static GLOBAL_EXT_PENPALB: GLOBAL_EXT_PENPALB = GLOBAL_EXT_PENPALB { + __private_field: (), +}; +impl ::lazy_static::__Deref for GLOBAL_EXT_PENPALB { + type Target = ::xcm_emulator::Mutex< + ::xcm_emulator::RefCell< + ::xcm_emulator::HashMap, + >, + >; + fn deref( + &self, + ) -> &::xcm_emulator::Mutex< + ::xcm_emulator::RefCell< + ::xcm_emulator::HashMap, + >, + > { + #[inline(always)] + fn __static_ref_initialize() -> ::xcm_emulator::Mutex< + ::xcm_emulator::RefCell< + ::xcm_emulator::HashMap, + >, + > { + ::xcm_emulator::Mutex::new( + ::xcm_emulator::RefCell::new(::xcm_emulator::HashMap::new()), + ) + } + #[inline(always)] + fn __stability() -> &'static ::xcm_emulator::Mutex< + ::xcm_emulator::RefCell< + ::xcm_emulator::HashMap, + >, + > { + static LAZY: ::lazy_static::lazy::Lazy< + ::xcm_emulator::Mutex< + ::xcm_emulator::RefCell< + ::xcm_emulator::HashMap< + String, + ::xcm_emulator::TestExternalities, + >, + >, + >, + > = ::lazy_static::lazy::Lazy::INIT; + LAZY.get(__static_ref_initialize) + } + __stability() + } +} +impl ::lazy_static::LazyStatic for GLOBAL_EXT_PENPALB { + fn initialize(lazy: &Self) { + let _ = &**lazy; + } +} +impl ::xcm_emulator::TestExt for PenpalB { + fn build_new_ext( + storage: ::xcm_emulator::Storage, + ) -> ::xcm_emulator::TestExternalities { + let mut ext = ::xcm_emulator::TestExternalities::new(storage); + ext.execute_with(|| { + #[allow(clippy::no_effect)] + { + penpal_runtime::AuraExt::on_initialize(1); + let is = penpal_runtime::System::set_storage( + penpal_runtime::RuntimeOrigin::root(), + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + ( + PenpalRelayNetworkId::key().to_vec(), + NetworkId::Westend.encode(), + ), + ]), + ), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }; + ::xcm_emulator::sp_tracing::try_init_simple(); + let mut block_number = ::System::block_number(); + block_number = std::cmp::max(1, block_number); + ::System::set_block_number(block_number); + }); + ext + } + fn new_ext() -> ::xcm_emulator::TestExternalities { + Self::build_new_ext(genesis(PARA_ID_B)) + } + fn move_ext_out(id: &'static str) { + use ::xcm_emulator::Deref; + let local_ext = LOCAL_EXT_PENPALB.with(|v| { v.take() }); + let global_ext_guard = GLOBAL_EXT_PENPALB.lock().unwrap(); + global_ext_guard.deref().borrow_mut().insert(id.to_string(), local_ext); + } + fn move_ext_in(id: &'static str) { + use ::xcm_emulator::Deref; + let mut global_ext_unlocked = false; + while !global_ext_unlocked { + let global_ext_result = GLOBAL_EXT_PENPALB.try_lock(); + if let Ok(global_ext_guard) = global_ext_result { + if !global_ext_guard.deref().borrow().contains_key(id) { + drop(global_ext_guard); + } else { + global_ext_unlocked = true; + } + } + } + let mut global_ext_guard = GLOBAL_EXT_PENPALB.lock().unwrap(); + let global_ext = global_ext_guard.deref(); + LOCAL_EXT_PENPALB + .with(|v| { + v.replace(global_ext.take().remove(id).unwrap()); + }); + } + fn reset_ext() { + LOCAL_EXT_PENPALB + .with(|v| *v.borrow_mut() = Self::build_new_ext(genesis(PARA_ID_B))); + } + fn execute_with(execute: impl FnOnce() -> R) -> R { + use ::xcm_emulator::{Chain, Get, Hooks, Network, Parachain, Encode}; + ::init(); + Self::new_block(); + let r = LOCAL_EXT_PENPALB.with(|v| v.borrow_mut().execute_with(execute)); + Self::finalize_block(); + let para_id = Self::para_id().into(); + LOCAL_EXT_PENPALB + .with(|v| { + v.borrow_mut() + .execute_with(|| { + let mock_header = ::xcm_emulator::HeaderT::new( + 0, + Default::default(), + Default::default(), + Default::default(), + Default::default(), + ); + let collation_info = ::ParachainSystem::collect_collation_info( + &mock_header, + ); + let relay_block_number = ::relay_block_number(); + for msg in collation_info.upward_messages.clone() { + ::send_upward_message(para_id, msg); + } + for msg in collation_info.horizontal_messages { + ::send_horizontal_messages( + msg.recipient.into(), + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([ + (para_id.into(), relay_block_number, msg.data), + ]), + ) + .into_iter(), + ); + } + type NetworkBridge = ::Bridge; + let bridge_messages = < as ::xcm_emulator::Bridge>::Handler as ::xcm_emulator::BridgeMessageHandler>::get_source_outbound_messages(); + for msg in bridge_messages { + ::send_bridged_messages(msg); + } + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::PenpalB", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + ::System::reset_events(); + }) + }); + ::process_messages(); + r + } + fn ext_wrapper(func: impl FnOnce() -> R) -> R { + LOCAL_EXT_PENPALB.with(|v| { v.borrow_mut().execute_with(|| { func() }) }) + } +} +impl< + N, + Origin, + Destination, + Hops, + Args, +> ::xcm_emulator::CheckAssertion for PenpalB +where + N: ::xcm_emulator::Network, + Origin: ::xcm_emulator::Chain + Clone, + Destination: ::xcm_emulator::Chain + Clone, + Origin::RuntimeOrigin: ::xcm_emulator::OriginTrait< + AccountId = ::xcm_emulator::AccountIdOf, + > + Clone, + Destination::RuntimeOrigin: ::xcm_emulator::OriginTrait< + AccountId = ::xcm_emulator::AccountIdOf, + > + Clone, + Hops: Clone, + Args: Clone, +{ + fn check_assertion(test: ::xcm_emulator::Test) { + use ::xcm_emulator::{Dispatchable, TestExt}; + let chain_name = std::any::type_name::>(); + >::execute_with(|| { + if let Some(dispatchable) = test.hops_dispatchable.get(chain_name) { + let is = dispatchable(test.clone()); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + } + if let Some(call) = test.hops_calls.get(chain_name) { + let is = match call.clone().dispatch(test.signed_origin.clone()) { + Ok(_) => Ok(()), + Err(error_with_post_info) => Err(error_with_post_info.error), + }; + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + } + if let Some(assertion) = test.hops_assertion.get(chain_name) { + assertion(test); + } + }); + } +} +impl PenpalA { + /// Fund a set of accounts with a balance + pub fn fund_accounts( + accounts: Vec< + ( + ::emulated_integration_tests_common::impls::AccountId, + ::emulated_integration_tests_common::impls::Balance, + ), + >, + ) { + ::execute_with(|| { + for account in accounts { + let who = account.0; + let actual = ::Balances::free_balance(&who); + let actual = actual + .saturating_add( + ::Balances::reserved_balance(&who), + ); + let is = ::Balances::force_set_balance( + ::RuntimeOrigin::root(), + who.into(), + actual.saturating_add(account.1), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + } + }); + } + /// Fund a sovereign account of sibling para. + pub fn fund_para_sovereign( + sibling_para_id: ::emulated_integration_tests_common::impls::ParaId, + balance: ::emulated_integration_tests_common::impls::Balance, + ) { + let sibling_location = Self::sibling_location_of(sibling_para_id); + let sovereign_account = Self::sovereign_account_id_of(sibling_location); + Self::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([(sovereign_account.into(), balance)]), + ), + ) + } + /// Return local sovereign account of `para_id` on other `network_id` + pub fn sovereign_account_of_parachain_on_other_global_consensus( + network_id: ::emulated_integration_tests_common::impls::NetworkId, + para_id: ::emulated_integration_tests_common::impls::ParaId, + ) -> ::emulated_integration_tests_common::impls::AccountId { + let remote_location = ::emulated_integration_tests_common::impls::Location::new( + 2, + [ + ::emulated_integration_tests_common::impls::Junction::GlobalConsensus( + network_id, + ), + ::emulated_integration_tests_common::impls::Junction::Parachain( + para_id.into(), + ), + ], + ); + ::execute_with(|| { + Self::sovereign_account_id_of(remote_location) + }) + } +} +impl PenpalB { + /// Fund a set of accounts with a balance + pub fn fund_accounts( + accounts: Vec< + ( + ::emulated_integration_tests_common::impls::AccountId, + ::emulated_integration_tests_common::impls::Balance, + ), + >, + ) { + ::execute_with(|| { + for account in accounts { + let who = account.0; + let actual = ::Balances::free_balance(&who); + let actual = actual + .saturating_add( + ::Balances::reserved_balance(&who), + ); + let is = ::Balances::force_set_balance( + ::RuntimeOrigin::root(), + who.into(), + actual.saturating_add(account.1), + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + } + }); + } + /// Fund a sovereign account of sibling para. + pub fn fund_para_sovereign( + sibling_para_id: ::emulated_integration_tests_common::impls::ParaId, + balance: ::emulated_integration_tests_common::impls::Balance, + ) { + let sibling_location = Self::sibling_location_of(sibling_para_id); + let sovereign_account = Self::sovereign_account_id_of(sibling_location); + Self::fund_accounts( + <[_]>::into_vec( + #[rustc_box] + ::alloc::boxed::Box::new([(sovereign_account.into(), balance)]), + ), + ) + } + /// Return local sovereign account of `para_id` on other `network_id` + pub fn sovereign_account_of_parachain_on_other_global_consensus( + network_id: ::emulated_integration_tests_common::impls::NetworkId, + para_id: ::emulated_integration_tests_common::impls::ParaId, + ) -> ::emulated_integration_tests_common::impls::AccountId { + let remote_location = ::emulated_integration_tests_common::impls::Location::new( + 2, + [ + ::emulated_integration_tests_common::impls::Junction::GlobalConsensus( + network_id, + ), + ::emulated_integration_tests_common::impls::Junction::Parachain( + para_id.into(), + ), + ], + ); + ::execute_with(|| { + Self::sovereign_account_id_of(remote_location) + }) + } +} +type PenpalARuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; +impl PenpalA { + /// Asserts a dispatchable is completely executed and XCM sent + pub fn assert_xcm_pallet_attempted_complete( + expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, + ) { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalARuntimeEvent::< + N, + >::PolkadotXcm( + ::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted { + outcome: ::emulated_integration_tests_common::impls::Outcome::Complete { + used: weight, + }, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "weight", + weight, + "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", + ), + ); + res + }); + } + meet_conditions + &= ::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Complete {\n used: weight\n } })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Complete {\n used: weight\n } })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a dispatchable is incompletely executed and XCM sent + pub fn assert_xcm_pallet_attempted_incomplete( + expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, + expected_error: Option<::emulated_integration_tests_common::impls::XcmError>, + ) { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalARuntimeEvent::< + N, + >::PolkadotXcm( + ::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted { + outcome: ::emulated_integration_tests_common::impls::Outcome::Incomplete { + used: weight, + error, + }, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "weight", + weight, + "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", + ), + ); + res + }); + } + meet_conditions + &= ::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ); + if !(*error == expected_error.unwrap_or((*error).into()).into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "error", + error, + "*error == expected_error.unwrap_or((*error).into()).into()", + ), + ); + res + }); + } + meet_conditions + &= *error == expected_error.unwrap_or((*error).into()).into(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Incomplete {\n used: weight, error\n } })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Incomplete {\n used: weight, error\n } })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a dispatchable throws and error when trying to be sent + pub fn assert_xcm_pallet_attempted_error( + expected_error: Option<::emulated_integration_tests_common::impls::XcmError>, + ) { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalARuntimeEvent::< + N, + >::PolkadotXcm( + ::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted { + outcome: ::emulated_integration_tests_common::impls::Outcome::Error { + error, + }, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*error == expected_error.unwrap_or((*error).into()).into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "error", + error, + "*error == expected_error.unwrap_or((*error).into()).into()", + ), + ); + res + }); + } + meet_conditions + &= *error == expected_error.unwrap_or((*error).into()).into(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Error { error }\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Error { error }\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a XCM message is sent + pub fn assert_xcm_pallet_sent() { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalARuntimeEvent::< + N, + >::PolkadotXcm( + ::emulated_integration_tests_common::impls::pallet_xcm::Event::Sent { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Sent {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Sent {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a XCM message is sent to Relay Chain + pub fn assert_parachain_system_ump_sent() { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalARuntimeEvent::< + N, + >::ParachainSystem( + ::emulated_integration_tests_common::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalARuntimeEvent::::ParachainSystem(::emulated_integration_tests_common::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalARuntimeEvent::::ParachainSystem(::emulated_integration_tests_common::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a XCM from Relay Chain is completely executed + pub fn assert_dmp_queue_complete( + expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, + ) { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalARuntimeEvent::< + N, + >::MessageQueue( + ::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed { + success: true, + weight_used: weight, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "weight", + weight, + "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", + ), + ); + res + }); + } + meet_conditions + &= ::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a XCM from Relay Chain is incompletely executed + pub fn assert_dmp_queue_incomplete( + expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, + ) { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalARuntimeEvent::< + N, + >::MessageQueue( + ::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed { + success: false, + weight_used: weight, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "weight", + weight, + "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", + ), + ); + res + }); + } + meet_conditions + &= ::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: false, weight_used: weight, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: false, weight_used: weight, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a XCM from Relay Chain is executed with error + pub fn assert_dmp_queue_error() { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalARuntimeEvent::< + N, + >::MessageQueue( + ::emulated_integration_tests_common::impls::pallet_message_queue::Event::ProcessingFailed { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::ProcessingFailed {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::ProcessingFailed {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a XCM from another Parachain is completely executed + pub fn assert_xcmp_queue_success( + expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, + ) { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalARuntimeEvent::< + N, + >::MessageQueue( + ::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed { + success: true, + weight_used: weight, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "weight", + weight, + "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", + ), + ); + res + }); + } + meet_conditions + &= ::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } +} +type PenpalBRuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; +impl PenpalB { + /// Asserts a dispatchable is completely executed and XCM sent + pub fn assert_xcm_pallet_attempted_complete( + expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, + ) { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalBRuntimeEvent::< + N, + >::PolkadotXcm( + ::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted { + outcome: ::emulated_integration_tests_common::impls::Outcome::Complete { + used: weight, + }, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "weight", + weight, + "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", + ), + ); + res + }); + } + meet_conditions + &= ::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Complete {\n used: weight\n } })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Complete {\n used: weight\n } })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a dispatchable is incompletely executed and XCM sent + pub fn assert_xcm_pallet_attempted_incomplete( + expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, + expected_error: Option<::emulated_integration_tests_common::impls::XcmError>, + ) { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalBRuntimeEvent::< + N, + >::PolkadotXcm( + ::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted { + outcome: ::emulated_integration_tests_common::impls::Outcome::Incomplete { + used: weight, + error, + }, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "weight", + weight, + "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", + ), + ); + res + }); + } + meet_conditions + &= ::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ); + if !(*error == expected_error.unwrap_or((*error).into()).into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "error", + error, + "*error == expected_error.unwrap_or((*error).into()).into()", + ), + ); + res + }); + } + meet_conditions + &= *error == expected_error.unwrap_or((*error).into()).into(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Incomplete {\n used: weight, error\n } })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Incomplete {\n used: weight, error\n } })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a dispatchable throws and error when trying to be sent + pub fn assert_xcm_pallet_attempted_error( + expected_error: Option<::emulated_integration_tests_common::impls::XcmError>, + ) { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalBRuntimeEvent::< + N, + >::PolkadotXcm( + ::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted { + outcome: ::emulated_integration_tests_common::impls::Outcome::Error { + error, + }, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*error == expected_error.unwrap_or((*error).into()).into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "error", + error, + "*error == expected_error.unwrap_or((*error).into()).into()", + ), + ); + res + }); + } + meet_conditions + &= *error == expected_error.unwrap_or((*error).into()).into(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Error { error }\n})", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Error { error }\n})", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a XCM message is sent + pub fn assert_xcm_pallet_sent() { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalBRuntimeEvent::< + N, + >::PolkadotXcm( + ::emulated_integration_tests_common::impls::pallet_xcm::Event::Sent { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Sent {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Sent {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a XCM message is sent to Relay Chain + pub fn assert_parachain_system_ump_sent() { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalBRuntimeEvent::< + N, + >::ParachainSystem( + ::emulated_integration_tests_common::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalBRuntimeEvent::::ParachainSystem(::emulated_integration_tests_common::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalBRuntimeEvent::::ParachainSystem(::emulated_integration_tests_common::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a XCM from Relay Chain is completely executed + pub fn assert_dmp_queue_complete( + expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, + ) { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalBRuntimeEvent::< + N, + >::MessageQueue( + ::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed { + success: true, + weight_used: weight, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "weight", + weight, + "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", + ), + ); + res + }); + } + meet_conditions + &= ::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a XCM from Relay Chain is incompletely executed + pub fn assert_dmp_queue_incomplete( + expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, + ) { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalBRuntimeEvent::< + N, + >::MessageQueue( + ::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed { + success: false, + weight_used: weight, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "weight", + weight, + "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", + ), + ); + res + }); + } + meet_conditions + &= ::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: false, weight_used: weight, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: false, weight_used: weight, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a XCM from Relay Chain is executed with error + pub fn assert_dmp_queue_error() { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalBRuntimeEvent::< + N, + >::MessageQueue( + ::emulated_integration_tests_common::impls::pallet_message_queue::Event::ProcessingFailed { + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::ProcessingFailed {\n.. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::ProcessingFailed {\n.. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } + /// Asserts a XCM from another Parachain is completely executed + pub fn assert_xcmp_queue_success( + expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, + ) { + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + PenpalBRuntimeEvent::< + N, + >::MessageQueue( + ::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed { + success: true, + weight_used: weight, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ) && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "weight", + weight, + "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", + ), + ); + res + }); + } + meet_conditions + &= ::emulated_integration_tests_common::impls::weight_within_threshold( + ( + ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, + ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, + ), + expected_weight.unwrap_or(*weight), + *weight, + ); + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + } +} +impl PenpalA { + /// Create assets using sudo `Assets::force_create()` + pub fn force_create_asset( + id: u32, + owner: ::emulated_integration_tests_common::impls::AccountId, + is_sufficient: bool, + min_balance: u128, + prefund_accounts: Vec< + (::emulated_integration_tests_common::impls::AccountId, u128), + >, + ) { + use ::emulated_integration_tests_common::impls::Inspect; + let sudo_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::root(); + ::execute_with(|| { + let is = ::Assets::force_create( + sudo_origin, + id.clone().into(), + owner.clone().into(), + is_sufficient, + min_balance, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + if !::Assets::asset_exists(id.clone()) { + ::core::panicking::panic( + "assertion failed: ::Assets::asset_exists(id.clone())", + ) + } + type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::< + N, + >::Assets( + ::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated { + asset_id, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + for (beneficiary, amount) in prefund_accounts.into_iter() { + let signed_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::signed( + owner.clone(), + ); + Self::mint_asset(signed_origin, id.clone(), beneficiary, amount); + } + } + /// Mint assets making use of the assets pallet + pub fn mint_asset( + signed_origin: ::RuntimeOrigin, + id: u32, + beneficiary: ::emulated_integration_tests_common::impls::AccountId, + amount_to_mint: u128, + ) { + ::execute_with(|| { + let is = ::Assets::mint( + signed_origin, + id.clone().into(), + beneficiary.clone().into(), + amount_to_mint, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::< + N, + >::Assets( + ::emulated_integration_tests_common::impls::pallet_assets::Event::Issued { + asset_id, + owner, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == id; + if !(*owner == beneficiary.clone().into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == beneficiary.clone().into()", + ), + ); + res + }); + } + meet_conditions &= *owner == beneficiary.clone().into(); + if !(*amount == amount_to_mint) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == amount_to_mint", + ), + ); + res + }); + } + meet_conditions &= *amount == amount_to_mint; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + /// Returns the encoded call for `create` from the assets pallet + pub fn create_asset_call( + asset_id: u32, + min_balance: ::emulated_integration_tests_common::impls::Balance, + admin: ::emulated_integration_tests_common::impls::AccountId, + ) -> ::emulated_integration_tests_common::impls::DoubleEncoded<()> { + use ::emulated_integration_tests_common::impls::{Chain, Encode}; + ::RuntimeCall::Assets(::emulated_integration_tests_common::impls::pallet_assets::Call::< + ::Runtime, + ::emulated_integration_tests_common::impls::pallet_assets::Instance1, + >::create { + id: asset_id.into(), + min_balance, + admin: admin.into(), + }) + .encode() + .into() + } +} +impl PenpalA { + /// Create foreign assets using sudo `ForeignAssets::force_create()` + pub fn force_create_foreign_asset( + id: xcm::latest::Location, + owner: ::emulated_integration_tests_common::impls::AccountId, + is_sufficient: bool, + min_balance: u128, + prefund_accounts: Vec< + (::emulated_integration_tests_common::impls::AccountId, u128), + >, + ) { + use ::emulated_integration_tests_common::impls::Inspect; + let sudo_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::root(); + ::execute_with(|| { + let is = ::ForeignAssets::force_create( + sudo_origin, + id.clone(), + owner.clone().into(), + is_sufficient, + min_balance, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + if !::ForeignAssets::asset_exists(id.clone()) { + ::core::panicking::panic( + "assertion failed: ::ForeignAssets::asset_exists(id.clone())", + ) + } + type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::< + N, + >::ForeignAssets( + ::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated { + asset_id, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + for (beneficiary, amount) in prefund_accounts.into_iter() { + let signed_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::signed( + owner.clone(), + ); + Self::mint_foreign_asset(signed_origin, id.clone(), beneficiary, amount); + } + } + /// Mint assets making use of the ForeignAssets pallet-assets instance + pub fn mint_foreign_asset( + signed_origin: ::RuntimeOrigin, + id: xcm::latest::Location, + beneficiary: ::emulated_integration_tests_common::impls::AccountId, + amount_to_mint: u128, + ) { + ::execute_with(|| { + let is = ::ForeignAssets::mint( + signed_origin, + id.clone().into(), + beneficiary.clone().into(), + amount_to_mint, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::< + N, + >::ForeignAssets( + ::emulated_integration_tests_common::impls::pallet_assets::Event::Issued { + asset_id, + owner, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == id; + if !(*owner == beneficiary.clone().into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == beneficiary.clone().into()", + ), + ); + res + }); + } + meet_conditions &= *owner == beneficiary.clone().into(); + if !(*amount == amount_to_mint) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == amount_to_mint", + ), + ); + res + }); + } + meet_conditions &= *amount == amount_to_mint; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + /// Returns the encoded call for `create` from the foreign assets pallet + pub fn create_foreign_asset_call( + asset_id: xcm::latest::Location, + min_balance: ::emulated_integration_tests_common::impls::Balance, + admin: ::emulated_integration_tests_common::impls::AccountId, + ) -> ::emulated_integration_tests_common::impls::DoubleEncoded<()> { + use ::emulated_integration_tests_common::impls::{Chain, Encode}; + ::RuntimeCall::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Call::< + ::Runtime, + ::emulated_integration_tests_common::impls::pallet_assets::Instance2, + >::create { + id: asset_id.into(), + min_balance, + admin: admin.into(), + }) + .encode() + .into() + } +} +impl PenpalB { + /// Create assets using sudo `Assets::force_create()` + pub fn force_create_asset( + id: u32, + owner: ::emulated_integration_tests_common::impls::AccountId, + is_sufficient: bool, + min_balance: u128, + prefund_accounts: Vec< + (::emulated_integration_tests_common::impls::AccountId, u128), + >, + ) { + use ::emulated_integration_tests_common::impls::Inspect; + let sudo_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::root(); + ::execute_with(|| { + let is = ::Assets::force_create( + sudo_origin, + id.clone().into(), + owner.clone().into(), + is_sufficient, + min_balance, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + if !::Assets::asset_exists(id.clone()) { + ::core::panicking::panic( + "assertion failed: ::Assets::asset_exists(id.clone())", + ) + } + type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::< + N, + >::Assets( + ::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated { + asset_id, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + for (beneficiary, amount) in prefund_accounts.into_iter() { + let signed_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::signed( + owner.clone(), + ); + Self::mint_asset(signed_origin, id.clone(), beneficiary, amount); + } + } + /// Mint assets making use of the assets pallet + pub fn mint_asset( + signed_origin: ::RuntimeOrigin, + id: u32, + beneficiary: ::emulated_integration_tests_common::impls::AccountId, + amount_to_mint: u128, + ) { + ::execute_with(|| { + let is = ::Assets::mint( + signed_origin, + id.clone().into(), + beneficiary.clone().into(), + amount_to_mint, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::< + N, + >::Assets( + ::emulated_integration_tests_common::impls::pallet_assets::Event::Issued { + asset_id, + owner, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == id; + if !(*owner == beneficiary.clone().into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == beneficiary.clone().into()", + ), + ); + res + }); + } + meet_conditions &= *owner == beneficiary.clone().into(); + if !(*amount == amount_to_mint) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == amount_to_mint", + ), + ); + res + }); + } + meet_conditions &= *amount == amount_to_mint; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + /// Returns the encoded call for `create` from the assets pallet + pub fn create_asset_call( + asset_id: u32, + min_balance: ::emulated_integration_tests_common::impls::Balance, + admin: ::emulated_integration_tests_common::impls::AccountId, + ) -> ::emulated_integration_tests_common::impls::DoubleEncoded<()> { + use ::emulated_integration_tests_common::impls::{Chain, Encode}; + ::RuntimeCall::Assets(::emulated_integration_tests_common::impls::pallet_assets::Call::< + ::Runtime, + ::emulated_integration_tests_common::impls::pallet_assets::Instance1, + >::create { + id: asset_id.into(), + min_balance, + admin: admin.into(), + }) + .encode() + .into() + } +} +impl PenpalB { + /// Create foreign assets using sudo `ForeignAssets::force_create()` + pub fn force_create_foreign_asset( + id: xcm::latest::Location, + owner: ::emulated_integration_tests_common::impls::AccountId, + is_sufficient: bool, + min_balance: u128, + prefund_accounts: Vec< + (::emulated_integration_tests_common::impls::AccountId, u128), + >, + ) { + use ::emulated_integration_tests_common::impls::Inspect; + let sudo_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::root(); + ::execute_with(|| { + let is = ::ForeignAssets::force_create( + sudo_origin, + id.clone(), + owner.clone().into(), + is_sufficient, + min_balance, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + if !::ForeignAssets::asset_exists(id.clone()) { + ::core::panicking::panic( + "assertion failed: ::ForeignAssets::asset_exists(id.clone())", + ) + } + type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::< + N, + >::ForeignAssets( + ::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated { + asset_id, + .. + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == id; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + for (beneficiary, amount) in prefund_accounts.into_iter() { + let signed_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::signed( + owner.clone(), + ); + Self::mint_foreign_asset(signed_origin, id.clone(), beneficiary, amount); + } + } + /// Mint assets making use of the ForeignAssets pallet-assets instance + pub fn mint_foreign_asset( + signed_origin: ::RuntimeOrigin, + id: xcm::latest::Location, + beneficiary: ::emulated_integration_tests_common::impls::AccountId, + amount_to_mint: u128, + ) { + ::execute_with(|| { + let is = ::ForeignAssets::mint( + signed_origin, + id.clone().into(), + beneficiary.clone().into(), + amount_to_mint, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; + let mut message: Vec = Vec::new(); + let mut events = ::events(); + let mut event_received = false; + let mut meet_conditions = true; + let mut index_match = 0; + let mut event_message: Vec = Vec::new(); + for (index, event) in events.iter().enumerate() { + meet_conditions = true; + match event { + RuntimeEvent::< + N, + >::ForeignAssets( + ::emulated_integration_tests_common::impls::pallet_assets::Event::Issued { + asset_id, + owner, + amount, + }, + ) => { + event_received = true; + let mut conditions_message: Vec = Vec::new(); + if !(*asset_id == id) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "asset_id", + asset_id, + "*asset_id == id", + ), + ); + res + }); + } + meet_conditions &= *asset_id == id; + if !(*owner == beneficiary.clone().into()) + && event_message.is_empty() + { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "owner", + owner, + "*owner == beneficiary.clone().into()", + ), + ); + res + }); + } + meet_conditions &= *owner == beneficiary.clone().into(); + if !(*amount == amount_to_mint) && event_message.is_empty() { + conditions_message + .push({ + let res = ::alloc::fmt::format( + format_args!( + " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", + "amount", + amount, + "*amount == amount_to_mint", + ), + ); + res + }); + } + meet_conditions &= *amount == amount_to_mint; + if event_received && meet_conditions { + index_match = index; + break; + } else { + event_message.extend(conditions_message); + } + } + _ => {} + } + } + if event_received && !meet_conditions { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", + "Self", + "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", + event_message.concat(), + ), + ); + res + }); + } else if !event_received { + message + .push({ + let res = ::alloc::fmt::format( + format_args!( + "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", + "Self", + "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", + ::events(), + ), + ); + res + }); + } else { + events.remove(index_match); + } + if !message.is_empty() { + ::events() + .iter() + .for_each(|event| { + { + let lvl = ::log::Level::Debug; + if lvl <= ::log::STATIC_MAX_LEVEL + && lvl <= ::log::max_level() + { + ::log::__private_api::log( + format_args!("{0:?}", event), + lvl, + &( + "events::Self", + "penpal_emulated_chain", + ::log::__private_api::loc(), + ), + (), + ); + } + }; + }); + { + #[cold] + #[track_caller] + #[inline(never)] + #[rustc_const_panic_str] + #[rustc_do_not_const_check] + const fn panic_cold_display(arg: &T) -> ! { + ::core::panicking::panic_display(arg) + } + panic_cold_display(&message.concat()); + } + } + }); + } + /// Returns the encoded call for `create` from the foreign assets pallet + pub fn create_foreign_asset_call( + asset_id: xcm::latest::Location, + min_balance: ::emulated_integration_tests_common::impls::Balance, + admin: ::emulated_integration_tests_common::impls::AccountId, + ) -> ::emulated_integration_tests_common::impls::DoubleEncoded<()> { + use ::emulated_integration_tests_common::impls::{Chain, Encode}; + ::RuntimeCall::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Call::< + ::Runtime, + ::emulated_integration_tests_common::impls::pallet_assets::Instance2, + >::create { + id: asset_id.into(), + min_balance, + admin: admin.into(), + }) + .encode() + .into() + } +} +impl PenpalA { + /// Set XCM version for destination. + pub fn force_xcm_version( + dest: ::emulated_integration_tests_common::impls::Location, + version: ::emulated_integration_tests_common::impls::XcmVersion, + ) { + ::execute_with(|| { + let is = ::PolkadotXcm::force_xcm_version( + ::RuntimeOrigin::root(), + Box::new(dest), + version, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + } + /// Set default/safe XCM version for runtime. + pub fn force_default_xcm_version( + version: Option<::emulated_integration_tests_common::impls::XcmVersion>, + ) { + ::execute_with(|| { + let is = ::PolkadotXcm::force_default_xcm_version( + ::RuntimeOrigin::root(), + version, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + } +} +impl PenpalB { + /// Set XCM version for destination. + pub fn force_xcm_version( + dest: ::emulated_integration_tests_common::impls::Location, + version: ::emulated_integration_tests_common::impls::XcmVersion, + ) { + ::execute_with(|| { + let is = ::PolkadotXcm::force_xcm_version( + ::RuntimeOrigin::root(), + Box::new(dest), + version, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + } + /// Set default/safe XCM version for runtime. + pub fn force_default_xcm_version( + version: Option<::emulated_integration_tests_common::impls::XcmVersion>, + ) { + ::execute_with(|| { + let is = ::PolkadotXcm::force_default_xcm_version( + ::RuntimeOrigin::root(), + version, + ); + match is { + Ok(_) => {} + _ => { + if !false { + { + ::core::panicking::panic_fmt( + format_args!("Expected Ok(_). Got {0:#?}", is), + ); + } + } + } + }; + }); + } +} diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 4313ea8c561a..7734305dc1aa 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -1051,9 +1051,6 @@ impl XcmExecutor { &reserve, Some(&mut self.holding), ); - // TODO: modify the message by adding setAssetClaimer. - // replicate for teleport and regular withdraw functions. - // add e2e tests. let mut message = vec![WithdrawAsset(assets), ClearOrigin]; message.extend(xcm.0.into_iter()); self.send(reserve, Xcm(message), FeeReason::InitiateReserveWithdraw)?; From b35d56bcb18d73a4d382a6d75670f9a5f5a36329 Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 18 Sep 2024 18:07:23 +0200 Subject: [PATCH 130/151] added HashedDescription conversion to BridgeHub --- .../runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs index deb2bb047659..0b40cdb041ee 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs @@ -40,7 +40,7 @@ use sp_runtime::traits::AccountIdConversion; use sp_std::marker::PhantomData; use testnet_parachains_constants::westend::snowbridge::EthereumNetwork; use xcm::latest::prelude::*; -use xcm_builder::{AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, GlobalConsensusParachainConvertsFor, HandleFee, HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic}; +use xcm_builder::{AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, DescribePalletTerminal, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, GlobalConsensusParachainConvertsFor, HandleFee, HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic}; use xcm_executor::{ traits::{FeeManager, FeeReason, FeeReason::Export}, XcmExecutor, @@ -70,7 +70,7 @@ pub type LocationToAccountId = ( AccountId32Aliases, // Foreign chain account alias into local accounts according to a hash of their standard // description. - HashedDescription>, + HashedDescription>, ); /// Means for transacting the native currency on this chain. From 833ce0262a61c900f6dfc11925b9319cb09ea2a6 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 19 Sep 2024 14:04:12 +0200 Subject: [PATCH 131/151] WIP: merging set_asset_claimer tests --- .../src/tests/set_asset_claimer.rs | 389 ++++++------------ .../src/tests/set_asset_claimer_multichain.rs | 114 ----- 2 files changed, 129 insertions(+), 374 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 794133ba6e5e..9a134db28f0c 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -26,7 +26,8 @@ use frame_support::{sp_runtime::{traits::Dispatchable}, assert_ok, LOG_TARGET}; use westend_system_emulated_network::penpal_emulated_chain::penpal_runtime; use westend_system_emulated_network::asset_hub_westend_emulated_chain::asset_hub_westend_runtime; use westend_system_emulated_network::westend_emulated_chain::westend_runtime::xcm_config::AssetHub; -use crate::imports::ahw_xcm_config::UniversalLocation; +use xcm_executor::traits::ConvertLocation; +use crate::imports::ahw_xcm_config::{LocationToAccountId, UniversalLocation}; #[test] fn test_set_asset_claimer_within_a_chain() { @@ -46,11 +47,8 @@ fn test_set_asset_claimer_within_a_chain() { let native_asset_location = RelayLocation::get(); let assets: Assets = (Parent, amount_to_send).into(); - // Fund accounts. fund_account(&alice_account, amount_to_send * 2); - - let alice_assets_before = query_balance(&alice_account, &native_asset_location); - assert_eq!(alice_assets_before, amount_to_send * 2); + assert_eq!(query_balance(&alice_account, &native_asset_location), amount_to_send * 2); let test_args = TestContext { sender: alice_account.clone(), @@ -89,11 +87,46 @@ fn test_set_asset_claimer_within_a_chain() { assert_eq!(bob_assets_after, amount_to_send); } -fn transfer_assets_ah( - test: SystemParaToParaTest, +fn account_and_location(account: &str) -> (AccountId32, Location) { + let account_id = PenpalA::account_id_of(account); + let account_clone = account_id.clone(); + let location: Location = [Junction::AccountId32 { network: Some(Westend), id: account_id.into() }].into(); + (account_clone, location) +} + +fn fund_account(account: &AccountId, amount: u128) { + let asset_owner = PenpalAssetOwner::get(); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner), + Location::parent(), + account.clone(), + amount, + ); +} + +fn query_balance(account: &AccountId, asset_location: &Location) -> u128 { + PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(asset_location.clone(), account) + }) +} + +fn execute_test( + test: ParaToParaThroughAHTest, + claimer: Location, + xcm_fn: impl Fn(ParaToParaThroughAHTest, Location) -> ::RuntimeCall, +) { + let call = xcm_fn(test.clone(), claimer.clone()); + PenpalA::execute_with(|| { + assert!(call.dispatch(test.signed_origin).is_ok()); + }); +} + +fn transfer_assets( + test: ParaToParaThroughAHTest, claimer: Location -) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; let local_xcm = Xcm::::builder_unsafe() .set_asset_claimer(claimer.clone()) @@ -107,284 +140,137 @@ fn transfer_assets_ah( }) } -#[test] -fn test_set_asset_claimer_on_ah() { - log::error!("anything_error"); - println!("printlined_error"); +fn claim_assets( + test: ParaToParaThroughAHTest, + claimer: Location +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; - let alice = AssetHubWestend::account_id_of(ALICE); - let alice_location = Location::new(0, Junction::AccountId32 { network: None, id: alice.clone().into() }); - let assets: Assets = (Parent, 1000u128).into(); - // let alice_on_asset_hub = Location::new(1, [Parachain(1000), Junction::AccountId32 { id: [67u8; 32], network: Some(Westend) }]); + let local_xcm = Xcm::::builder_unsafe() + .claim_asset(test.args.assets.clone(), Here) + .deposit_asset(AllCounted(test.args.assets.len() as u32), claimer) + .build(); + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(4_000_000_000_000, 300_000), + }) +} - let bob_on_penpal = Location::new( - 1, - [ - Parachain(PenpalA::para_id().into()), - Junction::AccountId32 { - network: None, - id: PenpalA::account_id_of(BOB).into()}], - ); - println!("PenpalA:: sender is {:?}", PenpalASender::get()); - println!("BOB on PenpalA: {:?}", bob_on_penpal); - // let bob_acc = AssetHubWestend::sovereign_account_id_of(PenpalASender::); +#[test] +fn test_sac_between_the_chains() { + let alice = AssetHubWestend::account_id_of(ALICE); + let bob = BridgeHubWestend::account_id_of(BOB); + let destination = AssetHubWestend::sibling_location_of(BridgeHubWestend::para_id()); + let bob_location = Location::new(0, Junction::AccountId32 { network: Some(Westend), id: bob.clone().into() }); let amount_to_send = 16_000_000_000_000u128; - let alice_acc = AssetHubWestend::account_id_of(ALICE); - AssetHubWestend::fund_accounts(vec![( - alice_acc.clone(), + BridgeHubWestend::fund_accounts(vec![( + bob.clone(), amount_to_send * 2, )]); + let balance = ::account_data_of(bob.clone()).free; - let balance = ::account_data_of(alice_acc.clone()).free; - println!("alice balance {:?}", balance); - + let assets: Assets = (Parent, amount_to_send).into(); let test_args = TestContext { - sender: alice_acc.clone(), - receiver: alice_acc.clone(), + sender: bob.clone(), + receiver: alice.clone(), args: TestArgs::new_para( - alice_location.clone(), - alice_acc.clone(), + bob_location.clone(), + bob.clone(), amount_to_send, assets.clone(), None, 0, ), }; - let test = SystemParaToParaTest::new(test_args); - execute_ah_test(test.clone(), bob_on_penpal.clone(), transfer_assets_ah); - - - - let balance = ::account_data_of(alice_acc.clone()).free; - println!("alice balance after {:?}", balance); - - - - - // let bob_ah_from_bh = BridgeHubWestend::sovereign_account_id_of(Location::new( - // 1, - // [Parachain(AssetHubWestend::para_id().into()), Junction::AccountId32 {network: Some(Westend), id: AssetHubWestend::account_id_of(BOB).into()}], - // )); - // let alice_sov_account_on_bridge_hub = BridgeHubWestend::sovereign_account_id_of(alice_on_asset_hub); - // println!("alice_sov_account_on_bridge_hub {:?}", alice_sov_account_on_bridge_hub); - - // let (alice_account, alice_location) = account_and_location_ah(ALICE); - // let (bob_account, bob_location) = account_and_location_ah(BOB); - - + let test = BridgeToAssetHubTest::new(test_args); + let alice_on_ah = Location::new( + 1, + [ + Parachain(1000), + Junction::AccountId32 { + network: Some(Westend), + id: alice.clone().into()}], + ); + execute_bob_bh_test(test.clone(), alice_on_ah.clone(), trap_assets_bh); - // PenpalA::execute_with(|| { - // type System = ::System; - // type RuntimeOrigin = ::RuntimeOrigin; - // assert_ok!(System::set_storage( - // RuntimeOrigin::root(), - // vec![(penpal_runtime::xcm_config::RelayNetworkId::key().to_vec(), NetworkId::Westend.encode())] - // )); - // }); - // + let balance = ::account_data_of(bob.clone()).free; - // log::trace!("alice account: {}" , alice_account); let amount_to_send = 16_000_000_000_000u128; - let alice_acc = ::account_id_of(ALICE); - // Fund accounts. AssetHubWestend::fund_accounts(vec![( - alice_acc.clone(), + alice.clone(), amount_to_send * 2, )]); - let balance = ::account_data_of(alice_acc.clone()).free; - println!("alice balance {:?}", balance); - // AssetHubWestend::execute_with(||{ - // }); - - let assets: Assets = (Parent, amount_to_send).into(); - let alice: AccountId = AssetHubWestend::account_id_of(ALICE); - - - let alice_signed = ::RuntimeOrigin::signed(alice.clone()); - // let bridge_hub = AssetHubWestend::sibling_location_of(BridgeHubWestend::para_id()).into(); - let xcm = Xcm::<()>::builder_unsafe() - .claim_asset(assets.clone(), Here) - .pay_fees(Asset { id: AssetId(Location::new(1, [])), fun: Fungibility::Fungible(1_000_000u128) }) - .build(); - // let bridge_hub = Location::new(1, Parachain(1002)); - - let bob_acc = ::account_id_of(BOB); - let bob_location = Location::new(0, Junction::AccountId32 { network: None, id: bob_acc.clone().into() }); - - - - // let xcm = Xcm::<()>::builder_unsafe() - // .buy_execution((Parent, 100u128), WeightLimit::Unlimited) - // // .pay_fees(Asset { id: AssetId(Location::new(1, [])), fun: Fungibility::Fungible(1_000u128) }) - // // .set_asset_claimer(bob_location) - // .build(); - - // AssetHubWestend::execute_with(|| { - // assert_ok!(::PolkadotXcm::send( - // alice_signed, - // bx!(bridge_hub), - // bx!(VersionedXcm::from(xcm)), - // )); - // // AssetHubWestend::assert_xcm_pallet_sent(); - // }); - - - - // BridgeHubWestend::execute_with(|| { - // type Balances = ::Balances; - // - // dbg!(&Balances::free_balance(&alice_sov_account_on_bridge_hub)); - // }); - // // let bob_account = BridgeHubWestend::sibling_location_of(AssetHubWestend::account_id_of(BOB)).into(); - // - // BridgeHubWestend::fund_accounts(vec![( - // alice_from_bh.clone(), - // amount_to_send * 2, - // )]); - - - - // BH - // 1. add assets to AccountId {parent 1, Chainid (1002 or 1000) Alice - - // let native_asset_location = RelayLocation::get(); - // let alice_assets_before = query_ah_balance(&alice_account, &native_asset_location); - // assert_eq!(alice_assets_before, amount_to_send * 2); - // log::debug!("{}" ,alice_assets_before); - - // let test_args = TestContext { - // sender: alice_account.clone(), - // receiver: bob_account.clone(), - // args: TestArgs::new_para( - // bob_location.clone(), - // bob_account.clone(), - // amount_to_send, - // assets.clone(), - // None, - // 0, - // ), - // }; - // let test = ParaToParaThroughAHTest::new(test_args); - // execute_test(test.clone(), bob_location.clone(), transfer_assets_to_ah); - - // let alice_assets_after = query_balance(&alice_account, &native_asset_location); - // assert_eq!(alice_assets_after, amount_to_send); + println!("before LocationToAccountId"); + // let alLoc = LocationToAccountId::convert_location(&alice_on_ah).unwrap(); + // println!("alice Loc is: {:?}", alLoc); + // // let balance = ::account_data_of(alLoc.clone()).free; + // println!("[AH] Alice balance before {:?}", balance); // let test_args = TestContext { - // sender: bob_account.clone(), - // receiver: alice_account.clone(), + // sender: alice.clone(), + // receiver: bob.clone(), // args: TestArgs::new_para( - // alice_location.clone(), - // alice_account.clone(), + // destination.clone(), + // bob.clone(), // amount_to_send, // assets.clone(), // None, // 0, // ), // }; - // let test = ParaToParaThroughAHTest::new(test_args); - // execute_test(test.clone(), bob_location.clone(), claim_assets); - // - // let bob_assets_after = query_balance(&bob_account, &native_asset_location); - // assert_eq!(bob_assets_after, amount_to_send); -} - -fn transfer_assets_to_ah( - test: ParaToParaThroughAHTest, - claimer: Location -) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; - - - let xcm_in_reserve = Xcm::::builder_unsafe() - .set_asset_claimer(claimer.clone()) - .withdraw_asset(test.args.assets) - .build(); - - let fee_asset: Asset = (Location::parent(), 1_000_000u128).into(); - - - // let local_xcm = Xcm::::builder_unsafe() - // .set_asset_claimer(claimer.clone()) - // .initiate_reserve_withdraw(fee_asset.clone(), Location::parent(), xcm_in_reserve) + // let alice_on_ah = Location::new( + // 1, + // [ + // Parachain(1000), + // Junction::AccountId32 { + // network: Some(Westend), + // id: alice.clone().into()}], + // ); + // let test = AssetHubToBridgeHubTest::new(test_args); + // let bridge_hub = AssetHubWestend::sibling_location_of( + // BridgeHubWestend::para_id() + // ).into(); + // let xcm_there = Xcm::<()>::builder_unsafe() + // .claim_asset(test.args.assets.clone(), Here) + // .pay_fees((Parent, 15_000_000_000_000u128)) + // .deposit_asset(All, alice_on_ah.clone()) // .build(); + // AssetHubWestend::execute_with(|| { + // assert_ok!(::PolkadotXcm::send( + // test.signed_origin, + // bx!(bridge_hub), + // bx!(VersionedXcm::from(xcm_there)), + // )); + // }); + // + // + // let alLoc = ahw_xcm_config::LocationToAccountId::convert_location(&alice_on_ah).unwrap(); + // let balance = ::account_data_of(alLoc).free; + // println!("[AH] Alice balance after {:?}", balance); - RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(xcm_in_reserve)), - max_weight: Weight::from_parts(4_000_000_000_000, 300_000), - }) -} - -fn account_and_location_ah(account: &str) -> (AccountId32, Location) { - let account_id = AssetHubWestend::account_id_of(account); - let clone = account_id.clone(); - let location: Location = [Junction::AccountId32 { network: Some(Westend), id: account_id.into() }].into(); - (clone, location) -} - -fn account_and_location(account: &str) -> (AccountId32, Location) { - let account_id = PenpalA::account_id_of(account); - let account_clone = account_id.clone(); - let location: Location = [Junction::AccountId32 { network: Some(Westend), id: account_id.into() }].into(); - (account_clone, location) -} - -fn fund_account(account: &AccountId, amount: u128) { - let asset_owner = PenpalAssetOwner::get(); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - Location::parent(), - account.clone(), - amount, - ); -} - -fn query_ah_balance(account: &AccountId, asset_location: &Location) -> u128 { - AssetHubWestend::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(asset_location.clone(), account) - }) -} - -fn query_balance(account: &AccountId, asset_location: &Location) -> u128 { - PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(asset_location.clone(), account) - }) -} - -fn execute_ah_test( - test: SystemParaToParaTest, - claimer: Location, - xcm_fn: impl Fn(SystemParaToParaTest, Location) -> ::RuntimeCall, -) { - let call = xcm_fn(test.clone(), claimer.clone()); - AssetHubWestend::execute_with(|| { - assert!(call.dispatch(test.signed_origin).is_ok()); - }); } -fn execute_test( - test: ParaToParaThroughAHTest, +fn execute_bob_bh_test( + test: BridgeToAssetHubTest, claimer: Location, - xcm_fn: impl Fn(ParaToParaThroughAHTest, Location) -> ::RuntimeCall, + xcm_fn: impl Fn(BridgeToAssetHubTest, Location) -> ::RuntimeCall, ) { let call = xcm_fn(test.clone(), claimer.clone()); - PenpalA::execute_with(|| { + BridgeHubWestend::execute_with(|| { assert!(call.dispatch(test.signed_origin).is_ok()); }); } -fn transfer_assets( - test: ParaToParaThroughAHTest, +fn trap_assets_bh( + test: BridgeToAssetHubTest, claimer: Location -) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; let local_xcm = Xcm::::builder_unsafe() .set_asset_claimer(claimer.clone()) @@ -394,23 +280,6 @@ fn transfer_assets( RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { message: bx!(VersionedXcm::from(local_xcm)), - max_weight: Weight::from_parts(4_000_000_000_000, 300_000), - }) -} - -fn claim_assets( - test: ParaToParaThroughAHTest, - claimer: Location -) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; - - let local_xcm = Xcm::::builder_unsafe() - .claim_asset(test.args.assets.clone(), Here) - .deposit_asset(AllCounted(test.args.assets.len() as u32), claimer) - .build(); - - RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(local_xcm)), - max_weight: Weight::from_parts(4_000_000_000_000, 300_000), + max_weight: Weight::from_parts(4_000_000_000_000, 700_000), }) -} +} \ No newline at end of file diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer_multichain.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer_multichain.rs index c6fba3d041fb..087ea5234183 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer_multichain.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer_multichain.rs @@ -201,117 +201,3 @@ fn trap_assets_ah( }) } - -#[test] -fn test_sac_ah_to_bh() { - let alice = AssetHubWestend::account_id_of(ALICE); - let bob = BridgeHubWestend::account_id_of(BOB); - let destination = AssetHubWestend::sibling_location_of(BridgeHubWestend::para_id()); - let bob_location = Location::new(0, Junction::AccountId32 { network: Some(Westend), id: bob.clone().into() }); - - let amount_to_send = 16_000_000_000_000u128; - BridgeHubWestend::fund_accounts(vec![( - bob.clone(), - amount_to_send * 2, - )]); - let balance = ::account_data_of(bob.clone()).free; - println!("[BH] Bob balance before {:?}", balance); - - let assets: Assets = (Parent, amount_to_send).into(); - let test_args = TestContext { - sender: bob.clone(), - receiver: alice.clone(), - args: TestArgs::new_para( - bob_location.clone(), - bob.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let test = BridgeToAssetHubTest::new(test_args); - let alice_on_ah = Location::new( - 1, - [ - Parachain(1000), - Junction::AccountId32 { - network: Some(Westend), - id: alice.clone().into()}], - ); - - execute_bob_bh_test(test.clone(), alice_on_ah.clone(), trap_assets_bh); - - let balance = ::account_data_of(bob.clone()).free; - println!("[BH] Bob balance after {:?}", balance); - - - let amount_to_send = 16_000_000_000_000u128; - AssetHubWestend::fund_accounts(vec![( - alice.clone(), - amount_to_send * 2, - )]); - - let balance = ::account_data_of(alice.clone()).free; - println!("[AH] Alice balance before {:?}", balance); - - let test_args = TestContext { - sender: alice.clone(), - receiver: bob.clone(), - args: TestArgs::new_para( - destination.clone(), - bob.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let test = AssetHubToBridgeHubTest::new(test_args); - let bridge_hub = AssetHubWestend::sibling_location_of( - BridgeHubWestend::para_id() - ).into(); - let xcm_there = Xcm::<()>::builder_unsafe() - .claim_asset(test.args.assets.clone(), Here) - .pay_fees((Parent, 15_000_000_000_000u128)) - .deposit_asset(All, alice_on_ah) - .build(); - // sign does not work bc of BadOrigin - AssetHubWestend::execute_with(|| { - assert_ok!(::PolkadotXcm::send( - test.signed_origin, - bx!(bridge_hub), - bx!(VersionedXcm::from(xcm_there)), - )); - }); - -} - -fn execute_bob_bh_test( - test: BridgeToAssetHubTest, - claimer: Location, - xcm_fn: impl Fn(BridgeToAssetHubTest, Location) -> ::RuntimeCall, -) { - let call = xcm_fn(test.clone(), claimer.clone()); - BridgeHubWestend::execute_with(|| { - assert!(call.dispatch(test.signed_origin).is_ok()); - }); -} - -fn trap_assets_bh( - test: BridgeToAssetHubTest, - claimer: Location -) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; - - let local_xcm = Xcm::::builder_unsafe() - .set_asset_claimer(claimer.clone()) - .withdraw_asset(test.args.assets.clone()) - .clear_origin() - .build(); - - RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(local_xcm)), - max_weight: Weight::from_parts(4_000_000_000_000, 700_000), - }) -} From ec4854adc40af361c04db15242c962b6a1ea8d02 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 19 Sep 2024 14:04:56 +0200 Subject: [PATCH 132/151] trying to add bridge_hub_westend_runtime to asset_hub_westend tests --- .../emulated/tests/assets/asset-hub-westend/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs index b02deb456eef..f08e5e8f1373 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs @@ -58,6 +58,14 @@ mod imports { genesis::{AssetHubWestendAssetOwner, ED as ASSET_HUB_WESTEND_ED}, AssetHubWestendParaPallet as AssetHubWestendPallet, }, + bridge_hub_westend_emulated_chain::{ + bridge_hub_westend_runtime::{ + xcm_config::{ + self as bhw_xcm_config, + XcmConfig as BridgeHubWestendXcmConfig, + }, + }, + }, collectives_westend_emulated_chain::CollectivesWestendParaPallet as CollectivesWestendPallet, penpal_emulated_chain::{ penpal_runtime::xcm_config::{ From c4ab1666472ac55291b2a8b1fa649970ce0e6017 Mon Sep 17 00:00:00 2001 From: ndk Date: Sun, 22 Sep 2024 18:38:38 +0300 Subject: [PATCH 133/151] fixed set_asset_claimer emulated tests and resolved PR comments --- .../bridges/bridge-hub-westend/src/lib.rs | 1 + .../parachains/testing/penpal/src/lib.rs | 1 - .../tests/assets/asset-hub-westend/src/lib.rs | 11 +- .../assets/asset-hub-westend/src/tests/mod.rs | 3 +- .../src/tests/set_asset_claimer.rs | 430 +- .../src/tests/set_asset_claimer_multichain.rs | 203 - .../asset-hub-westend/src/tests/teleport.rs | 4 +- .../asset-hub-westend/src/xcm_config.rs | 16 +- .../people-westend/src/weights/pallet_xcm.rs | 8 - expansion.rs | 4772 ----------------- polkadot/xcm/pallet-xcm/src/lib.rs | 5 - .../src/tests/set_asset_claimer.rs | 2 +- 12 files changed, 212 insertions(+), 5244 deletions(-) delete mode 100644 cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer_multichain.rs delete mode 100644 expansion.rs diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs index feb59c411c8d..71c09f7a3bba 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs @@ -16,6 +16,7 @@ pub mod genesis; pub use bridge_hub_westend_runtime::{ + self, xcm_config::XcmConfig as BridgeHubWestendXcmConfig, ExistentialDeposit as BridgeHubWestendExistentialDeposit, }; diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs index b7364856f21a..92dfa30f2e83 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs @@ -50,7 +50,6 @@ decl_test_parachains! { MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, }, pallets = { - System: penpal_runtime::System, PolkadotXcm: penpal_runtime::PolkadotXcm, Assets: penpal_runtime::Assets, ForeignAssets: penpal_runtime::ForeignAssets, diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs index f08e5e8f1373..659e4e4f0a0e 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs @@ -58,13 +58,8 @@ mod imports { genesis::{AssetHubWestendAssetOwner, ED as ASSET_HUB_WESTEND_ED}, AssetHubWestendParaPallet as AssetHubWestendPallet, }, - bridge_hub_westend_emulated_chain::{ - bridge_hub_westend_runtime::{ - xcm_config::{ - self as bhw_xcm_config, - XcmConfig as BridgeHubWestendXcmConfig, - }, - }, + bridge_hub_westend_emulated_chain::bridge_hub_westend_runtime::xcm_config::{ + self as bhw_xcm_config, XcmConfig as BridgeHubWestendXcmConfig, }, collectives_westend_emulated_chain::CollectivesWestendParaPallet as CollectivesWestendPallet, penpal_emulated_chain::{ @@ -106,7 +101,7 @@ mod imports { pub type ParaToParaThroughRelayTest = Test; pub type ParaToParaThroughAHTest = Test; pub type RelayToParaThroughAHTest = Test; - pub type BridgeToAssetHubTest = Test; + pub type BridgeHubToAssetHubTest = Test; pub type AssetHubToBridgeHubTest = Test; } diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs index 8ab45abc373e..c8ea815b8bde 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs @@ -18,10 +18,9 @@ mod fellowship_treasury; mod hybrid_transfers; mod reserve_transfer; mod send; +mod set_asset_claimer; mod set_xcm_versions; mod swap; mod teleport; mod treasury; mod xcm_fee_estimation; -mod set_asset_claimer; -mod set_asset_claimer_multichain; diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 9a134db28f0c..3c2824c49881 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -15,271 +15,243 @@ //! Tests related to claiming assets trapped during XCM execution. -use emulated_integration_tests_common::accounts::{ALICE, BOB, CHARLIE}; -use emulated_integration_tests_common::impls::AccountId32; -use emulated_integration_tests_common::xcm_emulator::log; -use crate::{ - imports::*, +use crate::imports::*; +use emulated_integration_tests_common::{ + accounts::{ALICE, BOB}, + impls::AccountId32, }; -use frame_support::{sp_runtime::{traits::Dispatchable}, assert_ok, LOG_TARGET}; -use westend_system_emulated_network::penpal_emulated_chain::penpal_runtime; -use westend_system_emulated_network::asset_hub_westend_emulated_chain::asset_hub_westend_runtime; -use westend_system_emulated_network::westend_emulated_chain::westend_runtime::xcm_config::AssetHub; +use frame_support::{assert_ok, sp_runtime::traits::Dispatchable}; use xcm_executor::traits::ConvertLocation; -use crate::imports::ahw_xcm_config::{LocationToAccountId, UniversalLocation}; +use crate::imports::bhw_xcm_config::{LocationToAccountId, UniversalLocation}; #[test] fn test_set_asset_claimer_within_a_chain() { - let (alice_account, alice_location) = account_and_location(ALICE); - let (bob_account, bob_location) = account_and_location(BOB); - - PenpalA::execute_with(|| { - type System = ::System; - type RuntimeOrigin = ::RuntimeOrigin; - assert_ok!(System::set_storage( - RuntimeOrigin::root(), - vec![(penpal_runtime::xcm_config::RelayNetworkId::key().to_vec(), NetworkId::Westend.encode())] - )); - }); - - let amount_to_send = 16_000_000_000_000; - let native_asset_location = RelayLocation::get(); - let assets: Assets = (Parent, amount_to_send).into(); - - fund_account(&alice_account, amount_to_send * 2); - assert_eq!(query_balance(&alice_account, &native_asset_location), amount_to_send * 2); - - let test_args = TestContext { - sender: alice_account.clone(), - receiver: bob_account.clone(), - args: TestArgs::new_para( - bob_location.clone(), - bob_account.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let test = ParaToParaThroughAHTest::new(test_args); - execute_test(test.clone(), bob_location.clone(), transfer_assets); - - let alice_assets_after = query_balance(&alice_account, &native_asset_location); - assert_eq!(alice_assets_after, amount_to_send); - - let test_args = TestContext { - sender: bob_account.clone(), - receiver: alice_account.clone(), - args: TestArgs::new_para( - alice_location.clone(), - alice_account.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let test = ParaToParaThroughAHTest::new(test_args); - execute_test(test.clone(), bob_location.clone(), claim_assets); - - let bob_assets_after = query_balance(&bob_account, &native_asset_location); - assert_eq!(bob_assets_after, amount_to_send); + let (alice_account, alice_location) = account_and_location(ALICE); + let (bob_account, bob_location) = account_and_location(BOB); + + let amount_to_send = 16_000_000_000_000; + let assets: Assets = (Parent, amount_to_send).into(); + + fund_account(&alice_account, amount_to_send * 2); + assert_eq!(query_balance(&alice_account, &RelayLocation::get()), amount_to_send * 2); + + let test_args = TestContext { + sender: alice_account.clone(), + receiver: bob_account.clone(), + args: TestArgs::new_para( + bob_location.clone(), + bob_account.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let test = ParaToParaThroughAHTest::new(test_args); + execute_test(test.clone(), bob_location.clone(), transfer_assets); + + let alice_assets_after = query_balance(&alice_account, &RelayLocation::get()); + assert_eq!(alice_assets_after, amount_to_send); + + let test_args = TestContext { + sender: bob_account.clone(), + receiver: alice_account.clone(), + args: TestArgs::new_para( + alice_location.clone(), + alice_account.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let test = ParaToParaThroughAHTest::new(test_args); + execute_test(test.clone(), bob_location.clone(), claim_assets); + + let bob_assets_after = query_balance(&bob_account, &RelayLocation::get()); + assert_eq!(bob_assets_after, amount_to_send); } fn account_and_location(account: &str) -> (AccountId32, Location) { - let account_id = PenpalA::account_id_of(account); - let account_clone = account_id.clone(); - let location: Location = [Junction::AccountId32 { network: Some(Westend), id: account_id.into() }].into(); - (account_clone, location) + let account_id = PenpalA::account_id_of(account); + let account_clone = account_id.clone(); + let location: Location = + [Junction::AccountId32 { network: Some(Westend), id: account_id.into() }].into(); + (account_clone, location) } fn fund_account(account: &AccountId, amount: u128) { - let asset_owner = PenpalAssetOwner::get(); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - Location::parent(), - account.clone(), - amount, - ); + let asset_owner = PenpalAssetOwner::get(); + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(asset_owner), + Location::parent(), + account.clone(), + amount, + ); } fn query_balance(account: &AccountId, asset_location: &Location) -> u128 { - PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(asset_location.clone(), account) - }) + PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(asset_location.clone(), account) + }) } fn execute_test( - test: ParaToParaThroughAHTest, - claimer: Location, - xcm_fn: impl Fn(ParaToParaThroughAHTest, Location) -> ::RuntimeCall, + test: ParaToParaThroughAHTest, + claimer: Location, + xcm_fn: impl Fn(ParaToParaThroughAHTest, Location) -> ::RuntimeCall, ) { - let call = xcm_fn(test.clone(), claimer.clone()); - PenpalA::execute_with(|| { - assert!(call.dispatch(test.signed_origin).is_ok()); - }); + let call = xcm_fn(test.clone(), claimer.clone()); + PenpalA::execute_with(|| { + assert!(call.dispatch(test.signed_origin).is_ok()); + }); } fn transfer_assets( - test: ParaToParaThroughAHTest, - claimer: Location + test: ParaToParaThroughAHTest, + claimer: Location, ) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; - - let local_xcm = Xcm::::builder_unsafe() - .set_asset_claimer(claimer.clone()) - .withdraw_asset(test.args.assets.clone()) - .clear_origin() - .build(); - - RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(local_xcm)), - max_weight: Weight::from_parts(4_000_000_000_000, 300_000), - }) + type RuntimeCall = ::RuntimeCall; + + let local_xcm = Xcm::::builder_unsafe() + .set_asset_claimer(claimer.clone()) + .withdraw_asset(test.args.assets.clone()) + .clear_origin() + .build(); + + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(4_000_000_000_000, 300_000), + }) } fn claim_assets( - test: ParaToParaThroughAHTest, - claimer: Location + test: ParaToParaThroughAHTest, + claimer: Location, ) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; + type RuntimeCall = ::RuntimeCall; - let local_xcm = Xcm::::builder_unsafe() - .claim_asset(test.args.assets.clone(), Here) - .deposit_asset(AllCounted(test.args.assets.len() as u32), claimer) - .build(); + let local_xcm = Xcm::::builder_unsafe() + .claim_asset(test.args.assets.clone(), Here) + .deposit_asset(AllCounted(test.args.assets.len() as u32), claimer) + .build(); - RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(local_xcm)), - max_weight: Weight::from_parts(4_000_000_000_000, 300_000), - }) + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(4_000_000_000_000, 300_000), + }) } +// The test: +// 1. Funds Bob account on BridgeHub, withdraws the funds, sets asset claimer to +// sibling account of Alice on AssetHub and traps the funds. +// 2. Sends an XCM from AssetHub to BridgeHub on behalf of Alice. The XCM: claims assets, +// pays fees and deposits assets to alice's sibling account. #[test] fn test_sac_between_the_chains() { - let alice = AssetHubWestend::account_id_of(ALICE); - let bob = BridgeHubWestend::account_id_of(BOB); - let destination = AssetHubWestend::sibling_location_of(BridgeHubWestend::para_id()); - let bob_location = Location::new(0, Junction::AccountId32 { network: Some(Westend), id: bob.clone().into() }); - - let amount_to_send = 16_000_000_000_000u128; - BridgeHubWestend::fund_accounts(vec![( - bob.clone(), - amount_to_send * 2, - )]); - let balance = ::account_data_of(bob.clone()).free; - - let assets: Assets = (Parent, amount_to_send).into(); - let test_args = TestContext { - sender: bob.clone(), - receiver: alice.clone(), - args: TestArgs::new_para( - bob_location.clone(), - bob.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let test = BridgeToAssetHubTest::new(test_args); - let alice_on_ah = Location::new( - 1, - [ - Parachain(1000), - Junction::AccountId32 { - network: Some(Westend), - id: alice.clone().into()}], - ); - - execute_bob_bh_test(test.clone(), alice_on_ah.clone(), trap_assets_bh); - - let balance = ::account_data_of(bob.clone()).free; - - - let amount_to_send = 16_000_000_000_000u128; - AssetHubWestend::fund_accounts(vec![( - alice.clone(), - amount_to_send * 2, - )]); - - println!("before LocationToAccountId"); - // let alLoc = LocationToAccountId::convert_location(&alice_on_ah).unwrap(); - // println!("alice Loc is: {:?}", alLoc); - // // let balance = ::account_data_of(alLoc.clone()).free; - // println!("[AH] Alice balance before {:?}", balance); - - // let test_args = TestContext { - // sender: alice.clone(), - // receiver: bob.clone(), - // args: TestArgs::new_para( - // destination.clone(), - // bob.clone(), - // amount_to_send, - // assets.clone(), - // None, - // 0, - // ), - // }; - // let alice_on_ah = Location::new( - // 1, - // [ - // Parachain(1000), - // Junction::AccountId32 { - // network: Some(Westend), - // id: alice.clone().into()}], - // ); - // let test = AssetHubToBridgeHubTest::new(test_args); - // let bridge_hub = AssetHubWestend::sibling_location_of( - // BridgeHubWestend::para_id() - // ).into(); - // let xcm_there = Xcm::<()>::builder_unsafe() - // .claim_asset(test.args.assets.clone(), Here) - // .pay_fees((Parent, 15_000_000_000_000u128)) - // .deposit_asset(All, alice_on_ah.clone()) - // .build(); - // AssetHubWestend::execute_with(|| { - // assert_ok!(::PolkadotXcm::send( - // test.signed_origin, - // bx!(bridge_hub), - // bx!(VersionedXcm::from(xcm_there)), - // )); - // }); - // - // - // let alLoc = ahw_xcm_config::LocationToAccountId::convert_location(&alice_on_ah).unwrap(); - // let balance = ::account_data_of(alLoc).free; - // println!("[AH] Alice balance after {:?}", balance); + let alice = AssetHubWestend::account_id_of(ALICE); + let alice_bh_sibling = Location::new( + 1, + [ + Parachain(AssetHubWestend::para_id().into()), + Junction::AccountId32 { network: Some(Westend), id: alice.clone().into() }, + ], + ); + let bob = BridgeHubWestend::account_id_of(BOB); + let bob_location = + Location::new(0, Junction::AccountId32 { network: Some(Westend), id: bob.clone().into() }); + + let amount_to_send = 16_000_000_000_000u128; + BridgeHubWestend::fund_accounts(vec![(bob.clone(), amount_to_send * 2)]); + + let assets: Assets = (Parent, amount_to_send).into(); + let test_args = TestContext { + sender: bob.clone(), + receiver: alice.clone(), + args: TestArgs::new_para( + bob_location.clone(), + bob.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let test = BridgeHubToAssetHubTest::new(test_args); + execute_bob_bh_test(test.clone(), alice_bh_sibling.clone(), trap_assets_bh); + + let alice_bh_acc = LocationToAccountId::convert_location(&alice_bh_sibling).unwrap(); + let balance = ::account_data_of(alice_bh_acc.clone()).free; + assert_eq!(balance, 0); + + let destination = AssetHubWestend::sibling_location_of(BridgeHubWestend::para_id()); + let test_args = TestContext { + sender: alice.clone(), + receiver: bob.clone(), + args: TestArgs::new_para( + destination.clone(), + bob.clone(), + amount_to_send, + assets.clone(), + None, + 0, + ), + }; + let alice_bh_sibling = Location::new( + 1, + [ + Parachain(AssetHubWestend::para_id().into()), + Junction::AccountId32 { network: Some(Westend), id: alice.clone().into() }, + ], + ); + let test = AssetHubToBridgeHubTest::new(test_args); + let pay_fees = 6_000_000_000_000u128; + let xcm_on_bh = Xcm::<()>::builder_unsafe() + .claim_asset(test.args.assets.clone(), Here) + .pay_fees((Parent, pay_fees)) + .deposit_asset(All, alice_bh_sibling.clone()) + .build(); + let bh_on_ah = AssetHubWestend::sibling_location_of(BridgeHubWestend::para_id()).into(); + AssetHubWestend::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + test.signed_origin, + bx!(bh_on_ah), + bx!(VersionedXcm::from(xcm_on_bh)), + )); + }); + + let al_bh_acc = LocationToAccountId::convert_location(&alice_bh_sibling).unwrap(); + let balance = ::account_data_of(al_bh_acc).free; + assert_eq!(balance, amount_to_send - pay_fees); +} +fn trap_assets_bh( + test: BridgeHubToAssetHubTest, + claimer: Location, +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; + + let local_xcm = Xcm::::builder_unsafe() + .set_asset_claimer(claimer.clone()) + .withdraw_asset(test.args.assets.clone()) + .clear_origin() + .build(); + + RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(4_000_000_000_000, 700_000), + }) } fn execute_bob_bh_test( - test: BridgeToAssetHubTest, - claimer: Location, - xcm_fn: impl Fn(BridgeToAssetHubTest, Location) -> ::RuntimeCall, + test: BridgeHubToAssetHubTest, + claimer: Location, + xcm_fn: impl Fn(BridgeHubToAssetHubTest, Location) -> ::RuntimeCall, ) { - let call = xcm_fn(test.clone(), claimer.clone()); - BridgeHubWestend::execute_with(|| { - assert!(call.dispatch(test.signed_origin).is_ok()); - }); + let call = xcm_fn(test.clone(), claimer.clone()); + BridgeHubWestend::execute_with(|| { + assert!(call.dispatch(test.signed_origin).is_ok()); + }); } - -fn trap_assets_bh( - test: BridgeToAssetHubTest, - claimer: Location -) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; - - let local_xcm = Xcm::::builder_unsafe() - .set_asset_claimer(claimer.clone()) - .withdraw_asset(test.args.assets.clone()) - .clear_origin() - .build(); - - RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(local_xcm)), - max_weight: Weight::from_parts(4_000_000_000_000, 700_000), - }) -} \ No newline at end of file diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer_multichain.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer_multichain.rs deleted file mode 100644 index 087ea5234183..000000000000 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer_multichain.rs +++ /dev/null @@ -1,203 +0,0 @@ -use emulated_integration_tests_common::accounts::{ALICE, BOB, CHARLIE}; -use emulated_integration_tests_common::impls::AccountId32; -use emulated_integration_tests_common::xcm_emulator::log; -use crate::{ - imports::*, -}; - -use frame_support::{sp_runtime::{traits::Dispatchable}, assert_ok, LOG_TARGET}; -use westend_system_emulated_network::asset_hub_westend_emulated_chain::asset_hub_westend_runtime; -use westend_system_emulated_network::bridge_hub_westend_emulated_chain::BridgeHubWestendParaPallet; -use westend_system_emulated_network::westend_emulated_chain::westend_runtime::xcm_config::AssetHub; -use crate::imports::ahw_xcm_config::UniversalLocation; - -#[test] -fn test_set_asset_claimer_on_multiverse() { - println!("printlined_error"); - - let alice = AssetHubWestend::account_id_of(ALICE); - let bob = BridgeHubWestend::account_id_of(BOB); - let destination = BridgeHubWestend::sibling_location_of(AssetHubWestend::para_id()); - let alice_location = Location::new(0, Junction::AccountId32 { network: None, id: alice.clone().into() }); - let assets: Assets = (Parent, 12300456000u128).into(); - // let alice_on_asset_hub = Location::new(1, [Parachain(1000), Junction::AccountId32 { id: [67u8; 32], network: Some(Westend) }]); - - - let bob_on_bh = Location::new( - 1, - [ - Parachain(BridgeHubWestend::para_id().into()), - Junction::AccountId32 { - network: Some(Westend), - id: bob.clone().into()}], - ); - println!("BOB on BridgeHub: {:?}", bob_on_bh); - // let bob_acc = AssetHubWestend::sovereign_account_id_of(PenpalASender::); - - let amount_to_send = 16_000_000_000_000u128; - let alice_acc = AssetHubWestend::account_id_of(ALICE); - AssetHubWestend::fund_accounts(vec![( - alice_acc.clone(), - amount_to_send * 2, - )]); - - let balance = ::account_data_of(alice_acc.clone()).free; - println!("alice balance {:?}", balance); - - - let test_args = TestContext { - sender: alice_acc.clone(), - receiver: alice_acc.clone(), - args: TestArgs::new_para( - alice_location.clone(), - alice_acc.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let test = SystemParaToParaTest::new(test_args); - execute_ah_test(test.clone(), bob_on_bh.clone(), trap_assets_ah); - - let balance = ::account_data_of(alice_acc.clone()).free; - println!("ali balance {:?}", balance); - - - - // SECOND PART OF THE TEST - - BridgeHubWestend::fund_accounts(vec![( - bob.clone(), - amount_to_send * 20000, - )]); - - let balance = ::account_data_of(bob.clone()).free; - println!("bob balance {:?}", balance); - - let test_args = TestContext { - sender: bob.clone(), - receiver: alice.clone(), - args: TestArgs::new_para( - destination.clone(), - alice_acc.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let test = BridgeToAssetHubTest::new(test_args); - let asset_hub = BridgeHubWestend::sibling_location_of( - AssetHubWestend::para_id() - ).into(); - let xcm_there = Xcm::<()>::builder_unsafe() - .claim_asset(test.args.assets.clone(), Here) - .pay_fees((Parent, 40_000_000_000u128)) - .deposit_asset(AllCounted(1), bob_on_bh.clone()) - .build(); - - BridgeHubWestend::execute_with(|| { - assert_ok!(::PolkadotXcm::send( - test.signed_origin, - bx!(asset_hub), - bx!(VersionedXcm::from(xcm_there)), - )); - }); - - // execute_bh_test(test.clone(), bob_on_bh.clone(), transfer_assets_from_bh); -} - -fn execute_bh_test( - test: BridgeToAssetHubTest, - claimer: Location, - xcm_fn: impl Fn(BridgeToAssetHubTest, Location) -> ::RuntimeCall, -) { - let call = xcm_fn(test.clone(), claimer.clone()); - BridgeHubWestend::execute_with(|| { - assert!(call.dispatch(test.signed_origin).is_ok()); - }); -} - -fn transfer_assets_from_bh( - test: BridgeToAssetHubTest, - claimer: Location -) -> ::RuntimeCall { - - let xcm_there = Xcm::<()>::builder_unsafe() - .pay_fees((Parent, 40_000_000_000u128)) - .claim_asset(test.args.assets.clone(), Here) - .deposit_asset(AllCounted(1), claimer) - .build(); - - let xcm_here = Xcm::::builder_unsafe() - .withdraw_asset((Parent, 200_000_000_000u128)) - .pay_fees((Parent, 40_000_000_000u128)) - .export_message( - Westend, - Parachain(1000), - xcm_there - ) - // .transfer_reserve_asset( - // (Parent, 60_000_000_000u128), - // test.args.dest.clone(), xcm_there) - // .initiate_teleport( - // Definite((Parent, 60_000_000_000u128).into()), - // test.args.dest.clone(), xcm_there) - .build(); - - type RuntimeCall = ::RuntimeCall; - RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(xcm_here)), - max_weight: Weight::from_parts(4_000_000_000_000, 300_000), - }) - - - // .transfer_reserve_asset(test.args.assets.clone(), bob_on_ah, xcm_there) - // .withdraw_asset(test.args.assets.clone()) - // .transfer_reserve_asset(test.args.assets.clone(), bob_on_ah, xcm_there) - // .deposit_reserve_asset(test.args.assets.clone(), test.args.dest.clone(), xcm_there) - // let al_ac = AssetHubWestend::account_id_of(ALICE); - // let bob_on_ah = Location::new( - // 1, - // [ - // Parachain(AssetHubWestend::para_id().into()), - // Junction::AccountId32 { - // network: None, - // id: al_ac.clone().into()} - // ], - // ); - // let fee_asset = Asset { id: AssetId(Location::new(0, [])), fun: Fungibility::Fungible(1_000_000_000u128) }; - // let asset_hub = BridgeHubWestend::sibling_location_of(AssetHubWestend::para_id());a -} - - -fn execute_ah_test( - test: SystemParaToParaTest, - claimer: Location, - xcm_fn: impl Fn(SystemParaToParaTest, Location) -> ::RuntimeCall, -) { - let call = xcm_fn(test.clone(), claimer.clone()); - AssetHubWestend::execute_with(|| { - assert!(call.dispatch(test.signed_origin).is_ok()); - }); -} - -fn trap_assets_ah( - test: SystemParaToParaTest, - claimer: Location -) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; - - let local_xcm = Xcm::::builder_unsafe() - .set_asset_claimer(claimer.clone()) - .withdraw_asset(test.args.assets.clone()) - .clear_origin() - .build(); - - RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(local_xcm)), - max_weight: Weight::from_parts(4_000_000_000_000, 300_000), - }) -} - diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs index 15d39858acca..c0f31d20513d 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs @@ -265,7 +265,9 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() { let delivery_fees = AssetHubWestend::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) + >( + test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest + ) }); // Sender's balance is reduced diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index ba5a4eae17c2..9c5b7b3004e8 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -45,20 +45,7 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice; use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor; use sp_runtime::traits::{AccountIdConversion, ConvertInto, TryConvertInto}; use xcm::latest::prelude::*; -use xcm_builder::{ - AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, - AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, - DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal, - EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, - GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint, - MatchedConvertedConcreteId, NetworkExportTableItem, NoChecking, NonFungiblesAdapter, - ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, - SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SingleAssetExchangeAdapter, SovereignPaidRemoteExporter, - SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus, TakeWeightCredit, - TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, - WithLatestLocationConverter, WithUniqueTopic, XcmFeeManagerFromComponents, -}; +use xcm_builder::{AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, DescribePalletTerminal, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint, MatchedConvertedConcreteId, NetworkExportTableItem, NoChecking, NonFungiblesAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SingleAssetExchangeAdapter, SovereignPaidRemoteExporter, SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithLatestLocationConverter, WithUniqueTopic, XcmFeeManagerFromComponents}; use xcm_executor::XcmExecutor; parameter_types! { @@ -96,6 +83,7 @@ pub type LocationToAccountId = ( // Foreign chain account alias into local accounts according to a hash of their standard // description. HashedDescription>, + HashedDescription>, // Different global consensus parachain sovereign account. // (Used for over-bridge transfers and reserve processing) GlobalConsensusParachainConvertsFor, diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs index 6b2f86551543..c337289243b7 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs @@ -343,12 +343,4 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - - fn set_asset_claimer() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 707_000 picoseconds. - Weight::from_parts(749_000, 0) - } } diff --git a/expansion.rs b/expansion.rs deleted file mode 100644 index c7136479719b..000000000000 --- a/expansion.rs +++ /dev/null @@ -1,4772 +0,0 @@ -#![feature(prelude_import)] -#[prelude_import] -use std::prelude::rust_2021::*; -#[macro_use] -extern crate std; -pub use penpal_runtime::{self, xcm_config::RelayNetworkId as PenpalRelayNetworkId}; -mod genesis { - use frame_support::parameter_types; - use sp_core::{sr25519, storage::Storage}; - use emulated_integration_tests_common::{ - accounts, build_genesis_storage, collators, get_account_id_from_seed, - SAFE_XCM_VERSION, - }; - use parachains_common::{AccountId, Balance}; - use penpal_runtime::xcm_config::{ - LocalReservableFromAssetHub, RelayLocation, UsdtFromAssetHub, - }; - pub const PARA_ID_A: u32 = 2000; - pub const PARA_ID_B: u32 = 2001; - pub const ED: Balance = penpal_runtime::EXISTENTIAL_DEPOSIT; - pub const USDT_ED: Balance = 70_000; - pub struct PenpalSudoAccount; - impl PenpalSudoAccount { - /// Returns the value of this parameter type. - pub fn get() -> AccountId { - get_account_id_from_seed::("Alice") - } - } - impl<_I: From> ::frame_support::traits::Get<_I> for PenpalSudoAccount { - fn get() -> _I { - _I::from(Self::get()) - } - } - impl ::frame_support::traits::TypedGet for PenpalSudoAccount { - type Type = AccountId; - fn get() -> AccountId { - Self::get() - } - } - pub struct PenpalAssetOwner; - impl PenpalAssetOwner { - /// Returns the value of this parameter type. - pub fn get() -> AccountId { - PenpalSudoAccount::get() - } - } - impl<_I: From> ::frame_support::traits::Get<_I> for PenpalAssetOwner { - fn get() -> _I { - _I::from(Self::get()) - } - } - impl ::frame_support::traits::TypedGet for PenpalAssetOwner { - type Type = AccountId; - fn get() -> AccountId { - Self::get() - } - } - pub fn genesis(para_id: u32) -> Storage { - let genesis_config = penpal_runtime::RuntimeGenesisConfig { - system: penpal_runtime::SystemConfig::default(), - balances: penpal_runtime::BalancesConfig { - balances: accounts::init_balances() - .iter() - .cloned() - .map(|k| (k, ED * 4096)) - .collect(), - }, - parachain_info: penpal_runtime::ParachainInfoConfig { - parachain_id: para_id.into(), - ..Default::default() - }, - collator_selection: penpal_runtime::CollatorSelectionConfig { - invulnerables: collators::invulnerables() - .iter() - .cloned() - .map(|(acc, _)| acc) - .collect(), - candidacy_bond: ED * 16, - ..Default::default() - }, - session: penpal_runtime::SessionConfig { - keys: collators::invulnerables() - .into_iter() - .map(|(acc, aura)| { - ( - acc.clone(), - acc, - penpal_runtime::SessionKeys { - aura, - }, - ) - }) - .collect(), - ..Default::default() - }, - polkadot_xcm: penpal_runtime::PolkadotXcmConfig { - safe_xcm_version: Some(SAFE_XCM_VERSION), - ..Default::default() - }, - sudo: penpal_runtime::SudoConfig { - key: Some(PenpalSudoAccount::get()), - }, - assets: penpal_runtime::AssetsConfig { - assets: <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - penpal_runtime::xcm_config::TELEPORTABLE_ASSET_ID, - PenpalAssetOwner::get(), - false, - ED, - ), - ]), - ), - ..Default::default() - }, - foreign_assets: penpal_runtime::ForeignAssetsConfig { - assets: <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (RelayLocation::get(), PenpalAssetOwner::get(), true, ED), - ( - LocalReservableFromAssetHub::get(), - PenpalAssetOwner::get(), - true, - ED, - ), - (UsdtFromAssetHub::get(), PenpalAssetOwner::get(), true, USDT_ED), - ]), - ), - ..Default::default() - }, - ..Default::default() - }; - build_genesis_storage( - &genesis_config, - penpal_runtime::WASM_BINARY - .expect("WASM binary was not built, please build it!"), - ) - } -} -pub use genesis::{ - genesis, PenpalAssetOwner, PenpalSudoAccount, ED, PARA_ID_A, PARA_ID_B, -}; -use frame_support::traits::OnInitialize; -use sp_core::Encode; -use emulated_integration_tests_common::{ - impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, - impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain, - impl_xcm_helpers_for_parachain, impls::{NetworkId, Parachain}, - xcm_emulator::decl_test_parachains, -}; -pub struct PenpalA(::xcm_emulator::PhantomData); -#[automatically_derived] -impl ::core::clone::Clone for PenpalA { - #[inline] - fn clone(&self) -> PenpalA { - PenpalA(::core::clone::Clone::clone(&self.0)) - } -} -impl ::xcm_emulator::Chain for PenpalA { - type Runtime = penpal_runtime::Runtime; - type RuntimeCall = penpal_runtime::RuntimeCall; - type RuntimeOrigin = penpal_runtime::RuntimeOrigin; - type RuntimeEvent = penpal_runtime::RuntimeEvent; - type System = ::xcm_emulator::SystemPallet; - type OriginCaller = penpal_runtime::OriginCaller; - type Network = N; - fn account_data_of( - account: ::xcm_emulator::AccountIdOf, - ) -> ::xcm_emulator::AccountData<::xcm_emulator::Balance> { - ::ext_wrapper(|| { - ::xcm_emulator::SystemPallet::::account(account).data.into() - }) - } - fn events() -> Vec<::RuntimeEvent> { - Self::System::events().iter().map(|record| record.event.clone()).collect() - } -} -impl ::xcm_emulator::Parachain for PenpalA { - type XcmpMessageHandler = penpal_runtime::XcmpQueue; - type LocationToAccountId = penpal_runtime::xcm_config::LocationToAccountId; - type ParachainSystem = ::xcm_emulator::ParachainSystemPallet< - ::Runtime, - >; - type ParachainInfo = penpal_runtime::ParachainInfo; - type MessageProcessor = ::xcm_emulator::DefaultParaMessageProcessor< - PenpalA, - cumulus_primitives_core::AggregateMessageOrigin, - >; - fn init() { - use ::xcm_emulator::{ - Chain, HeadData, Network, Hooks, Encode, Parachain, TestExt, - }; - LOCAL_EXT_PENPALA - .with(|v| *v.borrow_mut() = Self::build_new_ext(genesis(PARA_ID_A))); - Self::set_last_head(); - Self::new_block(); - Self::finalize_block(); - } - fn new_block() { - use ::xcm_emulator::{ - Chain, HeadData, Network, Hooks, Encode, Parachain, TestExt, - }; - let para_id = Self::para_id().into(); - Self::ext_wrapper(|| { - let mut relay_block_number = N::relay_block_number(); - relay_block_number += 1; - N::set_relay_block_number(relay_block_number); - let mut block_number = ::System::block_number(); - block_number += 1; - let parent_head_data = ::xcm_emulator::LAST_HEAD - .with(|b| { - b - .borrow_mut() - .get_mut(N::name()) - .expect("network not initialized?") - .get(¶_id) - .expect("network not initialized?") - .clone() - }); - ::System::initialize( - &block_number, - &parent_head_data.hash(), - &Default::default(), - ); - <::ParachainSystem as Hooks< - ::xcm_emulator::BlockNumberFor, - >>::on_initialize(block_number); - let _ = ::ParachainSystem::set_validation_data( - ::RuntimeOrigin::none(), - N::hrmp_channel_parachain_inherent_data( - para_id, - relay_block_number, - parent_head_data, - ), - ); - }); - } - fn finalize_block() { - use ::xcm_emulator::{Chain, Encode, Hooks, Network, Parachain, TestExt}; - Self::ext_wrapper(|| { - let block_number = ::System::block_number(); - ::ParachainSystem::on_finalize(block_number); - }); - Self::set_last_head(); - } - fn set_last_head() { - use ::xcm_emulator::{Chain, Encode, HeadData, Network, Parachain, TestExt}; - let para_id = Self::para_id().into(); - Self::ext_wrapper(|| { - let created_header = ::System::finalize(); - ::xcm_emulator::LAST_HEAD - .with(|b| { - b - .borrow_mut() - .get_mut(N::name()) - .expect("network not initialized?") - .insert(para_id, HeadData(created_header.encode())) - }); - }); - } -} -pub trait PenpalAParaPallet { - type System; - type PolkadotXcm; - type Assets; - type ForeignAssets; - type AssetConversion; - type Balances; -} -impl PenpalAParaPallet for PenpalA { - type System = penpal_runtime::System; - type PolkadotXcm = penpal_runtime::PolkadotXcm; - type Assets = penpal_runtime::Assets; - type ForeignAssets = penpal_runtime::ForeignAssets; - type AssetConversion = penpal_runtime::AssetConversion; - type Balances = penpal_runtime::Balances; -} -pub const LOCAL_EXT_PENPALA: ::std::thread::LocalKey< - ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, -> = { - #[inline] - fn __init() -> ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities> { - ::xcm_emulator::RefCell::new( - ::xcm_emulator::TestExternalities::new(genesis(PARA_ID_A)), - ) - } - unsafe { - use ::std::mem::needs_drop; - use ::std::thread::LocalKey; - use ::std::thread::local_impl::LazyStorage; - LocalKey::new(const { - if needs_drop::< - ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, - >() { - |init| { - #[thread_local] - static VAL: LazyStorage< - ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, - (), - > = LazyStorage::new(); - VAL.get_or_init(init, __init) - } - } else { - |init| { - #[thread_local] - static VAL: LazyStorage< - ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, - !, - > = LazyStorage::new(); - VAL.get_or_init(init, __init) - } - } - }) - } -}; -#[allow(missing_copy_implementations)] -#[allow(non_camel_case_types)] -#[allow(dead_code)] -pub struct GLOBAL_EXT_PENPALA { - __private_field: (), -} -#[doc(hidden)] -pub static GLOBAL_EXT_PENPALA: GLOBAL_EXT_PENPALA = GLOBAL_EXT_PENPALA { - __private_field: (), -}; -impl ::lazy_static::__Deref for GLOBAL_EXT_PENPALA { - type Target = ::xcm_emulator::Mutex< - ::xcm_emulator::RefCell< - ::xcm_emulator::HashMap, - >, - >; - fn deref( - &self, - ) -> &::xcm_emulator::Mutex< - ::xcm_emulator::RefCell< - ::xcm_emulator::HashMap, - >, - > { - #[inline(always)] - fn __static_ref_initialize() -> ::xcm_emulator::Mutex< - ::xcm_emulator::RefCell< - ::xcm_emulator::HashMap, - >, - > { - ::xcm_emulator::Mutex::new( - ::xcm_emulator::RefCell::new(::xcm_emulator::HashMap::new()), - ) - } - #[inline(always)] - fn __stability() -> &'static ::xcm_emulator::Mutex< - ::xcm_emulator::RefCell< - ::xcm_emulator::HashMap, - >, - > { - static LAZY: ::lazy_static::lazy::Lazy< - ::xcm_emulator::Mutex< - ::xcm_emulator::RefCell< - ::xcm_emulator::HashMap< - String, - ::xcm_emulator::TestExternalities, - >, - >, - >, - > = ::lazy_static::lazy::Lazy::INIT; - LAZY.get(__static_ref_initialize) - } - __stability() - } -} -impl ::lazy_static::LazyStatic for GLOBAL_EXT_PENPALA { - fn initialize(lazy: &Self) { - let _ = &**lazy; - } -} -impl ::xcm_emulator::TestExt for PenpalA { - fn build_new_ext( - storage: ::xcm_emulator::Storage, - ) -> ::xcm_emulator::TestExternalities { - let mut ext = ::xcm_emulator::TestExternalities::new(storage); - ext.execute_with(|| { - #[allow(clippy::no_effect)] - { - penpal_runtime::AuraExt::on_initialize(1); - let is = penpal_runtime::System::set_storage( - penpal_runtime::RuntimeOrigin::root(), - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - PenpalRelayNetworkId::key().to_vec(), - NetworkId::Rococo.encode(), - ), - ]), - ), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }; - ::xcm_emulator::sp_tracing::try_init_simple(); - let mut block_number = ::System::block_number(); - block_number = std::cmp::max(1, block_number); - ::System::set_block_number(block_number); - }); - ext - } - fn new_ext() -> ::xcm_emulator::TestExternalities { - Self::build_new_ext(genesis(PARA_ID_A)) - } - fn move_ext_out(id: &'static str) { - use ::xcm_emulator::Deref; - let local_ext = LOCAL_EXT_PENPALA.with(|v| { v.take() }); - let global_ext_guard = GLOBAL_EXT_PENPALA.lock().unwrap(); - global_ext_guard.deref().borrow_mut().insert(id.to_string(), local_ext); - } - fn move_ext_in(id: &'static str) { - use ::xcm_emulator::Deref; - let mut global_ext_unlocked = false; - while !global_ext_unlocked { - let global_ext_result = GLOBAL_EXT_PENPALA.try_lock(); - if let Ok(global_ext_guard) = global_ext_result { - if !global_ext_guard.deref().borrow().contains_key(id) { - drop(global_ext_guard); - } else { - global_ext_unlocked = true; - } - } - } - let mut global_ext_guard = GLOBAL_EXT_PENPALA.lock().unwrap(); - let global_ext = global_ext_guard.deref(); - LOCAL_EXT_PENPALA - .with(|v| { - v.replace(global_ext.take().remove(id).unwrap()); - }); - } - fn reset_ext() { - LOCAL_EXT_PENPALA - .with(|v| *v.borrow_mut() = Self::build_new_ext(genesis(PARA_ID_A))); - } - fn execute_with(execute: impl FnOnce() -> R) -> R { - use ::xcm_emulator::{Chain, Get, Hooks, Network, Parachain, Encode}; - ::init(); - Self::new_block(); - let r = LOCAL_EXT_PENPALA.with(|v| v.borrow_mut().execute_with(execute)); - Self::finalize_block(); - let para_id = Self::para_id().into(); - LOCAL_EXT_PENPALA - .with(|v| { - v.borrow_mut() - .execute_with(|| { - let mock_header = ::xcm_emulator::HeaderT::new( - 0, - Default::default(), - Default::default(), - Default::default(), - Default::default(), - ); - let collation_info = ::ParachainSystem::collect_collation_info( - &mock_header, - ); - let relay_block_number = ::relay_block_number(); - for msg in collation_info.upward_messages.clone() { - ::send_upward_message(para_id, msg); - } - for msg in collation_info.horizontal_messages { - ::send_horizontal_messages( - msg.recipient.into(), - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (para_id.into(), relay_block_number, msg.data), - ]), - ) - .into_iter(), - ); - } - type NetworkBridge = ::Bridge; - let bridge_messages = < as ::xcm_emulator::Bridge>::Handler as ::xcm_emulator::BridgeMessageHandler>::get_source_outbound_messages(); - for msg in bridge_messages { - ::send_bridged_messages(msg); - } - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalA", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - ::System::reset_events(); - }) - }); - ::process_messages(); - r - } - fn ext_wrapper(func: impl FnOnce() -> R) -> R { - LOCAL_EXT_PENPALA.with(|v| { v.borrow_mut().execute_with(|| { func() }) }) - } -} -impl< - N, - Origin, - Destination, - Hops, - Args, -> ::xcm_emulator::CheckAssertion for PenpalA -where - N: ::xcm_emulator::Network, - Origin: ::xcm_emulator::Chain + Clone, - Destination: ::xcm_emulator::Chain + Clone, - Origin::RuntimeOrigin: ::xcm_emulator::OriginTrait< - AccountId = ::xcm_emulator::AccountIdOf, - > + Clone, - Destination::RuntimeOrigin: ::xcm_emulator::OriginTrait< - AccountId = ::xcm_emulator::AccountIdOf, - > + Clone, - Hops: Clone, - Args: Clone, -{ - fn check_assertion(test: ::xcm_emulator::Test) { - use ::xcm_emulator::{Dispatchable, TestExt}; - let chain_name = std::any::type_name::>(); - >::execute_with(|| { - if let Some(dispatchable) = test.hops_dispatchable.get(chain_name) { - let is = dispatchable(test.clone()); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - } - if let Some(call) = test.hops_calls.get(chain_name) { - let is = match call.clone().dispatch(test.signed_origin.clone()) { - Ok(_) => Ok(()), - Err(error_with_post_info) => Err(error_with_post_info.error), - }; - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - } - if let Some(assertion) = test.hops_assertion.get(chain_name) { - assertion(test); - } - }); - } -} -pub struct PenpalB(::xcm_emulator::PhantomData); -#[automatically_derived] -impl ::core::clone::Clone for PenpalB { - #[inline] - fn clone(&self) -> PenpalB { - PenpalB(::core::clone::Clone::clone(&self.0)) - } -} -impl ::xcm_emulator::Chain for PenpalB { - type Runtime = penpal_runtime::Runtime; - type RuntimeCall = penpal_runtime::RuntimeCall; - type RuntimeOrigin = penpal_runtime::RuntimeOrigin; - type RuntimeEvent = penpal_runtime::RuntimeEvent; - type System = ::xcm_emulator::SystemPallet; - type OriginCaller = penpal_runtime::OriginCaller; - type Network = N; - fn account_data_of( - account: ::xcm_emulator::AccountIdOf, - ) -> ::xcm_emulator::AccountData<::xcm_emulator::Balance> { - ::ext_wrapper(|| { - ::xcm_emulator::SystemPallet::::account(account).data.into() - }) - } - fn events() -> Vec<::RuntimeEvent> { - Self::System::events().iter().map(|record| record.event.clone()).collect() - } -} -impl ::xcm_emulator::Parachain for PenpalB { - type XcmpMessageHandler = penpal_runtime::XcmpQueue; - type LocationToAccountId = penpal_runtime::xcm_config::LocationToAccountId; - type ParachainSystem = ::xcm_emulator::ParachainSystemPallet< - ::Runtime, - >; - type ParachainInfo = penpal_runtime::ParachainInfo; - type MessageProcessor = ::xcm_emulator::DefaultParaMessageProcessor< - PenpalB, - cumulus_primitives_core::AggregateMessageOrigin, - >; - fn init() { - use ::xcm_emulator::{ - Chain, HeadData, Network, Hooks, Encode, Parachain, TestExt, - }; - LOCAL_EXT_PENPALB - .with(|v| *v.borrow_mut() = Self::build_new_ext(genesis(PARA_ID_B))); - Self::set_last_head(); - Self::new_block(); - Self::finalize_block(); - } - fn new_block() { - use ::xcm_emulator::{ - Chain, HeadData, Network, Hooks, Encode, Parachain, TestExt, - }; - let para_id = Self::para_id().into(); - Self::ext_wrapper(|| { - let mut relay_block_number = N::relay_block_number(); - relay_block_number += 1; - N::set_relay_block_number(relay_block_number); - let mut block_number = ::System::block_number(); - block_number += 1; - let parent_head_data = ::xcm_emulator::LAST_HEAD - .with(|b| { - b - .borrow_mut() - .get_mut(N::name()) - .expect("network not initialized?") - .get(¶_id) - .expect("network not initialized?") - .clone() - }); - ::System::initialize( - &block_number, - &parent_head_data.hash(), - &Default::default(), - ); - <::ParachainSystem as Hooks< - ::xcm_emulator::BlockNumberFor, - >>::on_initialize(block_number); - let _ = ::ParachainSystem::set_validation_data( - ::RuntimeOrigin::none(), - N::hrmp_channel_parachain_inherent_data( - para_id, - relay_block_number, - parent_head_data, - ), - ); - }); - } - fn finalize_block() { - use ::xcm_emulator::{Chain, Encode, Hooks, Network, Parachain, TestExt}; - Self::ext_wrapper(|| { - let block_number = ::System::block_number(); - ::ParachainSystem::on_finalize(block_number); - }); - Self::set_last_head(); - } - fn set_last_head() { - use ::xcm_emulator::{Chain, Encode, HeadData, Network, Parachain, TestExt}; - let para_id = Self::para_id().into(); - Self::ext_wrapper(|| { - let created_header = ::System::finalize(); - ::xcm_emulator::LAST_HEAD - .with(|b| { - b - .borrow_mut() - .get_mut(N::name()) - .expect("network not initialized?") - .insert(para_id, HeadData(created_header.encode())) - }); - }); - } -} -pub trait PenpalBParaPallet { - type PolkadotXcm; - type Assets; - type ForeignAssets; - type AssetConversion; - type Balances; -} -impl PenpalBParaPallet for PenpalB { - type PolkadotXcm = penpal_runtime::PolkadotXcm; - type Assets = penpal_runtime::Assets; - type ForeignAssets = penpal_runtime::ForeignAssets; - type AssetConversion = penpal_runtime::AssetConversion; - type Balances = penpal_runtime::Balances; -} -pub const LOCAL_EXT_PENPALB: ::std::thread::LocalKey< - ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, -> = { - #[inline] - fn __init() -> ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities> { - ::xcm_emulator::RefCell::new( - ::xcm_emulator::TestExternalities::new(genesis(PARA_ID_B)), - ) - } - unsafe { - use ::std::mem::needs_drop; - use ::std::thread::LocalKey; - use ::std::thread::local_impl::LazyStorage; - LocalKey::new(const { - if needs_drop::< - ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, - >() { - |init| { - #[thread_local] - static VAL: LazyStorage< - ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, - (), - > = LazyStorage::new(); - VAL.get_or_init(init, __init) - } - } else { - |init| { - #[thread_local] - static VAL: LazyStorage< - ::xcm_emulator::RefCell<::xcm_emulator::TestExternalities>, - !, - > = LazyStorage::new(); - VAL.get_or_init(init, __init) - } - } - }) - } -}; -#[allow(missing_copy_implementations)] -#[allow(non_camel_case_types)] -#[allow(dead_code)] -pub struct GLOBAL_EXT_PENPALB { - __private_field: (), -} -#[doc(hidden)] -pub static GLOBAL_EXT_PENPALB: GLOBAL_EXT_PENPALB = GLOBAL_EXT_PENPALB { - __private_field: (), -}; -impl ::lazy_static::__Deref for GLOBAL_EXT_PENPALB { - type Target = ::xcm_emulator::Mutex< - ::xcm_emulator::RefCell< - ::xcm_emulator::HashMap, - >, - >; - fn deref( - &self, - ) -> &::xcm_emulator::Mutex< - ::xcm_emulator::RefCell< - ::xcm_emulator::HashMap, - >, - > { - #[inline(always)] - fn __static_ref_initialize() -> ::xcm_emulator::Mutex< - ::xcm_emulator::RefCell< - ::xcm_emulator::HashMap, - >, - > { - ::xcm_emulator::Mutex::new( - ::xcm_emulator::RefCell::new(::xcm_emulator::HashMap::new()), - ) - } - #[inline(always)] - fn __stability() -> &'static ::xcm_emulator::Mutex< - ::xcm_emulator::RefCell< - ::xcm_emulator::HashMap, - >, - > { - static LAZY: ::lazy_static::lazy::Lazy< - ::xcm_emulator::Mutex< - ::xcm_emulator::RefCell< - ::xcm_emulator::HashMap< - String, - ::xcm_emulator::TestExternalities, - >, - >, - >, - > = ::lazy_static::lazy::Lazy::INIT; - LAZY.get(__static_ref_initialize) - } - __stability() - } -} -impl ::lazy_static::LazyStatic for GLOBAL_EXT_PENPALB { - fn initialize(lazy: &Self) { - let _ = &**lazy; - } -} -impl ::xcm_emulator::TestExt for PenpalB { - fn build_new_ext( - storage: ::xcm_emulator::Storage, - ) -> ::xcm_emulator::TestExternalities { - let mut ext = ::xcm_emulator::TestExternalities::new(storage); - ext.execute_with(|| { - #[allow(clippy::no_effect)] - { - penpal_runtime::AuraExt::on_initialize(1); - let is = penpal_runtime::System::set_storage( - penpal_runtime::RuntimeOrigin::root(), - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - ( - PenpalRelayNetworkId::key().to_vec(), - NetworkId::Westend.encode(), - ), - ]), - ), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }; - ::xcm_emulator::sp_tracing::try_init_simple(); - let mut block_number = ::System::block_number(); - block_number = std::cmp::max(1, block_number); - ::System::set_block_number(block_number); - }); - ext - } - fn new_ext() -> ::xcm_emulator::TestExternalities { - Self::build_new_ext(genesis(PARA_ID_B)) - } - fn move_ext_out(id: &'static str) { - use ::xcm_emulator::Deref; - let local_ext = LOCAL_EXT_PENPALB.with(|v| { v.take() }); - let global_ext_guard = GLOBAL_EXT_PENPALB.lock().unwrap(); - global_ext_guard.deref().borrow_mut().insert(id.to_string(), local_ext); - } - fn move_ext_in(id: &'static str) { - use ::xcm_emulator::Deref; - let mut global_ext_unlocked = false; - while !global_ext_unlocked { - let global_ext_result = GLOBAL_EXT_PENPALB.try_lock(); - if let Ok(global_ext_guard) = global_ext_result { - if !global_ext_guard.deref().borrow().contains_key(id) { - drop(global_ext_guard); - } else { - global_ext_unlocked = true; - } - } - } - let mut global_ext_guard = GLOBAL_EXT_PENPALB.lock().unwrap(); - let global_ext = global_ext_guard.deref(); - LOCAL_EXT_PENPALB - .with(|v| { - v.replace(global_ext.take().remove(id).unwrap()); - }); - } - fn reset_ext() { - LOCAL_EXT_PENPALB - .with(|v| *v.borrow_mut() = Self::build_new_ext(genesis(PARA_ID_B))); - } - fn execute_with(execute: impl FnOnce() -> R) -> R { - use ::xcm_emulator::{Chain, Get, Hooks, Network, Parachain, Encode}; - ::init(); - Self::new_block(); - let r = LOCAL_EXT_PENPALB.with(|v| v.borrow_mut().execute_with(execute)); - Self::finalize_block(); - let para_id = Self::para_id().into(); - LOCAL_EXT_PENPALB - .with(|v| { - v.borrow_mut() - .execute_with(|| { - let mock_header = ::xcm_emulator::HeaderT::new( - 0, - Default::default(), - Default::default(), - Default::default(), - Default::default(), - ); - let collation_info = ::ParachainSystem::collect_collation_info( - &mock_header, - ); - let relay_block_number = ::relay_block_number(); - for msg in collation_info.upward_messages.clone() { - ::send_upward_message(para_id, msg); - } - for msg in collation_info.horizontal_messages { - ::send_horizontal_messages( - msg.recipient.into(), - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([ - (para_id.into(), relay_block_number, msg.data), - ]), - ) - .into_iter(), - ); - } - type NetworkBridge = ::Bridge; - let bridge_messages = < as ::xcm_emulator::Bridge>::Handler as ::xcm_emulator::BridgeMessageHandler>::get_source_outbound_messages(); - for msg in bridge_messages { - ::send_bridged_messages(msg); - } - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::PenpalB", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - ::System::reset_events(); - }) - }); - ::process_messages(); - r - } - fn ext_wrapper(func: impl FnOnce() -> R) -> R { - LOCAL_EXT_PENPALB.with(|v| { v.borrow_mut().execute_with(|| { func() }) }) - } -} -impl< - N, - Origin, - Destination, - Hops, - Args, -> ::xcm_emulator::CheckAssertion for PenpalB -where - N: ::xcm_emulator::Network, - Origin: ::xcm_emulator::Chain + Clone, - Destination: ::xcm_emulator::Chain + Clone, - Origin::RuntimeOrigin: ::xcm_emulator::OriginTrait< - AccountId = ::xcm_emulator::AccountIdOf, - > + Clone, - Destination::RuntimeOrigin: ::xcm_emulator::OriginTrait< - AccountId = ::xcm_emulator::AccountIdOf, - > + Clone, - Hops: Clone, - Args: Clone, -{ - fn check_assertion(test: ::xcm_emulator::Test) { - use ::xcm_emulator::{Dispatchable, TestExt}; - let chain_name = std::any::type_name::>(); - >::execute_with(|| { - if let Some(dispatchable) = test.hops_dispatchable.get(chain_name) { - let is = dispatchable(test.clone()); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - } - if let Some(call) = test.hops_calls.get(chain_name) { - let is = match call.clone().dispatch(test.signed_origin.clone()) { - Ok(_) => Ok(()), - Err(error_with_post_info) => Err(error_with_post_info.error), - }; - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - } - if let Some(assertion) = test.hops_assertion.get(chain_name) { - assertion(test); - } - }); - } -} -impl PenpalA { - /// Fund a set of accounts with a balance - pub fn fund_accounts( - accounts: Vec< - ( - ::emulated_integration_tests_common::impls::AccountId, - ::emulated_integration_tests_common::impls::Balance, - ), - >, - ) { - ::execute_with(|| { - for account in accounts { - let who = account.0; - let actual = ::Balances::free_balance(&who); - let actual = actual - .saturating_add( - ::Balances::reserved_balance(&who), - ); - let is = ::Balances::force_set_balance( - ::RuntimeOrigin::root(), - who.into(), - actual.saturating_add(account.1), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - } - }); - } - /// Fund a sovereign account of sibling para. - pub fn fund_para_sovereign( - sibling_para_id: ::emulated_integration_tests_common::impls::ParaId, - balance: ::emulated_integration_tests_common::impls::Balance, - ) { - let sibling_location = Self::sibling_location_of(sibling_para_id); - let sovereign_account = Self::sovereign_account_id_of(sibling_location); - Self::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([(sovereign_account.into(), balance)]), - ), - ) - } - /// Return local sovereign account of `para_id` on other `network_id` - pub fn sovereign_account_of_parachain_on_other_global_consensus( - network_id: ::emulated_integration_tests_common::impls::NetworkId, - para_id: ::emulated_integration_tests_common::impls::ParaId, - ) -> ::emulated_integration_tests_common::impls::AccountId { - let remote_location = ::emulated_integration_tests_common::impls::Location::new( - 2, - [ - ::emulated_integration_tests_common::impls::Junction::GlobalConsensus( - network_id, - ), - ::emulated_integration_tests_common::impls::Junction::Parachain( - para_id.into(), - ), - ], - ); - ::execute_with(|| { - Self::sovereign_account_id_of(remote_location) - }) - } -} -impl PenpalB { - /// Fund a set of accounts with a balance - pub fn fund_accounts( - accounts: Vec< - ( - ::emulated_integration_tests_common::impls::AccountId, - ::emulated_integration_tests_common::impls::Balance, - ), - >, - ) { - ::execute_with(|| { - for account in accounts { - let who = account.0; - let actual = ::Balances::free_balance(&who); - let actual = actual - .saturating_add( - ::Balances::reserved_balance(&who), - ); - let is = ::Balances::force_set_balance( - ::RuntimeOrigin::root(), - who.into(), - actual.saturating_add(account.1), - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - } - }); - } - /// Fund a sovereign account of sibling para. - pub fn fund_para_sovereign( - sibling_para_id: ::emulated_integration_tests_common::impls::ParaId, - balance: ::emulated_integration_tests_common::impls::Balance, - ) { - let sibling_location = Self::sibling_location_of(sibling_para_id); - let sovereign_account = Self::sovereign_account_id_of(sibling_location); - Self::fund_accounts( - <[_]>::into_vec( - #[rustc_box] - ::alloc::boxed::Box::new([(sovereign_account.into(), balance)]), - ), - ) - } - /// Return local sovereign account of `para_id` on other `network_id` - pub fn sovereign_account_of_parachain_on_other_global_consensus( - network_id: ::emulated_integration_tests_common::impls::NetworkId, - para_id: ::emulated_integration_tests_common::impls::ParaId, - ) -> ::emulated_integration_tests_common::impls::AccountId { - let remote_location = ::emulated_integration_tests_common::impls::Location::new( - 2, - [ - ::emulated_integration_tests_common::impls::Junction::GlobalConsensus( - network_id, - ), - ::emulated_integration_tests_common::impls::Junction::Parachain( - para_id.into(), - ), - ], - ); - ::execute_with(|| { - Self::sovereign_account_id_of(remote_location) - }) - } -} -type PenpalARuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; -impl PenpalA { - /// Asserts a dispatchable is completely executed and XCM sent - pub fn assert_xcm_pallet_attempted_complete( - expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, - ) { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalARuntimeEvent::< - N, - >::PolkadotXcm( - ::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted { - outcome: ::emulated_integration_tests_common::impls::Outcome::Complete { - used: weight, - }, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "weight", - weight, - "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", - ), - ); - res - }); - } - meet_conditions - &= ::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Complete {\n used: weight\n } })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Complete {\n used: weight\n } })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a dispatchable is incompletely executed and XCM sent - pub fn assert_xcm_pallet_attempted_incomplete( - expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, - expected_error: Option<::emulated_integration_tests_common::impls::XcmError>, - ) { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalARuntimeEvent::< - N, - >::PolkadotXcm( - ::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted { - outcome: ::emulated_integration_tests_common::impls::Outcome::Incomplete { - used: weight, - error, - }, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "weight", - weight, - "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", - ), - ); - res - }); - } - meet_conditions - &= ::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ); - if !(*error == expected_error.unwrap_or((*error).into()).into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "error", - error, - "*error == expected_error.unwrap_or((*error).into()).into()", - ), - ); - res - }); - } - meet_conditions - &= *error == expected_error.unwrap_or((*error).into()).into(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Incomplete {\n used: weight, error\n } })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Incomplete {\n used: weight, error\n } })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a dispatchable throws and error when trying to be sent - pub fn assert_xcm_pallet_attempted_error( - expected_error: Option<::emulated_integration_tests_common::impls::XcmError>, - ) { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalARuntimeEvent::< - N, - >::PolkadotXcm( - ::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted { - outcome: ::emulated_integration_tests_common::impls::Outcome::Error { - error, - }, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*error == expected_error.unwrap_or((*error).into()).into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "error", - error, - "*error == expected_error.unwrap_or((*error).into()).into()", - ), - ); - res - }); - } - meet_conditions - &= *error == expected_error.unwrap_or((*error).into()).into(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Error { error }\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Error { error }\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a XCM message is sent - pub fn assert_xcm_pallet_sent() { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalARuntimeEvent::< - N, - >::PolkadotXcm( - ::emulated_integration_tests_common::impls::pallet_xcm::Event::Sent { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Sent {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalARuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Sent {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a XCM message is sent to Relay Chain - pub fn assert_parachain_system_ump_sent() { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalARuntimeEvent::< - N, - >::ParachainSystem( - ::emulated_integration_tests_common::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalARuntimeEvent::::ParachainSystem(::emulated_integration_tests_common::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalARuntimeEvent::::ParachainSystem(::emulated_integration_tests_common::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a XCM from Relay Chain is completely executed - pub fn assert_dmp_queue_complete( - expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, - ) { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalARuntimeEvent::< - N, - >::MessageQueue( - ::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed { - success: true, - weight_used: weight, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "weight", - weight, - "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", - ), - ); - res - }); - } - meet_conditions - &= ::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a XCM from Relay Chain is incompletely executed - pub fn assert_dmp_queue_incomplete( - expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, - ) { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalARuntimeEvent::< - N, - >::MessageQueue( - ::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed { - success: false, - weight_used: weight, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "weight", - weight, - "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", - ), - ); - res - }); - } - meet_conditions - &= ::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: false, weight_used: weight, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: false, weight_used: weight, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a XCM from Relay Chain is executed with error - pub fn assert_dmp_queue_error() { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalARuntimeEvent::< - N, - >::MessageQueue( - ::emulated_integration_tests_common::impls::pallet_message_queue::Event::ProcessingFailed { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::ProcessingFailed {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::ProcessingFailed {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a XCM from another Parachain is completely executed - pub fn assert_xcmp_queue_success( - expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, - ) { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalARuntimeEvent::< - N, - >::MessageQueue( - ::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed { - success: true, - weight_used: weight, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "weight", - weight, - "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", - ), - ); - res - }); - } - meet_conditions - &= ::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalARuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } -} -type PenpalBRuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; -impl PenpalB { - /// Asserts a dispatchable is completely executed and XCM sent - pub fn assert_xcm_pallet_attempted_complete( - expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, - ) { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalBRuntimeEvent::< - N, - >::PolkadotXcm( - ::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted { - outcome: ::emulated_integration_tests_common::impls::Outcome::Complete { - used: weight, - }, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "weight", - weight, - "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", - ), - ); - res - }); - } - meet_conditions - &= ::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Complete {\n used: weight\n } })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Complete {\n used: weight\n } })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a dispatchable is incompletely executed and XCM sent - pub fn assert_xcm_pallet_attempted_incomplete( - expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, - expected_error: Option<::emulated_integration_tests_common::impls::XcmError>, - ) { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalBRuntimeEvent::< - N, - >::PolkadotXcm( - ::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted { - outcome: ::emulated_integration_tests_common::impls::Outcome::Incomplete { - used: weight, - error, - }, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "weight", - weight, - "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", - ), - ); - res - }); - } - meet_conditions - &= ::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ); - if !(*error == expected_error.unwrap_or((*error).into()).into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "error", - error, - "*error == expected_error.unwrap_or((*error).into()).into()", - ), - ); - res - }); - } - meet_conditions - &= *error == expected_error.unwrap_or((*error).into()).into(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Incomplete {\n used: weight, error\n } })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Incomplete {\n used: weight, error\n } })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a dispatchable throws and error when trying to be sent - pub fn assert_xcm_pallet_attempted_error( - expected_error: Option<::emulated_integration_tests_common::impls::XcmError>, - ) { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalBRuntimeEvent::< - N, - >::PolkadotXcm( - ::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted { - outcome: ::emulated_integration_tests_common::impls::Outcome::Error { - error, - }, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*error == expected_error.unwrap_or((*error).into()).into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "error", - error, - "*error == expected_error.unwrap_or((*error).into()).into()", - ), - ); - res - }); - } - meet_conditions - &= *error == expected_error.unwrap_or((*error).into()).into(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Error { error }\n})", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Attempted {\noutcome: ::emulated_integration_tests_common::impls::Outcome::Error { error }\n})", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a XCM message is sent - pub fn assert_xcm_pallet_sent() { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalBRuntimeEvent::< - N, - >::PolkadotXcm( - ::emulated_integration_tests_common::impls::pallet_xcm::Event::Sent { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Sent {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalBRuntimeEvent::::PolkadotXcm(::emulated_integration_tests_common::impls::pallet_xcm::Event::Sent {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a XCM message is sent to Relay Chain - pub fn assert_parachain_system_ump_sent() { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalBRuntimeEvent::< - N, - >::ParachainSystem( - ::emulated_integration_tests_common::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalBRuntimeEvent::::ParachainSystem(::emulated_integration_tests_common::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalBRuntimeEvent::::ParachainSystem(::emulated_integration_tests_common::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a XCM from Relay Chain is completely executed - pub fn assert_dmp_queue_complete( - expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, - ) { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalBRuntimeEvent::< - N, - >::MessageQueue( - ::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed { - success: true, - weight_used: weight, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "weight", - weight, - "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", - ), - ); - res - }); - } - meet_conditions - &= ::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a XCM from Relay Chain is incompletely executed - pub fn assert_dmp_queue_incomplete( - expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, - ) { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalBRuntimeEvent::< - N, - >::MessageQueue( - ::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed { - success: false, - weight_used: weight, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "weight", - weight, - "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", - ), - ); - res - }); - } - meet_conditions - &= ::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: false, weight_used: weight, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: false, weight_used: weight, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a XCM from Relay Chain is executed with error - pub fn assert_dmp_queue_error() { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalBRuntimeEvent::< - N, - >::MessageQueue( - ::emulated_integration_tests_common::impls::pallet_message_queue::Event::ProcessingFailed { - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::ProcessingFailed {\n.. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::ProcessingFailed {\n.. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } - /// Asserts a XCM from another Parachain is completely executed - pub fn assert_xcmp_queue_success( - expected_weight: Option<::emulated_integration_tests_common::impls::Weight>, - ) { - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - PenpalBRuntimeEvent::< - N, - >::MessageQueue( - ::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed { - success: true, - weight_used: weight, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ) && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "weight", - weight, - "::emulated_integration_tests_common::impls::weight_within_threshold((::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD,\n ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD),\n expected_weight.unwrap_or(*weight), *weight)", - ), - ); - res - }); - } - meet_conditions - &= ::emulated_integration_tests_common::impls::weight_within_threshold( - ( - ::emulated_integration_tests_common::impls::REF_TIME_THRESHOLD, - ::emulated_integration_tests_common::impls::PROOF_SIZE_THRESHOLD, - ), - expected_weight.unwrap_or(*weight), - *weight, - ); - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "PenpalBRuntimeEvent::::MessageQueue(::emulated_integration_tests_common::impls::pallet_message_queue::Event::Processed {\nsuccess: true, weight_used: weight, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - } -} -impl PenpalA { - /// Create assets using sudo `Assets::force_create()` - pub fn force_create_asset( - id: u32, - owner: ::emulated_integration_tests_common::impls::AccountId, - is_sufficient: bool, - min_balance: u128, - prefund_accounts: Vec< - (::emulated_integration_tests_common::impls::AccountId, u128), - >, - ) { - use ::emulated_integration_tests_common::impls::Inspect; - let sudo_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::root(); - ::execute_with(|| { - let is = ::Assets::force_create( - sudo_origin, - id.clone().into(), - owner.clone().into(), - is_sufficient, - min_balance, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - if !::Assets::asset_exists(id.clone()) { - ::core::panicking::panic( - "assertion failed: ::Assets::asset_exists(id.clone())", - ) - } - type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::< - N, - >::Assets( - ::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated { - asset_id, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - for (beneficiary, amount) in prefund_accounts.into_iter() { - let signed_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::signed( - owner.clone(), - ); - Self::mint_asset(signed_origin, id.clone(), beneficiary, amount); - } - } - /// Mint assets making use of the assets pallet - pub fn mint_asset( - signed_origin: ::RuntimeOrigin, - id: u32, - beneficiary: ::emulated_integration_tests_common::impls::AccountId, - amount_to_mint: u128, - ) { - ::execute_with(|| { - let is = ::Assets::mint( - signed_origin, - id.clone().into(), - beneficiary.clone().into(), - amount_to_mint, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::< - N, - >::Assets( - ::emulated_integration_tests_common::impls::pallet_assets::Event::Issued { - asset_id, - owner, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == id; - if !(*owner == beneficiary.clone().into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == beneficiary.clone().into()", - ), - ); - res - }); - } - meet_conditions &= *owner == beneficiary.clone().into(); - if !(*amount == amount_to_mint) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == amount_to_mint", - ), - ); - res - }); - } - meet_conditions &= *amount == amount_to_mint; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - /// Returns the encoded call for `create` from the assets pallet - pub fn create_asset_call( - asset_id: u32, - min_balance: ::emulated_integration_tests_common::impls::Balance, - admin: ::emulated_integration_tests_common::impls::AccountId, - ) -> ::emulated_integration_tests_common::impls::DoubleEncoded<()> { - use ::emulated_integration_tests_common::impls::{Chain, Encode}; - ::RuntimeCall::Assets(::emulated_integration_tests_common::impls::pallet_assets::Call::< - ::Runtime, - ::emulated_integration_tests_common::impls::pallet_assets::Instance1, - >::create { - id: asset_id.into(), - min_balance, - admin: admin.into(), - }) - .encode() - .into() - } -} -impl PenpalA { - /// Create foreign assets using sudo `ForeignAssets::force_create()` - pub fn force_create_foreign_asset( - id: xcm::latest::Location, - owner: ::emulated_integration_tests_common::impls::AccountId, - is_sufficient: bool, - min_balance: u128, - prefund_accounts: Vec< - (::emulated_integration_tests_common::impls::AccountId, u128), - >, - ) { - use ::emulated_integration_tests_common::impls::Inspect; - let sudo_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::root(); - ::execute_with(|| { - let is = ::ForeignAssets::force_create( - sudo_origin, - id.clone(), - owner.clone().into(), - is_sufficient, - min_balance, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - if !::ForeignAssets::asset_exists(id.clone()) { - ::core::panicking::panic( - "assertion failed: ::ForeignAssets::asset_exists(id.clone())", - ) - } - type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::< - N, - >::ForeignAssets( - ::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated { - asset_id, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - for (beneficiary, amount) in prefund_accounts.into_iter() { - let signed_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::signed( - owner.clone(), - ); - Self::mint_foreign_asset(signed_origin, id.clone(), beneficiary, amount); - } - } - /// Mint assets making use of the ForeignAssets pallet-assets instance - pub fn mint_foreign_asset( - signed_origin: ::RuntimeOrigin, - id: xcm::latest::Location, - beneficiary: ::emulated_integration_tests_common::impls::AccountId, - amount_to_mint: u128, - ) { - ::execute_with(|| { - let is = ::ForeignAssets::mint( - signed_origin, - id.clone().into(), - beneficiary.clone().into(), - amount_to_mint, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::< - N, - >::ForeignAssets( - ::emulated_integration_tests_common::impls::pallet_assets::Event::Issued { - asset_id, - owner, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == id; - if !(*owner == beneficiary.clone().into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == beneficiary.clone().into()", - ), - ); - res - }); - } - meet_conditions &= *owner == beneficiary.clone().into(); - if !(*amount == amount_to_mint) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == amount_to_mint", - ), - ); - res - }); - } - meet_conditions &= *amount == amount_to_mint; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - /// Returns the encoded call for `create` from the foreign assets pallet - pub fn create_foreign_asset_call( - asset_id: xcm::latest::Location, - min_balance: ::emulated_integration_tests_common::impls::Balance, - admin: ::emulated_integration_tests_common::impls::AccountId, - ) -> ::emulated_integration_tests_common::impls::DoubleEncoded<()> { - use ::emulated_integration_tests_common::impls::{Chain, Encode}; - ::RuntimeCall::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Call::< - ::Runtime, - ::emulated_integration_tests_common::impls::pallet_assets::Instance2, - >::create { - id: asset_id.into(), - min_balance, - admin: admin.into(), - }) - .encode() - .into() - } -} -impl PenpalB { - /// Create assets using sudo `Assets::force_create()` - pub fn force_create_asset( - id: u32, - owner: ::emulated_integration_tests_common::impls::AccountId, - is_sufficient: bool, - min_balance: u128, - prefund_accounts: Vec< - (::emulated_integration_tests_common::impls::AccountId, u128), - >, - ) { - use ::emulated_integration_tests_common::impls::Inspect; - let sudo_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::root(); - ::execute_with(|| { - let is = ::Assets::force_create( - sudo_origin, - id.clone().into(), - owner.clone().into(), - is_sufficient, - min_balance, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - if !::Assets::asset_exists(id.clone()) { - ::core::panicking::panic( - "assertion failed: ::Assets::asset_exists(id.clone())", - ) - } - type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::< - N, - >::Assets( - ::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated { - asset_id, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - for (beneficiary, amount) in prefund_accounts.into_iter() { - let signed_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::signed( - owner.clone(), - ); - Self::mint_asset(signed_origin, id.clone(), beneficiary, amount); - } - } - /// Mint assets making use of the assets pallet - pub fn mint_asset( - signed_origin: ::RuntimeOrigin, - id: u32, - beneficiary: ::emulated_integration_tests_common::impls::AccountId, - amount_to_mint: u128, - ) { - ::execute_with(|| { - let is = ::Assets::mint( - signed_origin, - id.clone().into(), - beneficiary.clone().into(), - amount_to_mint, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::< - N, - >::Assets( - ::emulated_integration_tests_common::impls::pallet_assets::Event::Issued { - asset_id, - owner, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == id; - if !(*owner == beneficiary.clone().into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == beneficiary.clone().into()", - ), - ); - res - }); - } - meet_conditions &= *owner == beneficiary.clone().into(); - if !(*amount == amount_to_mint) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == amount_to_mint", - ), - ); - res - }); - } - meet_conditions &= *amount == amount_to_mint; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "RuntimeEvent::::Assets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - /// Returns the encoded call for `create` from the assets pallet - pub fn create_asset_call( - asset_id: u32, - min_balance: ::emulated_integration_tests_common::impls::Balance, - admin: ::emulated_integration_tests_common::impls::AccountId, - ) -> ::emulated_integration_tests_common::impls::DoubleEncoded<()> { - use ::emulated_integration_tests_common::impls::{Chain, Encode}; - ::RuntimeCall::Assets(::emulated_integration_tests_common::impls::pallet_assets::Call::< - ::Runtime, - ::emulated_integration_tests_common::impls::pallet_assets::Instance1, - >::create { - id: asset_id.into(), - min_balance, - admin: admin.into(), - }) - .encode() - .into() - } -} -impl PenpalB { - /// Create foreign assets using sudo `ForeignAssets::force_create()` - pub fn force_create_foreign_asset( - id: xcm::latest::Location, - owner: ::emulated_integration_tests_common::impls::AccountId, - is_sufficient: bool, - min_balance: u128, - prefund_accounts: Vec< - (::emulated_integration_tests_common::impls::AccountId, u128), - >, - ) { - use ::emulated_integration_tests_common::impls::Inspect; - let sudo_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::root(); - ::execute_with(|| { - let is = ::ForeignAssets::force_create( - sudo_origin, - id.clone(), - owner.clone().into(), - is_sufficient, - min_balance, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - if !::ForeignAssets::asset_exists(id.clone()) { - ::core::panicking::panic( - "assertion failed: ::ForeignAssets::asset_exists(id.clone())", - ) - } - type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::< - N, - >::ForeignAssets( - ::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated { - asset_id, - .. - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == id; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::ForceCreated {\nasset_id, .. })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - for (beneficiary, amount) in prefund_accounts.into_iter() { - let signed_origin = as ::emulated_integration_tests_common::impls::Chain>::RuntimeOrigin::signed( - owner.clone(), - ); - Self::mint_foreign_asset(signed_origin, id.clone(), beneficiary, amount); - } - } - /// Mint assets making use of the ForeignAssets pallet-assets instance - pub fn mint_foreign_asset( - signed_origin: ::RuntimeOrigin, - id: xcm::latest::Location, - beneficiary: ::emulated_integration_tests_common::impls::AccountId, - amount_to_mint: u128, - ) { - ::execute_with(|| { - let is = ::ForeignAssets::mint( - signed_origin, - id.clone().into(), - beneficiary.clone().into(), - amount_to_mint, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - type RuntimeEvent = as ::emulated_integration_tests_common::impls::Chain>::RuntimeEvent; - let mut message: Vec = Vec::new(); - let mut events = ::events(); - let mut event_received = false; - let mut meet_conditions = true; - let mut index_match = 0; - let mut event_message: Vec = Vec::new(); - for (index, event) in events.iter().enumerate() { - meet_conditions = true; - match event { - RuntimeEvent::< - N, - >::ForeignAssets( - ::emulated_integration_tests_common::impls::pallet_assets::Event::Issued { - asset_id, - owner, - amount, - }, - ) => { - event_received = true; - let mut conditions_message: Vec = Vec::new(); - if !(*asset_id == id) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "asset_id", - asset_id, - "*asset_id == id", - ), - ); - res - }); - } - meet_conditions &= *asset_id == id; - if !(*owner == beneficiary.clone().into()) - && event_message.is_empty() - { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "owner", - owner, - "*owner == beneficiary.clone().into()", - ), - ); - res - }); - } - meet_conditions &= *owner == beneficiary.clone().into(); - if !(*amount == amount_to_mint) && event_message.is_empty() { - conditions_message - .push({ - let res = ::alloc::fmt::format( - format_args!( - " - The attribute {0:?} = {1:?} did not met the condition {2:?}\n", - "amount", - amount, - "*amount == amount_to_mint", - ), - ); - res - }); - } - meet_conditions &= *amount == amount_to_mint; - if event_received && meet_conditions { - index_match = index; - break; - } else { - event_message.extend(conditions_message); - } - } - _ => {} - } - } - if event_received && !meet_conditions { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was received but some of its attributes did not meet the conditions:\n{2}", - "Self", - "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", - event_message.concat(), - ), - ); - res - }); - } else if !event_received { - message - .push({ - let res = ::alloc::fmt::format( - format_args!( - "\n\n{0}::\u{1b}[31m{1}\u{1b}[0m was never received. All events:\n{2:#?}", - "Self", - "RuntimeEvent::::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Event::Issued {\nasset_id, owner, amount })", - ::events(), - ), - ); - res - }); - } else { - events.remove(index_match); - } - if !message.is_empty() { - ::events() - .iter() - .for_each(|event| { - { - let lvl = ::log::Level::Debug; - if lvl <= ::log::STATIC_MAX_LEVEL - && lvl <= ::log::max_level() - { - ::log::__private_api::log( - format_args!("{0:?}", event), - lvl, - &( - "events::Self", - "penpal_emulated_chain", - ::log::__private_api::loc(), - ), - (), - ); - } - }; - }); - { - #[cold] - #[track_caller] - #[inline(never)] - #[rustc_const_panic_str] - #[rustc_do_not_const_check] - const fn panic_cold_display(arg: &T) -> ! { - ::core::panicking::panic_display(arg) - } - panic_cold_display(&message.concat()); - } - } - }); - } - /// Returns the encoded call for `create` from the foreign assets pallet - pub fn create_foreign_asset_call( - asset_id: xcm::latest::Location, - min_balance: ::emulated_integration_tests_common::impls::Balance, - admin: ::emulated_integration_tests_common::impls::AccountId, - ) -> ::emulated_integration_tests_common::impls::DoubleEncoded<()> { - use ::emulated_integration_tests_common::impls::{Chain, Encode}; - ::RuntimeCall::ForeignAssets(::emulated_integration_tests_common::impls::pallet_assets::Call::< - ::Runtime, - ::emulated_integration_tests_common::impls::pallet_assets::Instance2, - >::create { - id: asset_id.into(), - min_balance, - admin: admin.into(), - }) - .encode() - .into() - } -} -impl PenpalA { - /// Set XCM version for destination. - pub fn force_xcm_version( - dest: ::emulated_integration_tests_common::impls::Location, - version: ::emulated_integration_tests_common::impls::XcmVersion, - ) { - ::execute_with(|| { - let is = ::PolkadotXcm::force_xcm_version( - ::RuntimeOrigin::root(), - Box::new(dest), - version, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - } - /// Set default/safe XCM version for runtime. - pub fn force_default_xcm_version( - version: Option<::emulated_integration_tests_common::impls::XcmVersion>, - ) { - ::execute_with(|| { - let is = ::PolkadotXcm::force_default_xcm_version( - ::RuntimeOrigin::root(), - version, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - } -} -impl PenpalB { - /// Set XCM version for destination. - pub fn force_xcm_version( - dest: ::emulated_integration_tests_common::impls::Location, - version: ::emulated_integration_tests_common::impls::XcmVersion, - ) { - ::execute_with(|| { - let is = ::PolkadotXcm::force_xcm_version( - ::RuntimeOrigin::root(), - Box::new(dest), - version, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - } - /// Set default/safe XCM version for runtime. - pub fn force_default_xcm_version( - version: Option<::emulated_integration_tests_common::impls::XcmVersion>, - ) { - ::execute_with(|| { - let is = ::PolkadotXcm::force_default_xcm_version( - ::RuntimeOrigin::root(), - version, - ); - match is { - Ok(_) => {} - _ => { - if !false { - { - ::core::panicking::panic_fmt( - format_args!("Expected Ok(_). Got {0:#?}", is), - ); - } - } - } - }; - }); - } -} diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 1543279059b4..6451901279b1 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -96,7 +96,6 @@ pub trait WeightInfo { fn new_query() -> Weight; fn take_response() -> Weight; fn claim_assets() -> Weight; - fn set_asset_claimer() -> Weight; } /// fallback implementation @@ -181,10 +180,6 @@ impl WeightInfo for TestWeightInfo { fn claim_assets() -> Weight { Weight::from_parts(100_000_000, 0) } - - fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) - } } #[frame_support::pallet] diff --git a/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs index 743da8d68869..fff6bfe55c0e 100644 --- a/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs +++ b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs @@ -136,4 +136,4 @@ fn set_asset_claimer_then_trap() { let result = vm.bench_process(xcm); assert!(result.is_err()); assert_eq!(vm.asset_claimer(), Some(bob)); -} \ No newline at end of file +} From 11a5b725dc09fed1f5aa5723a64db5798ecffe15 Mon Sep 17 00:00:00 2001 From: ndk Date: Wed, 25 Sep 2024 16:39:58 +0300 Subject: [PATCH 134/151] improved emulated tests, removed unnecessary weight calculations --- .../src/tests/set_asset_claimer.rs | 86 ++++++------------- .../src/weights/pallet_xcm.rs | 8 -- .../asset-hub-westend/src/xcm_config.rs | 4 +- .../src/weights/pallet_xcm.rs | 8 -- .../src/weights/pallet_xcm.rs | 8 -- .../src/weights/pallet_xcm.rs | 8 -- .../runtime/westend/src/weights/pallet_xcm.rs | 7 -- .../src/tests/set_asset_claimer.rs | 1 - 8 files changed, 29 insertions(+), 101 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 3c2824c49881..f788de87ee45 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -33,8 +33,10 @@ fn test_set_asset_claimer_within_a_chain() { let amount_to_send = 16_000_000_000_000; let assets: Assets = (Parent, amount_to_send).into(); - fund_account(&alice_account, amount_to_send * 2); - assert_eq!(query_balance(&alice_account, &RelayLocation::get()), amount_to_send * 2); + let alice_balance_before = ::account_data_of(alice_account.clone()).free; + AssetHubWestend::fund_accounts(vec![(alice_account.clone(), amount_to_send * 2)]); + let alice_balance_after = ::account_data_of(alice_account.clone()).free; + assert_eq!(alice_balance_after - alice_balance_before, amount_to_send * 2); let test_args = TestContext { sender: alice_account.clone(), @@ -48,12 +50,15 @@ fn test_set_asset_claimer_within_a_chain() { 0, ), }; - let test = ParaToParaThroughAHTest::new(test_args); - execute_test(test.clone(), bob_location.clone(), transfer_assets); + let test = SystemParaToParaTest::new(test_args); + AssetHubWestend::execute_with(|| { + assert_ok!(trap_assets_with_claimer(test.clone(), bob_location.clone()).dispatch(test.signed_origin)); + }); - let alice_assets_after = query_balance(&alice_account, &RelayLocation::get()); - assert_eq!(alice_assets_after, amount_to_send); + let balance_after_trap = ::account_data_of(alice_account.clone()).free; + assert_eq!(alice_balance_after - balance_after_trap, amount_to_send); + let bob_balance_before = ::account_data_of(bob_account.clone()).free; let test_args = TestContext { sender: bob_account.clone(), receiver: alice_account.clone(), @@ -66,54 +71,28 @@ fn test_set_asset_claimer_within_a_chain() { 0, ), }; - let test = ParaToParaThroughAHTest::new(test_args); - execute_test(test.clone(), bob_location.clone(), claim_assets); + let test = SystemParaToParaTest::new(test_args); + AssetHubWestend::execute_with(|| { + assert_ok!(claim_assets(test.clone(), bob_location.clone()).dispatch(test.signed_origin)); + }); - let bob_assets_after = query_balance(&bob_account, &RelayLocation::get()); - assert_eq!(bob_assets_after, amount_to_send); + let bob_balance_after = ::account_data_of(bob_account.clone()).free; + assert_eq!(bob_balance_after - bob_balance_before, amount_to_send); } fn account_and_location(account: &str) -> (AccountId32, Location) { - let account_id = PenpalA::account_id_of(account); + let account_id = AssetHubWestend::account_id_of(account); let account_clone = account_id.clone(); let location: Location = [Junction::AccountId32 { network: Some(Westend), id: account_id.into() }].into(); (account_clone, location) } -fn fund_account(account: &AccountId, amount: u128) { - let asset_owner = PenpalAssetOwner::get(); - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(asset_owner), - Location::parent(), - account.clone(), - amount, - ); -} - -fn query_balance(account: &AccountId, asset_location: &Location) -> u128 { - PenpalA::execute_with(|| { - type ForeignAssets = ::ForeignAssets; - >::balance(asset_location.clone(), account) - }) -} - -fn execute_test( - test: ParaToParaThroughAHTest, - claimer: Location, - xcm_fn: impl Fn(ParaToParaThroughAHTest, Location) -> ::RuntimeCall, -) { - let call = xcm_fn(test.clone(), claimer.clone()); - PenpalA::execute_with(|| { - assert!(call.dispatch(test.signed_origin).is_ok()); - }); -} - -fn transfer_assets( - test: ParaToParaThroughAHTest, +fn trap_assets_with_claimer( + test: SystemParaToParaTest, claimer: Location, -) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; let local_xcm = Xcm::::builder_unsafe() .set_asset_claimer(claimer.clone()) @@ -128,10 +107,10 @@ fn transfer_assets( } fn claim_assets( - test: ParaToParaThroughAHTest, + test: SystemParaToParaTest, claimer: Location, -) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; +) -> ::RuntimeCall { + type RuntimeCall = ::RuntimeCall; let local_xcm = Xcm::::builder_unsafe() .claim_asset(test.args.assets.clone(), Here) @@ -180,7 +159,9 @@ fn test_sac_between_the_chains() { ), }; let test = BridgeHubToAssetHubTest::new(test_args); - execute_bob_bh_test(test.clone(), alice_bh_sibling.clone(), trap_assets_bh); + BridgeHubWestend::execute_with(|| { + assert_ok!(trap_assets_bh(test.clone(), alice_bh_sibling.clone()).dispatch(test.signed_origin)); + }); let alice_bh_acc = LocationToAccountId::convert_location(&alice_bh_sibling).unwrap(); let balance = ::account_data_of(alice_bh_acc.clone()).free; @@ -244,14 +225,3 @@ fn trap_assets_bh( max_weight: Weight::from_parts(4_000_000_000_000, 700_000), }) } - -fn execute_bob_bh_test( - test: BridgeHubToAssetHubTest, - claimer: Location, - xcm_fn: impl Fn(BridgeHubToAssetHubTest, Location) -> ::RuntimeCall, -) { - let call = xcm_fn(test.clone(), claimer.clone()); - BridgeHubWestend::execute_with(|| { - assert!(call.dispatch(test.signed_origin).is_ok()); - }); -} diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs index 1f4e39db7c9d..be3d7661ab3c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs @@ -393,12 +393,4 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - - fn set_asset_claimer() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 707_000 picoseconds. - Weight::from_parts(749_000, 0) - } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 9c5b7b3004e8..e4183446c549 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -80,9 +80,7 @@ pub type LocationToAccountId = ( SiblingParachainConvertsVia, // Straight up local `AccountId32` origins just alias directly to `AccountId`. AccountId32Aliases, - // Foreign chain account alias into local accounts according to a hash of their standard - // description. - HashedDescription>, + // Foreign locations alias into accounts according to a hash of their standard description. HashedDescription>, // Different global consensus parachain sovereign account. // (Used for over-bridge transfers and reserve processing) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs index 47ce66716ef0..a78ff2355efa 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs @@ -373,12 +373,4 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - - fn set_asset_claimer() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 707_000 picoseconds. - Weight::from_parts(749_000, 0) - } } diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs index c95698ba4a73..5d427d850046 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs @@ -373,12 +373,4 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - - fn set_asset_claimer() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 707_000 picoseconds. - Weight::from_parts(749_000, 0) - } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs index ed1f303da6c9..fa588e982f09 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs @@ -361,12 +361,4 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - - fn set_asset_claimer() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 707_000 picoseconds. - Weight::from_parts(749_000, 0) - } } diff --git a/polkadot/runtime/westend/src/weights/pallet_xcm.rs b/polkadot/runtime/westend/src/weights/pallet_xcm.rs index 63c60fe51915..10725cecf249 100644 --- a/polkadot/runtime/westend/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/westend/src/weights/pallet_xcm.rs @@ -348,11 +348,4 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - - fn set_asset_claimer() -> Weight { - Weight::from_parts(35_299_000, 0) - .saturating_add(Weight::from_parts(0, 3488)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } } diff --git a/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs index fff6bfe55c0e..cdf519ca3cfc 100644 --- a/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs +++ b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs @@ -38,7 +38,6 @@ fn set_asset_claimer() { // if withdrawing fails we're not missing any corner case. .withdraw_asset((Here, 100u128)) .clear_origin() - // .trap(0u64) .set_asset_claimer(bob.clone()) .pay_fees((Here, 10u128)) // 10% destined for fees, not more. .build(); From 7ea3ffe64dc51519a4548e31d7fe413f2ad27bec Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 26 Sep 2024 11:36:02 +0300 Subject: [PATCH 135/151] refactored test_sac_between_the_chains --- .../src/tests/set_asset_claimer.rs | 74 ++++++++----------- 1 file changed, 32 insertions(+), 42 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index f788de87ee45..e47cef09625f 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -21,9 +21,9 @@ use emulated_integration_tests_common::{ impls::AccountId32, }; +use crate::imports::bhw_xcm_config::{LocationToAccountId, UniversalLocation}; use frame_support::{assert_ok, sp_runtime::traits::Dispatchable}; use xcm_executor::traits::ConvertLocation; -use crate::imports::bhw_xcm_config::{LocationToAccountId, UniversalLocation}; #[test] fn test_set_asset_claimer_within_a_chain() { @@ -33,9 +33,11 @@ fn test_set_asset_claimer_within_a_chain() { let amount_to_send = 16_000_000_000_000; let assets: Assets = (Parent, amount_to_send).into(); - let alice_balance_before = ::account_data_of(alice_account.clone()).free; + let alice_balance_before = + ::account_data_of(alice_account.clone()).free; AssetHubWestend::fund_accounts(vec![(alice_account.clone(), amount_to_send * 2)]); - let alice_balance_after = ::account_data_of(alice_account.clone()).free; + let alice_balance_after = + ::account_data_of(alice_account.clone()).free; assert_eq!(alice_balance_after - alice_balance_before, amount_to_send * 2); let test_args = TestContext { @@ -51,11 +53,23 @@ fn test_set_asset_claimer_within_a_chain() { ), }; let test = SystemParaToParaTest::new(test_args); + type RuntimeCall = ::RuntimeCall; + let local_xcm = Xcm::::builder_unsafe() + .set_asset_claimer(bob_location.clone()) + .withdraw_asset(test.args.assets.clone()) + .clear_origin() + .build(); + AssetHubWestend::execute_with(|| { - assert_ok!(trap_assets_with_claimer(test.clone(), bob_location.clone()).dispatch(test.signed_origin)); + assert_ok!(RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(local_xcm)), + max_weight: Weight::from_parts(4_000_000_000_000, 300_000), + }) + .dispatch(test.signed_origin)); }); - let balance_after_trap = ::account_data_of(alice_account.clone()).free; + let balance_after_trap = + ::account_data_of(alice_account.clone()).free; assert_eq!(alice_balance_after - balance_after_trap, amount_to_send); let bob_balance_before = ::account_data_of(bob_account.clone()).free; @@ -72,8 +86,17 @@ fn test_set_asset_claimer_within_a_chain() { ), }; let test = SystemParaToParaTest::new(test_args); + let xcm = Xcm::::builder_unsafe() + .claim_asset(test.args.assets.clone(), Here) + .deposit_asset(AllCounted(test.args.assets.len() as u32), bob_location.clone()) + .build(); + AssetHubWestend::execute_with(|| { - assert_ok!(claim_assets(test.clone(), bob_location.clone()).dispatch(test.signed_origin)); + assert_ok!(RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(xcm)), + max_weight: Weight::from_parts(4_000_000_000_000, 300_000), + }) + .dispatch(test.signed_origin)); }); let bob_balance_after = ::account_data_of(bob_account.clone()).free; @@ -88,41 +111,6 @@ fn account_and_location(account: &str) -> (AccountId32, Location) { (account_clone, location) } -fn trap_assets_with_claimer( - test: SystemParaToParaTest, - claimer: Location, -) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; - - let local_xcm = Xcm::::builder_unsafe() - .set_asset_claimer(claimer.clone()) - .withdraw_asset(test.args.assets.clone()) - .clear_origin() - .build(); - - RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(local_xcm)), - max_weight: Weight::from_parts(4_000_000_000_000, 300_000), - }) -} - -fn claim_assets( - test: SystemParaToParaTest, - claimer: Location, -) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; - - let local_xcm = Xcm::::builder_unsafe() - .claim_asset(test.args.assets.clone(), Here) - .deposit_asset(AllCounted(test.args.assets.len() as u32), claimer) - .build(); - - RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(local_xcm)), - max_weight: Weight::from_parts(4_000_000_000_000, 300_000), - }) -} - // The test: // 1. Funds Bob account on BridgeHub, withdraws the funds, sets asset claimer to // sibling account of Alice on AssetHub and traps the funds. @@ -160,7 +148,9 @@ fn test_sac_between_the_chains() { }; let test = BridgeHubToAssetHubTest::new(test_args); BridgeHubWestend::execute_with(|| { - assert_ok!(trap_assets_bh(test.clone(), alice_bh_sibling.clone()).dispatch(test.signed_origin)); + assert_ok!( + trap_assets_bh(test.clone(), alice_bh_sibling.clone()).dispatch(test.signed_origin) + ); }); let alice_bh_acc = LocationToAccountId::convert_location(&alice_bh_sibling).unwrap(); From 7a90cb33f58d610c8d1ffadaadd22071fb426d63 Mon Sep 17 00:00:00 2001 From: ndk Date: Thu, 26 Sep 2024 12:19:35 +0300 Subject: [PATCH 136/151] removed unnecessary weight and fixed prdoc --- .../src/weights/pallet_xcm.rs | 4 -- prdoc/pr_5416.prdoc | 37 ++++++++++++++++++- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs index e37ec773deef..a732e1a57343 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs @@ -373,8 +373,4 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - - fn set_asset_claimer() -> Weight { - Weight::from_parts(2_176_000, 0) - } } diff --git a/prdoc/pr_5416.prdoc b/prdoc/pr_5416.prdoc index 330c18390d9e..d4b115413d4d 100644 --- a/prdoc/pr_5416.prdoc +++ b/prdoc/pr_5416.prdoc @@ -1,14 +1,47 @@ # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json -title: Added SetAssetClaimer instruction +title: Added SetAssetClaimer instruction to XCM v5. doc: - audience: Runtime Dev description: | - ... + Added SetAssetClaimer implementation to XCM v5. With asset_claimer set users can retrieve their trapped assets + at any point in time without the need to go through OpenGov reclaim process. crates: +- name: bridge-hub-westend-emulated-chain + bump: minor +- name: asset-hub-westend-integration-tests + bump: minor +- name: asset-hub-rococo-runtime + bump: minor +- name: asset-hub-westend-runtime + bump: minor +- name: bridge-hub-rococo-runtime + bump: minor +- name: bridge-hub-westend-runtime + bump: minor +- name: coretime-rococo-runtime + bump: minor +- name: coretime-westend-runtime + bump: minor +- name: people-rococo-runtime + bump: minor +- name: people-westend-runtime + bump: minor +- name: penpal-runtime + bump: minor +- name: rococo-runtime + bump: minor +- name: westend-runtime + bump: minor +- name: staging-xcm + bump: minor - name: staging-xcm-executor bump: minor +- name: pallet-xcm-benchmarks + bump: minor +- name: pallet-multisig + bump: minor From 7b949cabd1b7369417ec8b5257a9561310050f70 Mon Sep 17 00:00:00 2001 From: ndk Date: Fri, 27 Sep 2024 12:02:39 +0300 Subject: [PATCH 137/151] refactored set_asset_claimer tests --- .../src/tests/set_asset_claimer.rs | 146 +++++------------- 1 file changed, 42 insertions(+), 104 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index e47cef09625f..3ef324603d21 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -15,14 +15,16 @@ //! Tests related to claiming assets trapped during XCM execution. -use crate::imports::*; +use crate::imports::{bhw_xcm_config::LocationToAccountId, *}; use emulated_integration_tests_common::{ accounts::{ALICE, BOB}, impls::AccountId32, }; - -use crate::imports::bhw_xcm_config::{LocationToAccountId, UniversalLocation}; use frame_support::{assert_ok, sp_runtime::traits::Dispatchable}; +use westend_system_emulated_network::{ + asset_hub_westend_emulated_chain::asset_hub_westend_runtime::RuntimeOrigin as AssetHubRuntimeOrigin, + bridge_hub_westend_emulated_chain::bridge_hub_westend_runtime::RuntimeOrigin as BridgeHubRuntimeOrigin, +}; use xcm_executor::traits::ConvertLocation; #[test] @@ -30,77 +32,51 @@ fn test_set_asset_claimer_within_a_chain() { let (alice_account, alice_location) = account_and_location(ALICE); let (bob_account, bob_location) = account_and_location(BOB); - let amount_to_send = 16_000_000_000_000; - let assets: Assets = (Parent, amount_to_send).into(); + let trap_amount = 16_000_000_000_000; + let assets: Assets = (Parent, trap_amount).into(); let alice_balance_before = ::account_data_of(alice_account.clone()).free; - AssetHubWestend::fund_accounts(vec![(alice_account.clone(), amount_to_send * 2)]); + AssetHubWestend::fund_accounts(vec![(alice_account.clone(), trap_amount * 2)]); let alice_balance_after = ::account_data_of(alice_account.clone()).free; - assert_eq!(alice_balance_after - alice_balance_before, amount_to_send * 2); - - let test_args = TestContext { - sender: alice_account.clone(), - receiver: bob_account.clone(), - args: TestArgs::new_para( - bob_location.clone(), - bob_account.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let test = SystemParaToParaTest::new(test_args); + assert_eq!(alice_balance_after - alice_balance_before, trap_amount * 2); + type RuntimeCall = ::RuntimeCall; - let local_xcm = Xcm::::builder_unsafe() + let asset_trap_xcm = Xcm::::builder_unsafe() .set_asset_claimer(bob_location.clone()) - .withdraw_asset(test.args.assets.clone()) + .withdraw_asset(assets.clone()) .clear_origin() .build(); AssetHubWestend::execute_with(|| { assert_ok!(RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(local_xcm)), + message: bx!(VersionedXcm::from(asset_trap_xcm)), max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) - .dispatch(test.signed_origin)); + .dispatch(AssetHubRuntimeOrigin::signed(alice_account.clone()))); }); let balance_after_trap = ::account_data_of(alice_account.clone()).free; - assert_eq!(alice_balance_after - balance_after_trap, amount_to_send); + assert_eq!(alice_balance_after - balance_after_trap, trap_amount); let bob_balance_before = ::account_data_of(bob_account.clone()).free; - let test_args = TestContext { - sender: bob_account.clone(), - receiver: alice_account.clone(), - args: TestArgs::new_para( - alice_location.clone(), - alice_account.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let test = SystemParaToParaTest::new(test_args); - let xcm = Xcm::::builder_unsafe() - .claim_asset(test.args.assets.clone(), Here) - .deposit_asset(AllCounted(test.args.assets.len() as u32), bob_location.clone()) + let claim_xcm = Xcm::::builder_unsafe() + .claim_asset(assets.clone(), Here) + .deposit_asset(AllCounted(assets.len() as u32), bob_location.clone()) .build(); AssetHubWestend::execute_with(|| { assert_ok!(RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(xcm)), + message: bx!(VersionedXcm::from(claim_xcm)), max_weight: Weight::from_parts(4_000_000_000_000, 300_000), }) - .dispatch(test.signed_origin)); + .dispatch(AssetHubRuntimeOrigin::signed(bob_account.clone()))); }); let bob_balance_after = ::account_data_of(bob_account.clone()).free; - assert_eq!(bob_balance_after - bob_balance_before, amount_to_send); + assert_eq!(bob_balance_after - bob_balance_before, trap_amount); } fn account_and_location(account: &str) -> (AccountId32, Location) { @@ -113,7 +89,7 @@ fn account_and_location(account: &str) -> (AccountId32, Location) { // The test: // 1. Funds Bob account on BridgeHub, withdraws the funds, sets asset claimer to -// sibling account of Alice on AssetHub and traps the funds. +// sibling-account-of(AssetHub/Alice) and traps the funds. // 2. Sends an XCM from AssetHub to BridgeHub on behalf of Alice. The XCM: claims assets, // pays fees and deposits assets to alice's sibling account. #[test] @@ -126,50 +102,31 @@ fn test_sac_between_the_chains() { Junction::AccountId32 { network: Some(Westend), id: alice.clone().into() }, ], ); + let bob = BridgeHubWestend::account_id_of(BOB); - let bob_location = - Location::new(0, Junction::AccountId32 { network: Some(Westend), id: bob.clone().into() }); - - let amount_to_send = 16_000_000_000_000u128; - BridgeHubWestend::fund_accounts(vec![(bob.clone(), amount_to_send * 2)]); - - let assets: Assets = (Parent, amount_to_send).into(); - let test_args = TestContext { - sender: bob.clone(), - receiver: alice.clone(), - args: TestArgs::new_para( - bob_location.clone(), - bob.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; - let test = BridgeHubToAssetHubTest::new(test_args); + let trap_amount = 16_000_000_000_000u128; + BridgeHubWestend::fund_accounts(vec![(bob.clone(), trap_amount * 2)]); + + let assets: Assets = (Parent, trap_amount).into(); + type RuntimeCall = ::RuntimeCall; + let trap_xcm = Xcm::::builder_unsafe() + .set_asset_claimer(alice_bh_sibling.clone()) + .withdraw_asset(assets.clone()) + .clear_origin() + .build(); + BridgeHubWestend::execute_with(|| { - assert_ok!( - trap_assets_bh(test.clone(), alice_bh_sibling.clone()).dispatch(test.signed_origin) - ); + assert_ok!(RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { + message: bx!(VersionedXcm::from(trap_xcm)), + max_weight: Weight::from_parts(4_000_000_000_000, 700_000), + }) + .dispatch(BridgeHubRuntimeOrigin::signed(bob.clone()))); }); let alice_bh_acc = LocationToAccountId::convert_location(&alice_bh_sibling).unwrap(); let balance = ::account_data_of(alice_bh_acc.clone()).free; assert_eq!(balance, 0); - let destination = AssetHubWestend::sibling_location_of(BridgeHubWestend::para_id()); - let test_args = TestContext { - sender: alice.clone(), - receiver: bob.clone(), - args: TestArgs::new_para( - destination.clone(), - bob.clone(), - amount_to_send, - assets.clone(), - None, - 0, - ), - }; let alice_bh_sibling = Location::new( 1, [ @@ -177,17 +134,16 @@ fn test_sac_between_the_chains() { Junction::AccountId32 { network: Some(Westend), id: alice.clone().into() }, ], ); - let test = AssetHubToBridgeHubTest::new(test_args); let pay_fees = 6_000_000_000_000u128; let xcm_on_bh = Xcm::<()>::builder_unsafe() - .claim_asset(test.args.assets.clone(), Here) + .claim_asset(assets.clone(), Here) .pay_fees((Parent, pay_fees)) .deposit_asset(All, alice_bh_sibling.clone()) .build(); let bh_on_ah = AssetHubWestend::sibling_location_of(BridgeHubWestend::para_id()).into(); AssetHubWestend::execute_with(|| { assert_ok!(::PolkadotXcm::send( - test.signed_origin, + AssetHubRuntimeOrigin::signed(alice.clone()), bx!(bh_on_ah), bx!(VersionedXcm::from(xcm_on_bh)), )); @@ -195,23 +151,5 @@ fn test_sac_between_the_chains() { let al_bh_acc = LocationToAccountId::convert_location(&alice_bh_sibling).unwrap(); let balance = ::account_data_of(al_bh_acc).free; - assert_eq!(balance, amount_to_send - pay_fees); -} - -fn trap_assets_bh( - test: BridgeHubToAssetHubTest, - claimer: Location, -) -> ::RuntimeCall { - type RuntimeCall = ::RuntimeCall; - - let local_xcm = Xcm::::builder_unsafe() - .set_asset_claimer(claimer.clone()) - .withdraw_asset(test.args.assets.clone()) - .clear_origin() - .build(); - - RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: bx!(VersionedXcm::from(local_xcm)), - max_weight: Weight::from_parts(4_000_000_000_000, 700_000), - }) + assert_eq!(balance, trap_amount - pay_fees); } From 21bd49d313bc00c9f69772ef60fe130c116949d4 Mon Sep 17 00:00:00 2001 From: ndk Date: Fri, 27 Sep 2024 12:13:44 +0300 Subject: [PATCH 138/151] removed unnecessary set_asset_claimer from pallet_xcm --- .../assets/asset-hub-rococo/src/weights/pallet_xcm.rs | 8 -------- .../coretime/coretime-rococo/src/weights/pallet_xcm.rs | 8 -------- .../people/people-rococo/src/weights/pallet_xcm.rs | 8 -------- 3 files changed, 24 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs index 1870bd223fb8..51b6543bae82 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs @@ -395,12 +395,4 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - - fn set_asset_claimer() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 707_000 picoseconds. - Weight::from_parts(749_000, 0) - } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs index 7fcf795fa4b3..7fb492173dad 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs @@ -361,12 +361,4 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - - fn set_asset_claimer() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 707_000 picoseconds. - Weight::from_parts(749_000, 0) - } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs index 8ceb4c57a9b7..fabce29b5fd9 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs @@ -343,12 +343,4 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - - fn set_asset_claimer() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 707_000 picoseconds. - Weight::from_parts(749_000, 0) - } } From f5e35875105fbdf9a46c74e3765b8d1e1a0b3379 Mon Sep 17 00:00:00 2001 From: Andrii Date: Fri, 27 Sep 2024 12:19:18 +0300 Subject: [PATCH 139/151] Update test description Co-authored-by: Adrian Catangiu --- .../assets/asset-hub-westend/src/tests/set_asset_claimer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 3ef324603d21..63a7b287842b 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -90,8 +90,8 @@ fn account_and_location(account: &str) -> (AccountId32, Location) { // The test: // 1. Funds Bob account on BridgeHub, withdraws the funds, sets asset claimer to // sibling-account-of(AssetHub/Alice) and traps the funds. -// 2. Sends an XCM from AssetHub to BridgeHub on behalf of Alice. The XCM: claims assets, -// pays fees and deposits assets to alice's sibling account. +// 2. Alice on AssetHub sends an XCM to BridgeHub to claim assets, pay fees and deposit +// remaining to her sibling account on BridgeHub. #[test] fn test_sac_between_the_chains() { let alice = AssetHubWestend::account_id_of(ALICE); From 598ae4aeac696d9f29ed29c42c6695550ca7f3e8 Mon Sep 17 00:00:00 2001 From: ndk Date: Fri, 27 Sep 2024 12:26:35 +0300 Subject: [PATCH 140/151] removed extra spaces and an extra set_asset_claimer fn --- .../assets/asset-hub-rococo/src/weights/xcm/mod.rs | 1 - .../bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs | 2 -- polkadot/runtime/rococo/src/weights/pallet_xcm.rs | 7 ------- polkadot/runtime/rococo/src/weights/xcm/mod.rs | 1 - 4 files changed, 11 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index 83261140b01d..e874fd369f37 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -156,7 +156,6 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight { fn set_asset_claimer(_location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } - fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index 84d9263d6432..201f0bb05d8b 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -155,11 +155,9 @@ impl XcmWeightInfo for BridgeHubWestendXcmWeight { fn clear_error() -> Weight { XcmGeneric::::clear_error() } - fn set_asset_claimer(_location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } - fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { XcmGeneric::::claim_asset() } diff --git a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs index a8049ab13252..5544ca44658c 100644 --- a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs @@ -346,11 +346,4 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - - fn set_asset_claimer() -> Weight { - Weight::from_parts(35_299_000, 0) - .saturating_add(Weight::from_parts(0, 3488)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } } diff --git a/polkadot/runtime/rococo/src/weights/xcm/mod.rs b/polkadot/runtime/rococo/src/weights/xcm/mod.rs index 128e07a49824..ac821b43f486 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/mod.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/mod.rs @@ -269,7 +269,6 @@ impl XcmWeightInfo for RococoXcmWeight { fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { XcmGeneric::::unpaid_execution() } - fn set_asset_claimer(_location: &Location) -> Weight { XcmGeneric::::set_asset_claimer() } From bf1f2b3374bb793419c24926d82f40155e639ba3 Mon Sep 17 00:00:00 2001 From: ndk Date: Fri, 27 Sep 2024 12:28:53 +0300 Subject: [PATCH 141/151] formatted affected crates --- .../bridges/bridge-hub-westend/src/lib.rs | 3 +- .../assets/asset-hub-rococo/src/lib.rs | 3 +- .../assets/asset-hub-westend/src/lib.rs | 3 +- .../asset-hub-westend/src/xcm_config.rs | 15 +- .../bridge-hub-westend/src/xcm_config.rs | 12 +- polkadot/runtime/westend/src/lib.rs | 3 +- polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs | 2 +- polkadot/xcm/xcm-executor/src/lib.rs | 42 ++-- .../src/tests/set_asset_claimer.rs | 192 +++++++++--------- 9 files changed, 155 insertions(+), 120 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs index 71c09f7a3bba..fb9de637788d 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs @@ -16,8 +16,7 @@ pub mod genesis; pub use bridge_hub_westend_runtime::{ - self, - xcm_config::XcmConfig as BridgeHubWestendXcmConfig, + self, xcm_config::XcmConfig as BridgeHubWestendXcmConfig, ExistentialDeposit as BridgeHubWestendExistentialDeposit, }; diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index b6aea71f7bd3..e39d8f6ae864 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -546,7 +546,8 @@ impl InstanceFilter for ProxyType { RuntimeCall::Utility { .. } | RuntimeCall::Multisig { .. } | RuntimeCall::NftFractionalization { .. } | - RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } + RuntimeCall::Nfts { .. } | + RuntimeCall::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 89a8ef0cab2c..dbdd1ada6a49 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -542,7 +542,8 @@ impl InstanceFilter for ProxyType { RuntimeCall::Utility { .. } | RuntimeCall::Multisig { .. } | RuntimeCall::NftFractionalization { .. } | - RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } + RuntimeCall::Nfts { .. } | + RuntimeCall::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index e4183446c549..e1c0f54f5024 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -45,7 +45,20 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice; use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor; use sp_runtime::traits::{AccountIdConversion, ConvertInto, TryConvertInto}; use xcm::latest::prelude::*; -use xcm_builder::{AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, DescribePalletTerminal, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint, MatchedConvertedConcreteId, NetworkExportTableItem, NoChecking, NonFungiblesAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SingleAssetExchangeAdapter, SovereignPaidRemoteExporter, SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithLatestLocationConverter, WithUniqueTopic, XcmFeeManagerFromComponents}; +use xcm_builder::{ + AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, + AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, + DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, + DescribePalletTerminal, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, + FungiblesAdapter, GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, + LocalMint, MatchedConvertedConcreteId, NetworkExportTableItem, NoChecking, NonFungiblesAdapter, + ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SingleAssetExchangeAdapter, SovereignPaidRemoteExporter, + SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus, TakeWeightCredit, + TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, + WithLatestLocationConverter, WithUniqueTopic, XcmFeeManagerFromComponents, +}; use xcm_executor::XcmExecutor; parameter_types! { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs index 0b40cdb041ee..b3b6fc1fa8b3 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs @@ -40,7 +40,17 @@ use sp_runtime::traits::AccountIdConversion; use sp_std::marker::PhantomData; use testnet_parachains_constants::westend::snowbridge::EthereumNetwork; use xcm::latest::prelude::*; -use xcm_builder::{AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, DescribePalletTerminal, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, GlobalConsensusParachainConvertsFor, HandleFee, HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic}; +use xcm_builder::{ + AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, + AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, + DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, + DescribePalletTerminal, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, + GlobalConsensusParachainConvertsFor, HandleFee, HashedDescription, IsConcrete, + ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, + UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, +}; use xcm_executor::{ traits::{FeeManager, FeeReason, FeeReason::Export}, XcmExecutor, diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index b02c2d8c671e..479ed83f7236 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -1113,7 +1113,8 @@ impl InstanceFilter for ProxyType { matches!( c, RuntimeCall::Staking(..) | - RuntimeCall::Session(..) | RuntimeCall::Utility(..) | + RuntimeCall::Session(..) | + RuntimeCall::Utility(..) | RuntimeCall::FastUnstake(..) | RuntimeCall::VoterList(..) | RuntimeCall::NominationPools(..) diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs index 4a12bb7f47c6..210b8f656377 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -72,7 +72,7 @@ pub fn generate_holding_assets(max_assets: u32) -> Assets { let fungibles_amount: u128 = 100; let holding_fungibles = max_assets / 2; let holding_non_fungibles = max_assets - holding_fungibles - 1; // -1 because of adding `Here` asset - // add count of `holding_fungibles` + // add count of `holding_fungibles` (0..holding_fungibles) .map(|i| { Asset { diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index 7734305dc1aa..94a42c711aba 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -194,7 +194,9 @@ impl XcmExecutor { pub fn set_topic(&mut self, v: Option<[u8; 32]>) { self.context.topic = v; } - pub fn asset_claimer(&self) -> Option { self.asset_claimer.clone() } + pub fn asset_claimer(&self) -> Option { + self.asset_claimer.clone() + } } pub struct WeighedMessage(Weight, Xcm); @@ -369,8 +371,7 @@ impl XcmExecutor { } else { self.context.origin.as_ref().unwrap_or(&self.original_origin) }; - let trap_weight = - Config::AssetTrap::drop_assets(claimer, self.holding, &self.context); + let trap_weight = Config::AssetTrap::drop_assets(claimer, self.holding, &self.context); weight_used.saturating_accrue(trap_weight); }; @@ -534,13 +535,20 @@ impl XcmExecutor { } else { // This condition exists to support `BuyExecution` while the ecosystem // transitions to `PayFees`. - let assets_taken_from_holding_to_pay_delivery_fees: AssetsInHolding = if self.fees.is_empty() { - // Means `BuyExecution` was used, we'll find the fees in the `holding` register. - self.holding.try_take(asset_to_pay_for_fees.clone().into()).map_err(|_| XcmError::NotHoldingFees)?.into() - } else { - // Means `PayFees` was used, we'll find the fees in the `fees` register. - self.fees.try_take(asset_to_pay_for_fees.clone().into()).map_err(|_| XcmError::NotHoldingFees)?.into() - }; + let assets_taken_from_holding_to_pay_delivery_fees: AssetsInHolding = + if self.fees.is_empty() { + // Means `BuyExecution` was used, we'll find the fees in the `holding` register. + self.holding + .try_take(asset_to_pay_for_fees.clone().into()) + .map_err(|_| XcmError::NotHoldingFees)? + .into() + } else { + // Means `PayFees` was used, we'll find the fees in the `fees` register. + self.fees + .try_take(asset_to_pay_for_fees.clone().into()) + .map_err(|_| XcmError::NotHoldingFees)? + .into() + }; tracing::trace!(target: "xcm::fees", ?assets_taken_from_holding_to_pay_delivery_fees); let mut iter = assets_taken_from_holding_to_pay_delivery_fees.fungible_assets_iter(); let asset = iter.next().ok_or(XcmError::NotHoldingFees)?; @@ -991,24 +999,26 @@ impl XcmExecutor { let old_holding = self.holding.clone(); let result = Config::TransactionalProcessor::process(|| { let maybe_delivery_fee = if self.fees.is_empty() { - // we need to do this take/put cycle to solve wildcards and get exact assets to - // be weighed + // we need to do this take/put cycle to solve wildcards and get exact assets + // to be weighed let to_weigh = self.holding.saturating_take(assets.clone()); self.holding.subsume_assets(to_weigh.clone()); let to_weigh_reanchored = Self::reanchored(to_weigh, &dest, None); let mut message_to_weigh = vec![ReserveAssetDeposited(to_weigh_reanchored), ClearOrigin]; message_to_weigh.extend(xcm.0.clone().into_iter()); - let (_, fee) = - validate_send::(dest.clone(), Xcm(message_to_weigh))?; + let (_, fee) = validate_send::( + dest.clone(), + Xcm(message_to_weigh), + )?; let maybe_delivery_fee = fee.get(0).map(|asset_needed_for_fees| { tracing::trace!( target: "xcm::DepositReserveAsset", "Asset provided to pay for fees {:?}, asset required for delivery fees: {:?}", self.asset_used_for_fees, asset_needed_for_fees, ); - let asset_to_pay_for_fees = - self.calculate_asset_for_delivery_fees(asset_needed_for_fees.clone()); + let asset_to_pay_for_fees = self + .calculate_asset_for_delivery_fees(asset_needed_for_fees.clone()); // set aside fee to be charged by XcmSender let delivery_fee = self.holding.saturating_take(asset_to_pay_for_fees.into()); diff --git a/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs index cdf519ca3cfc..bc504b8db2a2 100644 --- a/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs +++ b/polkadot/xcm/xcm-executor/src/tests/set_asset_claimer.rs @@ -27,112 +27,112 @@ use crate::XcmExecutor; #[test] fn set_asset_claimer() { - let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); - let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); - - // Make sure the user has enough funds to withdraw. - add_asset(sender.clone(), (Here, 100u128)); - - // Build xcm. - let xcm = Xcm::::builder_unsafe() - // if withdrawing fails we're not missing any corner case. - .withdraw_asset((Here, 100u128)) - .clear_origin() - .set_asset_claimer(bob.clone()) - .pay_fees((Here, 10u128)) // 10% destined for fees, not more. - .build(); - - // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we - // can inspect its fields. - let mut vm = - XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); - vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); - - let result = vm.bench_process(xcm); - assert!(result.is_ok()); - assert_eq!(vm.asset_claimer(), Some(bob)); + let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); + + // Make sure the user has enough funds to withdraw. + add_asset(sender.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder_unsafe() + // if withdrawing fails we're not missing any corner case. + .withdraw_asset((Here, 100u128)) + .clear_origin() + .set_asset_claimer(bob.clone()) + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .build(); + + // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we + // can inspect its fields. + let mut vm = + XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + + let result = vm.bench_process(xcm); + assert!(result.is_ok()); + assert_eq!(vm.asset_claimer(), Some(bob)); } #[test] fn do_not_set_asset_claimer_none() { - let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); - - // Make sure the user has enough funds to withdraw. - add_asset(sender.clone(), (Here, 100u128)); - - // Build xcm. - let xcm = Xcm::::builder_unsafe() - // if withdrawing fails we're not missing any corner case. - .withdraw_asset((Here, 100u128)) - .clear_origin() - .pay_fees((Here, 10u128)) // 10% destined for fees, not more. - .build(); - - // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we - // can inspect its fields. - let mut vm = - XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); - vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); - - let result = vm.bench_process(xcm); - assert!(result.is_ok()); - assert_eq!(vm.asset_claimer(), None); + let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + + // Make sure the user has enough funds to withdraw. + add_asset(sender.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder_unsafe() + // if withdrawing fails we're not missing any corner case. + .withdraw_asset((Here, 100u128)) + .clear_origin() + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .build(); + + // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we + // can inspect its fields. + let mut vm = + XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + + let result = vm.bench_process(xcm); + assert!(result.is_ok()); + assert_eq!(vm.asset_claimer(), None); } #[test] fn trap_then_set_asset_claimer() { - let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); - let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); - - // Make sure the user has enough funds to withdraw. - add_asset(sender.clone(), (Here, 100u128)); - - // Build xcm. - let xcm = Xcm::::builder_unsafe() - // if withdrawing fails we're not missing any corner case. - .withdraw_asset((Here, 100u128)) - .clear_origin() - .trap(0u64) - .set_asset_claimer(bob) - .pay_fees((Here, 10u128)) // 10% destined for fees, not more. - .build(); - - // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we - // can inspect its fields. - let mut vm = - XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); - vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); - - let result = vm.bench_process(xcm); - assert!(result.is_err()); - assert_eq!(vm.asset_claimer(), None); + let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); + + // Make sure the user has enough funds to withdraw. + add_asset(sender.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder_unsafe() + // if withdrawing fails we're not missing any corner case. + .withdraw_asset((Here, 100u128)) + .clear_origin() + .trap(0u64) + .set_asset_claimer(bob) + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .build(); + + // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we + // can inspect its fields. + let mut vm = + XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + + let result = vm.bench_process(xcm); + assert!(result.is_err()); + assert_eq!(vm.asset_claimer(), None); } #[test] fn set_asset_claimer_then_trap() { - let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); - let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); - - // Make sure the user has enough funds to withdraw. - add_asset(sender.clone(), (Here, 100u128)); - - // Build xcm. - let xcm = Xcm::::builder_unsafe() - // if withdrawing fails we're not missing any corner case. - .withdraw_asset((Here, 100u128)) - .clear_origin() - .set_asset_claimer(bob.clone()) - .trap(0u64) - .pay_fees((Here, 10u128)) // 10% destined for fees, not more. - .build(); - - // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we - // can inspect its fields. - let mut vm = - XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); - vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); - - let result = vm.bench_process(xcm); - assert!(result.is_err()); - assert_eq!(vm.asset_claimer(), Some(bob)); + let sender = Location::new(0, [AccountId32 { id: [0; 32], network: None }]); + let bob = Location::new(0, [AccountId32 { id: [2; 32], network: None }]); + + // Make sure the user has enough funds to withdraw. + add_asset(sender.clone(), (Here, 100u128)); + + // Build xcm. + let xcm = Xcm::::builder_unsafe() + // if withdrawing fails we're not missing any corner case. + .withdraw_asset((Here, 100u128)) + .clear_origin() + .set_asset_claimer(bob.clone()) + .trap(0u64) + .pay_fees((Here, 10u128)) // 10% destined for fees, not more. + .build(); + + // We create an XCVM instance instead of calling `XcmExecutor::<_>::prepare_and_execute` so we + // can inspect its fields. + let mut vm = + XcmExecutor::::new(sender, xcm.using_encoded(sp_io::hashing::blake2_256)); + vm.message_weight = XcmExecutor::::prepare(xcm.clone()).unwrap().weight_of(); + + let result = vm.bench_process(xcm); + assert!(result.is_err()); + assert_eq!(vm.asset_claimer(), Some(bob)); } From 23a7e65882b1cc691fa1ad8d7aff0ec25603fc0a Mon Sep 17 00:00:00 2001 From: ndk Date: Fri, 27 Sep 2024 12:33:38 +0300 Subject: [PATCH 142/151] changed pr_doc number --- prdoc/{pr_5416.prdoc => pr_5585.prdoc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename prdoc/{pr_5416.prdoc => pr_5585.prdoc} (100%) diff --git a/prdoc/pr_5416.prdoc b/prdoc/pr_5585.prdoc similarity index 100% rename from prdoc/pr_5416.prdoc rename to prdoc/pr_5585.prdoc From c37ac54bed96d54ee1729b3028d4eaeb789c00c4 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 30 Sep 2024 20:28:59 +0200 Subject: [PATCH 143/151] removed unused imports --- .../runtimes/assets/asset-hub-westend/src/xcm_config.rs | 6 +++--- .../bridge-hubs/bridge-hub-westend/src/xcm_config.rs | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index e1c0f54f5024..d1ac82d25dca 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -49,9 +49,9 @@ use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, - DescribePalletTerminal, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, - FungiblesAdapter, GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, - LocalMint, MatchedConvertedConcreteId, NetworkExportTableItem, NoChecking, NonFungiblesAdapter, + EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, + GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint, + MatchedConvertedConcreteId, NetworkExportTableItem, NoChecking, NonFungiblesAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SingleAssetExchangeAdapter, SovereignPaidRemoteExporter, diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs index b3b6fc1fa8b3..7e3411eab431 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs @@ -44,9 +44,8 @@ use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, - DescribePalletTerminal, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, - GlobalConsensusParachainConvertsFor, HandleFee, HashedDescription, IsConcrete, - ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, + EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, HandleFee, HashedDescription, + IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, From f0631fb7d7c50535bf4c6a9acbb5a5fb12f7dbcc Mon Sep 17 00:00:00 2001 From: ndk Date: Tue, 1 Oct 2024 04:21:13 +0200 Subject: [PATCH 144/151] removed dead code --- .../emulated/tests/assets/asset-hub-westend/src/lib.rs | 4 +--- .../assets/asset-hub-westend/src/tests/set_asset_claimer.rs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs index 659e4e4f0a0e..baf2e4a0f254 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs @@ -59,7 +59,7 @@ mod imports { AssetHubWestendParaPallet as AssetHubWestendPallet, }, bridge_hub_westend_emulated_chain::bridge_hub_westend_runtime::xcm_config::{ - self as bhw_xcm_config, XcmConfig as BridgeHubWestendXcmConfig, + self as bhw_xcm_config, }, collectives_westend_emulated_chain::CollectivesWestendParaPallet as CollectivesWestendPallet, penpal_emulated_chain::{ @@ -101,8 +101,6 @@ mod imports { pub type ParaToParaThroughRelayTest = Test; pub type ParaToParaThroughAHTest = Test; pub type RelayToParaThroughAHTest = Test; - pub type BridgeHubToAssetHubTest = Test; - pub type AssetHubToBridgeHubTest = Test; } #[cfg(test)] diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 63a7b287842b..1d6c8082b4fb 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -29,7 +29,7 @@ use xcm_executor::traits::ConvertLocation; #[test] fn test_set_asset_claimer_within_a_chain() { - let (alice_account, alice_location) = account_and_location(ALICE); + let (alice_account, _) = account_and_location(ALICE); let (bob_account, bob_location) = account_and_location(BOB); let trap_amount = 16_000_000_000_000; From df4df98ac3d8801e03ea743d1a70f47e5fe1cd93 Mon Sep 17 00:00:00 2001 From: ndk Date: Fri, 18 Oct 2024 21:32:56 +0300 Subject: [PATCH 145/151] fixed westend benchmarks --- .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 262b29190d26..2ad1cd6359a6 100644 --- a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -203,12 +203,6 @@ impl WeightInfo { Weight::from_parts(31_989_000, 3612) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) - // Measured: `147` - // Estimated: `3612` - // Minimum execution time: 30_726_000 picoseconds. - Weight::from_parts(31_268_000, 3612) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) } /// Storage: `XcmPallet::VersionNotifyTargets` (r:0 w:1) /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) From 20a5b85aaf733b86306febb2057e26f67ae1ff92 Mon Sep 17 00:00:00 2001 From: Andrii Date: Mon, 21 Oct 2024 09:48:47 +0300 Subject: [PATCH 146/151] Update test name Co-authored-by: Francisco Aguirre --- .../assets/asset-hub-westend/src/tests/set_asset_claimer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index 1d6c8082b4fb..e97522a33c01 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -93,7 +93,7 @@ fn account_and_location(account: &str) -> (AccountId32, Location) { // 2. Alice on AssetHub sends an XCM to BridgeHub to claim assets, pay fees and deposit // remaining to her sibling account on BridgeHub. #[test] -fn test_sac_between_the_chains() { +fn test_set_asset_claimer_between_the_chains() { let alice = AssetHubWestend::account_id_of(ALICE); let alice_bh_sibling = Location::new( 1, From d4e0f4bb231e25a8893df63bfd46715292c46524 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 21 Oct 2024 10:07:26 +0300 Subject: [PATCH 147/151] renamed a variable and removed a duplicate variable --- .../asset-hub-westend/src/tests/set_asset_claimer.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs index e97522a33c01..4e63ab58e943 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/set_asset_claimer.rs @@ -127,13 +127,6 @@ fn test_set_asset_claimer_between_the_chains() { let balance = ::account_data_of(alice_bh_acc.clone()).free; assert_eq!(balance, 0); - let alice_bh_sibling = Location::new( - 1, - [ - Parachain(AssetHubWestend::para_id().into()), - Junction::AccountId32 { network: Some(Westend), id: alice.clone().into() }, - ], - ); let pay_fees = 6_000_000_000_000u128; let xcm_on_bh = Xcm::<()>::builder_unsafe() .claim_asset(assets.clone(), Here) @@ -149,7 +142,7 @@ fn test_set_asset_claimer_between_the_chains() { )); }); - let al_bh_acc = LocationToAccountId::convert_location(&alice_bh_sibling).unwrap(); - let balance = ::account_data_of(al_bh_acc).free; + let alice_bh_acc = LocationToAccountId::convert_location(&alice_bh_sibling).unwrap(); + let balance = ::account_data_of(alice_bh_acc).free; assert_eq!(balance, trap_amount - pay_fees); } From 9e575f6ceacff7294f4fdb0169f13b4393b8ad27 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 21 Oct 2024 14:03:40 +0300 Subject: [PATCH 148/151] Added missing v4 import --- .../emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs index 80836095eef6..b63d76b4d930 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs @@ -13,6 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +use xcm::opaque::v4; use crate::imports::*; mod asset_transfers; From 93f96c8ca2d2d5657e207775b120082ecc3303b2 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 21 Oct 2024 15:08:15 +0300 Subject: [PATCH 149/151] used proper version of xcm junction --- .../emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs index b63d76b4d930..cd92e92e70c7 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use xcm::opaque::v4; +use xcm::opaque::v5; use crate::imports::*; mod asset_transfers; @@ -118,7 +118,7 @@ pub(crate) fn set_up_pool_with_wnd_on_ah_westend(asset: v5::Location, is_foreign )); } else { let asset_id = match asset.interior.last() { - Some(v4::Junction::GeneralIndex(id)) => *id as u32, + Some(GeneralIndex(id)) => *id as u32, _ => unreachable!(), }; assert_ok!(::Assets::mint( From f99c3f6e9133b56323ad3e9ec228aa7af276eaf3 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 21 Oct 2024 15:22:51 +0300 Subject: [PATCH 150/151] removed self dependency --- .../emulated/tests/bridges/bridge-hub-rococo/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs index 0c8f2eac5956..65a9f9660c0e 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs @@ -24,7 +24,7 @@ mod imports { pub use xcm::{ latest::ParentThen, prelude::{AccountId32 as AccountId32Junction, *}, - v5::{self, NetworkId::Westend as WestendId}, + v5::NetworkId::Westend as WestendId, }; pub use xcm_executor::traits::TransferType; From 8f42b3e1d0267bb564facaadb90d2391dd58ff0d Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 21 Oct 2024 15:33:01 +0300 Subject: [PATCH 151/151] formatted the imports --- .../emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs index cd92e92e70c7..fd43a3e78a51 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use xcm::opaque::v5; use crate::imports::*; +use xcm::opaque::v5; mod asset_transfers; mod claim_assets;