diff --git a/chain-extensions/pallet-assets/src/mock.rs b/chain-extensions/pallet-assets/src/mock.rs index 3b12da52cd..c6fed3656e 100644 --- a/chain-extensions/pallet-assets/src/mock.rs +++ b/chain-extensions/pallet-assets/src/mock.rs @@ -137,7 +137,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); - type MaxHolds = ConstU32<10>; + type MaxHolds = ConstU32<1>; type MaxFreezes = ConstU32<0>; } diff --git a/pallets/astar-xcm-benchmarks/src/mock.rs b/pallets/astar-xcm-benchmarks/src/mock.rs index d345cec9cf..28a78e0028 100644 --- a/pallets/astar-xcm-benchmarks/src/mock.rs +++ b/pallets/astar-xcm-benchmarks/src/mock.rs @@ -245,7 +245,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; - type Aliasers = (); + type Aliasers = Nothing; } impl pallet_xcm_benchmarks::Config for Test { diff --git a/pallets/inflation/src/mock.rs b/pallets/inflation/src/mock.rs index 9d699b4f43..96f04dab19 100644 --- a/pallets/inflation/src/mock.rs +++ b/pallets/inflation/src/mock.rs @@ -35,7 +35,7 @@ use sp_runtime::{ BuildStorage, Perquintill, }; -use astar_primitives::{testing::Header, Balance, BlockNumber}; +use astar_primitives::{Balance, BlockNumber}; pub(crate) type AccountId = u64; /// Initial inflation params set by the mock. diff --git a/precompiles/xcm/src/mock.rs b/precompiles/xcm/src/mock.rs index e0ac9c1458..1b6554a1ca 100644 --- a/precompiles/xcm/src/mock.rs +++ b/precompiles/xcm/src/mock.rs @@ -447,7 +447,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; - type Aliasers = (); + type Aliasers = Nothing; } parameter_types! { diff --git a/primitives/src/xcm/tests.rs b/primitives/src/xcm/tests.rs index 21dcfbeaef..86f5c70fdd 100644 --- a/primitives/src/xcm/tests.rs +++ b/primitives/src/xcm/tests.rs @@ -18,8 +18,9 @@ use super::*; use frame_support::assert_ok; -use sp_runtime::traits::Zero; -use xcm_executor::traits::Convert; +use sp_runtime::traits::{MaybeEquivalence, Zero}; +use xcm_builder::{DescribeAllTerminal, DescribeFamily, HashedDescription}; +use xcm_executor::traits::ConvertLocation; type AssetId = u128; @@ -79,22 +80,22 @@ fn execution_fee(weight: Weight, units_per_second: u128) -> u128 { fn asset_location_to_id() { // Test cases where the MultiLocation is valid assert_eq!( - AssetLocationIdConverter::::convert_ref(PARENT), - Ok(u128::MAX) + AssetLocationIdConverter::::convert(&PARENT), + Some(u128::MAX) ); assert_eq!( - AssetLocationIdConverter::::convert_ref(PARACHAIN), - Ok(20) + AssetLocationIdConverter::::convert(&PARACHAIN), + Some(20) ); assert_eq!( - AssetLocationIdConverter::::convert_ref(GENERAL_INDEX), - Ok(30) + AssetLocationIdConverter::::convert(&GENERAL_INDEX), + Some(30) ); // Test case where MultiLocation isn't supported assert_eq!( - AssetLocationIdConverter::::convert_ref(MultiLocation::here()), - Err(()) + AssetLocationIdConverter::::convert(&MultiLocation::here()), + None ); } @@ -102,22 +103,22 @@ fn asset_location_to_id() { fn asset_id_to_location() { // Test cases where the AssetId is valid assert_eq!( - AssetLocationIdConverter::::reverse_ref(u128::MAX), - Ok(PARENT) + AssetLocationIdConverter::::convert_back(&u128::MAX), + Some(PARENT) ); assert_eq!( - AssetLocationIdConverter::::reverse_ref(20), - Ok(PARACHAIN) + AssetLocationIdConverter::::convert_back(&20), + Some(PARACHAIN) ); assert_eq!( - AssetLocationIdConverter::::reverse_ref(30), - Ok(GENERAL_INDEX) + AssetLocationIdConverter::::convert_back(&30), + Some(GENERAL_INDEX) ); // Test case where the AssetId isn't supported assert_eq!( - AssetLocationIdConverter::::reverse_ref(0), - Err(()) + AssetLocationIdConverter::::convert_back(&0), + None ); } @@ -132,6 +133,12 @@ fn fixed_rate_of_foreign_asset_buy_is_ok() { fun: Fungibility::Fungible(total_payment), }; let weight: Weight = Weight::from_parts(1_000_000_000, 0); + let ctx = XcmContext { + // arbitary ML + origin: Some(MultiLocation::here()), + message_id: XcmHash::default(), + topic: None, + }; // Calculate the expected execution fee for the execution weight let expected_execution_fee = execution_fee( @@ -141,7 +148,7 @@ fn fixed_rate_of_foreign_asset_buy_is_ok() { assert!(expected_execution_fee > 0); // sanity check // 1. Buy weight and expect it to be successful - let result = fixed_rate_trader.buy_weight(weight, payment_multi_asset.clone().into()); + let result = fixed_rate_trader.buy_weight(weight, payment_multi_asset.clone().into(), &ctx); if let Ok(assets) = result { // We expect only one unused payment asset and specific amount assert_eq!(assets.len(), 1); @@ -172,7 +179,7 @@ fn fixed_rate_of_foreign_asset_buy_is_ok() { ); assert!(expected_execution_fee > 0); // sanity check - let result = fixed_rate_trader.buy_weight(weight, payment_multi_asset.clone().into()); + let result = fixed_rate_trader.buy_weight(weight, payment_multi_asset.clone().into(), &ctx); if let Ok(assets) = result { // We expect only one unused payment asset and specific amount assert_eq!(assets.len(), 1); @@ -213,7 +220,7 @@ fn fixed_rate_of_foreign_asset_buy_is_ok() { ); assert!(expected_execution_fee > 0); // sanity check - let result = fixed_rate_trader.buy_weight(weight, payment_multi_asset.clone().into()); + let result = fixed_rate_trader.buy_weight(weight, payment_multi_asset.clone().into(), &ctx); if let Ok(assets) = result { // We expect only one unused payment asset and specific amount assert_eq!(assets.len(), 1); @@ -248,6 +255,12 @@ fn fixed_rate_of_foreign_asset_buy_execution_fails() { fun: Fungibility::Fungible(total_payment), }; let weight: Weight = Weight::from_parts(3_000_000_000, 0); + let ctx = XcmContext { + // arbitary ML + origin: Some(MultiLocation::here()), + message_id: XcmHash::default(), + topic: None, + }; // Calculate the expected execution fee for the execution weight let expected_execution_fee = execution_fee( @@ -259,7 +272,7 @@ fn fixed_rate_of_foreign_asset_buy_execution_fails() { // Expect failure because we lack the required funds assert_eq!( - fixed_rate_trader.buy_weight(weight, payment_multi_asset.clone().into()), + fixed_rate_trader.buy_weight(weight, payment_multi_asset.clone().into(), &ctx), Err(XcmError::TooExpensive) ); @@ -269,7 +282,7 @@ fn fixed_rate_of_foreign_asset_buy_execution_fails() { fun: Fungibility::Fungible(total_payment), }; assert_eq!( - fixed_rate_trader.buy_weight(Weight::zero(), payment_multi_asset.clone().into()), + fixed_rate_trader.buy_weight(Weight::zero(), payment_multi_asset.clone().into(), &ctx), Err(XcmError::TooExpensive) ); } @@ -285,6 +298,12 @@ fn fixed_rate_of_foreign_asset_refund_is_ok() { fun: Fungibility::Fungible(total_payment), }; let weight: Weight = Weight::from_parts(1_000_000_000, 0); + let ctx = XcmContext { + // arbitary ML + origin: Some(MultiLocation::here()), + message_id: XcmHash::default(), + topic: None, + }; // Calculate the expected execution fee for the execution weight and buy it let expected_execution_fee = execution_fee( @@ -292,14 +311,14 @@ fn fixed_rate_of_foreign_asset_refund_is_ok() { ExecutionPayment::get_units_per_second(PARENT).unwrap(), ); assert!(expected_execution_fee > 0); // sanity check - assert_ok!(fixed_rate_trader.buy_weight(weight, payment_multi_asset.clone().into())); + assert_ok!(fixed_rate_trader.buy_weight(weight, payment_multi_asset.clone().into(), &ctx)); // Refund quarter and expect it to pass let weight_to_refund = weight / 4; let assets_to_refund = expected_execution_fee / 4; let (old_weight, old_consumed) = (fixed_rate_trader.weight, fixed_rate_trader.consumed); - let result = fixed_rate_trader.refund_weight(weight_to_refund); + let result = fixed_rate_trader.refund_weight(weight_to_refund, &ctx); if let Some(asset_location) = result { assert_eq!(asset_location, (PARENT, assets_to_refund).into()); @@ -310,7 +329,7 @@ fn fixed_rate_of_foreign_asset_refund_is_ok() { // Refund more than remains and expect it to pass (saturated) let assets_to_refund = fixed_rate_trader.consumed; - let result = fixed_rate_trader.refund_weight(weight + Weight::from_parts(10000, 0)); + let result = fixed_rate_trader.refund_weight(weight + Weight::from_parts(10000, 0), &ctx); if let Some(asset_location) = result { assert_eq!(asset_location, (PARENT, assets_to_refund).into()); @@ -423,10 +442,12 @@ fn hashed_description_sanity_check() { }; // Ensure derived value is same as it would be using `polkadot-v0.9.44` code. let derived_account = - HashedDescription::<[u8; 32], DescribeFamily>::convert(acc_key_20_mul); + HashedDescription::<[u8; 32], DescribeFamily>::convert_location( + &acc_key_20_mul, + ); assert_eq!( derived_account, - Ok([ + Some([ 61_u8, 117, 247, 231, 100, 219, 128, 176, 180, 200, 187, 102, 93, 107, 187, 145, 25, 146, 50, 248, 244, 153, 83, 95, 207, 165, 90, 10, 220, 39, 23, 49 ]) @@ -444,10 +465,12 @@ fn hashed_description_sanity_check() { }; // Ensure derived value is same as it would be using `polkadot-v0.9.44` code. let derived_account = - HashedDescription::<[u8; 32], DescribeFamily>::convert(acc_id_32_mul); + HashedDescription::<[u8; 32], DescribeFamily>::convert_location( + &acc_id_32_mul, + ); assert_eq!( derived_account, - Ok([ + Some([ 123, 171, 79, 159, 78, 47, 62, 233, 108, 149, 131, 249, 23, 192, 178, 52, 235, 133, 147, 145, 152, 89, 129, 92, 63, 79, 211, 235, 213, 152, 201, 205 ])