Skip to content
Open
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' } } ] }')" \
0 \
"$(jq --null-input '{ "V5": { "parents": 1, "interior": "Here" } }')" \
"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' } } ] }')" \
0 \
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } } }')" \
"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' } } ] }')" \
0 \
"$(jq --null-input '{ "V5": { "parents": 1, "interior": "Here" } }')" \
"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' } } ] }')" \
0 \
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } } }')" \
"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_item=$6
local fee_asset_id=$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_item: ${fee_asset_item}"
echo " fee_asset_id: ${fee_asset_id}"
echo " weight_limit: ${weight_limit}"
echo ""
echo "--------------------------------------------------"
Expand All @@ -304,7 +304,7 @@ function limited_reserve_transfer_assets() {
"${destination}" \
"${beneficiary}" \
"${assets}" \
"${fee_asset_item}" \
"${fee_asset_id}" \
"${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()),
0,
Box::new(Parent.into()),
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,14 +65,13 @@ 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), $xcm_call:ident ) => {
( $sender_para:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr), $fee_asset_id: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 @@ -93,7 +92,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_item: fee_asset_item,
fee_asset_id: Box::new($fee_asset_id.clone().into()),
weight_limit: weight_limit.clone(),
});

Expand Down Expand Up @@ -202,13 +201,14 @@ macro_rules! test_parachain_is_trusted_teleporter {

#[macro_export]
macro_rules! test_relay_is_trusted_teleporter {
( $sender_relay:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr), $xcm_call:ident ) => {
( $sender_relay:ty, vec![$( $receiver_para:ty ),+], $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 fee_asset_item = 0;
let assets: $crate::macros::Assets = ($crate::macros::Here, $amount).into();
let fee_asset_id: $crate::macros::AssetId = ($crate::macros::Here).into();
let weight_limit = $crate::macros::WeightLimit::Unlimited;

$(
Expand All @@ -228,8 +228,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_item: fee_asset_item,
assets: Box::new(assets.clone().into()),
fee_asset_id: Box::new(fee_asset_id.clone().into()),
weight_limit: weight_limit.clone(),
});

Expand Down Expand Up @@ -350,7 +350,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_item = 0;
let fee_asset_id: $crate::macros::AssetId = ($crate::macros::Parent).into();
let weight_limit = $crate::macros::WeightLimit::Unlimited;

// We need to mint funds into the checking account of `$receiver_relay`
Expand All @@ -376,7 +376,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_item: fee_asset_item,
fee_asset_id: Box::new(fee_asset_id.clone().into()),
weight_limit: weight_limit.clone(),
});

Expand Down Expand Up @@ -667,7 +667,7 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
$amount,
($asset_id, $amount).into(),
None,
0,
($asset_id).into(),
),
};
let mut test = ParaToParaThroughAHTest::new(test_args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,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_idx: usize) -> Option<(Location, u128)> {
let asset = assets.inner().into_iter().enumerate().find(|a| a.0 != fee_idx)?.1.clone();
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)?;
let asset_amount = match asset.fun {
Fungible(amount) => amount,
_ => return None,
};
Some((asset.id.0, asset_amount))
Some((asset.id.0.clone(), asset_amount))
}

/// Helper method to get the fee asset used in multiple assets transfer
pub fn fee_asset(assets: &Assets, fee_idx: usize) -> Option<(Location, u128)> {
let asset = assets.get(fee_idx)?;
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)?;
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,8 +52,14 @@ fn para_to_para_assethub_hop_assertions(t: ParaToParaThroughAHTest) {
}

fn ah_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
let fee_idx = t.args.fee_asset_item as usize;
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
let fee: Asset = t
.args
.assets
.inner()
.iter()
.find(|a| a.id == t.args.fee_asset_id)
.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 @@ -71,8 +77,14 @@ fn ah_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
}

fn para_to_ah_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
let fee_idx = t.args.fee_asset_item as usize;
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
let fee: Asset = t
.args
.assets
.inner()
.iter()
.find(|a| a.id == t.args.fee_asset_id)
.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 @@ -90,8 +102,14 @@ fn para_to_ah_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
}

fn para_to_para_transfer_assets_through_ah(t: ParaToParaThroughAHTest) -> DispatchResult {
let fee_idx = t.args.fee_asset_item as usize;
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
let fee: Asset = t
.args
.assets
.inner()
.iter()
.find(|a| a.id == t.args.fee_asset_id)
.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 @@ -110,8 +128,14 @@ fn para_to_para_transfer_assets_through_ah(t: ParaToParaThroughAHTest) -> Dispat
}

fn para_to_asset_hub_teleport_foreign_assets(t: ParaToSystemParaTest) -> DispatchResult {
let fee_idx = t.args.fee_asset_item as usize;
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
let fee: Asset = t
.args
.assets
.inner()
.iter()
.find(|a| a.id == t.args.fee_asset_id)
.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 @@ -129,8 +153,14 @@ fn para_to_asset_hub_teleport_foreign_assets(t: ParaToSystemParaTest) -> Dispatc
}

fn asset_hub_to_para_teleport_foreign_assets(t: SystemParaToParaTest) -> DispatchResult {
let fee_idx = t.args.fee_asset_item as usize;
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
let fee: Asset = t
.args
.assets
.inner()
.iter()
.find(|a| a.id == t.args.fee_asset_id)
.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 @@ -202,7 +232,6 @@ 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 @@ -214,7 +243,7 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
native_amount_to_send,
assets.into(),
None,
fee_asset_item,
fee_asset_id,
),
};
let mut test = SystemParaToParaTest::new(test_args);
Expand Down Expand Up @@ -357,7 +386,6 @@ 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 @@ -369,7 +397,7 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
native_amount_to_send,
assets.into(),
None,
fee_asset_item,
fee_asset_id,
),
};
let mut test = ParaToSystemParaTest::new(test_args);
Expand Down Expand Up @@ -525,7 +553,6 @@ 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 @@ -537,7 +564,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
roc_to_send,
assets.into(),
None,
fee_asset_item,
fee_asset_id,
),
};
let mut test = ParaToParaThroughAHTest::new(test_args);
Expand Down Expand Up @@ -750,8 +777,14 @@ fn transfer_native_asset_from_relay_to_para_through_asset_hub() {
);
}
fn transfer_assets_dispatchable(t: RelayToParaThroughAHTest) -> DispatchResult {
let fee_idx = t.args.fee_asset_item as usize;
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
let fee: Asset = t
.args
.assets
.inner()
.iter()
.find(|a| a.id == t.args.fee_asset_id)
.cloned()
.unwrap();
let asset_hub_location = Rococo::child_location_of(AssetHubRococo::para_id());
let context = RococoUniversalLocation::get();

Expand Down
Loading