Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polkadot-sdk v1.13.0 uplift #1358

Merged
merged 29 commits into from
Sep 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6068a3f
deps uplift
ipapandinas Sep 5, 2024
4fc0e05
RuntimeGenesisConfig generic type removed from GenericChainSpec
ipapandinas Sep 5, 2024
d190155
XcmRecorder type added xcm_executor config
ipapandinas Sep 5, 2024
b6506cc
MaxActiveOutboundChannels & MaxPageSize types added, xcmp queue palle…
ipapandinas Sep 5, 2024
6d63a79
XcmPaymentApi refactored, DryRunApi implemented
ipapandinas Sep 5, 2024
fc812f5
preservation Protect added to burn_from in pallet balances
ipapandinas Sep 5, 2024
277e37a
pallet balances weights updated
ipapandinas Sep 5, 2024
02f1c99
xcm api integration test extended
ipapandinas Sep 7, 2024
a411c7e
xcm api integration test extended
ipapandinas Sep 7, 2024
97551a6
xcm api implemented in fake_runtime_apis
ipapandinas Sep 7, 2024
4c1e26b
runtime used to generate genesis state for benchmarking
ipapandinas Sep 7, 2024
6738535
vendor libs updated
ipapandinas Sep 9, 2024
caae82b
cargo fmt
ipapandinas Sep 9, 2024
c3fe841
Small typo fixed and 'Preserve' used in burn_from
ipapandinas Sep 10, 2024
2c46cb3
fix zepter CI
ipapandinas Sep 10, 2024
b5a7618
revert xcm api implementation in fake_runtime_apis
ipapandinas Sep 10, 2024
a0f665b
Update scripts/run_benchmarks.sh
ipapandinas Sep 10, 2024
661ab10
Revert "vendor libs updated"
ipapandinas Sep 11, 2024
753df36
XcmRecorder relies on PolkadotXcm for production runtimes
ipapandinas Sep 11, 2024
1c2c599
fix to ensure asset XCM version conversion
ipapandinas Sep 11, 2024
cab7465
Revert "Update scripts/run_benchmarks.sh"
ipapandinas Sep 11, 2024
0187025
Revert "runtime used to generate genesis state for benchmarking"
ipapandinas Sep 11, 2024
0546708
weight_to_fee implemeted in pallet-xc-asset-config
ipapandinas Sep 11, 2024
ab3ec8c
fix typo
ipapandinas Sep 12, 2024
936d410
XcmRecorder integration test
ipapandinas Sep 12, 2024
fd33f7c
fix zepter CI
ipapandinas Sep 12, 2024
e593d3b
XcmRecorder integration test from Runtime XcmConfig
ipapandinas Sep 12, 2024
7141da7
DryRunApi integration tests improved
ipapandinas Sep 13, 2024
2a1dc19
todo comment added
ipapandinas Sep 16, 2024
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
DryRunApi integration tests improved
  • Loading branch information
ipapandinas committed Sep 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 7141da76220e4d74a28d9cb456df4b624d657cad
107 changes: 97 additions & 10 deletions tests/integration/src/xcm_api.rs
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@

use crate::setup::*;

use cumulus_primitives_core::Parent;
use cumulus_primitives_core::Unlimited;
use sp_runtime::traits::Zero;
use xcm::{
v4::{
@@ -26,7 +28,6 @@ use xcm::{
},
VersionedLocation, VersionedXcm,
};
use xcm_executor::RecordXcm;
use xcm_fee_payment_runtime_api::dry_run::runtime_decl_for_dry_run_api::DryRunApiV1;
use xcm_fee_payment_runtime_api::fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1;

@@ -209,32 +210,68 @@ fn dry_run_call_is_ok() {
});

let result = Runtime::dry_run_call(origin, call).expect("Must return some effects.");
assert_eq!(result.forwarded_xcms.len(), 1);
assert_eq!(
result.forwarded_xcms,
vec![(VersionedLocation::from((Parent, Here)), vec![],),]
);
})
}

