Skip to content

Commit

Permalink
Fix and remove more FAIL-CI @bkontur
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed May 24, 2024
1 parent d39cfd6 commit 6dd7b19
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 118 deletions.
95 changes: 2 additions & 93 deletions integration-tests/emulated/helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,98 +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`.
#[macro_export]
macro_rules! test_sibling_is_trusted_teleporter {
( $sender_para:ty, $sender_xcm_config:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr) ) => {
$crate::paste::paste! {
// init Origin variables
let sender = [<$sender_para Sender>]::get();
let mut para_sender_balance_before =
<$sender_para as $crate::Chain>::account_data_of(sender.clone()).free;
let origin = <$sender_para as $crate::Chain>::RuntimeOrigin::signed(sender.clone());
let fee_asset_item = 0;
let weight_limit = $crate::WeightLimit::Unlimited;

$(
{
// init Destination variables
let receiver = [<$receiver_para Receiver>]::get();
let para_receiver_balance_before =
<$receiver_para as $crate::Chain>::account_data_of(receiver.clone()).free;
let para_destination =
<$sender_para>::sibling_location_of(<$receiver_para>::para_id());
let beneficiary: Location =
$crate::AccountId32 { network: None, id: receiver.clone().into() }.into();

// Send XCM message from Origin Parachain
// We are only testing the limited teleport version, which should be ok since success will
// depend only on a proper `XcmConfig` at destination.
<$sender_para>::execute_with(|| {
assert_ok!(<$sender_para as [<$sender_para Pallet>]>::PolkadotXcm::limited_teleport_assets(
origin.clone(),
bx!(para_destination.clone().into()),
bx!(beneficiary.clone().into()),
bx!($assets.clone().into()),
fee_asset_item,
weight_limit.clone(),
));

type RuntimeEvent = <$sender_para as $crate::Chain>::RuntimeEvent;

assert_expected_events!(
$sender_para,
vec![
RuntimeEvent::PolkadotXcm(
$crate::pallet_xcm::Event::Attempted { outcome: Outcome::Complete { .. } }
) => {},
RuntimeEvent::XcmpQueue(
$crate::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }
) => {},
RuntimeEvent::Balances(
$crate::pallet_balances::Event::Burned { who: sender, amount }
) => {},
]
);
});

// Receive XCM message in Destination Parachain
<$receiver_para>::execute_with(|| {
type RuntimeEvent = <$receiver_para as $crate::Chain>::RuntimeEvent;

assert_expected_events!(
$receiver_para,
vec![
RuntimeEvent::Balances(
$crate::pallet_balances::Event::Minted { who: receiver, .. }
) => {},
RuntimeEvent::MessageQueue(
$crate::pallet_message_queue::Event::Processed { success: true, .. }
) => {},
]
);
});

// Check if balances are updated accordingly in Origin and Destination Parachains
let para_sender_balance_after =
<$sender_para as $crate::Chain>::account_data_of(sender.clone()).free;
let para_receiver_balance_after =
<$receiver_para as $crate::Chain>::account_data_of(receiver.clone()).free;
let delivery_fees = <$sender_para>::execute_with(|| {
$crate::asset_test_utils::xcm_helpers::teleport_assets_delivery_fees::<
<$sender_xcm_config as xcm_executor::Config>::XcmSender,
>($assets.clone(), fee_asset_item, weight_limit.clone(), beneficiary, para_destination)
});

assert_eq!(para_sender_balance_before - $amount - delivery_fees, para_sender_balance_after);
assert!(para_receiver_balance_after > para_receiver_balance_before);

// Update sender balance
para_sender_balance_before = <$sender_para as $crate::Chain>::account_data_of(sender.clone()).free;
}
)+
}
};
}
/// TODO: backport this macros to polkadot-sdk
#[macro_export]
macro_rules! test_relay_is_trusted_teleporter {
Expand Down Expand Up @@ -215,7 +124,7 @@ macro_rules! test_relay_is_trusted_teleporter {
}

#[macro_export]
macro_rules! test_parachain_is_trusted_teleporter {
macro_rules! test_parachain_is_trusted_teleporter_for_relay {
( $sender_para:ty, $sender_xcm_config:ty, $receiver_relay:ty, $amount:expr ) => {
$crate::paste::paste! {
// init Origin variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ pub use xcm::{
// Cumulus
pub use asset_test_utils::xcm_helpers;
pub use emulated_integration_tests_common::{
test_parachain_is_trusted_teleporter,
xcm_emulator::{
assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para,
RelayChain as Relay, Test, TestArgs, TestContext, TestExt,
},
xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution},
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
};
pub use integration_tests_helpers::test_sibling_is_trusted_teleporter;
pub use kusama_system_emulated_network::{
asset_hub_kusama_emulated_chain::{
genesis::ED as ASSET_HUB_KUSAMA_ED, AssetHubKusamaParaPallet as AssetHubKusamaPallet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,12 @@ fn teleport_to_other_system_parachains_works() {
let amount = ASSET_HUB_KUSAMA_ED * 100;
let native_asset: Assets = (Parent, amount).into();

/*test_sibling_is_trusted_teleporter!(
test_parachain_is_trusted_teleporter!(
AssetHubKusama, // Origin
AssetHubKusamaXcmConfig, // XCM Configuration
vec![BridgeHubKusama], // Destinations
(native_asset, amount)
);*/
todo!() // FAIL-CI @bkontur
);
}

/// Bidirectional teleports of local Penpal assets to Asset Hub as foreign assets should work
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ pub use xcm::{
// Cumulus
pub use asset_test_utils::xcm_helpers;
pub use emulated_integration_tests_common::{
test_parachain_is_trusted_teleporter,
xcm_emulator::{
assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para,
RelayChain as Relay, Test, TestArgs, TestContext, TestExt,
},
xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution},
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
};
pub use integration_tests_helpers::test_sibling_is_trusted_teleporter;
pub use parachains_common::{AccountId, Balance};
pub use polkadot_system_emulated_network::{
asset_hub_polkadot_emulated_chain::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ fn teleport_to_other_system_parachains_works() {
let amount = ASSET_HUB_POLKADOT_ED * 100;
let native_asset: Assets = (Parent, amount).into();

test_sibling_is_trusted_teleporter!(
test_parachain_is_trusted_teleporter!(
AssetHubPolkadot, // Origin
AssetHubPolkadotXcmConfig, // XCM Configuration
vec![BridgeHubPolkadot], // Destinations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ pub use bp_messages::LaneId;
pub use emulated_integration_tests_common::{
accounts::{ALICE, BOB},
impls::Inspect,
test_parachain_is_trusted_teleporter,
xcm_emulator::{
assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para,
RelayChain as Relay, Test, TestArgs, TestContext, TestExt,
},
xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution},
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
};
pub use integration_tests_helpers::test_sibling_is_trusted_teleporter;
pub use kusama_polkadot_system_emulated_network::{
asset_hub_kusama_emulated_chain::{
genesis::ED as ASSET_HUB_KUSAMA_ED, AssetHubKusamaParaPallet as AssetHubKusamaPallet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ fn teleport_to_other_system_parachains_works() {
let amount = BRIDGE_HUB_KUSAMA_ED * 100;
let native_asset: Assets = (Parent, amount).into();

/*
FAIL-CI @bkontur
test_sibling_is_trusted_teleporter!(
test_parachain_is_trusted_teleporter!(
BridgeHubKusama, // Origin
XcmConfig, // XCM configuration
vec![AssetHubKusama], // Destinations
(native_asset, amount)
);*/
todo!()
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ pub use bp_messages::LaneId;
pub use emulated_integration_tests_common::{
accounts::{ALICE, BOB},
impls::Inspect,
test_parachain_is_trusted_teleporter,
xcm_emulator::{
assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para,
RelayChain as Relay, Test, TestArgs, TestContext, TestExt,
},
xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution},
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
};
pub use integration_tests_helpers::test_sibling_is_trusted_teleporter;
pub use kusama_polkadot_system_emulated_network::{
asset_hub_kusama_emulated_chain::{
genesis::ED as ASSET_HUB_KUSAMA_ED, AssetHubKusamaParaPallet as AssetHubKusamaPallet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@

use crate::*;
use bridge_hub_polkadot_runtime::xcm_config::XcmConfig;
use integration_tests_helpers::test_parachain_is_trusted_teleporter;

#[test]
fn teleport_to_other_system_parachains_works() {
let amount = BRIDGE_HUB_POLKADOT_ED * 100;
let native_asset: Assets = (Parent, amount).into();

/*test_parachain_is_trusted_teleporter!(
BridgeHubPolkadot, // Origin
XcmConfig, // XCM Configuration
BridgeHubPolkadot, // Destination
test_parachain_is_trusted_teleporter!(
BridgeHubPolkadot, // Origin
XcmConfig, // XCM Configuration
vec![AssetHubPolkadot], // Destination
(native_asset, amount)
);*/
todo!() // FAIL-CI @bkontur
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub use xcm::{prelude::*, v3};
// Cumulus
pub use emulated_integration_tests_common::{
accounts::ALICE,
test_parachain_is_trusted_teleporter,
xcm_emulator::{assert_expected_events, bx, Chain, Parachain, RelayChain as Relay, TestExt},
};
pub use polkadot_system_emulated_network::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ use asset_hub_polkadot_runtime::xcm_config::XcmConfig as AssetHubPolkadotXcmConf
use collectives_polkadot_runtime::xcm_config::XcmConfig as CollectivesPolkadotXcmConfig;
use frame_support::assert_ok;
use integration_tests_helpers::{
test_parachain_is_trusted_teleporter, test_relay_is_trusted_teleporter,
test_sibling_is_trusted_teleporter,
test_parachain_is_trusted_teleporter_for_relay, test_relay_is_trusted_teleporter,
};
use polkadot_runtime::xcm_config::XcmConfig as PolkadotXcmConfig;

Expand All @@ -35,7 +34,7 @@ fn teleport_from_and_to_relay() {
(native_asset, amount)
);

test_parachain_is_trusted_teleporter!(
test_parachain_is_trusted_teleporter_for_relay!(
CollectivesPolkadot, // Origin
CollectivesPolkadotXcmConfig, // XCM Configuration
Polkadot, // Destination
Expand All @@ -48,7 +47,7 @@ fn teleport_from_collectives_to_asset_hub() {
let amount = ASSET_HUB_POLKADOT_ED * 100;
let native_asset: Assets = (Parent, amount).into();

test_sibling_is_trusted_teleporter!(
test_parachain_is_trusted_teleporter!(
CollectivesPolkadot, // Origin
CollectivesPolkadotXcmConfig, // XCM Configuration
vec![AssetHubPolkadot], // Destinations
Expand All @@ -61,7 +60,7 @@ fn teleport_from_asset_hub_to_collectives() {
let amount = COLLECTIVES_POLKADOT_ED * 100;
let native_asset: Assets = (Parent, amount).into();

test_sibling_is_trusted_teleporter!(
test_parachain_is_trusted_teleporter!(
AssetHubPolkadot, // Origin
AssetHubPolkadotXcmConfig, // XCM Configuration
vec![CollectivesPolkadot], // Destinations
Expand Down

0 comments on commit 6dd7b19

Please sign in to comment.