From 93fb88b94020dc34f4c61c9a71d43b4346494d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Andr=C3=A9s=20Dorado=20Su=C3=A1rez?= Date: Mon, 28 Oct 2024 08:07:51 -0500 Subject: [PATCH] change(integration-tests/asset-hub-kusama): remove test references to Sepolia testnet, and use mainnet instead. --- .../src/tests/reserve_transfer.rs | 55 +++++++++++++++++++ .../bridge-hub-kusama/src/tests/mod.rs | 2 +- .../asset-hub-kusama/src/xcm_config.rs | 8 +-- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/reserve_transfer.rs b/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/reserve_transfer.rs index 11d886d0e6..fe613d8642 100644 --- a/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/reserve_transfer.rs +++ b/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/reserve_transfer.rs @@ -1055,3 +1055,58 @@ fn reserve_transfer_ksm_from_para_to_para_through_relay() { // Receiver's balance is increased assert!(receiver_assets_after > receiver_assets_before); } + +/// Reserve Withdraw Native Asset from AssetHub to Parachain fails. +#[test] +fn reserve_withdraw_from_untrusted_reserve_fails() { + // Init values for Parachain Origin + let destination = AssetHubKusama::sibling_location_of(PenpalA::para_id()); + let signed_origin = + ::RuntimeOrigin::signed(AssetHubKusamaSender::get().into()); + let ksm_to_send: Balance = KUSAMA_ED * 10000; + let ksm_location = KsmLocation::get(); + + // Assets to send + let assets: Vec = vec![(ksm_location.clone(), ksm_to_send).into()]; + let fee_id: AssetId = ksm_location.into(); + + // this should fail + AssetHubKusama::execute_with(|| { + let result = ::PolkadotXcm::transfer_assets_using_type_and_then( + signed_origin.clone(), + bx!(destination.clone().into()), + bx!(assets.clone().into()), + bx!(TransferType::DestinationReserve), + bx!(fee_id.into()), + bx!(TransferType::DestinationReserve), + bx!(VersionedXcm::from(Xcm::<()>::new())), + Unlimited, + ); + assert_err!( + result, + DispatchError::Module(sp_runtime::ModuleError { + index: 31, + error: [22, 0, 0, 0], + message: Some("InvalidAssetUnsupportedReserve") + }) + ); + }); + + // this should also fail + AssetHubKusama::execute_with(|| { + let xcm: Xcm = Xcm(vec![ + WithdrawAsset(assets.into()), + InitiateReserveWithdraw { + assets: Wild(All), + reserve: destination, + xcm: Xcm::<()>::new(), + }, + ]); + let result = ::PolkadotXcm::execute( + signed_origin, + bx!(xcm::VersionedXcm::V4(xcm)), + Weight::MAX, + ); + assert!(result.is_err()); + }); +} diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/mod.rs b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/mod.rs index b943295e4a..b6edd6a076 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/mod.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/mod.rs @@ -22,7 +22,7 @@ mod send_xcm; mod teleport; mod snowbridge { - pub const CHAIN_ID: u64 = 11155111; + pub const CHAIN_ID: u64 = 1; pub const WETH: [u8; 20] = hex_literal::hex!("87d1f7fdfEe7f651FaBc8bFCB6E086C278b77A7d"); } diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs index 0850b9d3cd..ac22f2dfee 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs @@ -518,9 +518,7 @@ pub mod bridging { pub const EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 1 }; // TODO: @bkontur or @acatangiu, please confirm if this should be in the configuration, or if // this `chain_id` is just for testing purposes. - pub const EthereumNetworkSnowbridgeChain: NetworkId = NetworkId::Ethereum { chain_id: 11155111 }; pub EthereumEcosystem: Location = Location::new(2, [GlobalConsensus(EthereumNetwork::get())]); - pub EthereumSnowbridge: Location = Location::new(2, [GlobalConsensus(EthereumNetworkSnowbridgeChain::get())]); pub DotLocation: Location = Location::new(2, [GlobalConsensus(PolkadotNetwork::get())]); pub AssetHubPolkadot: Location = Location::new( 2, @@ -564,11 +562,7 @@ pub mod bridging { /// Allow any asset native to the Polkadot or Ethereum ecosystems if it comes from Polkadot /// Asset Hub. pub type PolkadotOrEthereumAssetFromAssetHubPolkadot = RemoteAssetFromLocation< - ( - StartsWith, - StartsWith, - StartsWith, - ), + (StartsWith, StartsWith), AssetHubPolkadot, >;