Skip to content

Commit

Permalink
Adjust tests with latest vogue
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Sep 19, 2024
1 parent 90203c2 commit d5dc6f4
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 101 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion bridges/modules/xcm-bridge-hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ pub mod pallet {
}

impl<T: Config<I>, I: 'static> Pallet<T, I> {
pub(crate) fn do_open_bridge(
/// Open bridge for lane.
pub fn do_open_bridge(
locations: Box<BridgeLocations>,
lane_id: T::LaneId,
create_lanes: bool,
Expand Down
116 changes: 58 additions & 58 deletions bridges/testing/environments/rococo-westend/bridges_rococo_westend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,66 +53,66 @@ ASSET_HUB_ROCOCO_SOVEREIGN_ACCOUNT_AT_BRIDGE_HUB_ROCOCO="5Eg2fntNprdN3FgH4sfEaaZ
# Expected sovereign accounts for rewards on BridgeHubs.
#
# Generated by:
# #[test]
# fn generate_sovereign_accounts_for_rewards() {
# use bp_messages::LaneId;
# use bp_relayers::{PayRewardFromAccount, RewardsAccountOwner, RewardsAccountParams};
# use sp_core::crypto::Ss58Codec;
##[test]
#fn generate_sovereign_accounts_for_rewards() {
# use bp_messages::LegacyLaneId;
# use bp_relayers::{PayRewardFromAccount, RewardsAccountOwner, RewardsAccountParams};
# use sp_core::crypto::Ss58Codec;
#
# // SS58=42
# println!(
# "ON_BRIDGE_HUB_ROCOCO_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhwd_ThisChain=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# PayRewardFromAccount::<[u8; 32], [u8; 32]>::rewards_account(RewardsAccountParams::new(
# LaneId([0, 0, 0, 2]),
# *b"bhwd",
# RewardsAccountOwner::ThisChain
# ))
# )
# .to_ss58check_with_version(42_u16.into())
# );
# // SS58=42
# println!(
# "ON_BRIDGE_HUB_ROCOCO_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhwd_BridgedChain=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# PayRewardFromAccount::<[u8; 32], [u8; 32]>::rewards_account(RewardsAccountParams::new(
# LaneId([0, 0, 0, 2]),
# *b"bhwd",
# RewardsAccountOwner::BridgedChain
# ))
# )
# .to_ss58check_with_version(42_u16.into())
# );
# // SS58=42
# println!(
# "ON_BRIDGE_HUB_ROCOCO_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhwd_ThisChain=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# PayRewardFromAccount::<[u8; 32], [u8; 32], LegacyLaneId>::rewards_account(RewardsAccountParams::new(
# LegacyLaneId([0, 0, 0, 2]),
# *b"bhwd",
# RewardsAccountOwner::ThisChain
# ))
# )
# .to_ss58check_with_version(42_u16.into())
# );
# // SS58=42
# println!(
# "ON_BRIDGE_HUB_ROCOCO_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhwd_BridgedChain=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# PayRewardFromAccount::<[u8; 32], [u8; 32], LegacyLaneId>::rewards_account(RewardsAccountParams::new(
# LegacyLaneId([0, 0, 0, 2]),
# *b"bhwd",
# RewardsAccountOwner::BridgedChain
# ))
# )
# .to_ss58check_with_version(42_u16.into())
# );
#
# // SS58=42
# println!(
# "ON_BRIDGE_HUB_WESTEND_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhro_ThisChain=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# PayRewardFromAccount::<[u8; 32], [u8; 32]>::rewards_account(RewardsAccountParams::new(
# LaneId([0, 0, 0, 2]),
# *b"bhro",
# RewardsAccountOwner::ThisChain
# ))
# )
# .to_ss58check_with_version(42_u16.into())
# );
# // SS58=42
# println!(
# "ON_BRIDGE_HUB_WESTEND_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhro_BridgedChain=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# PayRewardFromAccount::<[u8; 32], [u8; 32]>::rewards_account(RewardsAccountParams::new(
# LaneId([0, 0, 0, 2]),
# *b"bhro",
# RewardsAccountOwner::BridgedChain
# ))
# )
# .to_ss58check_with_version(42_u16.into())
# );
# }
ON_BRIDGE_HUB_ROCOCO_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhwd_ThisChain="5EHnXaT5BhiSGP5hbdsoVGtzi2sQVgpDNToTxLYeQvKoMPEm"
ON_BRIDGE_HUB_ROCOCO_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhwd_BridgedChain="5EHnXaT5BhiSGP5hbdt5EJSapXYbxEv678jyWHEUskCXcjqo"
ON_BRIDGE_HUB_WESTEND_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhro_ThisChain="5EHnXaT5BhiSGP5h9Rg8sgUJqoLym3iEaWUiboT8S9AT5xFh"
ON_BRIDGE_HUB_WESTEND_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhro_BridgedChain="5EHnXaT5BhiSGP5h9RgQci1txJ2BDbp7KBRE9k8xty3BMUSi"
# // SS58=42
# println!(
# "ON_BRIDGE_HUB_WESTEND_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhro_ThisChain=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# PayRewardFromAccount::<[u8; 32], [u8; 32], LegacyLaneId>::rewards_account(RewardsAccountParams::new(
# LegacyLaneId([0, 0, 0, 2]),
# *b"bhro",
# RewardsAccountOwner::ThisChain
# ))
# )
# .to_ss58check_with_version(42_u16.into())
# );
# // SS58=42
# println!(
# "ON_BRIDGE_HUB_WESTEND_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhro_BridgedChain=\"{}\"",
# frame_support::sp_runtime::AccountId32::new(
# PayRewardFromAccount::<[u8; 32], [u8; 32], LegacyLaneId>::rewards_account(RewardsAccountParams::new(
# LegacyLaneId([0, 0, 0, 2]),
# *b"bhro",
# RewardsAccountOwner::BridgedChain
# ))
# )
# .to_ss58check_with_version(42_u16.into())
# );
#}
ON_BRIDGE_HUB_ROCOCO_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhwd_ThisChain="5EHnXaT5GApse1euZWj9hycMbgjKBCNQL9WEwScL8QDx6mhK"
ON_BRIDGE_HUB_ROCOCO_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhwd_BridgedChain="5EHnXaT5Tnt4A8aiP9CsuAFRhKPjKZJXRrj4a3mtihFvKpTi"
ON_BRIDGE_HUB_WESTEND_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhro_ThisChain="5EHnXaT5GApry9tS6yd1FVusPq8o8bQJGCKyvXTFCoEKk5Z9"
ON_BRIDGE_HUB_WESTEND_SOVEREIGN_ACCOUNT_FOR_LANE_00000002_bhro_BridgedChain="5EHnXaT5Tnt3VGpEvc6jSgYwVToDGxLRMuYoZ8coo6GHyWbR"

LANE_ID="00000002"
XCM_VERSION=3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ pub use xcm_emulator::{
// Bridges
use bp_messages::{
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
LaneId, MessageKey, OutboundLaneData,
MessageKey, OutboundLaneData,
};
pub use bp_xcm_bridge_hub::XcmBridgeHubCall;
use pallet_bridge_messages::{Config as BridgeMessagesConfig, OutboundLanes, Pallet};
use pallet_bridge_messages::{Config as BridgeMessagesConfig, LaneIdOf, OutboundLanes, Pallet};
pub use pallet_bridge_messages::{
Instance1 as BridgeMessagesInstance1, Instance2 as BridgeMessagesInstance2,
Instance3 as BridgeMessagesInstance3,
Expand All @@ -75,14 +75,14 @@ pub struct BridgeHubMessageHandler<S, SI, T, TI> {
_marker: std::marker::PhantomData<(S, SI, T, TI)>,
}

struct LaneIdWrapper(LaneId);
impl From<LaneIdWrapper> for BridgeLaneId {
fn from(lane_id: LaneIdWrapper) -> BridgeLaneId {
struct LaneIdWrapper<LaneId>(LaneId);
impl<LaneId: Encode> From<LaneIdWrapper<LaneId>> for BridgeLaneId {
fn from(lane_id: LaneIdWrapper<LaneId>) -> BridgeLaneId {
lane_id.0.encode()
}
}
impl From<BridgeLaneId> for LaneIdWrapper {
fn from(id: BridgeLaneId) -> LaneIdWrapper {
impl<LaneId: Decode> From<BridgeLaneId> for LaneIdWrapper<LaneId> {
fn from(id: BridgeLaneId) -> LaneIdWrapper<LaneId> {
LaneIdWrapper(LaneId::decode(&mut &id[..]).expect("decodable"))
}
}
Expand Down Expand Up @@ -154,7 +154,7 @@ where
}

fn notify_source_message_delivery(lane_id: BridgeLaneId) {
let lane_id = LaneIdWrapper::from(lane_id).0;
let lane_id: LaneIdOf<S, SI> = LaneIdWrapper::from(lane_id).0;
let data = OutboundLanes::<S, SI>::get(lane_id).unwrap();
let new_data = OutboundLaneData {
oldest_unpruned_nonce: data.oldest_unpruned_nonce + 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ fn change_required_stake_by_governance_works() {

mod bridge_hub_westend_tests {
use super::*;
use bp_messages::LegacyLaneId;
use bridge_common_config::{
BridgeGrandpaWestendInstance, BridgeParachainWestendInstance, DeliveryRewardInBalance,
RelayersForLegacyLaneIdsMessagesInstance,
Expand Down Expand Up @@ -340,7 +341,16 @@ mod bridge_hub_westend_tests {
XcmOverBridgeHubWestendInstance,
LocationToAccountId,
TokenLocation,
>(SiblingParachainLocation::get(), BridgedUniversalLocation::get()).1
>(
SiblingParachainLocation::get(),
BridgedUniversalLocation::get(),
|locations, fee| {
bridge_hub_test_utils::open_bridge_with_storage::<
Runtime,
XcmOverBridgeHubWestendInstance
>(locations, fee, LegacyLaneId([0, 0, 0, 1]))
}
).1
},
)
}
Expand Down Expand Up @@ -395,7 +405,16 @@ mod bridge_hub_westend_tests {
XcmOverBridgeHubWestendInstance,
LocationToAccountId,
TokenLocation,
>(SiblingParachainLocation::get(), BridgedUniversalLocation::get())
>(
SiblingParachainLocation::get(),
BridgedUniversalLocation::get(),
|locations, fee| {
bridge_hub_test_utils::open_bridge_with_storage::<
Runtime,
XcmOverBridgeHubWestendInstance,
>(locations, fee, LegacyLaneId([0, 0, 0, 1]))
},
)
.1
},
construct_and_apply_extrinsic,
Expand All @@ -419,7 +438,16 @@ mod bridge_hub_westend_tests {
XcmOverBridgeHubWestendInstance,
LocationToAccountId,
TokenLocation,
>(SiblingParachainLocation::get(), BridgedUniversalLocation::get())
>(
SiblingParachainLocation::get(),
BridgedUniversalLocation::get(),
|locations, fee| {
bridge_hub_test_utils::open_bridge_with_storage::<
Runtime,
XcmOverBridgeHubWestendInstance,
>(locations, fee, LegacyLaneId([0, 0, 0, 1]))
},
)
.1
},
construct_and_apply_extrinsic,
Expand Down Expand Up @@ -507,6 +535,7 @@ mod bridge_hub_westend_tests {

mod bridge_hub_bulletin_tests {
use super::*;
use bp_messages::LegacyLaneId;
use bridge_common_config::BridgeGrandpaRococoBulletinInstance;
use bridge_hub_rococo_runtime::bridge_common_config::RelayersForLegacyLaneIdsMessagesInstance;
use bridge_hub_test_utils::test_cases::from_grandpa_chain;
Expand Down Expand Up @@ -593,7 +622,16 @@ mod bridge_hub_bulletin_tests {
XcmOverPolkadotBulletinInstance,
LocationToAccountId,
TokenLocation,
>(SiblingPeopleParachainLocation::get(), BridgedBulletinLocation::get()).1
>(
SiblingPeopleParachainLocation::get(),
BridgedBulletinLocation::get(),
|locations, fee| {
bridge_hub_test_utils::open_bridge_with_storage::<
Runtime,
XcmOverPolkadotBulletinInstance
>(locations, fee, LegacyLaneId([0, 0, 0, 2]))
}
).1
},
)
}
Expand Down Expand Up @@ -647,7 +685,16 @@ mod bridge_hub_bulletin_tests {
XcmOverPolkadotBulletinInstance,
LocationToAccountId,
TokenLocation,
>(SiblingPeopleParachainLocation::get(), BridgedBulletinLocation::get())
>(
SiblingPeopleParachainLocation::get(),
BridgedBulletinLocation::get(),
|locations, fee| {
bridge_hub_test_utils::open_bridge_with_storage::<
Runtime,
XcmOverPolkadotBulletinInstance,
>(locations, fee, LegacyLaneId([0, 0, 0, 2]))
},
)
.1
},
construct_and_apply_extrinsic,
Expand All @@ -670,7 +717,16 @@ mod bridge_hub_bulletin_tests {
XcmOverPolkadotBulletinInstance,
LocationToAccountId,
TokenLocation,
>(SiblingPeopleParachainLocation::get(), BridgedBulletinLocation::get())
>(
SiblingPeopleParachainLocation::get(),
BridgedBulletinLocation::get(),
|locations, fee| {
bridge_hub_test_utils::open_bridge_with_storage::<
Runtime,
XcmOverPolkadotBulletinInstance,
>(locations, fee, LegacyLaneId([0, 0, 0, 2]))
},
)
.1
},
construct_and_apply_extrinsic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#![cfg(test)]

use bp_messages::LegacyLaneId;
use bp_polkadot_core::Signature;
use bridge_common_config::{
DeliveryRewardInBalance, RelayersForLegacyLaneIdsMessagesInstance,
Expand Down Expand Up @@ -239,7 +240,15 @@ fn handle_export_message_from_system_parachain_add_to_outbound_queue_works() {
XcmOverBridgeHubRococoInstance,
LocationToAccountId,
WestendLocation,
>(SiblingParachainLocation::get(), BridgedUniversalLocation::get()).1
>(
SiblingParachainLocation::get(),
BridgedUniversalLocation::get(),
|locations, fee| {
bridge_hub_test_utils::open_bridge_with_storage::<
Runtime, XcmOverBridgeHubRococoInstance
>(locations, fee, LegacyLaneId([0, 0, 0, 1]))
}
).1
},
)
}
Expand Down Expand Up @@ -292,7 +301,12 @@ fn relayed_incoming_message_works() {
XcmOverBridgeHubRococoInstance,
LocationToAccountId,
WestendLocation,
>(SiblingParachainLocation::get(), BridgedUniversalLocation::get())
>(SiblingParachainLocation::get(), BridgedUniversalLocation::get(), |locations, fee| {
bridge_hub_test_utils::open_bridge_with_storage::<
Runtime,
XcmOverBridgeHubRococoInstance,
>(locations, fee, LegacyLaneId([0, 0, 0, 1]))
})
.1
},
construct_and_apply_extrinsic,
Expand All @@ -316,7 +330,12 @@ fn free_relay_extrinsic_works() {
XcmOverBridgeHubRococoInstance,
LocationToAccountId,
WestendLocation,
>(SiblingParachainLocation::get(), BridgedUniversalLocation::get())
>(SiblingParachainLocation::get(), BridgedUniversalLocation::get(), |locations, fee| {
bridge_hub_test_utils::open_bridge_with_storage::<
Runtime,
XcmOverBridgeHubRococoInstance,
>(locations, fee, LegacyLaneId([0, 0, 0, 1]))
})
.1
},
construct_and_apply_extrinsic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ parachains-runtimes-test-utils = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
pallet-xcm = { workspace = true }

# Bridges
bp-header-chain = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ extern crate alloc;
pub use bp_test_utils::test_header;
pub use parachains_runtimes_test_utils::*;
use sp_runtime::Perbill;
pub use test_cases::helpers::ensure_opened_bridge;
pub use test_cases::helpers::{
ensure_opened_bridge, open_bridge_with_extrinsic, open_bridge_with_storage,
};

/// A helper function for comparing the actual value of a fee constant with its estimated value. The
/// estimated value can be overestimated (`overestimate_in_percent`), and if the difference to the
Expand Down
Loading

0 comments on commit d5dc6f4

Please sign in to comment.