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

Cleanup bridges tests: with-parachain case #2772

Merged
merged 2 commits into from
Dec 21, 2023
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 @@ -137,6 +137,7 @@ mod bridge_hub_westend_tests {
use bridge_common_config::{
BridgeGrandpaWestendInstance, BridgeParachainWestendInstance, DeliveryRewardInBalance,
};
use bridge_hub_test_utils::test_cases::from_parachain;
use bridge_to_westend_config::{
BridgeHubWestendChainId, BridgeHubWestendLocation, WestendGlobalConsensusNetwork,
WithBridgeHubWestendMessageBridge, WithBridgeHubWestendMessagesInstance,
Expand All @@ -146,6 +147,16 @@ mod bridge_hub_westend_tests {
// Para id of sibling chain used in tests.
pub const SIBLING_PARACHAIN_ID: u32 = 1000;

// Runtime from tests PoV
type RuntimeTestsAdapter = from_parachain::WithRemoteParachainHelperAdapter<
Runtime,
AllPalletsWithoutSystem,
BridgeGrandpaWestendInstance,
BridgeParachainWestendInstance,
WithBridgeHubWestendMessagesInstance,
WithBridgeHubWestendMessageBridge,
>;

#[test]
fn initialize_bridge_by_governance_works() {
// for RococoBulletin finality
Expand Down Expand Up @@ -259,15 +270,7 @@ mod bridge_hub_westend_tests {
#[test]
fn relayed_incoming_message_works() {
// from Westend
bridge_hub_test_utils::test_cases::from_parachain::relayed_incoming_message_works::<
Runtime,
AllPalletsWithoutSystem,
ParachainSystem,
BridgeGrandpaWestendInstance,
BridgeParachainWestendInstance,
WithBridgeHubWestendMessagesInstance,
WithBridgeHubWestendMessageBridge,
>(
from_parachain::relayed_incoming_message_works::<RuntimeTestsAdapter>(
collator_session_keys(),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
Expand All @@ -283,16 +286,7 @@ mod bridge_hub_westend_tests {
#[test]
pub fn complex_relay_extrinsic_works() {
// for Westend
bridge_hub_test_utils::test_cases::from_parachain::complex_relay_extrinsic_works::<
Runtime,
AllPalletsWithoutSystem,
XcmConfig,
ParachainSystem,
BridgeGrandpaWestendInstance,
BridgeParachainWestendInstance,
WithBridgeHubWestendMessagesInstance,
WithBridgeHubWestendMessageBridge,
>(
from_parachain::complex_relay_extrinsic_works::<RuntimeTestsAdapter>(
collator_session_keys(),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
Expand Down Expand Up @@ -325,16 +319,9 @@ mod bridge_hub_westend_tests {

#[test]
pub fn can_calculate_fee_for_complex_message_delivery_transaction() {
let estimated = bridge_hub_test_utils::test_cases::from_parachain::can_calculate_fee_for_complex_message_delivery_transaction::<
Runtime,
BridgeGrandpaWestendInstance,
BridgeParachainWestendInstance,
WithBridgeHubWestendMessagesInstance,
WithBridgeHubWestendMessageBridge,
>(
collator_session_keys(),
construct_and_estimate_extrinsic_fee
);
let estimated = from_parachain::can_calculate_fee_for_complex_message_delivery_transaction::<
RuntimeTestsAdapter,
>(collator_session_keys(), construct_and_estimate_extrinsic_fee);

// check if estimated value is sane
let max_expected = bp_bridge_hub_rococo::BridgeHubRococoBaseDeliveryFeeInRocs::get();
Expand All @@ -348,16 +335,10 @@ mod bridge_hub_westend_tests {

#[test]
pub fn can_calculate_fee_for_complex_message_confirmation_transaction() {
let estimated = bridge_hub_test_utils::test_cases::from_parachain::can_calculate_fee_for_complex_message_confirmation_transaction::<
Runtime,
BridgeGrandpaWestendInstance,
BridgeParachainWestendInstance,
WithBridgeHubWestendMessagesInstance,
WithBridgeHubWestendMessageBridge,
>(
collator_session_keys(),
construct_and_estimate_extrinsic_fee
);
let estimated =
from_parachain::can_calculate_fee_for_complex_message_confirmation_transaction::<
RuntimeTestsAdapter,
>(collator_session_keys(), construct_and_estimate_extrinsic_fee);

// check if estimated value is sane
let max_expected = bp_bridge_hub_rococo::BridgeHubRococoBaseConfirmationFeeInRocs::get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use bp_polkadot_core::Signature;
use bridge_common_config::{DeliveryRewardInBalance, RequiredStakeForStakeAndSlash};
use bridge_hub_test_utils::test_cases::from_parachain;
use bridge_hub_westend_runtime::{
bridge_common_config, bridge_to_rococo_config,
xcm_config::{RelayNetwork, WestendLocation, XcmConfig},
Expand All @@ -43,6 +44,16 @@ use xcm::latest::prelude::*;
// Para id of sibling chain used in tests.
pub const SIBLING_PARACHAIN_ID: u32 = 1000;

// Runtime from tests PoV
type RuntimeTestsAdapter = from_parachain::WithRemoteParachainHelperAdapter<
Runtime,
AllPalletsWithoutSystem,
BridgeGrandpaRococoInstance,
BridgeParachainRococoInstance,
WithBridgeHubRococoMessagesInstance,
WithBridgeHubRococoMessageBridge,
>;

parameter_types! {
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
}
Expand Down Expand Up @@ -239,15 +250,7 @@ fn message_dispatch_routing_works() {

#[test]
fn relayed_incoming_message_works() {
bridge_hub_test_utils::test_cases::from_parachain::relayed_incoming_message_works::<
Runtime,
AllPalletsWithoutSystem,
ParachainSystem,
BridgeGrandpaRococoInstance,
BridgeParachainRococoInstance,
WithBridgeHubRococoMessagesInstance,
WithBridgeHubRococoMessageBridge,
>(
from_parachain::relayed_incoming_message_works::<RuntimeTestsAdapter>(
collator_session_keys(),
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
Expand All @@ -262,16 +265,7 @@ fn relayed_incoming_message_works() {

#[test]
pub fn complex_relay_extrinsic_works() {
bridge_hub_test_utils::test_cases::from_parachain::complex_relay_extrinsic_works::<
Runtime,
AllPalletsWithoutSystem,
XcmConfig,
ParachainSystem,
BridgeGrandpaRococoInstance,
BridgeParachainRococoInstance,
WithBridgeHubRococoMessagesInstance,
WithBridgeHubRococoMessageBridge,
>(
from_parachain::complex_relay_extrinsic_works::<RuntimeTestsAdapter>(
collator_session_keys(),
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
Expand Down Expand Up @@ -304,16 +298,9 @@ pub fn can_calculate_weight_for_paid_export_message_with_reserve_transfer() {

#[test]
pub fn can_calculate_fee_for_complex_message_delivery_transaction() {
let estimated = bridge_hub_test_utils::test_cases::from_parachain::can_calculate_fee_for_complex_message_delivery_transaction::<
Runtime,
BridgeGrandpaRococoInstance,
BridgeParachainRococoInstance,
WithBridgeHubRococoMessagesInstance,
WithBridgeHubRococoMessageBridge,
>(
collator_session_keys(),
construct_and_estimate_extrinsic_fee
);
let estimated = from_parachain::can_calculate_fee_for_complex_message_delivery_transaction::<
RuntimeTestsAdapter,
>(collator_session_keys(), construct_and_estimate_extrinsic_fee);

// check if estimated value is sane
let max_expected = bp_bridge_hub_westend::BridgeHubWestendBaseDeliveryFeeInWnds::get();
Expand All @@ -327,16 +314,9 @@ pub fn can_calculate_fee_for_complex_message_delivery_transaction() {

#[test]
pub fn can_calculate_fee_for_complex_message_confirmation_transaction() {
let estimated = bridge_hub_test_utils::test_cases::from_parachain::can_calculate_fee_for_complex_message_confirmation_transaction::<
Runtime,
BridgeGrandpaRococoInstance,
BridgeParachainRococoInstance,
WithBridgeHubRococoMessagesInstance,
WithBridgeHubRococoMessageBridge,
>(
collator_session_keys(),
construct_and_estimate_extrinsic_fee
);
let estimated = from_parachain::can_calculate_fee_for_complex_message_confirmation_transaction::<
RuntimeTestsAdapter,
>(collator_session_keys(), construct_and_estimate_extrinsic_fee);

// check if estimated value is sane
let max_expected = bp_bridge_hub_westend::BridgeHubWestendBaseConfirmationFeeInWnds::get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ use xcm::latest::prelude::*;

/// Helper trait to test bridges with remote GRANDPA chain.
///
/// This is only used to decrease amount of lines, dedicated to bounds
/// This is only used to decrease amount of lines, dedicated to bounds.
pub trait WithRemoteGrandpaChainHelper {
/// This chaiin runtime.
/// This chain runtime.
type Runtime: BasicParachainRuntime
+ cumulus_pallet_xcmp_queue::Config
+ BridgeGrandpaConfig<
Expand All @@ -74,7 +74,7 @@ pub trait WithRemoteGrandpaChainHelper {
type MB: MessageBridge;
}

/// Adapter struct that implements `WithRemoteGrandpaChainHelper`
/// Adapter struct that implements [`WithRemoteGrandpaChainHelper`].
pub struct WithRemoteGrandpaChainHelperAdapter<Runtime, AllPalletsWithoutSystem, GPI, MPI, MB>(
sp_std::marker::PhantomData<(Runtime, AllPalletsWithoutSystem, GPI, MPI, MB)>,
);
Expand Down
Loading