Skip to content

Commit

Permalink
runtime test for create asset in AH
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Jan 12, 2024
1 parent c23c50f commit 40310a3
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>

pub use asset_hub_rococo_runtime::{Runtime, RuntimeCall};
use codec::Encode;
use frame_support::instances::Instance2;
use sp_runtime::MultiAddress;
use xcm::latest::prelude::*;

#[test]
fn test_foreign_create_asset_call_compatibility() {
assert_eq!(
RuntimeCall::ForeignAssets(pallet_assets::Call::create {
id: MultiLocation::default(),
admin: MultiAddress::Id([0; 32].into()),
min_balance: 1,
})
.encode(),
snowbridge_router_primitives::inbound::Call::ForeignAssets(
snowbridge_router_primitives::inbound::ForeignAssetsCall::create {
id: MultiLocation::default(),
admin: MultiAddress::Id([0; 32].into()),
min_balance: 1,
}
)
.encode()
);
}

#[test]
fn check_foreign_create_asset_call_with_sane_weight() {
use pallet_assets::WeightInfo;
let actual = <Runtime as pallet_assets::Config<Instance2>>::WeightInfo::create();
let max_weight = snowbridge_router_primitives::inbound::FOREIGN_CREATE_ASSET_WEIGHT_AT_MOST;
assert!(
actual.all_lte(max_weight),
"max_weight: {:?} should be adjusted to actual {:?}",
max_weight,
actual
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ parameter_types! {
}

parameter_types! {
pub const CreateAssetCall: [u8;2] = [53, 0];
pub const CreateAssetDeposit: u128 = (UNITS / 10) + EXISTENTIAL_DEPOSIT;
pub const InboundQueuePalletInstance: u8 = parachains_common::rococo::snowbridge::INBOUND_QUEUE_PALLET_INDEX;
pub Parameters: PricingParameters<u128> = PricingParameters {
Expand Down Expand Up @@ -560,13 +559,8 @@ impl snowbridge_pallet_inbound_queue::Config for Runtime {
type GatewayAddress = EthereumGatewayAddress;
#[cfg(feature = "runtime-benchmarks")]
type Helper = Runtime;
type MessageConverter = MessageToXcm<
CreateAssetCall,
CreateAssetDeposit,
InboundQueuePalletInstance,
AccountId,
Balance,
>;
type MessageConverter =
MessageToXcm<CreateAssetDeposit, InboundQueuePalletInstance, AccountId, Balance>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type MaxMessageSize = ConstU32<2048>;
Expand Down

0 comments on commit 40310a3

Please sign in to comment.