From 21e6692d65f2be4b2b6f41fa911d2616531fe024 Mon Sep 17 00:00:00 2001 From: nakul1010 Date: Tue, 5 Sep 2023 12:16:21 +0530 Subject: [PATCH] fix: remove relay chain test --- Cargo.lock | 20 +- parachain/runtime/runtime-tests/src/lib.rs | 1 - .../relaychain/kusama_cross_chain_transfer.rs | 693 ------------------ .../src/relaychain/kusama_test_net.rs | 307 -------- .../runtime-tests/src/relaychain/mod.rs | 4 - 5 files changed, 10 insertions(+), 1015 deletions(-) delete mode 100644 parachain/runtime/runtime-tests/src/relaychain/kusama_cross_chain_transfer.rs delete mode 100644 parachain/runtime/runtime-tests/src/relaychain/kusama_test_net.rs delete mode 100644 parachain/runtime/runtime-tests/src/relaychain/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 7c5e8e800d..7fb70758e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17605,6 +17605,16 @@ dependencies = [ "pkg-config", ] +[[patch.unused]] +name = "asset-hub-kusama-runtime" +version = "0.9.420" +source = "git+https://github.com/paritytech//cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" + +[[patch.unused]] +name = "asset-hub-polkadot-runtime" +version = "0.9.420" +source = "git+https://github.com/paritytech//cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" + [[patch.unused]] name = "pallet-nfts" version = "4.0.0-dev" @@ -17659,13 +17669,3 @@ source = "git+https://github.com/paritytech//frontier?branch=polkadot-v1.0.0#b52 name = "pallet-hotfix-sufficients" version = "1.0.0" source = "git+https://github.com/paritytech//frontier?branch=polkadot-v1.0.0#b520b749eb90df15177144dbece3fbd3622a2b19" - -[[patch.unused]] -name = "asset-hub-kusama-runtime" -version = "0.9.420" -source = "git+https://github.com/paritytech//cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" - -[[patch.unused]] -name = "asset-hub-polkadot-runtime" -version = "0.9.420" -source = "git+https://github.com/paritytech//cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" diff --git a/parachain/runtime/runtime-tests/src/lib.rs b/parachain/runtime/runtime-tests/src/lib.rs index bfed5e8af5..99f6eb6d88 100644 --- a/parachain/runtime/runtime-tests/src/lib.rs +++ b/parachain/runtime/runtime-tests/src/lib.rs @@ -4,6 +4,5 @@ mod bitcoin_data; mod parachain; -mod relaychain; mod setup; mod utils; diff --git a/parachain/runtime/runtime-tests/src/relaychain/kusama_cross_chain_transfer.rs b/parachain/runtime/runtime-tests/src/relaychain/kusama_cross_chain_transfer.rs deleted file mode 100644 index 0b50eba3c5..0000000000 --- a/parachain/runtime/runtime-tests/src/relaychain/kusama_cross_chain_transfer.rs +++ /dev/null @@ -1,693 +0,0 @@ -// use crate::relaychain::kusama_test_net::*; -// use codec::Encode; -// use frame_support::assert_ok; -// use orml_traits::MultiCurrency; -// use primitives::{ -// CurrencyId::{ForeignAsset, Token}, -// CustomMetadata, TokenSymbol, -// }; -// use sp_runtime::{FixedPointNumber, FixedU128}; -// use xcm::latest::{prelude::*, Weight}; -// use xcm_builder::ParentIsPreset; -// use xcm_emulator::{TestExt, XcmExecutor}; -// use xcm_executor::traits::Convert; -// -// mod fees { -// use super::*; -// -// // N * unit_weight * (weight/10^12) * token_per_second -// fn weight_calculation(instruction_count: u32, unit_weight: Weight, per_second: u128) -> u128 { -// let weight = unit_weight.saturating_mul(instruction_count as u64); -// let weight_ratio = -// FixedU128::saturating_from_rational(weight.ref_time() as u128, WEIGHT_REF_TIME_PER_SECOND as u128); -// weight_ratio.saturating_mul_int(per_second) -// } -// -// fn native_unit_cost(instruction_count: u32, per_second: u128) -> u128 { -// let unit_weight: Weight = kintsugi_runtime_parachain::xcm_config::UnitWeightCost::get(); -// assert_eq!(unit_weight.ref_time(), 200_000_000); -// assert_eq!(unit_weight.proof_size(), 0); -// -// weight_calculation(instruction_count, unit_weight, per_second) -// } -// -// pub fn ksm_per_second_as_fee(instruction_count: u32) -> u128 { -// let ksm_per_second = kintsugi_runtime_parachain::xcm_config::ksm_per_second(); -// -// // check ksm per second. It's by no means essential - it's just useful to be forced to check the -// // change after polkadot updates -// assert!(ksm_per_second < 210000000000); -// -// native_unit_cost(instruction_count, ksm_per_second) -// } -// -// pub fn kint_per_second_as_fee(instruction_count: u32) -> u128 { -// let kint_per_second = kintsugi_runtime_parachain::xcm_config::kint_per_second(); -// -// native_unit_cost(instruction_count, kint_per_second) -// } -// } -// -// mod hrmp { -// use super::*; -// -// use polkadot_runtime_parachains::hrmp; -// fn construct_xcm(call: hrmp::Call) -> Xcm<()> { -// Xcm(vec![ -// WithdrawAsset((Here, 410000000000u128).into()), -// BuyExecution { -// fees: (Here, 400000000000u128).into(), -// weight_limit: Unlimited, -// }, -// Transact { -// require_weight_at_most: Weight::from_parts(10000000000, 1_000_000u64), // actual pov size = 31015 -// origin_kind: OriginKind::Native, -// call: kusama_runtime::RuntimeCall::Hrmp(call).encode().into(), -// }, -// RefundSurplus, -// DepositAsset { -// assets: All.into(), -// beneficiary: Junction::AccountId32 { id: BOB, network: None }.into(), -// }, -// ]) -// } -// -// fn has_open_channel_requested_event(sender: u32, recipient: u32) -> bool { -// KusamaNet::execute_with(|| { -// kusama_runtime::System::events().iter().any(|r| { -// matches!( -// r.event, -// kusama_runtime::RuntimeEvent::Hrmp(hrmp::Event::OpenChannelRequested( -// actual_sender, -// actual_recipient, -// 1000, -// 102400 -// )) if actual_sender == sender.into() && actual_recipient == recipient.into() -// ) -// }) -// }) -// } -// -// fn has_open_channel_accepted_event(sender: u32, recipient: u32) -> bool { -// KusamaNet::execute_with(|| { -// kusama_runtime::System::events().iter().any(|r| { -// matches!( -// r.event, -// kusama_runtime::RuntimeEvent::Hrmp(hrmp::Event::OpenChannelAccepted( -// actual_sender, -// actual_recipient -// )) if actual_sender == sender.into() && actual_recipient == recipient.into() -// ) -// }) -// }) -// } -// -// fn init_open_channel(sender: u32, recipient: u32) -// where -// T: TestExt, -// { -// // do hrmp_init_open_channel -// assert!(!has_open_channel_requested_event(sender, recipient)); // just a sanity check -// T::execute_with(|| { -// let message = construct_xcm(hrmp::Call::::hrmp_init_open_channel { -// recipient: recipient.into(), -// proposed_max_capacity: 1000, -// proposed_max_message_size: 102400, -// }); -// assert_ok!(pallet_xcm::Pallet::::send_xcm( -// Here, Parent, message -// )); -// }); -// assert!(has_open_channel_requested_event(sender, recipient)); -// } -// -// fn accept_open_channel(sender: u32, recipient: u32) -// where -// T: TestExt, -// { -// // do hrmp_accept_open_channel -// assert!(!has_open_channel_accepted_event(sender, recipient)); // just a sanity check -// T::execute_with(|| { -// let message = construct_xcm(hrmp::Call::::hrmp_accept_open_channel { -// sender: sender.into(), -// }); -// assert_ok!(pallet_xcm::Pallet::::send_xcm( -// Here, Parent, message -// )); -// }); -// assert!(has_open_channel_accepted_event(sender, recipient)); -// } -// #[test] -// fn open_hrmp_channel() { -// // setup sovereign account balances -// KusamaNet::execute_with(|| { -// // transfer the required funds, and make sure that the account remains above the existential deposit -// // afterwards -// assert_ok!(kusama_runtime::Balances::transfer( -// kusama_runtime::RuntimeOrigin::signed(ALICE.into()), -// sp_runtime::MultiAddress::Id(kintsugi_sovereign_account_on_kusama()), -// 10_820_000_000_000 + kusama_runtime::ExistentialDeposit::get() -// )); -// assert_ok!(kusama_runtime::Balances::transfer( -// kusama_runtime::RuntimeOrigin::signed(ALICE.into()), -// sp_runtime::MultiAddress::Id(sibling_sovereign_account_on_kusama()), -// 10_820_000_000_000 + kusama_runtime::ExistentialDeposit::get() -// )); -// }); -// // open channel kintsugi -> sibling -// init_open_channel::(KINTSUGI_PARA_ID, SIBLING_PARA_ID); -// accept_open_channel::(KINTSUGI_PARA_ID, SIBLING_PARA_ID); -// -// // open channel sibling -> kintsugi -// init_open_channel::(SIBLING_PARA_ID, KINTSUGI_PARA_ID); -// accept_open_channel::(SIBLING_PARA_ID, KINTSUGI_PARA_ID); -// -// // check that Bob received left-over funds (from both Kintsugi and Sibling). -// // We expect slightly less than 4 * 0.41 KSM -// KusamaNet::execute_with(|| { -// let free_balance = kusama_runtime::Balances::free_balance(&AccountId::from(BOB)); -// assert!(free_balance > 1_600_000_000_000 && free_balance < 1_640_000_000_000); -// }); -// } -// } -// -// #[test] -// fn test_transact_barrier() { -// let call = orml_tokens::Call::::transfer_all { -// dest: ALICE.into(), -// currency_id: Token(KSM), -// keep_alive: false, -// }; -// let message = Xcm(vec![ -// WithdrawAsset((Here, 410000000000u128).into()), -// BuyExecution { -// fees: (Here, 400000000000u128).into(), -// weight_limit: Unlimited, -// }, -// Transact { -// require_weight_at_most: Weight::from_parts(10000000000, 0u64), -// origin_kind: OriginKind::Native, -// call: kintsugi_runtime_parachain::RuntimeCall::Tokens(call).encode().into(), -// }, -// RefundSurplus, -// DepositAsset { -// assets: All.into(), -// beneficiary: Junction::AccountId32 { id: BOB, network: None }.into(), -// }, -// ]); -// -// KusamaNet::execute_with(|| { -// assert_ok!(pallet_xcm::Pallet::::send_xcm( -// Here, -// X1(Parachain(2092)), -// message -// )); -// }); -// -// Kintsugi::execute_with(|| { -// assert!(System::events().iter().any(|r| matches!( -// r.event, -// RuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { -// outcome: Outcome::Error(XcmError::Barrier), -// .. -// }) -// ))); -// }); -// } -// -// #[test] -// fn transfer_from_relay_chain() { -// KusamaNet::execute_with(|| { -// assert_ok!(kusama_runtime::XcmPallet::reserve_transfer_assets( -// kusama_runtime::RuntimeOrigin::signed(ALICE.into()), -// Box::new(Parachain(KINTSUGI_PARA_ID).into_versioned()), -// Box::new(Junction::AccountId32 { id: BOB, network: None }.into_versioned()), -// Box::new((Here, KSM.one()).into()), -// 0 -// )); -// }); -// -// Kintsugi::execute_with(|| { -// let xcm_fee = KSM.one() - Tokens::free_balance(Token(KSM), &AccountId::from(BOB)); -// -// assert!(xcm_fee < 1000000000); // fees are set to 1000000000 in ui - make sure it's enough -// assert!(xcm_fee > 0); // check that some fees are taken -// -// // check that fees go to treasury -// assert_eq!(Tokens::free_balance(Token(KSM), &TreasuryAccount::get()), xcm_fee); -// }); -// } -// -// #[test] -// fn transfer_to_relay_chain() { -// KusamaNet::execute_with(|| { -// assert_ok!(kusama_runtime::Balances::transfer( -// kusama_runtime::RuntimeOrigin::signed(ALICE.into()), -// sp_runtime::MultiAddress::Id(kintsugi_sovereign_account_on_kusama()), -// 2 * KSM.one() -// )); -// }); -// -// Kintsugi::execute_with(|| { -// assert_ok!(XTokens::transfer( -// RuntimeOrigin::signed(ALICE.into()), -// Token(KSM), -// KSM.one(), -// Box::new(MultiLocation::new(1, X1(Junction::AccountId32 { id: BOB, network: None })).into()), -// WeightLimit::Unlimited -// )); -// }); -// -// KusamaNet::execute_with(|| { -// let fee = KSM.one() - kusama_runtime::Balances::free_balance(&AccountId::from(BOB)); -// -// // UI uses 165940672 - make sure that that's an overestimation -// assert!(fee < 165940672); -// }); -// } -// -// /// Send KINT to sibling. On the sibling, it will be registered as a foreign asset. -// /// By also transferring it back, we test that the asset-registry has been properly -// /// integrated. -// #[test] -// fn transfer_to_sibling_and_back() { -// fn sibling_sovereign_account() -> AccountId { -// use sp_runtime::traits::AccountIdConversion; -// polkadot_parachain::primitives::Sibling::from(SIBLING_PARA_ID).into_account_truncating() -// } -// -// Sibling::execute_with(|| { -// register_kint_as_foreign_asset(); -// }); -// -// Kintsugi::execute_with(|| { -// assert_ok!(Tokens::deposit( -// Token(KINT), -// &AccountId::from(ALICE), -// 100_000_000_000_000 -// )); -// }); -// -// Kintsugi::execute_with(|| { -// assert_ok!(XTokens::transfer( -// RuntimeOrigin::signed(ALICE.into()), -// Token(KINT), -// 10_000_000_000_000, -// Box::new( -// MultiLocation::new( -// 1, -// X2( -// Parachain(SIBLING_PARA_ID), -// Junction::AccountId32 { -// network: None, -// id: BOB.into(), -// } -// ) -// ) -// .into() -// ), -// WeightLimit::Unlimited, -// )); -// -// assert_eq!( -// Tokens::free_balance(Token(KINT), &AccountId::from(ALICE)), -// 90_000_000_000_000 -// ); -// -// assert_eq!( -// Tokens::free_balance(Token(KINT), &sibling_sovereign_account()), -// 10_000_000_000_000 -// ); -// }); -// -// Sibling::execute_with(|| { -// let xcm_fee = 800_000_000; -// -// // check reception -// assert_eq!( -// Tokens::free_balance(ForeignAsset(1), &AccountId::from(BOB)), -// 10_000_000_000_000 - xcm_fee -// ); -// -// // return some back to kintsugi -// assert_ok!(XTokens::transfer( -// RuntimeOrigin::signed(BOB.into()), -// ForeignAsset(1), -// 5_000_000_000_000, -// Box::new( -// MultiLocation::new( -// 1, -// X2( -// Parachain(KINTSUGI_PARA_ID), -// Junction::AccountId32 { -// network: None, -// id: ALICE.into(), -// } -// ) -// ) -// .into() -// ), -// WeightLimit::Unlimited, -// )); -// }); -// -// // check reception -// Kintsugi::execute_with(|| { -// let xcm_fee = fees::kint_per_second_as_fee(4); -// assert_eq!( -// Tokens::free_balance(Token(KINT), &AccountId::from(ALICE)), -// 95_000_000_000_000 - xcm_fee -// ); -// -// assert_eq!(Tokens::free_balance(Token(KINT), &TreasuryAccount::get()), xcm_fee); -// -// assert_eq!( -// Tokens::free_balance(Token(KINT), &sibling_sovereign_account()), -// 5_000_000_000_000 -// ); -// }); -// } -// -// #[test] -// fn xcm_transfer_execution_barrier_trader_works() { -// let unit_instruction_weight: Weight = kintsugi_runtime_parachain::xcm_config::UnitWeightCost::get(); -// let message_weight = unit_instruction_weight.saturating_mul(3); -// let xcm_fee = fees::ksm_per_second_as_fee(3); -// -// // relay-chain use normal account to send xcm, destination parachain can't pass Barrier check -// let message = Xcm(vec![ -// ReserveAssetDeposited((Parent, 100).into()), -// BuyExecution { -// fees: (Parent, 100).into(), -// weight_limit: Unlimited, -// }, -// DepositAsset { -// assets: All.into(), -// beneficiary: Here.into(), -// }, -// ]); -// KusamaNet::execute_with(|| { -// // Kusama effectively disabled the `send` extrinsic in 0.9.19, so use send_xcm -// assert_ok!(pallet_xcm::Pallet::::send_xcm( -// X1(Junction::AccountId32 { -// network: None, -// id: ALICE.into(), -// }), -// Parachain(KINTSUGI_PARA_ID), -// message -// )); -// }); -// Kintsugi::execute_with(|| { -// assert!(System::events().iter().any(|r| matches!( -// r.event, -// RuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { -// outcome: Outcome::Error(XcmError::Barrier), -// .. -// }) -// ))); -// }); -// -// // AllowTopLevelPaidExecutionFrom barrier test case: -// // para-chain use XcmExecutor `execute_xcm()` method to execute xcm. -// // if `weight_limit` in BuyExecution is less than `xcm_weight(max_weight)`, then Barrier can't pass. -// // other situation when `weight_limit` is `Unlimited` or large than `xcm_weight`, then it's ok. -// let message = Xcm::(vec![ -// ReserveAssetDeposited((Parent, 100).into()), -// BuyExecution { -// fees: (Parent, 100).into(), -// weight_limit: Limited(message_weight - Weight::from_parts(1, 0u64)), -// }, -// DepositAsset { -// assets: All.into(), -// beneficiary: Here.into(), -// }, -// ]); -// Kintsugi::execute_with(|| { -// let hash = message.using_encoded(sp_io::hashing::blake2_256); -// let r = XcmExecutor::::execute_xcm(Parent, message, hash, message_weight); -// assert_eq!(r, Outcome::Error(XcmError::Barrier)); -// }); -// -// // trader inside BuyExecution have TooExpensive error if payment less than calculated weight amount. -// // the minimum of calculated weight amount(`FixedRateOfFungible`). -// let message = Xcm::(vec![ -// ReserveAssetDeposited((Parent, xcm_fee - 1).into()), -// BuyExecution { -// fees: (Parent, xcm_fee - 1).into(), -// weight_limit: Limited(message_weight), -// }, -// DepositAsset { -// assets: All.into(), -// beneficiary: Here.into(), -// }, -// ]); -// Kintsugi::execute_with(|| { -// let hash = message.using_encoded(sp_io::hashing::blake2_256); -// let r = XcmExecutor::::execute_xcm(Parent, message, hash, message_weight); -// assert_eq!( -// r, -// Outcome::Incomplete(message_weight - unit_instruction_weight, XcmError::TooExpensive) -// ); -// }); -// -// // all situation fulfilled, execute success -// let message = Xcm::(vec![ -// ReserveAssetDeposited((Parent, xcm_fee).into()), -// BuyExecution { -// fees: (Parent, xcm_fee).into(), -// weight_limit: Limited(message_weight), -// }, -// DepositAsset { -// assets: All.into(), -// beneficiary: Here.into(), -// }, -// ]); -// Kintsugi::execute_with(|| { -// let hash = message.using_encoded(sp_io::hashing::blake2_256); -// let r = XcmExecutor::::execute_xcm(Parent, message, hash, message_weight); -// assert_eq!(r, Outcome::Complete(message_weight)); -// }); -// } -// -// #[test] -// fn subscribe_version_notify_works() { -// // relay chain subscribe version notify of para chain -// KusamaNet::execute_with(|| { -// let r = pallet_xcm::Pallet::::force_subscribe_version_notify( -// kusama_runtime::RuntimeOrigin::root(), -// Box::new(Parachain(KINTSUGI_PARA_ID).into_versioned()), -// ); -// assert_ok!(r); -// }); -// KusamaNet::execute_with(|| { -// kusama_runtime::System::assert_has_event(kusama_runtime::RuntimeEvent::XcmPallet( -// pallet_xcm::Event::SupportedVersionChanged( -// MultiLocation { -// parents: 0, -// interior: X1(Parachain(KINTSUGI_PARA_ID)), -// }, -// 3, -// ), -// )); -// }); -// -// // para chain subscribe version notify of relay chain -// Kintsugi::execute_with(|| { -// let r = pallet_xcm::Pallet::::force_subscribe_version_notify( -// RuntimeOrigin::root(), -// Box::new(Parent.into()), -// ); -// assert_ok!(r); -// }); -// Kintsugi::execute_with(|| { -// System::assert_has_event(kintsugi_runtime_parachain::RuntimeEvent::PolkadotXcm( -// pallet_xcm::Event::SupportedVersionChanged( -// MultiLocation { -// parents: 1, -// interior: Here, -// }, -// 3, -// ), -// )); -// }); -// -// // para chain subscribe version notify of sibling chain -// Kintsugi::execute_with(|| { -// let r = pallet_xcm::Pallet::::force_subscribe_version_notify( -// RuntimeOrigin::root(), -// Box::new((Parent, Parachain(SIBLING_PARA_ID)).into()), -// ); -// assert_ok!(r); -// }); -// Kintsugi::execute_with(|| { -// assert!(kintsugi_runtime_parachain::System::events().iter().any(|r| matches!( -// r.event, -// kintsugi_runtime_parachain::RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { -// message_hash: Some(_) -// }) -// ))); -// }); -// Sibling::execute_with(|| { -// assert!(kintsugi_runtime_parachain::System::events().iter().any(|r| matches!( -// r.event, -// kintsugi_runtime_parachain::RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { -// message_hash: Some(_) -// }) | kintsugi_runtime_parachain::RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { -// message_hash: Some(_), -// weight: _, -// }) -// ))); -// }); -// } -// -// fn general_key_of(token_symbol: TokenSymbol) -> Junction { -// let id = Token(token_symbol); -// let encoded = id.encode(); -// let mut data = [0u8; 32]; -// if encoded.len() > 32 { -// // we are not returning result, so panic is inevitable. Let's make it explicit. -// panic!("Currency ID was too long to be encoded"); -// } -// data[..encoded.len()].copy_from_slice(&encoded[..]); -// GeneralKey { -// length: encoded.len() as u8, -// data, -// } -// } -// -// #[test] -// fn trap_assets_works() { -// let mut kint_treasury_amount = 0; -// let mut ksm_treasury_amount = 0; -// let (ksm_asset_amount, kint_asset_amount) = (KSM.one(), KINT.one()); -// let trader_weight_to_treasury = fees::ksm_per_second_as_fee(3); -// -// let parent_account: AccountId = ParentIsPreset::::convert(Parent.into()).unwrap(); -// -// Kintsugi::execute_with(|| { -// assert_ok!(Tokens::deposit(Token(KSM), &parent_account, 100 * KSM.one())); -// assert_ok!(Tokens::deposit(Token(KINT), &parent_account, 100 * KINT.one())); -// -// kint_treasury_amount = Tokens::free_balance(Token(KINT), &TreasuryAccount::get()); -// ksm_treasury_amount = Tokens::free_balance(Token(KSM), &TreasuryAccount::get()); -// }); -// -// let assets: MultiAsset = (Parent, ksm_asset_amount).into(); -// // Withdraw kint and ksm on kintsugi but don't deposit it -// KusamaNet::execute_with(|| { -// let xcm = vec![ -// WithdrawAsset(assets.clone().into()), -// BuyExecution { -// fees: assets, -// weight_limit: Limited(Weight::from_parts(KSM.one() as u64, 0u64)), -// }, -// WithdrawAsset( -// ( -// (Parent, X2(Parachain(KINTSUGI_PARA_ID), general_key_of(KINT))), -// kint_asset_amount, -// ) -// .into(), -// ), -// ]; -// assert_ok!(pallet_xcm::Pallet::::send_xcm( -// Here, -// Parachain(KINTSUGI_PARA_ID), -// Xcm(xcm), -// )); -// }); -// -// let mut trapped_assets: Option = None; -// // verify that the assets got trapped (i.e. didn't get burned) -// Kintsugi::execute_with(|| { -// assert!(System::events().iter().any(|r| matches!( -// r.event, -// RuntimeEvent::PolkadotXcm(pallet_xcm::Event::AssetsTrapped(_, _, _)) -// ))); -// -// let event = System::events() -// .iter() -// .find(|r| { -// matches!( -// r.event, -// RuntimeEvent::PolkadotXcm(pallet_xcm::Event::AssetsTrapped(_, _, _)) -// ) -// }) -// .cloned() -// .unwrap(); -// -// use std::convert::TryFrom; -// use xcm::VersionedMultiAssets; -// trapped_assets = match event.event { -// RuntimeEvent::PolkadotXcm(pallet_xcm::Event::AssetsTrapped(_, _, ticket)) => { -// Some(TryFrom::::try_from(ticket).unwrap()) -// } -// _ => panic!("event not found"), -// }; -// -// // unchanged treasury amounts -// assert_eq!( -// trader_weight_to_treasury, -// Tokens::free_balance(Token(KSM), &TreasuryAccount::get()) -// ); -// assert_eq!( -// kint_treasury_amount, -// Tokens::free_balance(Token(KINT), &TreasuryAccount::get()) -// ); -// }); -// -// // Now reclaim trapped assets -// KusamaNet::execute_with(|| { -// let xcm = vec![ -// ClaimAsset { -// assets: trapped_assets.unwrap(), -// ticket: Here.into(), -// }, -// BuyExecution { -// fees: ( -// (Parent, X2(Parachain(KINTSUGI_PARA_ID), general_key_of(KINT))), -// kint_asset_amount / 2, -// ) -// .into(), -// weight_limit: Limited(Weight::from_parts(KSM.one() as u64, 0u64)), -// }, -// DepositAsset { -// assets: All.into(), -// beneficiary: Junction::AccountId32 { id: BOB, network: None }.into(), -// }, -// ]; -// assert_ok!(pallet_xcm::Pallet::::send_xcm( -// Here, -// Parachain(KINTSUGI_PARA_ID), -// Xcm(xcm), -// )); -// }); -// -// // verify that assets were claimed successfully (deposited into Bob's account) -// Kintsugi::execute_with(|| { -// let kint_xcm_fee = fees::kint_per_second_as_fee(3); -// let ksm_xcm_fee = fees::ksm_per_second_as_fee(3); -// assert_eq!( -// Tokens::free_balance(Token(KINT), &AccountId::from(BOB)), -// kint_asset_amount - kint_xcm_fee -// ); -// assert_eq!( -// Tokens::free_balance(Token(KSM), &AccountId::from(BOB)), -// ksm_asset_amount - ksm_xcm_fee -// ); -// }); -// } -// -// fn register_kint_as_foreign_asset() { -// let metadata = AssetMetadata { -// decimals: 12, -// name: "Kintsugi native".as_bytes().to_vec(), -// symbol: "extKINT".as_bytes().to_vec(), -// existential_deposit: 0, -// location: Some(MultiLocation::new(1, X2(Parachain(KINTSUGI_PARA_ID), general_key_of(KINT))).into()), -// additional: CustomMetadata { -// fee_per_second: 1_000_000_000_000, -// coingecko_id: "kint-sugi".as_bytes().to_vec(), -// }, -// }; -// AssetRegistry::register_asset(RuntimeOrigin::root(), metadata, None).unwrap(); -// } diff --git a/parachain/runtime/runtime-tests/src/relaychain/kusama_test_net.rs b/parachain/runtime/runtime-tests/src/relaychain/kusama_test_net.rs deleted file mode 100644 index ec35f7d769..0000000000 --- a/parachain/runtime/runtime-tests/src/relaychain/kusama_test_net.rs +++ /dev/null @@ -1,307 +0,0 @@ -// use cumulus_primitives_core::MultiLocation; -// use frame_support::{traits::GenesisBuild, weights::Weight}; -// pub use kintsugi_runtime_parachain::{xcm_config::*, *}; -// use polkadot_primitives::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE}; -// use polkadot_runtime_parachains::{configuration::HostConfiguration, paras::ParaKind}; -// pub use primitives::{ -// CurrencyId::Token, -// TokenSymbol::{KINT, KSM}, -// }; -// use sp_runtime::traits::AccountIdConversion; -// use xcm::prelude::*; -// use xcm_emulator::{ -// decl_test_bridges, decl_test_networks, decl_test_parachains, decl_test_relay_chains, -// decl_test_sender_receiver_accounts_parameter_types, BridgeMessageHandler, Parachain, RelayChain, TestExt, -// }; -// -// use sp_core::{sr25519, storage::Storage, Pair, Public}; -// use xcm_executor::traits::ConvertLocation; -// -// pub const KINTSUGI_PARA_ID: u32 = 2092; -// pub const SIBLING_PARA_ID: u32 = 2001; -// -// decl_test_relay_chains! { -// #[api_version(5)] -// pub struct KusamaNet { -// genesis = kusama_ext(), -// on_init = (), -// runtime = { -// Runtime: kusama_runtime::Runtime, -// RuntimeOrigin: kusama_runtime::RuntimeOrigin, -// RuntimeCall: kusama_runtime::RuntimeCall, -// RuntimeEvent: kusama_runtime::RuntimeEvent, -// MessageQueue: kusama_runtime::MessageQueue, -// XcmConfig: kusama_runtime::xcm_config::XcmConfig, -// SovereignAccountOf: kusama_runtime::xcm_config::SovereignAccountOf, -// System: kusama_runtime::System, -// Balances: kusama_runtime::Balances, -// }, -// pallets_extra = { -// XcmPallet: kusama_runtime::XcmPallet, -// } -// } -// } -// -// decl_test_parachains! { -// pub struct Kintsugi { -// genesis = para_ext(KINTSUGI_PARA_ID), -// on_init = (), -// runtime = { -// Runtime: kintsugi_runtime_parachain::Runtime, -// RuntimeOrigin: kintsugi_runtime_parachain::RuntimeOrigin, -// RuntimeCall: kintsugi_runtime_parachain::RuntimeCall, -// RuntimeEvent: kintsugi_runtime_parachain::RuntimeEvent, -// XcmpMessageHandler: kintsugi_runtime_parachain::XcmpQueue, -// DmpMessageHandler: kintsugi_runtime_parachain::DmpQueue, -// LocationToAccountId: kintsugi_runtime_parachain::xcm_config::LocationToAccountId, -// System: kintsugi_runtime_parachain::System, -// // Balances: , -// ParachainSystem: kintsugi_runtime_parachain::ParachainSystem, -// ParachainInfo: kintsugi_runtime_parachain::ParachainInfo, -// }, -// pallets_extra = { -// PolkadotXcm: kintsugi_runtime_parachain::PolkadotXcm, -// } -// }, -// pub struct Sibling { -// genesis = para_ext(SIBLING_PARA_ID), -// on_init = (), -// runtime = { -// Runtime: kintsugi_runtime_parachain::Runtime, -// RuntimeOrigin: kintsugi_runtime_parachain::RuntimeOrigin, -// RuntimeCall: kintsugi_runtime_parachain::RuntimeCall, -// RuntimeEvent: kintsugi_runtime_parachain::RuntimeEvent, -// XcmpMessageHandler: kintsugi_runtime_parachain::XcmpQueue, -// DmpMessageHandler: kintsugi_runtime_parachain::DmpQueue, -// LocationToAccountId: kintsugi_runtime_parachain::xcm_config::LocationToAccountId, -// System: kintsugi_runtime_parachain::System, -// // Balances: , -// ParachainSystem: kintsugi_runtime_parachain::ParachainSystem, -// ParachainInfo: kintsugi_runtime_parachain::ParachainInfo, -// }, -// pallets_extra = { -// PolkadotXcm: kintsugi_runtime_parachain::PolkadotXcm, -// // Assets: asset_hub_polkadot_runtime::Assets, -// } -// -// } -// } -// -// // decl_test_parachains! { -// // pub struct Sibling { -// // Runtime = kintsugi_runtime_parachain::Runtime, -// // RuntimeOrigin = kintsugi_runtime_parachain::RuntimeOrigin, -// // XcmpMessageHandler = kintsugi_runtime_parachain::XcmpQueue, -// // DmpMessageHandler = kintsugi_runtime_parachain::DmpQueue, -// // new_ext = para_ext(SIBLING_PARA_ID), -// // } -// // } -// // -// // note: can't use SIBLING_PARA_ID and KINTSUGI_PARA_ID in this macro - we are forced to use raw numbers -// decl_test_networks! { -// pub struct TestNet { -// relay_chain = KusamaNet, -// parachains = vec![ -// Kintsugi, -// Sibling, -// ], -// bridge = () -// } -// } -// // -// // fn default_parachains_host_configuration() -> HostConfiguration { -// // HostConfiguration { -// // minimum_validation_upgrade_delay: 5, -// // validation_upgrade_cooldown: 5u32, -// // validation_upgrade_delay: 5, -// // code_retention_period: 1200, -// // max_code_size: MAX_CODE_SIZE, -// // max_pov_size: MAX_POV_SIZE, -// // max_head_data_size: 32 * 1024, -// // group_rotation_frequency: 20, -// // chain_availability_period: 4, -// // thread_availability_period: 4, -// // max_upward_queue_count: 8, -// // max_upward_queue_size: 1024 * 1024, -// // max_downward_message_size: 1024, -// // ump_service_total_weight: Weight::from_parts(4 * 1_000_000_000 as u64, 0u64), -// // max_upward_message_size: 50 * 1024, -// // max_upward_message_num_per_candidate: 5, -// // hrmp_sender_deposit: 5_000_000_000_000, -// // hrmp_recipient_deposit: 5_000_000_000_000, -// // hrmp_channel_max_capacity: 1000, -// // hrmp_channel_max_total_size: 8 * 1024, -// // hrmp_max_parachain_inbound_channels: 4, -// // hrmp_max_parathread_inbound_channels: 4, -// // hrmp_channel_max_message_size: 102400, -// // hrmp_max_parachain_outbound_channels: 4, -// // hrmp_max_parathread_outbound_channels: 4, -// // hrmp_max_message_num_per_candidate: 5, -// // dispute_period: 6, -// // no_show_slots: 2, -// // n_delay_tranches: 25, -// // needed_approvals: 2, -// // relay_vrf_modulo_samples: 2, -// // zeroth_delay_tranche_width: 0, -// // ..Default::default() -// // } -// // } -// // -// pub fn kusama_ext() -> Storage { -// use kusama_runtime::{Runtime, System}; -// use polkadot_parachain::primitives::{HeadData, ValidationCode}; -// -// let mut t = frame_system::GenesisConfig::::default() -// .build_storage() -// .unwrap(); -// -// // let x = pallet_balances::GenesisConfig:: { -// // balances: vec![ -// // (AccountId::from(ALICE), 2002 * KSM.one()), -// // // (ParaId::from(KINTSUGI_PARA_ID).into_account_truncating(), 2 * KSM.one()), -// // ], -// // }; -// -// // let x = pallet_balances::GenesisConfig:: { -// // balances: vec![ -// // (AccountId::from(ALICE), 2002 * KSM.one()), -// // // (ParaId::from(KINTSUGI_PARA_ID).into_account_truncating(), 2 * KSM.one()), -// // ], -// // } -// // .assimilate_storage(&mut t) -// // .unwrap(); -// // -// // // register a parachain so that we can test opening hrmp channel -// // let fake_para = polkadot_runtime_parachains::paras::ParaGenesisArgs { -// // genesis_head: HeadData(vec![]), -// // para_kind: ParaKind::Parachain, -// // validation_code: ValidationCode(vec![0]), -// // }; -// // >::assimilate_storage( -// // &polkadot_runtime_parachains::paras::GenesisConfig { -// // paras: vec![ -// // (KINTSUGI_PARA_ID.into(), fake_para.clone()), -// // (SIBLING_PARA_ID.into(), fake_para.clone()), -// // ], -// // }, -// // &mut t, -// // ) -// // .unwrap(); -// // -// // polkadot_runtime_parachains::configuration::GenesisConfig:: { -// // config: default_parachains_host_configuration(), -// // } -// // .assimilate_storage(&mut t) -// // .unwrap(); -// // -// // >::assimilate_storage( -// // &pallet_xcm::GenesisConfig { -// // safe_xcm_version: Some(3), -// // }, -// // &mut t, -// // ) -// // .unwrap(); -// -// t -// // let mut ext = sp_io::TestExternalities::new(t); -// // ext.execute_with(|| System::set_block_number(1)); -// // ext -// } -// // -// pub fn para_ext(parachain_id: u32) -> Storage { -// ExtBuilder::default() -// .balances(vec![ -// (AccountId::from(ALICE), Token(KSM), 10 * KSM.one()), -// // (kintsugi_runtime_parachain::TreasuryAccount::get(), Token(KSM), KSM.one()), -// ]) -// .parachain_id(parachain_id) -// .build() -// } -// -// #[allow(dead_code)] -// pub const DEFAULT: [u8; 32] = [0u8; 32]; -// #[allow(dead_code)] -// pub const ALICE: [u8; 32] = [4u8; 32]; -// #[allow(dead_code)] -// pub const BOB: [u8; 32] = [5u8; 32]; -// -// pub struct ExtBuilder { -// balances: Vec<(AccountId, CurrencyId, Balance)>, -// parachain_id: u32, -// } -// // -// impl Default for ExtBuilder { -// fn default() -> Self { -// Self { -// balances: vec![], -// parachain_id: 2000, -// } -// } -// } -// // -// impl ExtBuilder { -// pub fn balances(mut self, balances: Vec<(AccountId, CurrencyId, Balance)>) -> Self { -// self.balances = balances; -// self -// } -// -// #[allow(dead_code)] -// pub fn parachain_id(mut self, parachain_id: u32) -> Self { -// self.parachain_id = parachain_id; -// self -// } -// -// pub fn build(self) -> Storage { -// let mut t = frame_system::GenesisConfig::::default() -// .build_storage() -// .unwrap(); -// t -// // let native_currency_id = GetNativeCurrencyId::get(); -// // -// // orml_tokens::GenesisConfig:: { -// // balances: self -// // .balances -// // .into_iter() -// // .filter(|(_, currency_id, _)| *currency_id != native_currency_id) -// // .collect::>(), -// // } -// // .assimilate_storage(&mut t) -// // .unwrap(); -// // -// // >::assimilate_storage( -// // ¶chain_info::GenesisConfig { -// // parachain_id: self.parachain_id.into(), -// // }, -// // &mut t, -// // ) -// // .unwrap(); -// // -// // >::assimilate_storage( -// // &pallet_xcm::GenesisConfig { -// // safe_xcm_version: Some(2), // NOTE! if this was required for tests we may need it on mainnet -// // }, -// // &mut t, -// // ) -// // .unwrap(); -// // -// // let mut ext = sp_io::TestExternalities::new(t); -// // ext.execute_with(|| { -// // System::set_block_number(1); -// // PolkadotXcm::force_xcm_version( -// // kintsugi_runtime_parachain::RuntimeOrigin::root(), -// // Box::new(MultiLocation::parent()), -// // 3, -// // ) -// // .unwrap(); -// // }); -// // ext -// } -// } -// -// pub(crate) fn kintsugi_sovereign_account_on_kusama() -> AccountId { -// polkadot_parachain::primitives::Id::from(KINTSUGI_PARA_ID).into_account_truncating() -// } -// -// pub(crate) fn sibling_sovereign_account_on_kusama() -> AccountId { -// polkadot_parachain::primitives::Id::from(SIBLING_PARA_ID).into_account_truncating() -// } diff --git a/parachain/runtime/runtime-tests/src/relaychain/mod.rs b/parachain/runtime/runtime-tests/src/relaychain/mod.rs deleted file mode 100644 index 970f7b02bd..0000000000 --- a/parachain/runtime/runtime-tests/src/relaychain/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -// mod kusama_cross_chain_transfer; -// pub mod kusama_test_net; -// mod polkadot_cross_chain_transfer; -// pub mod polkadot_test_net;