Skip to content

Commit 015e867

Browse files
BACKPORT-CONFLICT
1 parent 44b719a commit 015e867

File tree

10 files changed

+916
-35
lines changed

10 files changed

+916
-35
lines changed

cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs

+44-4
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,12 @@ impl_runtime_apis! {
15631563
fn dispatch_benchmark(
15641564
config: frame_benchmarking::BenchmarkConfig
15651565
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
1566+
<<<<<<< HEAD
15661567
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
1568+
=======
1569+
use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
1570+
use frame_support::assert_ok;
1571+
>>>>>>> c4b8ec12 (Use non-native token to benchmark xcm on asset hub (#7893))
15671572
use sp_storage::TrackedStorageKey;
15681573

15691574
use frame_system_benchmarking::Pallet as SystemBench;
@@ -1688,9 +1693,27 @@ impl_runtime_apis! {
16881693
}
16891694

16901695
fn get_asset() -> Asset {
1696+
use frame_benchmarking::whitelisted_caller;
1697+
use frame_support::traits::tokens::fungible::{Inspect, Mutate};
1698+
let account = whitelisted_caller();
1699+
assert_ok!(<Balances as Mutate<_>>::mint_into(
1700+
&account,
1701+
<Balances as Inspect<_>>::minimum_balance(),
1702+
));
1703+
let asset_id = 1984;
1704+
assert_ok!(Assets::force_create(
1705+
RuntimeOrigin::root(),
1706+
asset_id.into(),
1707+
account.into(),
1708+
true,
1709+
1u128,
1710+
));
1711+
let amount = 1_000_000u128;
1712+
let asset_location = Location::new(0, [PalletInstance(50), GeneralIndex(u32::from(asset_id).into())]);
1713+
16911714
Asset {
1692-
id: AssetId(Location::parent()),
1693-
fun: Fungible(ExistentialDeposit::get()),
1715+
id: AssetId(asset_location),
1716+
fun: Fungible(amount),
16941717
}
16951718
}
16961719
}
@@ -1784,9 +1807,26 @@ impl_runtime_apis! {
17841807
type TrustedReserve = TrustedReserve;
17851808

17861809
fn get_asset() -> Asset {
1810+
use frame_support::traits::tokens::fungible::{Inspect, Mutate};
1811+
let (account, _) = pallet_xcm_benchmarks::account_and_location::<Runtime>(1);
1812+
assert_ok!(<Balances as Mutate<_>>::mint_into(
1813+
&account,
1814+
<Balances as Inspect<_>>::minimum_balance(),
1815+
));
1816+
let asset_id = 1984;
1817+
assert_ok!(Assets::force_create(
1818+
RuntimeOrigin::root(),
1819+
asset_id.into(),
1820+
account.clone().into(),
1821+
true,
1822+
1u128,
1823+
));
1824+
let amount = 1_000_000u128;
1825+
let asset_location = Location::new(0, [PalletInstance(50), GeneralIndex(u32::from(asset_id).into())]);
1826+
17871827
Asset {
1788-
id: AssetId(TokenLocation::get()),
1789-
fun: Fungible(UNITS),
1828+
id: AssetId(asset_location),
1829+
fun: Fungible(amount),
17901830
}
17911831
}
17921832
}

0 commit comments

Comments
 (0)