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
6 changes: 5 additions & 1 deletion integration-tests/src/chains/pop_network/genesis.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use emulated_integration_tests_common::{build_genesis_storage, collators};
use pop_runtime_common::Balance;
use pop_runtime_devnet as runtime;
use sp_core::storage::Storage;

use super::runtime;

#[cfg(not(feature = "mainnet"))]
pub(crate) const ED: Balance = runtime::EXISTENTIAL_DEPOSIT;
#[cfg(feature = "mainnet")]
pub(crate) const ED: Balance = runtime::EXISTENTIAL_DEPOSIT * 100;
const PARA_ID: u32 = 9090;
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;

Expand Down
6 changes: 3 additions & 3 deletions integration-tests/src/chains/pop_network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use emulated_integration_tests_common::{
};
use frame_support::traits::OnInitialize;
#[cfg(feature = "devnet")]
use pop_runtime_devnet as runtime;
pub(crate) use pop_runtime_devnet as runtime;
#[cfg(feature = "mainnet")]
use pop_runtime_mainnet as runtime;
pub(crate) use pop_runtime_mainnet as runtime;
#[cfg(feature = "testnet")]
use pop_runtime_testnet as runtime;
pub(crate) use pop_runtime_testnet as runtime;

// PopNetwork Parachain declaration
decl_test_parachains! {
Expand Down
41 changes: 17 additions & 24 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use chains::{
genesis::ED as ASSET_HUB_ED, runtime::xcm_config::XcmConfig as AssetHubXcmConfig, AssetHub,
AssetHubParaPallet,
},
pop_network::{genesis::ED as POP_ED, PopNetwork, PopNetworkParaPallet},
pop_network::{
runtime::config::xcm::XcmConfig as PopNetworkXcmConfig, PopNetwork, PopNetworkParaPallet,
},
relay::{
genesis::ED as RELAY_ED, runtime::xcm_config::XcmConfig as RelayXcmConfig, Relay,
RelayRelayPallet as RelayPallet,
Expand All @@ -22,10 +24,6 @@ use emulated_integration_tests_common::{
};
use frame_support::{pallet_prelude::Weight, sp_runtime::DispatchResult};
use pop_runtime_common::Balance;
#[cfg(not(feature = "mainnet"))]
use pop_runtime_devnet::config::xcm::XcmConfig as PopNetworkXcmConfig;
#[cfg(feature = "mainnet")]
use pop_runtime_mainnet::config::xcm::XcmConfig as PopNetworkXcmConfig;
use xcm::prelude::*;

mod chains;
Expand Down Expand Up @@ -315,23 +313,8 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
// Init values for Pop Network Parachain
let destination = PopNetworkPara::sibling_location_of(AssetHubPara::para_id());
let beneficiary_id = AssetHubParaReceiver::get(); // bob on asset hub
let amount_to_send = PopNetworkPara::account_data_of(PopNetworkParaReceiver::get()).free; // bob on pop balance
let assets: Assets = (Parent, amount_to_send).into();

let delivery_fees = PopNetworkPara::execute_with(|| {
xcm_helpers::teleport_assets_delivery_fees::<
<PopNetworkXcmConfig as xcm_executor::Config>::XcmSender,
>(
assets.clone(), 0, Unlimited, Location::from(beneficiary_id.clone()), destination.clone()
)
});

// Mainnet ED is 100 times higher.
let pop_mainnet_ed = POP_ED * 100;
// We need to keep `delivery_fees` in balance to pay for these fees locally.
// To avoid the account from being reaped we need to ensure its balance is >= ED.
let amount_to_send = amount_to_send - (pop_mainnet_ed + delivery_fees);
let assets: Assets = (Parent, amount_to_send).into();
let amount_to_send = PopNetworkPara::account_data_of(PopNetworkParaReceiver::get()).free / 4; // bob on pop balance
Copy link
Member

@al3mart al3mart Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason for the division. Is it arbitrary ?

If the reason is not having the account balance lower than the ED I'd argue that showing that explicitly gives more information.

let assets = (Parent, amount_to_send).into();

let test_args = TestContext {
sender: PopNetworkParaReceiver::get(), // bob on pop
Expand All @@ -344,6 +327,18 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
let sender_balance_before = test.sender.balance;
let receiver_balance_before = test.receiver.balance;

let delivery_fees = PopNetworkPara::execute_with(|| {
xcm_helpers::teleport_assets_delivery_fees::<
<PopNetworkXcmConfig as xcm_executor::Config>::XcmSender,
>(
test.args.assets.clone(),
0,
test.args.weight_limit.clone(),
test.args.beneficiary.clone(),
test.args.dest.clone(),
)
});

let pop_net_location_as_seen_by_ahr =
AssetHubPara::sibling_location_of(PopNetworkPara::para_id());
let sov_pop_net_on_ahr = AssetHubPara::sovereign_account_id_of(pop_net_location_as_seen_by_ahr);
Expand All @@ -361,8 +356,6 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {

// Sender's balance is reduced
assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after);
// Sender's remaining balance equals ED.
assert_eq!(pop_mainnet_ed, sender_balance_after);
// Receiver's balance is increased
assert!(receiver_balance_after > receiver_balance_before);
// Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`;
Expand Down
Loading