Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve xcm integration test with CI #988

Merged
merged 30 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0f43b92
Update sdk
yrong Nov 2, 2023
235c581
Merge branch 'main' into ron/xcm-integration-test
yrong Nov 2, 2023
b5911d9
Improve integration tests with CI
yrong Nov 2, 2023
ae15055
Revert to MessageReceived
yrong Nov 6, 2023
39027c0
Merge recent from main branch
yrong Nov 6, 2023
bcc4c32
Resolve conflict
yrong Nov 6, 2023
60102b2
Change to Ethereum sovereign
yrong Nov 6, 2023
eea7edc
Update sdk
yrong Nov 6, 2023
9eccb77
remove gateway
alistair-singh Nov 6, 2023
1d3a6ec
updated polkadot
alistair-singh Nov 6, 2023
a30945b
new parsing code
alistair-singh Nov 6, 2023
f0e0b0d
added test for clear origin
alistair-singh Nov 6, 2023
8afa1dd
validate fees
alistair-singh Nov 6, 2023
6021da8
fix clippy
alistair-singh Nov 6, 2023
353ba9b
make set topic optional
alistair-singh Nov 6, 2023
f07cdf7
Add tests for token transfer
yrong Nov 6, 2023
f1abd08
make clear origin and set topic optional
alistair-singh Nov 6, 2023
450e499
Merge branch 'ron/xcm-integration-test' into ron/new-reserve-transfer…
yrong Nov 7, 2023
12c2d58
make buy execution optional
alistair-singh Nov 7, 2023
4618668
rename
alistair-singh Nov 7, 2023
da15bbc
changed name
alistair-singh Nov 7, 2023
7353005
updated polkadot-sdk
alistair-singh Nov 7, 2023
433a0e3
Update sdk
yrong Nov 2, 2023
0e573e3
Improve integration tests with CI
yrong Nov 2, 2023
e8b9ba3
Revert to MessageReceived
yrong Nov 6, 2023
68afc53
Merge recent from main branch
yrong Nov 6, 2023
cac39fc
update polkadot-sdk
alistair-singh Nov 7, 2023
9ec35f3
Merge branch 'main' into ron/xcm-integration-test
alistair-singh Nov 7, 2023
87b9832
Merge branch 'main' into ron/xcm-integration-test
yrong Nov 8, 2023
8501967
Merge branch 'ron/xcm-integration-test' of https://github.com/Snowfor…
yrong Nov 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
30 changes: 21 additions & 9 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 @@ -130,8 +130,8 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T> {
/// A message was received from Ethereum
MessageReceived {
/// Xcm message sent to dest chain
MessageSent {
yrong marked this conversation as resolved.
Show resolved Hide resolved
/// The destination parachain
dest: ParaId,
/// The message nonce
Expand Down Expand Up @@ -245,16 +245,14 @@ 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 {
Self::deposit_event(Event::MessageSent {
dest: envelope.dest,
nonce: envelope.nonce,
xcm_hash,
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/pallets/inbound-queue/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ fn test_submit_happy_path() {
},
};
assert_ok!(InboundQueue::submit(origin.clone(), message.clone()));
expect_events(vec![InboundQueueEvent::MessageReceived {
expect_events(vec![InboundQueueEvent::MessageSent {
dest: ASSET_HUB_PARAID.into(),
nonce: 1,
xcm_hash: XCM_HASH,
Expand Down
Loading