Skip to content

Commit

Permalink
Merge branch 'ron/xcm-integration-test' into ron/new-reserve-transfer…
Browse files Browse the repository at this point in the history
…-with-emulated-tests
  • Loading branch information
yrong committed Nov 7, 2023
2 parents f1abd08 + f07cdf7 commit 450e499
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 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)
}
}
}

0 comments on commit 450e499

Please sign in to comment.