mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 16:51:02 +00:00
[xcm-emulator] Improve hygiene and clean up (#1301)
* improve hygiene & clean up * improve hygiene & clean up - xcm-emulator * improve hygiene & clean up - common * improve hygiene & clean up - tests * improve hygiene & clean up - tests 2 * last hygiene bits * ".git/.scripts/commands/fmt/fmt.sh" --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -14,46 +14,24 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pub use lazy_static;
|
||||
pub mod constants;
|
||||
pub mod impls;
|
||||
pub mod xcm_helpers;
|
||||
|
||||
pub use codec::Encode;
|
||||
pub use constants::{
|
||||
use constants::{
|
||||
accounts::{ALICE, BOB},
|
||||
asset_hub_kusama, asset_hub_polkadot, asset_hub_westend, bridge_hub_kusama,
|
||||
bridge_hub_polkadot, bridge_hub_rococo, collectives, kusama, penpal, polkadot, rococo, westend,
|
||||
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD,
|
||||
};
|
||||
use frame_support::{
|
||||
assert_ok,
|
||||
instances::Instance1,
|
||||
parameter_types,
|
||||
traits::{fungibles::Inspect, Hooks},
|
||||
};
|
||||
pub use impls::{RococoWococoMessageHandler, WococoRococoMessageHandler};
|
||||
pub use parachains_common::{AccountId, Balance};
|
||||
pub use paste;
|
||||
use polkadot_parachain_primitives::primitives::HrmpChannelId;
|
||||
use polkadot_primitives::runtime_api::runtime_decl_for_parachain_host::ParachainHostV6;
|
||||
pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId};
|
||||
pub use sp_core::{sr25519, storage::Storage, Get};
|
||||
use sp_tracing;
|
||||
use xcm_emulator::{
|
||||
assert_expected_events, bx, decl_test_bridges, decl_test_networks, decl_test_parachains,
|
||||
decl_test_relay_chains, decl_test_sender_receiver_accounts_parameter_types,
|
||||
helpers::weight_within_threshold, BridgeMessageHandler, Chain, DefaultMessageProcessor, ParaId,
|
||||
Parachain, RelayChain, TestExt,
|
||||
};
|
||||
use impls::{RococoWococoMessageHandler, WococoRococoMessageHandler};
|
||||
|
||||
pub use xcm::{
|
||||
prelude::{
|
||||
AccountId32, All, BuyExecution, DepositAsset, MultiAsset, MultiAssets, MultiLocation,
|
||||
OriginKind, Outcome, RefundSurplus, Transact, UnpaidExecution, VersionedXcm, Weight,
|
||||
WeightLimit, WithdrawAsset, Xcm, X1,
|
||||
},
|
||||
v3::Error,
|
||||
DoubleEncoded,
|
||||
// Substrate
|
||||
use frame_support::traits::OnInitialize;
|
||||
|
||||
// Cumulus
|
||||
use xcm_emulator::{
|
||||
decl_test_bridges, decl_test_networks, decl_test_parachains, decl_test_relay_chains,
|
||||
decl_test_sender_receiver_accounts_parameter_types, DefaultMessageProcessor,
|
||||
};
|
||||
|
||||
decl_test_relay_chains! {
|
||||
@@ -87,7 +65,7 @@ decl_test_relay_chains! {
|
||||
Hrmp: kusama_runtime::Hrmp,
|
||||
}
|
||||
},
|
||||
#[api_version(5)]
|
||||
#[api_version(6)]
|
||||
pub struct Westend {
|
||||
genesis = westend::genesis(),
|
||||
on_init = (),
|
||||
@@ -582,44 +560,3 @@ decl_test_sender_receiver_accounts_parameter_types! {
|
||||
PenpalWestendA { sender: ALICE, receiver: BOB },
|
||||
PenpalRococoA { sender: ALICE, receiver: BOB }
|
||||
}
|
||||
|
||||
/// Helper method to build a XCM with a `Transact` instruction and paying for its execution
|
||||
pub fn xcm_transact_paid_execution(
|
||||
call: DoubleEncoded<()>,
|
||||
origin_kind: OriginKind,
|
||||
native_asset: MultiAsset,
|
||||
beneficiary: AccountId,
|
||||
) -> VersionedXcm<()> {
|
||||
let weight_limit = WeightLimit::Unlimited;
|
||||
let require_weight_at_most = Weight::from_parts(1000000000, 200000);
|
||||
let native_assets: MultiAssets = native_asset.clone().into();
|
||||
|
||||
VersionedXcm::from(Xcm(vec![
|
||||
WithdrawAsset(native_assets),
|
||||
BuyExecution { fees: native_asset, weight_limit },
|
||||
Transact { require_weight_at_most, origin_kind, call },
|
||||
RefundSurplus,
|
||||
DepositAsset {
|
||||
assets: All.into(),
|
||||
beneficiary: MultiLocation {
|
||||
parents: 0,
|
||||
interior: X1(AccountId32 { network: None, id: beneficiary.into() }),
|
||||
},
|
||||
},
|
||||
]))
|
||||
}
|
||||
|
||||
/// Helper method to build a XCM with a `Transact` instruction without paying for its execution
|
||||
pub fn xcm_transact_unpaid_execution(
|
||||
call: DoubleEncoded<()>,
|
||||
origin_kind: OriginKind,
|
||||
) -> VersionedXcm<()> {
|
||||
let weight_limit = WeightLimit::Unlimited;
|
||||
let require_weight_at_most = Weight::from_parts(1000000000, 200000);
|
||||
let check_origin = None;
|
||||
|
||||
VersionedXcm::from(Xcm(vec![
|
||||
UnpaidExecution { weight_limit, check_origin },
|
||||
Transact { require_weight_at_most, origin_kind, call },
|
||||
]))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user