Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #29 from Snowfork/ron/message-queue-compatibility
Browse files Browse the repository at this point in the history
Fix breaking tests
  • Loading branch information
yrong authored Nov 15, 2023
2 parents a7f55a8 + e842815 commit 409ad4d
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 28 deletions.
18 changes: 18 additions & 0 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ parachains-common = { path = "../../../../../../../parachains/common" }
cumulus-primitives-core = { path = "../../../../../../../primitives/core", default-features = false }
emulated-integration-tests-common = { path = "../../../../common", default-features = false }
bridge-hub-rococo-runtime = { path = "../../../../../../runtimes/bridge-hubs/bridge-hub-rococo" }

# Snowbridge
snowbridge-core = { path = "../../../../../../../../../parachain/primitives/core", default-features = false }
snowbridge-router-primitives = { path = "../../../../../../../../../parachain/primitives/router", default-features = false }
snowbridge-control = { path = "../../../../../../../../../parachain/pallets/control", default-features = false }
snowbridge-inbound-queue = { path = "../../../../../../../../../parachain/pallets/inbound-queue", default-features = false }
snowbridge-outbound-queue = { path = "../../../../../../../../../parachain/pallets/outbound-queue", default-features = false }

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ decl_test_parachains! {
pallets = {
PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm,
Balances: bridge_hub_rococo_runtime::Balances,
EthereumControl: bridge_hub_rococo_runtime::EthereumControl,
EthereumInboundQueue: bridge_hub_rococo_runtime::EthereumInboundQueue,
EthereumOutboundQueue: bridge_hub_rococo_runtime::EthereumOutboundQueue,
}
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ publish = false

[dependencies]
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
hex = "0.4.3"
hex-literal = "0.4.1"

# Substrate
sp-core = { path = "../../../../../../../substrate/primitives/core", default-features = false}
frame-support = { path = "../../../../../../../substrate/frame/support", default-features = false}
pallet-message-queue = { path = "../../../../../../../substrate/frame/message-queue" }
pallet-assets = { path = "../../../../../../../substrate/frame/assets", default-features = false }
pallet-balances = { path = "../../../../../../../substrate/frame/balances", default-features = false }

# Polkadot
xcm = { package = "staging-xcm", path = "../../../../../../../polkadot/xcm", default-features = false}
Expand All @@ -30,4 +36,13 @@ cumulus-pallet-xcmp-queue = { path = "../../../../../../pallets/xcmp-queue", def
cumulus-pallet-dmp-queue = { path = "../../../../../../pallets/dmp-queue", default-features = false}
bridge-hub-rococo-runtime = { path = "../../../../../../parachains/runtimes/bridge-hubs/bridge-hub-rococo", default-features = false }
emulated-integration-tests-common = { path = "../../../common", default-features = false}
rococo-wococo-system-emulated-network ={ path = "../../../networks/rococo-wococo-system" }
rococo-wococo-system-emulated-network = { path = "../../../networks/rococo-wococo-system" }
bridge-hub-rococo-emulated-chain = { path = "../../../chains/parachains/bridges/bridge-hub-rococo"}
asset-hub-rococo-emulated-chain = { path = "../../../chains/parachains/assets/asset-hub-rococo"}

# Snowbridge
snowbridge-core = { path = "../../../../../../../../parachain/primitives/core", default-features = false }
snowbridge-router-primitives = { path = "../../../../../../../../parachain/primitives/router", default-features = false }
snowbridge-control = { path = "../../../../../../../../parachain/pallets/control", default-features = false }
snowbridge-inbound-queue = { path = "../../../../../../../../parachain/pallets/inbound-queue", default-features = false }
snowbridge-outbound-queue = { path = "../../../../../../../../parachain/pallets/outbound-queue", default-features = false }
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
use codec::Encode;
use asset_hub_rococo_emulated_chain::AssetHubRococoParaPallet as AssetHubRococoPallet;
use bridge_hub_rococo_emulated_chain::BridgeHubRococoParaPallet as BridgeHubRococoPallet;
use codec::{Decode, Encode};
use frame_support::pallet_prelude::TypeInfo;
use hex_literal::hex;
use integration_tests_common::{AssetHubRococoPallet, BridgeHubRococoPallet};
use snowbridge_control;
use snowbridge_core::outbound::OperatingMode;
use snowbridge_router_primitives::inbound::{Command, Destination, MessageV1, VersionedMessage};
Expand Down Expand Up @@ -52,7 +54,7 @@ fn create_agent() {
Transact {
require_weight_at_most: 3000000000.into(),
origin_kind: OriginKind::Xcm,
call: vec![51, 2].into(),
call: vec![63, 2].into(),
},
]));

Expand Down Expand Up @@ -81,10 +83,6 @@ fn create_agent() {
assert_expected_events!(
BridgeHubRococo,
vec![
RuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward {
outcome: Outcome::Complete(_),
..
}) => {},
RuntimeEvent::EthereumControl(snowbridge_control::Event::CreateAgent {
..
}) => {},
Expand All @@ -93,6 +91,19 @@ fn create_agent() {
});
}

#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub enum CreateChannelCall {
#[codec(index = 3)]
CreateChannel { mode: OperatingMode, outbound_fee: u128 },
}

#[allow(clippy::large_enum_variant)]
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub enum SnowbridgeControl {
#[codec(index = 63)]
Control(CreateChannelCall),
}

#[test]
fn create_channel() {
let origin_para: u32 = 1001;
Expand All @@ -114,17 +125,22 @@ fn create_channel() {
Transact {
require_weight_at_most: 3000000000.into(),
origin_kind: OriginKind::Xcm,
call: vec![51, 2].into(),
call: vec![63, 2].into(),
},
]));

let create_channel_call = SnowbridgeControl::Control(CreateChannelCall::CreateChannel {
mode: OperatingMode::Normal,
outbound_fee: 1,
});

let create_channel_xcm = VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
DescendOrigin(X1(Parachain(origin_para))),
Transact {
require_weight_at_most: 3000000000.into(),
origin_kind: OriginKind::Xcm,
call: ([51u8, 3u8], OperatingMode::Normal, 1u128).encode().into(),
call: create_channel_call.encode().into(),
},
]));

Expand Down Expand Up @@ -159,10 +175,6 @@ fn create_channel() {
assert_expected_events!(
BridgeHubRococo,
vec![
RuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward {
outcome: Outcome::Complete(_),
..
}) => {},
RuntimeEvent::EthereumControl(snowbridge_control::Event::CreateChannel {
..
}) => {},
Expand Down Expand Up @@ -209,9 +221,6 @@ fn register_token() {
AssetHubRococo,
vec![
RuntimeEvent::ForeignAssets(pallet_assets::Event::Created { .. }) => {},
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { message_id, .. }) => {
message_id: H256::from(*message_id) == message_id_,
},
]
);
});
Expand Down Expand Up @@ -271,9 +280,6 @@ fn send_token() {
AssetHubRococo,
vec![
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {},
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { message_id, .. }) => {
message_id: H256::from(*message_id) == message_id_,
},
]
);
});
Expand Down Expand Up @@ -335,9 +341,6 @@ fn reserve_transfer_token() {
AssetHubRococo,
vec![
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {},
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { message_id, .. }) => {
message_id: H256::from(*message_id) == message_id_,
},
]
);
let assets = vec![MultiAsset {
Expand Down Expand Up @@ -379,7 +382,6 @@ fn reserve_transfer_token() {
BridgeHubRococo,
vec![
RuntimeEvent::EthereumOutboundQueue(snowbridge_outbound_queue::Event::MessageQueued {..}) => {},
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {},
]
);
let events = BridgeHubRococo::events();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ use parachains_common::{
};

#[cfg(feature = "runtime-benchmarks")]
use crate::xcm_config::benchmark_helper::DoNothingRouter;
use crate::xcm_config::DoNothingRouter;
#[cfg(feature = "runtime-benchmarks")]
use snowbridge_beacon_primitives::CompactExecutionHeader;
#[cfg(feature = "runtime-benchmarks")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ impl Contains<RuntimeCall> for SafeCallFilter {
snowbridge_ethereum_beacon_client::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumInboundQueue(
snowbridge_inbound_queue::Call::set_operating_mode { .. },
) /* | RuntimeCall::EthereumOutboundQueue(
snowbridge_outbound_queue::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumControl(..) */
) | RuntimeCall::EthereumOutboundQueue(
snowbridge_outbound_queue::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumControl(..)
)
}
}
Expand Down Expand Up @@ -488,3 +488,14 @@ impl<
fee
}
}

pub struct DoNothingRouter;
impl SendXcm for DoNothingRouter {
type Ticket = ();
fn validate(_dest: &mut Option<MultiLocation>, _msg: &mut Option<Xcm<()>>) -> SendResult<()> {
Ok(((), MultiAssets::new()))
}
fn deliver(_: ()) -> Result<XcmHash, SendError> {
Ok([0; 32])
}
}

0 comments on commit 409ad4d

Please sign in to comment.