Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ case "$1" in
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V5": { "parents": 0, "interior": { "X1": [{ "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } }] } } }')" \
"$(jq --null-input '{ "V5": [ { "id": { "parents": 1, "interior": "Here" }, "fun": { "Fungible": '$amount' } } ] }')" \
"$(jq --null-input '{ "V5": { "parents": 1, "interior": "Here" } }')" \
0 \
"Unlimited"
;;
withdraw-reserve-assets-from-asset-hub-rococo-local)
Expand All @@ -380,7 +380,7 @@ case "$1" in
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V5": { "parents": 0, "interior": { "X1": [{ "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } }] } } }')" \
"$(jq --null-input '{ "V5": [ { "id": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } }, "fun": { "Fungible": '$amount' } } ] }')" \
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } } }')" \
0 \
"Unlimited"
;;
reserve-transfer-assets-from-asset-hub-westend-local)
Expand All @@ -393,7 +393,7 @@ case "$1" in
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V5": { "parents": 0, "interior": { "X1": [{ "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } }] } } }')" \
"$(jq --null-input '{ "V5": [ { "id": { "parents": 1, "interior": "Here" }, "fun": { "Fungible": '$amount' } } ] }')" \
"$(jq --null-input '{ "V5": { "parents": 1, "interior": "Here" } }')" \
0 \
"Unlimited"
;;
withdraw-reserve-assets-from-asset-hub-westend-local)
Expand All @@ -406,7 +406,7 @@ case "$1" in
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V5": { "parents": 0, "interior": { "X1": [{ "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } }] } } }')" \
"$(jq --null-input '{ "V5": [ { "id": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } }, "fun": { "Fungible": '$amount' } } ] }')" \
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } } }')" \
0 \
"Unlimited"
;;
claim-rewards-bridge-hub-rococo-local)
Expand Down
6 changes: 3 additions & 3 deletions bridges/testing/framework/utils/bridges.sh
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,15 @@ function limited_reserve_transfer_assets() {
local destination=$3
local beneficiary=$4
local assets=$5
local fee_asset_id=$6
local fee_asset_item=$6
local weight_limit=$7
echo " calling limited_reserve_transfer_assets:"
echo " url: ${url}"
echo " seed: ${seed}"
echo " destination: ${destination}"
echo " beneficiary: ${beneficiary}"
echo " assets: ${assets}"
echo " fee_asset_id: ${fee_asset_id}"
echo " fee_asset_item: ${fee_asset_item}"
echo " weight_limit: ${weight_limit}"
echo ""
echo "--------------------------------------------------"
Expand All @@ -304,7 +304,7 @@ function limited_reserve_transfer_assets() {
"${destination}" \
"${beneficiary}" \
"${assets}" \
"${fee_asset_id}" \
"${fee_asset_item}" \
"${weight_limit}"
}

Expand Down
2 changes: 1 addition & 1 deletion cumulus/parachains/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ where
.into(),
),
Box::new((Parent, imbalance).into()),
Box::new(Parent.into()),
0,
WeightLimit::Unlimited,
);

Expand Down
20 changes: 10 additions & 10 deletions cumulus/parachains/integration-tests/emulated/common/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ pub use crate::{ASSETS_PALLET_ID, USDT_ID};

