Skip to content

Commit

Permalink
Revert "init"
Browse files Browse the repository at this point in the history
This reverts commit 1770ae8.
  • Loading branch information
Daanvdplas committed Oct 8, 2024
1 parent 1770ae8 commit 52fb7f0
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 286 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ tracing-subscriber = { workspace = true, features = [
frame-support.workspace = true
pallet-assets.workspace = true
pallet-balances.workspace = true
pallet-contracts.workspace = true
pallet-message-queue.workspace = true
sp-authority-discovery.workspace = true
sp-consensus-aura.workspace = true
sp-consensus-babe.workspace = true
sp-consensus-beefy.workspace = true
sp-consensus-grandpa.workspace = true
sp-core.workspace = true
sp-io.workspace = true
sp-runtime.workspace = true

# Polkadot
Expand Down Expand Up @@ -61,7 +59,6 @@ std = [
"frame-support/std",
"pallet-assets/std",
"pallet-balances/std",
"pallet-contracts/std",
"pallet-message-queue/std",
"pallet-xcm/std",
"paseo-runtime-constants/std",
Expand All @@ -77,7 +74,6 @@ std = [
"sp-consensus-beefy/std",
"sp-consensus-grandpa/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"xcm-executor/std",
"xcm/std",
Expand All @@ -89,7 +85,6 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-contracts/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"paseo-runtime/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
Expand All @@ -105,7 +100,6 @@ try-runtime = [
"frame-support/try-runtime",
"pallet-assets/try-runtime",
"pallet-balances/std",
"pallet-contracts/std",
"pallet-message-queue/try-runtime",
"paseo-runtime/try-runtime",
"pop-runtime-devnet/try-runtime",
Expand Down
Empty file removed integration-tests/expanded.rs
Empty file.
1 change: 0 additions & 1 deletion integration-tests/src/chains/pop_network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ decl_test_parachains! {
pallets = {
PolkadotXcm: runtime::PolkadotXcm,
Balances: runtime::Balances,
Contracts: runtime::Contracts,
}
},
}
Expand Down
165 changes: 0 additions & 165 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
let sender_balance_after = test.sender.balance;
let receiver_balance_after = test.receiver.balance;

// TODO: Delivery fees on destination chain
let delivery_fees = PopNetworkPara::execute_with(|| {
xcm_helpers::teleport_assets_delivery_fees::<
<PopNetworkXcmConfig as xcm_executor::Config>::XcmSender,
Expand All @@ -482,170 +481,6 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
assert!(receiver_balance_after < receiver_balance_before + amount_to_send);
}

/// Reserve Transfers of DOT from Pop Net to Asset Hub, paying fees with DOT on Pop Net, should
/// work.
#[test]
fn reserve_transfer_native_asset_from_para_to_system_para_special() {
init_tracing();

// Setup: reserve transfer DOT from AH to Bob on Pop Network.
let amount_to_send: Balance = ASSET_HUB_PASEO_ED * 1000;
let bob_on_pop = PopNetworkParaReceiver::get();
fund_pop_from_system_para(
AssetHubPaseoParaSender::get(),
amount_to_send,
bob_on_pop.clone(),
(Parent, amount_to_send).into(),
);

// Init values for Pop Network Parachain.
// Asset Hub location from Pop Net's view.
let destination = PopNetworkPara::sibling_location_of(AssetHubPaseoPara::para_id());
// Random account on asset hub.
let receiver_ah = sp_runtime::AccountId32::from([1u8; 32]);
let amount_to_send = PopNetworkPara::account_data_of(bob_on_pop.clone()).free;

let test_args = TestContext {
sender: bob_on_pop,
receiver: receiver_ah.clone(),
args: TestArgs::new_para(
destination,
receiver_ah,
amount_to_send * 2,
(Parent, amount_to_send).into(),
None,
0,
),
};

let mut test = ParaToSystemParaTest::new(test_args);

let bob_on_pop_balance_before = test.sender.balance;
let receiver_ah_balance_before = test.receiver.balance;
assert_eq!(receiver_ah_balance_before, 0);

let pop_net_location_as_seen_by_ah =
AssetHubPaseoPara::sibling_location_of(PopNetworkPara::para_id());
let sov_pop_net_on_ah =
AssetHubPaseoPara::sovereign_account_id_of(pop_net_location_as_seen_by_ah);
// // fund Pop Network's SA on AH with the native tokens held in reserve
AssetHubPaseoPara::fund_accounts(vec![(sov_pop_net_on_ah.into(), amount_to_send * 2)]);

test.set_assertion::<PopNetworkPara>(para_to_system_para_sender_assertions);
test.set_assertion::<AssetHubPaseoPara>(para_to_system_para_receiver_assertions);
test.set_dispatchable::<PopNetworkPara>(para_to_system_para_reserve_transfer_assets);
test.assert();

let bob_on_pop_balance_after = test.sender.balance;
let receiver_ah_balance_after = test.receiver.balance;

// TODO: Delivery fees on destination chain
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, test.args.beneficiary, test.args.dest
)
});

// Sender's balance is reduced
assert_eq!(
bob_on_pop_balance_before - amount_to_send - delivery_fees,
bob_on_pop_balance_after
);
// Receiver's balance is increased
assert!(receiver_ah_balance_after > receiver_ah_balance_before);
// Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`;
// `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown
// but should be non-zero
assert!(receiver_ah_balance_after < receiver_ah_balance_before + amount_to_send);
}

#[test]
#[ignore]
fn test_contract_interaction_on_pop_network() {
use codec::Encode;
use frame_support::traits::fungible::Inspect;
use pallet_contracts::{Code, CollectEvents, Determinism};

const GAS_LIMIT: Weight = Weight::from_parts(100_000_000_000, 3 * 1024 * 1024);
const DEBUG_OUTPUT: pallet_contracts::DebugInfo = pallet_contracts::DebugInfo::UnsafeDebug;

// Initialize tracing if needed
init_tracing();

let bob_on_pop = PopNetworkParaReceiver::get();
// Setup: reserve transfer from AH to Pop, so that sovereign account accurate for return
// transfer
let amount_to_send: Balance = ASSET_HUB_PASEO_ED * 1000;
fund_pop_from_system_para(
AssetHubPaseoParaSender::get(),
amount_to_send * 10,
bob_on_pop.clone(),
(Parent, amount_to_send * 10).into(),
);
let path = "../pop-api/examples/balance-transfer/target/ink/balance_transfer.wasm";
let wasm_binary = std::fs::read(path).expect("could not read .wasm file");

PopNetwork::<PaseoMockNet>::execute_with(|| {
// Account with empty balance on Pop.
let receiver_pop = sp_runtime::AccountId32::from([1u8; 32]);
let balance_before =
<PopNetwork<PaseoMockNet> as PopNetworkParaPallet>::Balances::balance(&receiver_pop);

// Instantiate the contract
let instantiate_result =
<PopNetwork<PaseoMockNet> as PopNetworkParaPallet>::Contracts::bare_instantiate(
bob_on_pop.clone(),
amount_to_send,
GAS_LIMIT,
None,
Code::Upload(wasm_binary),
function_selector("new"),
vec![],
DEBUG_OUTPUT,
CollectEvents::Skip,
)
.result
.expect("Contract instantiation failed");

assert!(
!instantiate_result.result.did_revert(),
"Deploying contract reverted: {:?}",
instantiate_result
);

let contract = instantiate_result.account_id;

// Prepare the call data
let function = function_selector("transfer");
let params = [receiver_pop.encode(), (amount_to_send / 2).encode()].concat();
let input = [function, params].concat();

// Call the contract
let call_result = <PopNetwork<PaseoMockNet> as PopNetworkParaPallet>::Contracts::bare_call(
bob_on_pop.clone(),
contract.into(),
0,
GAS_LIMIT,
None,
input,
DEBUG_OUTPUT,
CollectEvents::Skip,
Determinism::Enforced,
);

assert!(call_result.result.is_ok(), "Contract call failed: {:?}", call_result.result);
let balance_after =
<PopNetwork<PaseoMockNet> as PopNetworkParaPallet>::Balances::balance(&receiver_pop);
assert_eq!(balance_after, balance_before + (amount_to_send / 2));
});
}
fn function_selector(name: &str) -> Vec<u8> {
let hash = sp_io::hashing::blake2_256(name.as_bytes());
[hash[0..4].to_vec()].concat()
}

// Note: commented out until coretime added to Paseo
// #[test]
// fn place_coretime_spot_order_from_para_to_relay() {
Expand Down
9 changes: 8 additions & 1 deletion pop-api/examples/balance-transfer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ name = "balance_transfer"
version = "0.1.0"

[dependencies]
ink = { git = "https://github.com/use-ink/ink", branch = "xcm", default-features = false }
ink = { version = "5.0.0", default-features = false }
pop-api = { path = "../../../pop-api", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = [ "derive" ] }
scale-info = { version = "2.6", default-features = false, features = [ "derive" ], optional = true }

[dev-dependencies]
ink_e2e = "5.0.0"

[lib]
path = "lib.rs"
Expand All @@ -18,4 +23,6 @@ ink-as-dependency = [ ]
std = [
"ink/std",
"pop-api/std",
"scale-info/std",
"scale/std",
]
Loading

0 comments on commit 52fb7f0

Please sign in to comment.