Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for release 1.3.1 #133

Merged
merged 5 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use emulated_integration_tests_common::{
accounts, build_genesis_storage, collators, get_account_id_from_seed, SAFE_XCM_VERSION,
};
use parachains_common::{AccountId, Balance};
use penpal_runtime::xcm_config::{LocalReservableFromAssetHub, RelayLocation};

// Penpal
pub const PARA_ID_A: u32 = 2000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use emulated_integration_tests_common::{
impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain, impls::Parachain,
xcm_emulator::decl_test_parachains,
};
use paseo_emulated_chain::Paseo;

// Penpal Parachain declaration
decl_test_parachains! {
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/emulated/helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub use xcm_emulator::Chain;

/// TODO: when bumping to polkadot-sdk v1.8.0,
/// remove this crate altogether and get the macros from `emulated-integration-tests-common`.
/// remove this crate altogether and get the macros from `emulated-integration-tests-common`.
/// TODO: backport this macros to paseo-sdk

#[macro_export]
Expand Down Expand Up @@ -192,7 +193,7 @@ macro_rules! test_parachain_is_trusted_teleporter_for_relay {
$crate::AccountId32 { network: None, id: receiver.clone().into() }.into();

// Dry-run first.
let call = <$sender_para as Chain>::RuntimeCall::PaseoXcm(pallet_xcm::Call::limited_teleport_assets {
let call = <$sender_para as Chain>::RuntimeCall::PolkadotXcm(pallet_xcm::Call::limited_teleport_assets {
dest: bx!(relay_destination.clone().into()),
beneficiary: bx!(beneficiary.clone().into()),
assets: bx!(assets.clone().into()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,22 @@ pub use emulated_integration_tests_common::{
xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution},
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
};
/*
pub use kusama_paseo_system_emulated_network::{
asset_hub_kusama_emulated_chain::{
genesis::ED as ASSET_HUB_KUSAMA_ED, AssetHubKusamaParaPallet as AssetHubKusamaPallet,
},
pub use paseo_system_emulated_network::{
asset_hub_paseo_emulated_chain::{
genesis::ED as ASSET_HUB_POLKAPAS_ED, AssetHubPaseoParaPallet as AssetHubPaseoPallet,
genesis::ED as ASSET_HUB_POLKADOT_ED, AssetHubPaseoParaPallet as AssetHubPaseoPallet,
},
bridge_hub_paseo_emulated_chain::{
genesis::ED as BRIDGE_HUB_POLKAPAS_ED,
genesis::ED as BRIDGE_HUB_POLKADOT_ED,
BridgeHubPaseoParaPallet as BridgeHubPaseoPallet,
},
paseo_emulated_chain::{genesis::ED as POLKAPAS_ED, PaseoRelayPallet as PaseoPallet},
AssetHubKusamaPara as AssetHubKusama, AssetHubKusamaParaReceiver as AssetHubKusamaReceiver,
paseo_emulated_chain::{genesis::ED as POLKADOT_ED, PaseoRelayPallet as PaseoPallet},
AssetHubPaseoPara as AssetHubPaseo,
AssetHubPaseoParaReceiver as AssetHubPaseoReceiver,
AssetHubPaseoParaSender as AssetHubPaseoSender, BridgeHubKusamaPara as BridgeHubKusama,
AssetHubPaseoParaSender as AssetHubPaseoSender,
BridgeHubPaseoPara as BridgeHubPaseo,
BridgeHubPaseoParaSender as BridgeHubPaseoSender, PaseoRelay as Paseo,
PaseoRelayReceiver as PaseoReceiver, PaseoRelaySender as PaseoSender,
};
*/

pub use parachains_common::{AccountId, Balance};
pub use paseo_system_emulated_network::{
penpal_emulated_chain::PenpalBParaPallet as PenpalBPallet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@

use crate::*;

use bridge_hub_polkadot_runtime::ExistentialDeposit;
use bridge_hub_paseo_runtime::ExistentialDeposit;
use integration_tests_helpers::test_chain_can_claim_assets;
use xcm_executor::traits::DropAssets;
use xcm::v3::NetworkId::Polkadot as PaseoId;


#[test]
fn assets_can_be_claimed() {
let amount = ExistentialDeposit::get();
let assets: Assets = (Parent, amount).into();

test_chain_can_claim_assets!(
AssetHubPolkadot,
AssetHubPaseo,
RuntimeCall,
NetworkId::Polkadot,
PaseoId.into(),
assets,
amount
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,96 +15,98 @@

use crate::*;

mod asset_transfers;
mod claim_assets;
mod send_xcm;

mod snowbridge;
mod teleport;
mod claim_assets;

pub(crate) fn asset_hub_kusama_location() -> Location {
Location::new(
2,
[GlobalConsensus(NetworkId::Kusama), Parachain(AssetHubKusama::para_id().into())],
)
}

pub(crate) fn bridge_hub_kusama_location() -> Location {
Location::new(
2,
[GlobalConsensus(NetworkId::Kusama), Parachain(BridgeHubKusama::para_id().into())],
)
}

pub(crate) fn send_asset_from_asset_hub_paseo(
destination: Location,
(id, amount): (Location, u128),
) -> DispatchResult {
let signed_origin =
<AssetHubPaseo as Chain>::RuntimeOrigin::signed(AssetHubPaseoSender::get());

let beneficiary: Location =
AccountId32Junction { network: None, id: AssetHubKusamaReceiver::get().into() }.into();

let assets: Assets = (id, amount).into();
let fee_asset_item = 0;

AssetHubPaseo::execute_with(|| {
<AssetHubPaseo as AssetHubPaseoPallet>::PaseoXcm::limited_reserve_transfer_assets(
signed_origin,
bx!(destination.into()),
bx!(beneficiary.into()),
bx!(assets.into()),
fee_asset_item,
WeightLimit::Unlimited,
)
})
}

pub(crate) fn assert_bridge_hub_paseo_message_accepted(expected_processed: bool) {
BridgeHubPaseo::execute_with(|| {
type RuntimeEvent = <BridgeHubPaseo as Chain>::RuntimeEvent;

if expected_processed {
assert_expected_events!(
BridgeHubPaseo,
vec![
// pay for bridge fees
RuntimeEvent::Balances(pallet_balances::Event::Burned { .. }) => {},
// message exported
RuntimeEvent::BridgeKusamaMessages(
pallet_bridge_messages::Event::MessageAccepted { .. }
) => {},
// message processed successfully
RuntimeEvent::MessageQueue(
pallet_message_queue::Event::Processed { success: true, .. }
) => {},
]
);
} else {
assert_expected_events!(
BridgeHubPaseo,
vec![
RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {
success: false,
..
}) => {},
]
);
}
});
}

pub(crate) fn assert_bridge_hub_kusama_message_received() {
BridgeHubKusama::execute_with(|| {
type RuntimeEvent = <BridgeHubKusama as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubKusama,
vec![
// message sent to destination
RuntimeEvent::XcmpQueue(
cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }
) => {},
]
);
})
}
// pub(crate) fn asset_hub_kusama_location() -> Location {
// Location::new(
// 2,
// [GlobalConsensus(NetworkId::Kusama), Parachain(AssetHubKusama::para_id().into())],
// )
// }
//
// pub(crate) fn bridge_hub_kusama_location() -> Location {
// Location::new(
// 2,
// [GlobalConsensus(NetworkId::Kusama), Parachain(BridgeHubKusama::para_id().into())],
// )
// }
//
// pub(crate) fn send_asset_from_asset_hub_paseo(
// destination: Location,
// (id, amount): (Location, u128),
// ) -> DispatchResult {
// let signed_origin =
// <AssetHubPaseo as Chain>::RuntimeOrigin::signed(AssetHubPaseoSender::get());
//
// let beneficiary: Location =
// AccountId32Junction { network: None, id: AssetHubKusamaReceiver::get().into() }.into();
//
// let assets: Assets = (id, amount).into();
// let fee_asset_item = 0;
//
// AssetHubPaseo::execute_with(|| {
// <AssetHubPaseo as AssetHubPaseoPallet>::PolkadotXcm::limited_reserve_transfer_assets(
// signed_origin,
// bx!(destination.into()),
// bx!(beneficiary.into()),
// bx!(assets.into()),
// fee_asset_item,
// WeightLimit::Unlimited,
// )
// })
// }
//
// pub(crate) fn assert_bridge_hub_paseo_message_accepted(expected_processed: bool) {
// BridgeHubPaseo::execute_with(|| {
// type RuntimeEvent = <BridgeHubPaseo as Chain>::RuntimeEvent;
//
// if expected_processed {
// assert_expected_events!(
// BridgeHubPaseo,
// vec![
// // pay for bridge fees
// RuntimeEvent::Balances(pallet_balances::Event::Burned { .. }) => {},
// // message exported
// RuntimeEvent::BridgeKusamaMessages(
// pallet_bridge_messages::Event::MessageAccepted { .. }
// ) => {},
// // message processed successfully
// RuntimeEvent::MessageQueue(
// pallet_message_queue::Event::Processed { success: true, .. }
// ) => {},
// ]
// );
// } else {
// assert_expected_events!(
// BridgeHubPaseo,
// vec![
// RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {
// success: false,
// ..
// }) => {},
// ]
// );
// }
// });
// }
//
// pub(crate) fn assert_bridge_hub_kusama_message_received() {
// BridgeHubKusama::execute_with(|| {
// type RuntimeEvent = <BridgeHubKusama as Chain>::RuntimeEvent;
// assert_expected_events!(
// BridgeHubKusama,
// vec![
// // message sent to destination
// RuntimeEvent::XcmpQueue(
// cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }
// ) => {},
// ]
// );
// })
// }
//
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use sp_runtime::{DispatchError::Token, FixedU128, TokenError::FundsUnavailable};
use system_parachains_constants::paseo::currency::UNITS;

const INITIAL_FUND: u128 = 5_000_000_000 * POLKADOT_ED;
const CHAIN_ID: u64 = 1;
const CHAIN_ID: u64 = 11155111;
const WETH: [u8; 20] = hex!("87d1f7fdfEe7f651FaBc8bFCB6E086C278b77A7d");
const ETHEREUM_DESTINATION_ADDRESS: [u8; 20] = hex!("44a57ee2f2FCcb85FDa2B0B18EBD0D8D2333700e");
const GATEWAY_ADDRESS: [u8; 20] = hex!("EDa338E4dC46038493b885327842fD3E301CaB39");
Expand Down Expand Up @@ -606,7 +606,7 @@ fn send_weth_asset_from_asset_hub_to_ethereum() {
);
// Send the Weth back to Ethereum
assert_ok!(
<AssetHubPaseo as AssetHubPaseoPallet>::PaseoXcm::limited_reserve_transfer_assets(
<AssetHubPaseo as AssetHubPaseoPallet>::PolkadotXcm::limited_reserve_transfer_assets(
RuntimeOrigin::signed(AssetHubPaseoReceiver::get()),
Box::new(destination),
Box::new(beneficiary),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.

use crate::*;
use bridge_hub_polkadot_runtime::xcm_config::XcmConfig;
use bridge_hub_paseo_runtime::xcm_config::XcmConfig;
use frame_support::{
dispatch::RawOrigin, sp_runtime::traits::Dispatchable, traits::fungible::Mutate,
};
Expand All @@ -32,9 +32,9 @@ fn teleport_to_other_system_parachains_works() {
let native_asset: Assets = (Parent, amount).into();

test_parachain_is_trusted_teleporter!(
BridgeHubPolkadot, // Origin
BridgeHubPaseo, // Origin
XcmConfig, // XCM Configuration
vec![AssetHubPolkadot], // Destination
vec![AssetHubPaseo], // Destination
(native_asset, amount)
);
}
Expand All @@ -45,16 +45,16 @@ fn teleport_from_and_to_relay() {
let native_asset: Assets = (Here, amount).into();

test_relay_is_trusted_teleporter!(
Polkadot,
PolkadotXcmConfig,
vec![BridgeHubPolkadot],
Paseo,
PaseoXcmConfig,
vec![BridgeHubPaseo],
(native_asset, amount)
);

test_parachain_is_trusted_teleporter_for_relay!(
BridgeHubPolkadot,
BridgeHubPolkadotXcmConfig,
Polkadot,
BridgeHubPaseo,
BridgeHubPaseoXcmConfig,
Paseo,
amount
);
}
Loading