Skip to content

Commit

Permalink
Improve xcm integration test with CI (#988)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
yrong and alistair-singh authored Nov 8, 2023
1 parent 7b2d4aa commit ecc8ae9
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/parachain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/BeefyClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
24 changes: 18 additions & 6 deletions parachain/pallets/inbound-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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::<T>::ConvertMessage(e))?,
Ok(message) => Self::do_convert(message)?,
Err(_) => return Err(Error::<T>::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::<T::XcmSender>(dest, xcm).map_err(Error::<T>::from)?;
let xcm_hash = Self::send_xcm(xcm, envelope.dest)?;

Self::deposit_event(Event::MessageReceived {
dest: envelope.dest,
Expand All @@ -276,4 +274,18 @@ pub mod pallet {
Ok(())
}
}

impl<T: Config> Pallet<T> {
pub fn do_convert(message: inbound::VersionedMessage) -> Result<Xcm<()>, Error<T>> {
let xcm =
T::MessageConverter::convert(message).map_err(|e| Error::<T>::ConvertMessage(e))?;
Ok(xcm)
}

pub fn send_xcm(xcm: Xcm<()>, dest: ParaId) -> Result<XcmHash, Error<T>> {
let dest = MultiLocation { parents: 1, interior: X1(Parachain(dest.into())) };
let (xcm_hash, _) = send_xcm::<T::XcmSender>(dest, xcm).map_err(Error::<T>::from)?;
Ok(xcm_hash)
}
}
}
2 changes: 1 addition & 1 deletion parachain/primitives/router/src/outbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit ecc8ae9

Please sign in to comment.