// Minimal test in a runtime isolated environment to make sure `dry_run_xcm` is callable
#[test]
fn dry_run_xcm_is_ok() {
new_test_ext().execute_with(|| {
// Prepare a dummy location and xcm sequence
let location = VersionedLocation::V4(Location::here());
let transfer_amount = 10_000 * UNIT;
let native_asset: XcmAsset =
XcmAssetId(Location::here()).into_asset(Fungibility::Fungible(transfer_amount.clone()));

// Prepare an xcm sequence
let xcm_sequence = Xcm::<()>::builder_unsafe()
.clear_error()
.unsubscribe_version()
.withdraw_asset(native_asset.clone())
.clear_origin()
.buy_execution((Here, 1 * UNIT), Unlimited) // TODO: This can be improved by estimating real execution fees
.deposit_asset(
native_asset,
Junction::AccountId32 {
network: None,
id: BOB.clone().into(),
},
)
.build();

// ALICE location origin
let origin_location = VersionedLocation::V4(
Junction::AccountId32 {
id: ALICE.into(),
network: None,
}
.into(),
);
let dummy_message =
Xcm::<RuntimeCall>::from(VersionedXcm::V4(xcm_sequence).try_into().unwrap());
let versioned_xcm = VersionedXcm::V4(dummy_message);

let result =
Runtime::dry_run_xcm(location, versioned_xcm).expect("Must return some effects.");
assert_eq!(result.forwarded_xcms.len(), 1);
let result = Runtime::dry_run_xcm(origin_location, versioned_xcm)
.expect("Must return some effects.");

assert_eq!(
result.forwarded_xcms,
vec![(VersionedLocation::from((Parent, Here)), vec![],),]
);

assert_eq!(
result.emitted_events[0],
RuntimeEvent::Balances(pallet_balances::Event::Burned {
who: ALICE.into(),
amount: transfer_amount
}),
);
})
}

#[test]
fn xcm_recorder_configuration_is_ok() {
use xcm_executor::RecordXcm;

new_test_ext().execute_with(|| {
let result = <xcm_config::XcmConfig as xcm_executor::Config>::XcmRecorder::should_record();
assert!(
@@ -250,3 +287,53 @@ fn xcm_recorder_configuration_is_ok() {
);
})
}

// Ideal test dry-running XCM. However the execution emits a "SendFailure" error.

// #[test]
// fn dry_run_call_is_ok() {
// use cumulus_primitives_core::{Parachain, Parent};
// use xcm::VersionedAssets;
// use xcm_executor::RecordXcm;

// new_test_ext().execute_with(|| {
// let origin = OriginCaller::system(frame_system::RawOrigin::Signed(ALICE.into()));
// let native_asset: XcmAsset =
// XcmAssetId(Location::here()).into_asset(Fungibility::Fungible(10_000 * UNIT));

// // let call = RuntimeCall::PolkadotXcm(pallet_xcm::Call::limited_reserve_transfer_assets {
// // dest: Box::new(Here.into()),
// // beneficiary: Box::new(BOB.clone().into()),
// // assets: Box::new(native_asset.into()),
// // fee_asset_item: 0,
// // weight_limit: Unlimited,
// // });

// let call = RuntimeCall::PolkadotXcm(pallet_xcm::Call::limited_reserve_transfer_assets {
// dest: Box::new(VersionedLocation::from((
// Parent,
// Parachain(ParachainInfo::parachain_id().into()),
// ))),
// beneficiary: Box::new(VersionedLocation::from(Junction::AccountId32 {
// id: BOB.clone().into(),
// network: None,
// })),
// assets: Box::new(VersionedAssets::from(native_asset)),
// fee_asset_item: 0,
// weight_limit: Unlimited,
// });

// let result = Runtime::dry_run_call(origin, call).expect("Must return some effects.");
// println!("{:?}", result);

// // ensure XcmRecorder is properly configured in XcmConfig
// let expected_local_xcm =
// <xcm_config::XcmConfig as xcm_executor::Config>::XcmRecorder::recorded_xcm()
// .map(VersionedXcm::<()>::from);

// assert_eq!(result.local_xcm, expected_local_xcm);

// // test result.emitted_events
// // test result.forwarded_xcms
// })
// }
Loading