Skip to content

Commit 1c3b815

Browse files
authored
Backport patch for xcm fungible benchmarks required by new FungibleAdapter for 1.6 (#3422)
More info here: #3417 Expected patch for `pallet-xcm-benchmarks` as `7.0.4`
1 parent 73368f0 commit 1c3b815

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ benchmarks_instance_pallet! {
7171
let dest_account = T::AccountIdConverter::convert_location(&dest_location).unwrap();
7272

7373
<AssetTransactorOf<T>>::deposit_asset(&asset, &sender_location, None).unwrap();
74+
// We deposit the asset twice so we have enough for ED after transferring
75+
<AssetTransactorOf<T>>::deposit_asset(&asset, &sender_location, None).unwrap();
76+
let sender_account_balance_before = T::TransactAsset::balance(&sender_account);
7477
assert!(T::TransactAsset::balance(&dest_account).is_zero());
7578

7679
let mut executor = new_executor::<T>(sender_location);
@@ -79,7 +82,7 @@ benchmarks_instance_pallet! {
7982
}: {
8083
executor.bench_process(xcm)?;
8184
} verify {
82-
assert!(T::TransactAsset::balance(&sender_account).is_zero());
85+
assert!(T::TransactAsset::balance(&sender_account) < sender_account_balance_before);
8386
assert!(!T::TransactAsset::balance(&dest_account).is_zero());
8487
}
8588

@@ -93,12 +96,13 @@ benchmarks_instance_pallet! {
9396
&dest_location,
9497
FeeReason::TransferReserveAsset
9598
);
96-
let sender_account_balance_before = T::TransactAsset::balance(&sender_account);
9799

98100
let asset = T::get_multi_asset();
99101
<AssetTransactorOf<T>>::deposit_asset(&asset, &sender_location, None).unwrap();
100-
assert!(T::TransactAsset::balance(&sender_account) > sender_account_balance_before);
101-
let assets: MultiAssets = vec![ asset ].into();
102+
// We deposit the asset twice so we have enough for ED after transferring
103+
<AssetTransactorOf<T>>::deposit_asset(&asset, &sender_location, None).unwrap();
104+
let sender_account_balance_before = T::TransactAsset::balance(&sender_account);
105+
let assets: MultiAssets = vec![asset].into();
102106
assert!(T::TransactAsset::balance(&dest_account).is_zero());
103107

104108
let mut executor = new_executor::<T>(sender_location);

polkadot/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ impl xcm_executor::traits::MatchesFungible<u64> for MatchAnyFungible {
103103
}
104104

105105
// Use balances as the asset transactor.
106-
#[allow(deprecated)]
107-
pub type AssetTransactor = xcm_builder::CurrencyAdapter<
106+
pub type AssetTransactor = xcm_builder::FungibleAdapter<
108107
Balances,
109108
MatchAnyFungible,
110109
AccountIdConverter,
@@ -193,8 +192,7 @@ impl xcm_balances_benchmark::Config for Test {
193192
type TrustedReserve = TrustedReserve;
194193

195194
fn get_multi_asset() -> MultiAsset {
196-
let amount =
197-
<Balances as frame_support::traits::fungible::Inspect<u64>>::minimum_balance() as u128;
195+
let amount = 1_000_000_000_000;
198196
MultiAsset { id: Concrete(Here.into()), fun: Fungible(amount) }
199197
}
200198
}

0 commit comments

Comments
 (0)