This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor CreateAssetCall as structure & Move to common
- Loading branch information
Showing
5 changed files
with
31 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 15 additions & 18 deletions
33
cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/snowbridge.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,34 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]> | ||
|
||
pub use asset_hub_rococo_runtime::{Runtime, RuntimeCall}; | ||
use asset_hub_rococo_runtime::Runtime; | ||
pub use asset_hub_rococo_runtime::RuntimeCall; | ||
use codec::Encode; | ||
use frame_support::instances::Instance2; | ||
use parachains_common::rococo::snowbridge::CreateAssetCall; | ||
use snowbridge_router_primitives::inbound::CreateAssetCallInfo; | ||
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() | ||
// ); | ||
let call = &RuntimeCall::ForeignAssets(pallet_assets::Call::create { | ||
id: MultiLocation::default(), | ||
admin: MultiAddress::Id([0; 32].into()), | ||
min_balance: 1, | ||
}) | ||
.encode(); | ||
let call_index = &call[..2]; | ||
let snowbridge_call: CreateAssetCallInfo = CreateAssetCall::get(); | ||
assert_eq!(call_index, snowbridge_call.call_index); | ||
} | ||
|
||
#[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; | ||
let snowbridge_call: CreateAssetCallInfo = CreateAssetCall::get(); | ||
let max_weight = snowbridge_call.transact_weight_at_most; | ||
assert!( | ||
actual.all_lte(max_weight), | ||
"max_weight: {:?} should be adjusted to actual {:?}", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters