From ecc8ae9350b3676bb3a111658b3669998fbf07cb Mon Sep 17 00:00:00 2001 From: Ron Date: Wed, 8 Nov 2023 11:05:19 +0800 Subject: [PATCH] Improve xcm integration test with CI (#988) * Update sdk * Improve integration tests with CI * Revert to MessageReceived * Merge recent from main branch * Change to Ethereum sovereign * Update sdk * remove gateway * updated polkadot * new parsing code * added test for clear origin * validate fees * fix clippy * make set topic optional * Add tests for token transfer * make clear origin and set topic optional * make buy execution optional * rename * changed name * updated polkadot-sdk * Update sdk * Improve integration tests with CI * Revert to MessageReceived * Merge recent from main branch * update polkadot-sdk --------- Co-authored-by: Alistair Singh --- .github/workflows/parachain.yml | 18 ++++++++++++++ contracts/src/BeefyClient.sol | 2 +- parachain/pallets/inbound-queue/src/lib.rs | 24 ++++++++++++++----- .../primitives/router/src/outbound/mod.rs | 2 +- polkadot-sdk | 2 +- 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/.github/workflows/parachain.yml b/.github/workflows/parachain.yml index 76a8d405e3..dd20041612 100644 --- a/.github/workflows/parachain.yml +++ b/.github/workflows/parachain.yml @@ -148,6 +148,24 @@ jobs: --package bridge-hub-rococo-runtime --features runtime-benchmarks + integration-tests: + needs: test + runs-on: snowbridge-runner + steps: + - uses: actions/checkout@v2 + with: + submodules: "true" + - uses: arduino/setup-protoc@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: setup rust toolchain + run: rustup show + - name: snowbridge integration + run: > + cargo test + --manifest-path polkadot-sdk/Cargo.toml + -p bridge-hub-rococo-integration-tests + beacon-fuzz: if: false needs: test diff --git a/contracts/src/BeefyClient.sol b/contracts/src/BeefyClient.sol index 0dc8ef7696..dafcb5e8b5 100644 --- a/contracts/src/BeefyClient.sol +++ b/contracts/src/BeefyClient.sol @@ -449,7 +449,7 @@ contract BeefyClient { // Start with the minimum number of signatures. uint256 numRequiredSignatures = minRequiredSignatures; - // We must substract minimumSignatures from the number of validators or we might end up + // We must subtract minimumSignatures from the number of validators or we might end up // requiring more signatures than there are validators. uint256 extraValidatorsLen = validatorSetLen.saturatingSub(minRequiredSignatures); if (extraValidatorsLen > 1) { diff --git a/parachain/pallets/inbound-queue/src/lib.rs b/parachain/pallets/inbound-queue/src/lib.rs index a48b8ff4ce..d937efe8b7 100644 --- a/parachain/pallets/inbound-queue/src/lib.rs +++ b/parachain/pallets/inbound-queue/src/lib.rs @@ -47,8 +47,8 @@ use frame_system::ensure_signed; use scale_info::TypeInfo; use sp_core::H160; use sp_std::convert::TryFrom; -use xcm::v3::{ - send_xcm, Junction::*, Junctions::*, MultiLocation, SendError as XcmpSendError, SendXcm, +use xcm::prelude::{ + send_xcm, Junction::*, Junctions::*, MultiLocation, SendError as XcmpSendError, SendXcm, Xcm, XcmHash, }; @@ -245,14 +245,12 @@ pub mod pallet { // Decode message into XCM let xcm = match inbound::VersionedMessage::decode_all(&mut envelope.payload.as_ref()) { - Ok(message) => T::MessageConverter::convert(message) - .map_err(|e| Error::::ConvertMessage(e))?, + Ok(message) => Self::do_convert(message)?, Err(_) => return Err(Error::::InvalidPayload.into()), }; // Attempt to send XCM to a dest parachain - let dest = MultiLocation { parents: 1, interior: X1(Parachain(envelope.dest.into())) }; - let (xcm_hash, _) = send_xcm::(dest, xcm).map_err(Error::::from)?; + let xcm_hash = Self::send_xcm(xcm, envelope.dest)?; Self::deposit_event(Event::MessageReceived { dest: envelope.dest, @@ -276,4 +274,18 @@ pub mod pallet { Ok(()) } } + + impl Pallet { + pub fn do_convert(message: inbound::VersionedMessage) -> Result, Error> { + let xcm = + T::MessageConverter::convert(message).map_err(|e| Error::::ConvertMessage(e))?; + Ok(xcm) + } + + pub fn send_xcm(xcm: Xcm<()>, dest: ParaId) -> Result> { + let dest = MultiLocation { parents: 1, interior: X1(Parachain(dest.into())) }; + let (xcm_hash, _) = send_xcm::(dest, xcm).map_err(Error::::from)?; + Ok(xcm_hash) + } + } } diff --git a/parachain/primitives/router/src/outbound/mod.rs b/parachain/primitives/router/src/outbound/mod.rs index 15814616b2..99bb027664 100644 --- a/parachain/primitives/router/src/outbound/mod.rs +++ b/parachain/primitives/router/src/outbound/mod.rs @@ -791,7 +791,7 @@ mod tests { } #[test] - fn xcm_converter_convert_without_clear_origin_yields_set_topic_expected() { + fn xcm_converter_convert_without_set_topic_yields_set_topic_expected() { let network = BridgedNetwork::get(); let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000"); diff --git a/polkadot-sdk b/polkadot-sdk index 0378a75a1f..0b22697c04 160000 --- a/polkadot-sdk +++ b/polkadot-sdk @@ -1 +1 @@ -Subproject commit 0378a75a1f7d32da9529bb1bdf860f1c9f2ed090 +Subproject commit 0b22697c04cb30d86fc618d3217d771b58ffd734