Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5018eb5
add integration tests to xcm-builder
apopiak Jul 31, 2021
29b7b04
add an integration test for reserve_transfer_assets
apopiak Jul 31, 2021
ee9b9c7
add query holding and teleport tests
apopiak Jul 31, 2021
7a09753
formatting
apopiak Jul 31, 2021
d1539f6
add to barrier doc comments and fix doc tests warnings
apopiak Jul 31, 2021
d9ebc77
use more realistic barrier for integration tests
apopiak Jul 31, 2021
ec426b9
improve imports
apopiak Jul 31, 2021
32b67ca
adjust base xcm weight and existential deposit to be in line with Kusama
apopiak Jul 31, 2021
7881628
remove AnyNetwork
apopiak Aug 1, 2021
5e8507f
add more comments and remove unnecessary code
apopiak Aug 1, 2021
cea48f9
Merge branch 'apopiak/xcm-integration-tests' of github.com:paritytech…
apopiak Aug 1, 2021
24b79ec
move mock into separate file
apopiak Aug 1, 2021
4aba2d6
reduce imports
apopiak Aug 1, 2021
114ef4e
update cargo.lock
apopiak Aug 1, 2021
97fb7a8
remove reserve transfer test from xcm builder integration tests
apopiak Aug 3, 2021
21a7e74
reword barrier doc comment
apopiak Aug 3, 2021
aababe1
elaborate on QueryHolding test scenario
apopiak Aug 3, 2021
2b63830
add an integration test for reserve based transfers from parachain to…
apopiak Aug 3, 2021
eed0fbc
add teleport tests
apopiak Aug 3, 2021
dc2a1bf
fix failing teleport filter tests
apopiak Aug 3, 2021
5dd3744
Update xcm/xcm-builder/src/integration_tests.rs
apopiak Aug 10, 2021
3b63468
Update xcm/xcm-builder/src/integration_tests.rs
apopiak Aug 10, 2021
26e7f53
Update xcm/xcm-builder/src/integration_tests.rs
apopiak Aug 10, 2021
4bd50a7
Move integration tests to tests/ directory
KiChjang Aug 14, 2021
75d0971
Merge remote-tracking branch 'origin/master' into apopiak/xcm-integra…
KiChjang Aug 14, 2021
f8a4847
Fix merge
KiChjang Aug 14, 2021
e3605c5
Replace All wildcard with a concrete seed amount
KiChjang Aug 14, 2021
4266a94
Rename SEED_AMOUNT to REGISTER_AMOUNT
KiChjang Aug 14, 2021
412ce69
Fix compilation error
KiChjang Aug 14, 2021
72975eb
Check for teleport destination first before checking out assets
KiChjang Aug 14, 2021
0d17e0a
Fix unit test
KiChjang Aug 14, 2021
304fd94
Do not run tests in integration mock
KiChjang Aug 14, 2021
ab81960
Add a permissive assets filter for teleportation
KiChjang Aug 14, 2021
2fba6af
Remove check for teleport location in InitiateTeleport XCM
KiChjang Aug 16, 2021
fd51b75
Remove defunct test
KiChjang Aug 17, 2021
1f15e4b
Apply suggestions from code review
apopiak Aug 17, 2021
dcd947b
Reword comment
apopiak Aug 17, 2021
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
Prev Previous commit
Next Next commit
add teleport tests
  • Loading branch information
apopiak committed Aug 3, 2021
commit eed0fbc407a2f02676fbb39746a09aa3c9e1e0ba
12 changes: 10 additions & 2 deletions xcm/xcm-builder/src/integration_mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32};
use polkadot_parachain::primitives::Id as ParaId;
use polkadot_runtime_parachains::{configuration, origin, shared};
use xcm::opaque::v0::MultiAsset;
use xcm::v0::{MultiLocation::self, NetworkId};
use xcm::v0::{Junction::*, MultiLocation::{self, *}, NetworkId};
use xcm_executor::XcmExecutor;

use crate as xcm_builder;
Expand Down Expand Up @@ -130,14 +130,22 @@ pub type Barrier = (
AllowUnpaidExecutionFrom<IsChildSystemParachain<ParaId>>,
);

parameter_types! {
pub const KusamaForStatemint: (MultiAsset, MultiLocation) =
(MultiAsset::AllConcreteFungible { id: Null }, X1(Parachain(1000)));
}
pub type TrustedTeleporters = (
xcm_builder::Case<KusamaForStatemint>,
);

pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type Call = Call;
type XcmSender = mock::TestSendXcm;
type AssetTransactor = LocalAssetTransactor;
type OriginConverter = LocalOriginConverter;
type IsReserve = ();
type IsTeleporter = ();
type IsTeleporter = TrustedTeleporters;
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
Expand Down
18 changes: 18 additions & 0 deletions xcm/xcm-builder/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,30 @@ fn teleport_to_statemine_works() {
let balances = vec![(ALICE, INITIAL_BALANCE), (para_acc.clone(), INITIAL_BALANCE)];
kusama_like_with_balances(balances).execute_with(|| {
let statemine_id = 1000;
let other_para_id = 3000;
let amount = 10 * ExistentialDeposit::get();
let teleport_effects = vec![
buy_execution(5), // unchecked mock value
Order::DepositAsset { assets: vec![All], dest: X2(Parent, Parachain(PARA_ID)) },
];
let weight = 3 * BaseXcmWeight::get();
let r = XcmExecutor::<XcmConfig>::execute_xcm(
Parachain(PARA_ID).into(),
Copy link
Contributor

Choose a reason for hiding this comment

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

should this not be called ORIGIN_PARA_ID?

Xcm::WithdrawAsset {
assets: vec![ConcreteFungible { id: Null, amount }],
effects: vec![
buy_execution(weight),
Order::InitiateTeleport {
assets: vec![All],
dest: Parachain(other_para_id).into(),
effects: teleport_effects.clone(),
},
],
},
weight,
);
// teleports not allowed to community chains
assert_eq!(r, Outcome::Error(XcmError::UntrustedTeleportLocation));
let r = XcmExecutor::<XcmConfig>::execute_xcm(
Parachain(PARA_ID).into(),
Xcm::WithdrawAsset {
Expand Down
40 changes: 40 additions & 0 deletions xcm/xcm-builder/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,43 @@ fn prepaid_result_of_query_should_get_free_execution() {
let r = XcmExecutor::<TestConfig>::execute_xcm(origin.clone(), message.clone(), weight_limit);
assert_eq!(r, Outcome::Incomplete(10, XcmError::Barrier));
}

#[test]
fn teleport_destinations_should_be_filtered() {
let one = X1(AccountIndex64{index:1, network:Any});
let two = X1(AccountIndex64{index:2, network:Any});
AllowPaidFrom::set(vec![ one.clone(), two.clone() ]);
add_asset(1, ConcreteFungible { id: X1(Parent), amount: 100 });
add_asset(2, ConcreteFungible { id: X1(Parent), amount: 100 });
WeightPrice::set((X1(Parent), 1_000_000_000_000));

// teleport should fail to non-teleport locations
{
let origin = two.clone();
let message = Xcm::<TestCall>::WithdrawAsset {
assets: vec![ ConcreteFungible { id: X1(Parent), amount: 100 } ], // enough for 100 units of weight.
effects: vec![
Order::<TestCall>::BuyExecution { fees: All, weight: 0, debt: 30, halt_on_error: true, xcm: vec![] },
Order::<TestCall>::InitiateTeleport { assets: vec![ All ], dest: two.clone(), effects: vec![] },
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, I would've expected the test to teleport assets from one to two, instead of it trying to teleport from two back to itself, is this intended?

],
};
let weight_limit = 100;
let r = XcmExecutor::<TestConfig>::execute_xcm(origin, message, weight_limit);
assert_eq!(r, Outcome::Error(XcmError::UntrustedTeleportLocation));
}

add_teleporter(one.clone(), AllConcreteFungible { id: X1(Parent) });
// teleport should succed for known teleport locations
let origin = one.clone();
let message = Xcm::<TestCall>::WithdrawAsset {
assets: vec![ ConcreteFungible { id: X1(Parent), amount: 100 } ], // enough for 100 units of weight.
effects: vec![
Order::<TestCall>::BuyExecution { fees: All, weight: 0, debt: 30, halt_on_error: true, xcm: vec![] },
Order::<TestCall>::InitiateTeleport { assets: vec![ All ], dest: one.clone(), effects: vec![] },
],
};
let weight_limit = 100;
let r = XcmExecutor::<TestConfig>::execute_xcm(origin, message, weight_limit);
assert_eq!(r, Outcome::Complete(50));
assert_eq!(assets(1), vec![ ConcreteFungible { id: X1(Parent), amount: 50 } ]);
}