#[macro_export]
macro_rules! test_parachain_is_trusted_teleporter {
( $sender_para:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr), $fee_asset_id:expr, $xcm_call:ident ) => {
( $sender_para:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr), $xcm_call:ident ) => {
$crate::macros::paste::paste! {
// init Origin variables
let sender = [<$sender_para Sender>]::get();
let mut para_sender_balance_before =
<$sender_para as $crate::macros::Chain>::account_data_of(sender.clone()).free;
let origin = <$sender_para as $crate::macros::Chain>::RuntimeOrigin::signed(sender.clone());
let fee_asset_item = 0;
let weight_limit = $crate::macros::WeightLimit::Unlimited;

$(
Expand All @@ -92,7 +93,7 @@ macro_rules! test_parachain_is_trusted_teleporter {
dest: Box::new(para_destination.clone().into()),
beneficiary: Box::new(beneficiary.clone().into()),
assets: Box::new($assets.clone().into()),
fee_asset_id: Box::new($fee_asset_id.clone().into()),
fee_asset_item: fee_asset_item,
weight_limit: weight_limit.clone(),
});

Expand Down Expand Up @@ -207,14 +208,13 @@ macro_rules! test_parachain_is_trusted_teleporter {

#[macro_export]
macro_rules! test_relay_is_trusted_teleporter {
( $sender_relay:ty, vec![$( $receiver_para:ty ),+], $amount:expr, $xcm_call:ident ) => {
( $sender_relay:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr), $xcm_call:ident ) => {
$crate::macros::paste::paste! {
// init Origin variables
let sender = [<$sender_relay Sender>]::get();
let mut relay_sender_balance_before =
<$sender_relay as $crate::macros::Chain>::account_data_of(sender.clone()).free;
let assets: $crate::macros::Assets = ($crate::macros::Here, $amount).into();
let fee_asset_id: $crate::macros::AssetId = ($crate::macros::Here).into();
let fee_asset_item = 0;
let weight_limit = $crate::macros::WeightLimit::Unlimited;

$(
Expand All @@ -234,8 +234,8 @@ macro_rules! test_relay_is_trusted_teleporter {
$crate::macros::pallet_xcm::Call::$xcm_call {
dest: Box::new(para_destination.clone().into()),
beneficiary: Box::new(beneficiary.clone().into()),
assets: Box::new(assets.clone().into()),
fee_asset_id: Box::new(fee_asset_id.clone().into()),
assets: Box::new($assets.clone().into()),
fee_asset_item: fee_asset_item,
weight_limit: weight_limit.clone(),
});

Expand Down Expand Up @@ -362,7 +362,7 @@ macro_rules! test_parachain_is_trusted_teleporter_for_relay {
<$sender_para as $crate::macros::Chain>::account_data_of(sender.clone()).free;
let origin = <$sender_para as $crate::macros::Chain>::RuntimeOrigin::signed(sender.clone());
let assets: $crate::macros::Assets = ($crate::macros::Parent, $amount).into();
let fee_asset_id: $crate::macros::AssetId = ($crate::macros::Parent).into();
let fee_asset_item = 0;
let weight_limit = $crate::macros::WeightLimit::Unlimited;

// We need to mint funds into the checking account of `$receiver_relay`
Expand All @@ -388,7 +388,7 @@ macro_rules! test_parachain_is_trusted_teleporter_for_relay {
dest: Box::new(relay_destination.clone().into()),
beneficiary: Box::new(beneficiary.clone().into()),
assets: Box::new(assets.clone().into()),
fee_asset_id: Box::new(fee_asset_id.clone().into()),
fee_asset_item: fee_asset_item,
weight_limit: weight_limit.clone(),
});

Expand Down Expand Up @@ -685,7 +685,7 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
$amount,
($asset_id, $amount).into(),
None,
($asset_id).into(),
0,
),
};
let mut test = ParaToParaThroughAHTest::new(test_args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ pub fn xcm_transact_unpaid_execution(
}

/// Helper method to get the non-fee asset used in multiple assets transfer
pub fn non_fee_asset(assets: &Assets, fee_asset_id: &AssetId) -> Option<(Location, u128)> {
let asset = assets.inner().into_iter().find(|a| a.id != *fee_asset_id)?;
pub fn non_fee_asset(assets: &Assets, fee_idx: usize) -> Option<(Location, u128)> {
let asset = assets.inner().into_iter().enumerate().find(|a| a.0 != fee_idx)?.1.clone();
let asset_amount = match asset.fun {
Fungible(amount) => amount,
_ => return None,
};
Some((asset.id.0.clone(), asset_amount))
Some((asset.id.0, asset_amount))
}

/// Helper method to get the fee asset used in multiple assets transfer
pub fn fee_asset(assets: &Assets, fee_asset_id: &AssetId) -> Option<(Location, u128)> {
let asset = assets.inner().iter().find(|a| a.id == *fee_asset_id)?;
pub fn fee_asset(assets: &Assets, fee_idx: usize) -> Option<(Location, u128)> {
let asset = assets.get(fee_idx)?;
let asset_amount = match asset.fun {
Fungible(amount) => amount,
_ => return None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,8 @@ fn para_to_para_assethub_hop_assertions(t: ParaToParaThroughAHTest) {
}

fn ah_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
let fee: Asset = t
.args
.assets
.inner()
.iter()
.find(|a| a.id == t.args.fee_asset_id)
.cloned()
.unwrap();
let fee_idx = t.args.fee_asset_item as usize;
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset {
assets: Wild(AllCounted(t.args.assets.len() as u32)),
beneficiary: t.args.beneficiary,
Expand All @@ -77,14 +71,8 @@ fn ah_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
}

fn para_to_ah_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
let fee: Asset = t
.args
.assets
.inner()
.iter()
.find(|a| a.id == t.args.fee_asset_id)
.cloned()
.unwrap();
let fee_idx = t.args.fee_asset_item as usize;
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset {
assets: Wild(AllCounted(t.args.assets.len() as u32)),
beneficiary: t.args.beneficiary,
Expand All @@ -102,14 +90,8 @@ fn para_to_ah_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
}

fn para_to_para_transfer_assets_through_ah(t: ParaToParaThroughAHTest) -> DispatchResult {
let fee: Asset = t
.args
.assets
.inner()
.iter()
.find(|a| a.id == t.args.fee_asset_id)
.cloned()
.unwrap();
let fee_idx = t.args.fee_asset_item as usize;
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
let asset_hub_location: Location = PenpalA::sibling_location_of(AssetHubRococo::para_id());
let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset {
assets: Wild(AllCounted(t.args.assets.len() as u32)),
Expand All @@ -128,14 +110,8 @@ fn para_to_para_transfer_assets_through_ah(t: ParaToParaThroughAHTest) -> Dispat
}

fn para_to_asset_hub_teleport_foreign_assets(t: ParaToSystemParaTest) -> DispatchResult {
let fee: Asset = t
.args
.assets
.inner()
.iter()
.find(|a| a.id == t.args.fee_asset_id)
.cloned()
.unwrap();
let fee_idx = t.args.fee_asset_item as usize;
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset {
assets: Wild(AllCounted(t.args.assets.len() as u32)),
beneficiary: t.args.beneficiary,
Expand All @@ -153,14 +129,8 @@ fn para_to_asset_hub_teleport_foreign_assets(t: ParaToSystemParaTest) -> Dispatc
}

fn asset_hub_to_para_teleport_foreign_assets(t: SystemParaToParaTest) -> DispatchResult {
let fee: Asset = t
.args
.assets
.inner()
.iter()
.find(|a| a.id == t.args.fee_asset_id)
.cloned()
.unwrap();
let fee_idx = t.args.fee_asset_item as usize;
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset {
assets: Wild(AllCounted(t.args.assets.len() as u32)),
beneficiary: t.args.beneficiary,
Expand Down Expand Up @@ -232,6 +202,7 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
(wnd_at_rococo_parachains.clone(), foreign_amount_to_send).into(),
];
let fee_asset_id = AssetId(Parent.into());
let fee_asset_item = assets.iter().position(|a| a.id == fee_asset_id).unwrap() as u32;

// Init Test
let test_args = TestContext {
Expand All @@ -243,7 +214,7 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
native_amount_to_send,
assets.into(),
None,
fee_asset_id,
fee_asset_item,
),
};
let mut test = SystemParaToParaTest::new(test_args);
Expand Down Expand Up @@ -386,6 +357,7 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
(wnd_at_rococo_parachains.clone(), foreign_amount_to_send).into(),
];
let fee_asset_id = AssetId(Parent.into());
let fee_asset_item = assets.iter().position(|a| a.id == fee_asset_id).unwrap() as u32;

// Init Test
let test_args = TestContext {
Expand All @@ -397,7 +369,7 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
native_amount_to_send,
assets.into(),
None,
fee_asset_id,
fee_asset_item,
),
};
let mut test = ParaToSystemParaTest::new(test_args);
Expand Down Expand Up @@ -553,6 +525,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
(wnd_at_rococo_parachains.clone(), wnd_to_send).into(),
];
let fee_asset_id: AssetId = roc_location.clone().into();
let fee_asset_item = assets.iter().position(|a| a.id == fee_asset_id).unwrap() as u32;

// Init Test
let test_args = TestContext {
Expand All @@ -564,7 +537,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
roc_to_send,
assets.into(),
None,
fee_asset_id,
fee_asset_item,
),
};
let mut test = ParaToParaThroughAHTest::new(test_args);
Expand Down Expand Up @@ -777,14 +750,8 @@ fn transfer_native_asset_from_relay_to_para_through_asset_hub() {
);
}
fn transfer_assets_dispatchable(t: RelayToParaThroughAHTest) -> DispatchResult {
let fee: Asset = t
.args
.assets
.inner()
.iter()
.find(|a| a.id == t.args.fee_asset_id)
.cloned()
.unwrap();
let fee_idx = t.args.fee_asset_item as usize;
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
let asset_hub_location = Rococo::child_location_of(AssetHubRococo::para_id());
let context = RococoUniversalLocation::get();

Expand Down
Loading
Loading