Skip to content
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1a5d2cf
stopped using TakeFirstAssetTrader in AH Rococo & Westend, parametris…
x3c41a Apr 29, 2025
5b13008
fmt
x3c41a Apr 29, 2025
110062f
prdoct
x3c41a Apr 29, 2025
0df29cc
Merge branch 'master' into rm_tak_first_asset_trader
x3c41a Apr 29, 2025
9bac89f
Merge branch 'master' into rm_tak_first_asset_trader
x3c41a Apr 30, 2025
a6c56eb
newline in prdoc
x3c41a Apr 30, 2025
4878293
Introduced a way to add configurable amount of both asset to the liqu…
x3c41a May 1, 2025
110e6c5
Merge branch 'master' into rm_tak_first_asset_trader
x3c41a May 1, 2025
9a37952
removed unused import
x3c41a May 1, 2025
7b58abd
Merge branch 'master' into rm_tak_first_asset_trader
x3c41a May 1, 2025
98538a3
Changed to Westend fix only
x3c41a May 1, 2025
5cae428
Merge branch 'master' into rm_tak_first_asset_trader
x3c41a May 1, 2025
a21c540
removed the tests that were verifying first_asset_trader functionalit…
x3c41a May 1, 2025
50f090a
removed unused imports
x3c41a May 1, 2025
3ead716
fixed other emulated failing tests
x3c41a May 1, 2025
5580912
fixed other snowbridge tests
x3c41a May 1, 2025
908f771
improved snowbridge macro and fixed the tests
x3c41a May 2, 2025
c75d8f8
prdoc
x3c41a May 2, 2025
f5505f2
Merge branch 'master' into rm_tak_first_asset_trader
x3c41a May 2, 2025
d3b842a
prdoc fix
x3c41a May 2, 2025
85e4c99
fmt
x3c41a May 2, 2025
f56b178
snowbridge fmt
x3c41a May 2, 2025
14d3d48
removed unused helper types
x3c41a May 2, 2025
023861d
removed unused import
x3c41a May 2, 2025
7afb1d4
Merge branch 'master' into rm_tak_first_asset_trader
x3c41a May 2, 2025
ec6fabc
removed rococo config
x3c41a May 2, 2025
d37dc44
removed take_first_trader_tests
x3c41a May 2, 2025
14651af
fixed or remove some asset-hub-rococo-runtime tests
x3c41a May 2, 2025
cb07b26
commented out failing AH westend & rococo tests. I'll investigate the…
x3c41a May 2, 2025
1f1cb9a
improved commenting out
x3c41a May 2, 2025
bc6b98a
removed unused rococo imports
x3c41a May 2, 2025
159d8ed
Merge branch 'master' into rm_tak_first_asset_trader
x3c41a May 2, 2025
7a78c22
fmt
x3c41a May 2, 2025
e30f79c
removed unused imports from ahw-emulated-chain
x3c41a May 2, 2025
d2c84a8
removed unused imports from ahw-emulated-chain[2]
x3c41a May 2, 2025
c178347
fmt
x3c41a May 2, 2025
05cf055
fixed AHW send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_…
x3c41a May 2, 2025
23d2322
removed unused import
x3c41a May 2, 2025
f0edff0
fmt
x3c41a May 2, 2025
66ea765
fixed AHR send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_…
x3c41a May 2, 2025
6e4178a
fixed prdoc
x3c41a May 2, 2025
6d13087
Update prdoc/pr_8376.prdoc
x3c41a May 2, 2025
39b93c8
Update prdoc/pr_8376.prdoc
acatangiu May 2, 2025
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
15 changes: 13 additions & 2 deletions cumulus/parachains/integration-tests/emulated/common/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,17 @@ macro_rules! test_cross_chain_alias {
#[macro_export]
macro_rules! create_pool_with_native_on {
( $chain:ident, $asset:expr, $is_foreign:expr, $asset_owner:expr ) => {
$crate::create_pool_with_native_on!(
$chain,
$asset,
$is_foreign,
$asset_owner,
1_000_000_000_000,
2_000_000_000_000
);
};

( $chain:ident, $asset:expr, $is_foreign:expr, $asset_owner:expr, $native_amount:expr, $asset_amount:expr ) => {
emulated_integration_tests_common::impls::paste::paste! {
<$chain>::execute_with(|| {
type RuntimeEvent = <$chain as Chain>::RuntimeEvent;
Expand Down Expand Up @@ -871,8 +882,8 @@ macro_rules! create_pool_with_native_on {
signed_owner,
Box::new(native_asset),
Box::new($asset),
1_000_000_000_000,
2_000_000_000_000, // $asset is worth half of native_asset
$native_amount,
$asset_amount,
0,
0,
owner.into()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,80 @@ mod swap;
mod teleport;
mod treasury;
mod xcm_fee_estimation;

#[macro_export]
macro_rules! create_pool_with_roc_on {
// default amounts
( $chain:ident, $asset_id:expr, $is_foreign:expr, $asset_owner:expr ) => {
$crate::create_pool_with_roc_on!(
$chain,
$asset_id,
$is_foreign,
$asset_owner,
1_000_000_000_000,
2_000_000_000_000
);
};

// custom amounts
( $chain:ident, $asset_id:expr, $is_foreign:expr, $asset_owner:expr, $roc_amount:expr, $asset_amount:expr ) => {
emulated_integration_tests_common::impls::paste::paste! {
<$chain>::execute_with(|| {
type RuntimeEvent = <$chain as Chain>::RuntimeEvent;
let owner = $asset_owner;
let signed_owner = <$chain as Chain>::RuntimeOrigin::signed(owner.clone());
let roc_location: Location = Parent.into();
if $is_foreign {
assert_ok!(<$chain as [<$chain Pallet>]>::ForeignAssets::mint(
signed_owner.clone(),
$asset_id.clone().into(),
owner.clone().into(),
10_000_000_000_000, // For it to have more than enough.
));
} else {
let asset_id = match $asset_id.interior.last() {
Some(GeneralIndex(id)) => *id as u32,
_ => unreachable!(),
};
assert_ok!(<$chain as [<$chain Pallet>]>::Assets::mint(
signed_owner.clone(),
asset_id.into(),
owner.clone().into(),
10_000_000_000_000, // For it to have more than enough.
));
}

assert_ok!(<$chain as [<$chain Pallet>]>::AssetConversion::create_pool(
signed_owner.clone(),
Box::new(roc_location.clone()),
Box::new($asset_id.clone()),
));

assert_expected_events!(
$chain,
vec![
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { .. }) => {},
]
);

assert_ok!(<$chain as [<$chain Pallet>]>::AssetConversion::add_liquidity(
signed_owner,
Box::new(roc_location),
Box::new($asset_id),
$roc_amount,
$asset_amount,
0,
0,
owner.into()
));

assert_expected_events!(
$chain,
vec![
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded { .. }) => {},
]
);
});
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::imports::*;
use crate::{create_pool_with_roc_on, imports::*};

/// Relay Chain should be able to execute `Transact` instructions in System Parachain
/// when `OriginKind::Superuser`.
Expand Down Expand Up @@ -139,6 +139,8 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset() {
let fee_amount = ASSET_MIN_BALANCE * 1000000;
let asset =
([PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], fee_amount).into();
let asset_location =
Location::new(0, [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())]);

let root_origin = <PenpalA as Chain>::RuntimeOrigin::root();
let system_para_destination = PenpalA::sibling_location_of(AssetHubRococo::para_id()).into();
Expand All @@ -150,6 +152,15 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset() {
ASSET_HUB_ROCOCO_ED * 10000000000,
)]);

create_pool_with_roc_on!(
AssetHubRococo,
asset_location,
false,
para_sovereign_account.clone(),
9_000_000_000_000_000,
9_000_000_000_000
);

PenpalA::execute_with(|| {
assert_ok!(<PenpalA as PenpalAPallet>::PolkadotXcm::send(
root_origin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,20 @@ macro_rules! foreign_balance_on {

#[macro_export]
macro_rules! create_pool_with_wnd_on {
// default amounts
( $chain:ident, $asset_id:expr, $is_foreign:expr, $asset_owner:expr ) => {
$crate::create_pool_with_wnd_on!(
$chain,
$asset_id,
$is_foreign,
$asset_owner,
1_000_000_000_000,
2_000_000_000_000
);
};

// custom amounts
( $chain:ident, $asset_id:expr, $is_foreign:expr, $asset_owner:expr, $wnd_amount:expr, $asset_amount:expr ) => {
emulated_integration_tests_common::impls::paste::paste! {
<$chain>::execute_with(|| {
type RuntimeEvent = <$chain as Chain>::RuntimeEvent;
Expand Down Expand Up @@ -87,8 +100,8 @@ macro_rules! create_pool_with_wnd_on {
signed_owner,
Box::new(wnd_location),
Box::new($asset_id),
1_000_000_000_000,
2_000_000_000_000, // $asset_id is worth half of wnd
$wnd_amount,
$asset_amount,
0,
0,
owner.into()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::imports::*;
use crate::{create_pool_with_wnd_on, imports::*};

/// Relay Chain should be able to execute `Transact` instructions in System Parachain
/// when `OriginKind::Superuser`.
Expand Down Expand Up @@ -139,6 +139,8 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset() {
let fee_amount = ASSET_MIN_BALANCE * 1000000;
let asset =
([PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], fee_amount).into();
let asset_location =
Location::new(0, [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())]);

let root_origin = <PenpalA as Chain>::RuntimeOrigin::root();
let system_para_destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()).into();
Expand All @@ -150,6 +152,15 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset() {
ASSET_HUB_WESTEND_ED * 10000000000,
)]);

create_pool_with_wnd_on!(
AssetHubWestend,
asset_location,
false,
para_sovereign_account.clone(),
9_000_000_000_000_000,
9_000_000_000_000
);

PenpalA::execute_with(|| {
assert_ok!(<PenpalA as PenpalAPallet>::PolkadotXcm::send(
root_origin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@ fn transact_from_para_to_para_through_asset_hub() {

// We create a pool between WND and USDT in AssetHub.
let usdt = Location::new(0, [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(USDT_ID.into())]);
create_pool_with_wnd_on!(AssetHubWestend, usdt, false, AssetHubWestendSender::get());
create_pool_with_wnd_on!(
AssetHubWestend,
usdt,
false,
AssetHubWestendSender::get(),
1_000_000_000_000,
20_000_000_000
);
// We also need a pool between WND and USDT on PenpalA.
create_pool_with_wnd_on!(PenpalA, PenpalUsdtFromAssetHub::get(), true, PenpalAssetOwner::get());
// We also need a pool between WND and USDT on PenpalB.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ fn send_rocs_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_westend()
let local_asset_hub = PenpalA::sibling_location_of(AssetHubRococo::para_id());
let (roc_at_rococo_parachains, roc_at_asset_hub_westend) =
set_up_rocs_for_penpal_rococo_through_ahr_to_ahw(&sender, amount);
set_up_pool_with_wnd_on_ah_westend(roc_at_asset_hub_westend.clone(), true);

let sov_ahw_on_ahr = AssetHubRococo::sovereign_account_of_parachain_on_other_global_consensus(
ByGenesis(WESTEND_GENESIS_HASH),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,22 @@ pub fn create_pools_on_ah() {
let ethereum_sovereign = snowbridge_sovereign();
AssetHubWestend::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);
PenpalB::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);
create_pool_with_native_on!(AssetHubWestend, weth_location(), true, ethereum_sovereign.clone());
create_pool_with_native_on!(AssetHubWestend, ethereum(), true, ethereum_sovereign.clone());
create_pool_with_native_on!(
AssetHubWestend,
weth_location(),
true,
ethereum_sovereign.clone(),
1_000_000_000_000,
20_000_000_000
);
create_pool_with_native_on!(
AssetHubWestend,
ethereum(),
true,
ethereum_sovereign.clone(),
1_000_000_000_000,
20_000_000_000
);
}

pub(crate) fn set_up_eth_and_dot_pool() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ fn send_token_v2() {
NativeTokenERC20 { token_id: token.into(), value: token_transfer_value },
];

set_up_eth_and_dot_pool();
let topic_id = BridgeHubWestend::execute_with(|| {
type RuntimeEvent = <BridgeHubWestend as Chain>::RuntimeEvent;
let instructions = vec![
Expand Down Expand Up @@ -280,6 +281,7 @@ fn send_weth_v2() {
NativeTokenERC20 { token_id: WETH.into(), value: token_transfer_value },
];

set_up_eth_and_dot_pool();
BridgeHubWestend::execute_with(|| {
type RuntimeEvent = <BridgeHubWestend as Chain>::RuntimeEvent;
let instructions = vec![
Expand Down Expand Up @@ -769,6 +771,7 @@ fn send_foreign_erc20_token_back_to_polkadot() {
.appended_with(asset_id.clone().interior)
.unwrap();

set_up_eth_and_dot_pool();
// Register token
BridgeHubWestend::execute_with(|| {
type RuntimeOrigin = <BridgeHubWestend as Chain>::RuntimeOrigin;
Expand Down Expand Up @@ -963,6 +966,7 @@ fn invalid_claimer_does_not_fail_the_message() {

let origin = H160::random();

set_up_eth_and_dot_pool();
BridgeHubWestend::execute_with(|| {
type RuntimeEvent = <BridgeHubWestend as Chain>::RuntimeEvent;
let instructions = vec![
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,23 @@ fn transact_from_ethereum_to_penpalb_through_asset_hub() {

// We create a pool between WND and WETH in AssetHub to support paying for fees with WETH.
let snowbridge_sovereign = snowbridge_sovereign();
create_pool_with_native_on!(AssetHubWestend, bridged_weth.clone(), true, snowbridge_sovereign);
create_pool_with_native_on!(
AssetHubWestend,
bridged_weth.clone(),
true,
snowbridge_sovereign,
1_000_000_000_000,
20_000_000_000
);
// We also need a pool between WND and WETH on PenpalB to support paying for fees with WETH.
create_pool_with_native_on!(PenpalB, bridged_weth.clone(), true, PenpalAssetOwner::get());
create_pool_with_native_on!(
PenpalB,
bridged_weth.clone(),
true,
PenpalAssetOwner::get(),
1_000_000_000_000,
20_000_000_000
);

// Init values for Parachain Destination
let receiver = PenpalBReceiver::get();
Expand Down
Loading
Loading