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

Commit

Permalink
Fix compile error & breaking tests (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong authored Nov 25, 2023
1 parent 585e5cb commit e9fd347
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 132 deletions.
4 changes: 4 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 @@ -38,6 +38,7 @@ decl_test_parachains! {
XcmpMessageHandler: asset_hub_westend_runtime::XcmpQueue,
LocationToAccountId: asset_hub_westend_runtime::xcm_config::LocationToAccountId,
ParachainInfo: asset_hub_westend_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: asset_hub_westend_runtime::PolkadotXcm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ 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" }
bridge-hub-common = { path = "../../../../../../runtimes/bridge-hubs/common", default-features = false }

# Snowbridge
snowbridge-core = { path = "../../../../../../../../../parachain/primitives/core", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ decl_test_parachains! {
XcmpMessageHandler: bridge_hub_rococo_runtime::XcmpQueue,
LocationToAccountId: bridge_hub_rococo_runtime::xcm_config::LocationToAccountId,
ParachainInfo: bridge_hub_rococo_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
MessageOrigin: bridge_hub_common::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ 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-westend-runtime = { path = "../../../../../../runtimes/bridge-hubs/bridge-hub-westend" }
bridge-hub-common = { path = "../../../../../../runtimes/bridge-hubs/common", default-features = false }
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ decl_test_parachains! {
XcmpMessageHandler: bridge_hub_westend_runtime::XcmpQueue,
LocationToAccountId: bridge_hub_westend_runtime::xcm_config::LocationToAccountId,
ParachainInfo: bridge_hub_westend_runtime::ParachainInfo,
MessageOrigin: bridge_hub_common::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: bridge_hub_westend_runtime::PolkadotXcm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ rococo-westend-system-emulated-network = { path = "../../../networks/rococo-west
bridge-hub-rococo-emulated-chain = { path = "../../../chains/parachains/bridges/bridge-hub-rococo"}
asset-hub-rococo-emulated-chain = { path = "../../../chains/parachains/assets/asset-hub-rococo"}
penpal-emulated-chain = { path = "../../../chains/parachains/testing/penpal" }
penpal-runtime = { path = "../../../../../runtimes/testing/penpal" }
rococo-system-emulated-network ={ path = "../../../networks/rococo-system" }

# Snowbridge
snowbridge-core = { path = "../../../../../../../../parachain/primitives/core", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ pub use emulated_integration_tests_common::{
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
};
pub use parachains_common::{AccountId, Balance};
pub use rococo_system_emulated_network::{
penpal_emulated_chain::PenpalAParaPallet as PenpalAPallet,
BridgeHubRococoParaReceiver as BridgeHubRococoReceiver, PenpalAPara as PenpalA,
PenpalAParaReceiver as PenpalAReceiver, PenpalAParaSender as PenpalASender,
};
pub use rococo_westend_system_emulated_network::{
asset_hub_rococo_emulated_chain::{
genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococoParaPallet as AssetHubRococoPallet,
Expand All @@ -51,16 +56,13 @@ pub use rococo_westend_system_emulated_network::{
bridge_hub_rococo_emulated_chain::{
genesis::ED as BRIDGE_HUB_ROCOCO_ED, BridgeHubRococoParaPallet as BridgeHubRococoPallet,
},
penpal_emulated_chain::PenpalAParaPallet as PenpalAPallet,
rococo_emulated_chain::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet},
AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver,
AssetHubRococoParaSender as AssetHubRococoSender, AssetHubWestendPara as AssetHubWestend,
AssetHubWestendParaReceiver as AssetHubWestendReceiver, BridgeHubRococoPara as BridgeHubRococo,
BridgeHubRococoParaReceiver as BridgeHubRococoReceiver,
BridgeHubRococoParaSender as BridgeHubRococoSender, BridgeHubWestendPara as BridgeHubWestend,
PenpalAPara as PenpalA, PenpalAParaReceiver as PenpalAReceiver,
PenpalAParaSender as PenpalASender, RococoRelay as Rococo,
RococoRelayReceiver as RococoReceiver, RococoRelaySender as RococoSender,
RococoRelay as Rococo, RococoRelayReceiver as RococoReceiver,
RococoRelaySender as RococoSender,
};

pub const ASSET_ID: u32 = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,102 +224,95 @@ fn register_token() {
});
}

#[test]
fn send_token_to_penpal() {
let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(
MultiLocation {
parents: 1,
interior: X1(Parachain(ASSETHUB_PARA_ID)),
}
);
BridgeHubRococo::fund_accounts(vec![(
asset_hub_sovereign.clone(),
INITIAL_FUND,
)]);

// Fund ethereum sovereign in asset hub
AssetHubRococo::fund_accounts(vec![
(AssetHubRococoReceiver::get(), INITIAL_FUND),
]);

PenpalA::fund_accounts(vec![
(PenpalAReceiver::get(), INITIAL_FUND),
(PenpalASender::get(), INITIAL_FUND),
]);

let weth_asset_id: MultiLocation = (
Parent,
Parent,
Ethereum { chain_id: 15 },
AccountKey20 { network: None, key: WETH }
).into();

// Create asset on penpal.
PenpalA::execute_with(|| {
assert_ok!(<PenpalA as PenpalAPallet>::ForeignAssets::create(
<PenpalA as Chain>::RuntimeOrigin::signed(PenpalASender::get()),
weth_asset_id,
asset_hub_sovereign.into(),
1000,
));

//assert!(<PenpalA as PenpalAPallet>::Assets::asset_exists(weth_asset_id));
});

let message_id_: H256 = [1; 32].into();

BridgeHubRococo::execute_with(|| {
type RuntimeEvent = <BridgeHubRococo as Chain>::RuntimeEvent;
type EthereumInboundQueue =
<BridgeHubRococo as BridgeHubRococoPallet>::EthereumInboundQueue;
let message = VersionedMessage::V1(MessageV1 {
chain_id: CHAIN_ID,
command: Command::RegisterToken { token: WETH.into() },
});
let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap();
let message = VersionedMessage::V1(MessageV1 {
chain_id: CHAIN_ID,
command: Command::SendToken {
token: WETH.into(),
destination: Destination::ForeignAccountId32 { para_id: 2000, id: PenpalAReceiver::get().into() },
amount: 1_000_000_000,
},
});
let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap();

assert_expected_events!(
BridgeHubRococo,
vec![
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {},
]
);
});

AssetHubRococo::execute_with(|| {
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;

assert_expected_events!(
AssetHubRococo,
vec![
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {},
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {},
]
);
});

PenpalA::execute_with(|| {
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;

assert_expected_events!(
PenpalA,
vec![
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {},
]
);
});
}
// #[test]
// fn send_token_to_penpal() {
// let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation {
// parents: 1,
// interior: X1(Parachain(ASSETHUB_PARA_ID)),
// });
// BridgeHubRococo::fund_accounts(vec![(asset_hub_sovereign.clone(), INITIAL_FUND)]);
//
// // Fund ethereum sovereign in asset hub
// AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]);
//
// PenpalA::fund_accounts(vec![
// (PenpalAReceiver::get(), INITIAL_FUND),
// (PenpalASender::get(), INITIAL_FUND),
// ]);
//
// let weth_asset_id: MultiLocation =
// (Parent, Parent, Ethereum { chain_id: 15 }, AccountKey20 { network: None, key: WETH })
// .into();
//
// // Create asset on penpal.
// PenpalA::execute_with(|| {
// assert_ok!(<PenpalA as PenpalAPallet>::ForeignAssets::create(
// <PenpalA as Chain>::RuntimeOrigin::signed(PenpalASender::get()),
// weth_asset_id,
// asset_hub_sovereign.into(),
// 1000,
// ));
//
// //assert!(<PenpalA as PenpalAPallet>::Assets::asset_exists(weth_asset_id));
// });
//
// let message_id_: H256 = [1; 32].into();
//
// BridgeHubRococo::execute_with(|| {
// type RuntimeEvent = <BridgeHubRococo as Chain>::RuntimeEvent;
// type EthereumInboundQueue =
// <BridgeHubRococo as BridgeHubRococoPallet>::EthereumInboundQueue;
// let message = VersionedMessage::V1(MessageV1 {
// chain_id: CHAIN_ID,
// command: Command::RegisterToken { token: WETH.into() },
// });
// let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap();
// let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap();
// let message = VersionedMessage::V1(MessageV1 {
// chain_id: CHAIN_ID,
// command: Command::SendToken {
// token: WETH.into(),
// destination: Destination::ForeignAccountId32 {
// para_id: 2000,
// id: PenpalAReceiver::get().into(),
// },
// amount: 1_000_000_000,
// },
// });
// let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap();
// let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap();
//
// assert_expected_events!(
// BridgeHubRococo,
// vec![
// RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {},
// ]
// );
// });
//
// AssetHubRococo::execute_with(|| {
// type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
//
// assert_expected_events!(
// AssetHubRococo,
// vec![
// RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {},
// RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {},
// ]
// );
// });
//
// PenpalA::execute_with(|| {
// type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
//
// assert_expected_events!(
// PenpalA,
// vec![
// RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {},
// ]
// );
// });
// }

#[test]
fn send_token() {
Expand All @@ -332,9 +325,7 @@ fn send_token() {
)]);

// Fund ethereum sovereign in asset hub
AssetHubRococo::fund_accounts(vec![
(AssetHubRococoReceiver::get(), INITIAL_FUND),
]);
AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]);

let message_id_: H256 = [1; 32].into();

Expand Down Expand Up @@ -381,20 +372,14 @@ fn send_token() {

#[test]
fn reserve_transfer_token() {
let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of(
MultiLocation {
parents: 1,
interior: X1(Parachain(ASSETHUB_PARA_ID)),
}
);
let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation {
parents: 1,
interior: X1(Parachain(ASSETHUB_PARA_ID)),
});

BridgeHubRococo::fund_accounts(vec![
(assethub_sovereign.clone(), INITIAL_FUND)
]);
BridgeHubRococo::fund_accounts(vec![(assethub_sovereign.clone(), INITIAL_FUND)]);

AssetHubRococo::fund_accounts(vec![
(AssetHubRococoReceiver::get(), INITIAL_FUND),
]);
AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]);

const WETH_AMOUNT: u128 = 1_000_000_000;
let message_id_: H256 = [1; 32].into();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
//! Runtime configuration for MessageQueue pallet
use codec::{Decode, Encode, MaxEncodedLen};
use cumulus_primitives_core::ParaId;
use cumulus_primitives_core::{AggregateMessageOrigin as CumulusAggregateMessageOrigin, ParaId};
use frame_support::{
traits::{ProcessMessage, ProcessMessageError, QueueFootprint, QueuePausedQuery},
weights::WeightMeter,
Expand Down Expand Up @@ -57,6 +57,16 @@ impl From<AggregateMessageOrigin> for MultiLocation {
}
}

impl From<CumulusAggregateMessageOrigin> for AggregateMessageOrigin {
fn from(origin: CumulusAggregateMessageOrigin) -> Self {
match origin {
CumulusAggregateMessageOrigin::Here => Self::Here,
CumulusAggregateMessageOrigin::Parent => Self::Parent,
CumulusAggregateMessageOrigin::Sibling(id) => Self::Sibling(id),
}
}
}

#[cfg(feature = "runtime-benchmarks")]
impl From<u32> for AggregateMessageOrigin {
fn from(x: u32) -> Self {
Expand Down
7 changes: 0 additions & 7 deletions cumulus/primitives/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ pub enum AggregateMessageOrigin {
///
/// This is used by the HRMP queue.
Sibling(ParaId),
/// The message came from some origin identified by a 32-byte ID.
///
/// Due to its generality, this is can be used by pallets
/// other than the DMP and HRMP queue.
GeneralKey([u8; 32]),
}

impl From<AggregateMessageOrigin> for xcm::v3::MultiLocation {
Expand All @@ -105,8 +100,6 @@ impl From<AggregateMessageOrigin> for xcm::v3::MultiLocation {
AggregateMessageOrigin::Parent => MultiLocation::parent(),
AggregateMessageOrigin::Sibling(id) =>
MultiLocation::new(1, Junction::Parachain(id.into())),
AggregateMessageOrigin::GeneralKey(id) =>
MultiLocation::new(0, Junction::GeneralKey { length: 32, data: id }),
}
}
}
Expand Down
Loading

0 comments on commit e9fd347

Please sign in to comment.