Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn spend_roc_on_asset_hub() {
})),
});

// Dispatched from Root to `despatch_as` `Signed(treasury_account)`.
// Dispatched from Root to `dispatch_as` `Signed(treasury_account)`.
assert_ok!(teleport_call.dispatch(root));

assert_expected_events!(
Expand Down
18 changes: 13 additions & 5 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ use asset_hub_rococo_runtime::{
xcm_config,
xcm_config::{
bridging, AssetFeeAsExistentialDepositMultiplierFeeCharger, CheckingAccount,
<<<<<<< HEAD
ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger, ForeignCreatorsSovereignAccountOf,
=======
ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger, GovernanceLocation,
>>>>>>> e9be92d6 (Authorize upgrade tests for testnet runtimes + `execute_as_governance` refactor (#7656))
LocationToAccountId, StakingPot, TokenLocation, TrustBackedAssetsPalletLocation, XcmConfig,
},
AllPalletsWithoutSystem, AssetConversion, AssetDeposit, Assets, Balances, Block,
Expand All @@ -31,13 +35,13 @@ use asset_hub_rococo_runtime::{
};
use asset_test_utils::{
test_cases_over_bridge::TestBridgingConfig, CollatorSessionKey, CollatorSessionKeys,
ExtBuilder, SlotDurations,
ExtBuilder, GovernanceOrigin, SlotDurations,
};
use codec::{Decode, Encode};
use core::ops::Mul;
use cumulus_primitives_utility::ChargeWeightInFungibles;
use frame_support::{
assert_noop, assert_ok,
assert_noop, assert_ok, parameter_types,
traits::{
fungible::{Inspect, Mutate},
fungibles::{
Expand All @@ -58,6 +62,10 @@ use xcm_executor::traits::{JustTry, WeightTrader};
const ALICE: [u8; 32] = [1u8; 32];
const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32];

parameter_types! {
pub Governance: GovernanceOrigin<RuntimeOrigin> = GovernanceOrigin::Location(GovernanceLocation::get());
}

type AssetIdForTrustBackedAssetsConvert =
assets_common::AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation>;

Expand Down Expand Up @@ -1393,7 +1401,7 @@ fn change_xcm_bridge_hub_router_byte_fee_by_governance_works() {
>(
collator_session_keys(),
1000,
Box::new(|call| RuntimeCall::System(call).encode()),
Governance::get(),
|| {
(
bridging::XcmBridgeHubRouterByteFee::key().to_vec(),
Expand All @@ -1419,7 +1427,7 @@ fn change_xcm_bridge_hub_router_base_fee_by_governance_works() {
>(
collator_session_keys(),
1000,
Box::new(|call| RuntimeCall::System(call).encode()),
Governance::get(),
|| {
log::error!(
target: "bridges::estimate",
Expand Down Expand Up @@ -1451,7 +1459,7 @@ fn change_xcm_bridge_hub_ethereum_base_fee_by_governance_works() {
>(
collator_session_keys(),
1000,
Box::new(|call| RuntimeCall::System(call).encode()),
Governance::get(),
|| {
log::error!(
target: "bridges::estimate",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@ use parachains_common::{
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
<<<<<<< HEAD
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
use xcm::latest::prelude::*;
=======
use snowbridge_router_primitives::inbound::EthereumLocationsConverterFor;
use sp_runtime::traits::{AccountIdConversion, ConvertInto, TryConvertInto};
use westend_runtime_constants::system_parachain::COLLECTIVES_ID;
use xcm::latest::{prelude::*, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH};
>>>>>>> e9be92d6 (Authorize upgrade tests for testnet runtimes + `execute_as_governance` refactor (#7656))
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
Expand Down Expand Up @@ -261,17 +268,17 @@ impl Contains<Location> for FellowshipEntities {
fn contains(location: &Location) -> bool {
matches!(
location.unpack(),
(1, [Parachain(1001), Plurality { id: BodyId::Technical, .. }]) |
(1, [Parachain(1001), PalletInstance(64)]) |
(1, [Parachain(1001), PalletInstance(65)])
(1, [Parachain(COLLECTIVES_ID), Plurality { id: BodyId::Technical, .. }]) |
(1, [Parachain(COLLECTIVES_ID), PalletInstance(64)]) |
(1, [Parachain(COLLECTIVES_ID), PalletInstance(65)])
)
}
}

pub struct AmbassadorEntities;
impl Contains<Location> for AmbassadorEntities {
fn contains(location: &Location) -> bool {
matches!(location.unpack(), (1, [Parachain(1001), PalletInstance(74)]))
matches!(location.unpack(), (1, [Parachain(COLLECTIVES_ID), PalletInstance(74)]))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ use asset_hub_westend_runtime::{
xcm_config,
xcm_config::{
bridging, AssetFeeAsExistentialDepositMultiplierFeeCharger, CheckingAccount,
<<<<<<< HEAD
ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger, ForeignCreatorsSovereignAccountOf,
=======
ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger, GovernanceLocation,
>>>>>>> e9be92d6 (Authorize upgrade tests for testnet runtimes + `execute_as_governance` refactor (#7656))
LocationToAccountId, StakingPot, TrustBackedAssetsPalletLocation, WestendLocation,
XcmConfig,
},
Expand All @@ -33,12 +37,12 @@ use asset_hub_westend_runtime::{
pub use asset_hub_westend_runtime::{AssetConversion, AssetDeposit, CollatorSelection, System};
use asset_test_utils::{
test_cases_over_bridge::TestBridgingConfig, CollatorSessionKey, CollatorSessionKeys,
ExtBuilder, SlotDurations,
ExtBuilder, GovernanceOrigin, SlotDurations,
};
use codec::{Decode, Encode};
use cumulus_primitives_utility::ChargeWeightInFungibles;
use frame_support::{
assert_noop, assert_ok,
assert_err, assert_noop, assert_ok, parameter_types,
traits::{
fungible::{Inspect, Mutate},
fungibles::{
Expand All @@ -49,7 +53,12 @@ use frame_support::{
};
use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance};
use sp_consensus_aura::SlotDuration;
<<<<<<< HEAD
use sp_runtime::traits::MaybeEquivalence;
=======
use sp_core::crypto::Ss58Codec;
use sp_runtime::{traits::MaybeEquivalence, Either};
>>>>>>> e9be92d6 (Authorize upgrade tests for testnet runtimes + `execute_as_governance` refactor (#7656))
use std::{convert::Into, ops::Mul};
use testnet_parachains_constants::westend::{consensus::*, currency::UNITS, fee::WeightToFee};
use xcm::latest::prelude::{Assets as XcmAssets, *};
Expand All @@ -59,6 +68,10 @@ use xcm_executor::traits::{ConvertLocation, JustTry, WeightTrader};
const ALICE: [u8; 32] = [1u8; 32];
const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32];

parameter_types! {
pub Governance: GovernanceOrigin<RuntimeOrigin> = GovernanceOrigin::Location(GovernanceLocation::get());
}

type AssetIdForTrustBackedAssetsConvert =
assets_common::AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation>;

Expand Down Expand Up @@ -1341,7 +1354,7 @@ fn change_xcm_bridge_hub_router_byte_fee_by_governance_works() {
>(
collator_session_keys(),
1000,
Box::new(|call| RuntimeCall::System(call).encode()),
Governance::get(),
|| {
(
bridging::XcmBridgeHubRouterByteFee::key().to_vec(),
Expand All @@ -1367,7 +1380,7 @@ fn change_xcm_bridge_hub_router_base_fee_by_governance_works() {
>(
collator_session_keys(),
1000,
Box::new(|call| RuntimeCall::System(call).encode()),
Governance::get(),
|| {
log::error!(
target: "bridges::estimate",
Expand Down Expand Up @@ -1435,3 +1448,54 @@ fn xcm_payment_api_works() {
Block,
>();
}

#[test]
fn governance_authorize_upgrade_works() {
use westend_runtime_constants::system_parachain::{ASSET_HUB_ID, COLLECTIVES_ID};

// no - random para
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(12334)))),
Either::Right(XcmError::Barrier)
);
// no - AssetHub
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(ASSET_HUB_ID)))),
Either::Right(XcmError::Barrier)
);
// no - Collectives
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::new(1, Parachain(COLLECTIVES_ID)))),
Either::Right(XcmError::Barrier)
);
// no - Collectives Voice of Fellows plurality
assert_err!(
parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::LocationAndDescendOrigin(
Location::new(1, Parachain(COLLECTIVES_ID)),
Plurality { id: BodyId::Technical, part: BodyPart::Voice }.into()
)),
Either::Right(XcmError::BadOrigin)
);

// ok - relaychain
assert_ok!(parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(Location::parent())));
assert_ok!(parachains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
Runtime,
RuntimeOrigin,
>(GovernanceOrigin::Location(GovernanceLocation::get())));
}
Loading