mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 16:21:02 +00:00
Rename Statemint to Asset Hub (#2633)
* change dir names * cargo toml updates * fix crate imports for build * change chain spec names and PR review rule * update cli to accept asset-hub * find/replace benchmark commands * integration tests * bridges docs * more integration tests * AuraId * other statemint tidying * rename statemint mod * chain spec mod * rename e2e test dirs * one more Runtime::Statemine * benchmark westmint * rename chain spec name and id * rename chain spec files * more tidying in scripts/docs/tests * rename old dir if exists * Force people to manually do the move. (Safer as there could be additional considerations with their setup) * review touchups * more renaming * Update polkadot-parachain/src/command.rs Co-authored-by: Bastian Köcher <git@kchr.de> * better error message * do not break on-chain spec_name * log info message that path has been renamed * better penpal docs --------- Co-authored-by: gilescope <gilescope@gmail.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
pub use codec::Encode;
|
||||
pub use frame_support::{
|
||||
assert_ok, instances::Instance1, pallet_prelude::Weight, traits::fungibles::Inspect,
|
||||
};
|
||||
pub use integration_tests_common::{
|
||||
constants::{
|
||||
accounts::{ALICE, BOB},
|
||||
polkadot::ED as POLKADOT_ED,
|
||||
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
|
||||
},
|
||||
AccountId, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender,
|
||||
AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender,
|
||||
BHKusama, BHKusamaPallet, BHKusamaReceiver, BHKusamaSender, BHPolkadot, BHPolkadotPallet,
|
||||
BHPolkadotReceiver, BHPolkadotSender, Collectives, CollectivesPallet, CollectivesReceiver,
|
||||
CollectivesSender, Kusama, KusamaMockNet, KusamaPallet, KusamaReceiver, KusamaSender,
|
||||
PenpalKusama, PenpalKusamaReceiver, PenpalKusamaSender, PenpalPolkadot, PenpalPolkadotReceiver,
|
||||
PenpalPolkadotSender, Polkadot, PolkadotMockNet, PolkadotPallet, PolkadotReceiver,
|
||||
PolkadotSender,
|
||||
};
|
||||
pub use polkadot_core_primitives::InboundDownwardMessage;
|
||||
pub use xcm::{
|
||||
prelude::*,
|
||||
v3::{
|
||||
Error,
|
||||
NetworkId::{Kusama as KusamaId, Polkadot as PolkadotId},
|
||||
},
|
||||
};
|
||||
pub use xcm_emulator::{
|
||||
assert_expected_events, bx, cumulus_pallet_dmp_queue, helpers::weight_within_threshold,
|
||||
Parachain as Para, RelayChain as Relay, TestExt,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
mod reserve_transfer;
|
||||
mod teleport;
|
||||
mod transact;
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
use crate::*;
|
||||
|
||||
#[test]
|
||||
fn reserve_transfer_native_asset_from_relay_to_assets() {
|
||||
// Init tests variables
|
||||
let amount = POLKADOT_ED * 1000;
|
||||
let relay_sender_balance_before = Polkadot::account_data_of(PolkadotSender::get()).free;
|
||||
let para_receiver_balance_before =
|
||||
AssetHubPolkadot::account_data_of(AssetHubPolkadotReceiver::get()).free;
|
||||
|
||||
let origin = <Polkadot as Relay>::RuntimeOrigin::signed(PolkadotSender::get());
|
||||
let assets_para_destination: VersionedMultiLocation =
|
||||
Polkadot::child_location_of(AssetHubPolkadot::para_id()).into();
|
||||
let beneficiary: VersionedMultiLocation =
|
||||
AccountId32 { network: None, id: AssetHubPolkadotReceiver::get().into() }.into();
|
||||
let native_assets: VersionedMultiAssets = (Here, amount).into();
|
||||
let fee_asset_item = 0;
|
||||
let weight_limit = WeightLimit::Unlimited;
|
||||
|
||||
// Send XCM message from Relay Chain
|
||||
Polkadot::execute_with(|| {
|
||||
assert_ok!(<Polkadot as PolkadotPallet>::XcmPallet::limited_reserve_transfer_assets(
|
||||
origin,
|
||||
bx!(assets_para_destination),
|
||||
bx!(beneficiary),
|
||||
bx!(native_assets),
|
||||
fee_asset_item,
|
||||
weight_limit,
|
||||
));
|
||||
|
||||
type RuntimeEvent = <Polkadot as Relay>::RuntimeEvent;
|
||||
|
||||
assert_expected_events!(
|
||||
Polkadot,
|
||||
vec![
|
||||
RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted { outcome: Outcome::Complete(weight) }) => {
|
||||
weight: weight_within_threshold((REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), Weight::from_parts(2_000_000_000, 0), *weight),
|
||||
},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Receive XCM message in Assets Parachain
|
||||
AssetHubPolkadot::execute_with(|| {
|
||||
type RuntimeEvent = <AssetHubPolkadot as Para>::RuntimeEvent;
|
||||
|
||||
assert_expected_events!(
|
||||
AssetHubPolkadot,
|
||||
vec![
|
||||
RuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward {
|
||||
outcome: Outcome::Incomplete(_, Error::UntrustedReserveLocation),
|
||||
..
|
||||
}) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Check if balances are updated accordingly in Relay Chain and Assets Parachain
|
||||
let relay_sender_balance_after = Polkadot::account_data_of(PolkadotSender::get()).free;
|
||||
let para_sender_balance_after =
|
||||
AssetHubPolkadot::account_data_of(AssetHubPolkadotReceiver::get()).free;
|
||||
|
||||
assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after);
|
||||
assert_eq!(para_sender_balance_after, para_receiver_balance_before);
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
use crate::*;
|
||||
|
||||
#[test]
|
||||
fn teleport_native_assets_from_relay_to_assets_para() {
|
||||
// Init tests variables
|
||||
let amount = POLKADOT_ED * 1000;
|
||||
let relay_sender_balance_before = Polkadot::account_data_of(PolkadotSender::get()).free;
|
||||
let para_receiver_balance_before =
|
||||
AssetHubPolkadot::account_data_of(AssetHubPolkadotReceiver::get()).free;
|
||||
|
||||
let origin = <Polkadot as Relay>::RuntimeOrigin::signed(PolkadotSender::get());
|
||||
let assets_para_destination: VersionedMultiLocation =
|
||||
Polkadot::child_location_of(AssetHubPolkadot::para_id()).into();
|
||||
let beneficiary: VersionedMultiLocation =
|
||||
AccountId32 { network: None, id: AssetHubPolkadotReceiver::get().into() }.into();
|
||||
let native_assets: VersionedMultiAssets = (Here, amount).into();
|
||||
let fee_asset_item = 0;
|
||||
let weight_limit = WeightLimit::Unlimited;
|
||||
|
||||
// Send XCM message from Relay Chain
|
||||
Polkadot::execute_with(|| {
|
||||
assert_ok!(<Polkadot as PolkadotPallet>::XcmPallet::limited_teleport_assets(
|
||||
origin,
|
||||
bx!(assets_para_destination),
|
||||
bx!(beneficiary),
|
||||
bx!(native_assets),
|
||||
fee_asset_item,
|
||||
weight_limit,
|
||||
));
|
||||
|
||||
type RuntimeEvent = <Polkadot as Relay>::RuntimeEvent;
|
||||
|
||||
assert_expected_events!(
|
||||
Polkadot,
|
||||
vec![
|
||||
RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted { outcome: Outcome::Complete { .. } }) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Receive XCM message in Assets Parachain
|
||||
AssetHubPolkadot::execute_with(|| {
|
||||
type RuntimeEvent = <AssetHubPolkadot as Para>::RuntimeEvent;
|
||||
|
||||
assert_expected_events!(
|
||||
AssetHubPolkadot,
|
||||
vec![
|
||||
RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => {
|
||||
who: *who == AssetHubPolkadotReceiver::get().into(),
|
||||
},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Check if balances are updated accordingly in Relay Chain and Assets Parachain
|
||||
let relay_sender_balance_after = Polkadot::account_data_of(PolkadotSender::get()).free;
|
||||
let para_sender_balance_after =
|
||||
AssetHubPolkadot::account_data_of(AssetHubPolkadotReceiver::get()).free;
|
||||
|
||||
assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after);
|
||||
assert!(para_sender_balance_after > para_receiver_balance_before);
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
use crate::*;
|
||||
|
||||
#[test]
|
||||
fn transact_sudo_from_relay_to_assets_para() {
|
||||
// Init tests variables
|
||||
// Call to be executed in Assets Parachain
|
||||
const ASSET_ID: u32 = 1;
|
||||
|
||||
let call = <AssetHubPolkadot as Para>::RuntimeCall::Assets(pallet_assets::Call::<
|
||||
<AssetHubPolkadot as Para>::Runtime,
|
||||
Instance1,
|
||||
>::force_create {
|
||||
id: ASSET_ID.into(),
|
||||
is_sufficient: true,
|
||||
min_balance: 1000,
|
||||
owner: AssetHubPolkadotSender::get().into(),
|
||||
})
|
||||
.encode()
|
||||
.into();
|
||||
|
||||
// XcmPallet send arguments
|
||||
let sudo_origin = <Polkadot as Relay>::RuntimeOrigin::root();
|
||||
let assets_para_destination: VersionedMultiLocation =
|
||||
Polkadot::child_location_of(AssetHubPolkadot::para_id()).into();
|
||||
|
||||
let weight_limit = WeightLimit::Unlimited;
|
||||
let require_weight_at_most = Weight::from_parts(1000000000, 200000);
|
||||
let origin_kind = OriginKind::Superuser;
|
||||
let check_origin = None;
|
||||
|
||||
let xcm = VersionedXcm::from(Xcm(vec![
|
||||
UnpaidExecution { weight_limit, check_origin },
|
||||
Transact { require_weight_at_most, origin_kind, call },
|
||||
]));
|
||||
|
||||
// Send XCM message from Relay Chain
|
||||
Polkadot::execute_with(|| {
|
||||
assert_ok!(<Polkadot as PolkadotPallet>::XcmPallet::send(
|
||||
sudo_origin,
|
||||
bx!(assets_para_destination),
|
||||
bx!(xcm),
|
||||
));
|
||||
|
||||
type RuntimeEvent = <Polkadot as Relay>::RuntimeEvent;
|
||||
|
||||
assert_expected_events!(
|
||||
Polkadot,
|
||||
vec![
|
||||
RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Receive XCM message in Assets Parachain
|
||||
AssetHubPolkadot::execute_with(|| {
|
||||
assert!(<AssetHubPolkadot as AssetHubPolkadotPallet>::Assets::asset_exists(ASSET_ID));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user