feat: Rebrand Polkadot/Substrate references to PezkuwiChain
This commit systematically rebrands various references from Parity Technologies' Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk. Key changes include: - Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks. - Modified internal documentation and code comments to reflect PezkuwiChain naming and structure. - Replaced direct references to with or specific paths within the for XCM, Pezkuwi, and other modules. - Cleaned up deprecated issue and PR references in various and files, particularly in and modules. - Adjusted image and logo URLs in documentation to point to PezkuwiChain assets. - Removed or rephrased comments related to external Polkadot/Substrate PRs and issues. This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
[package]
|
||||
name = "governance-zagros-integration-tests"
|
||||
version = "0.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
description = "Zagros governance integration tests with xcm-emulator"
|
||||
publish = false
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
codec = { workspace = true, default-features = true }
|
||||
|
||||
# Bizinikiwi
|
||||
pezframe-support = { workspace = true, default-features = true }
|
||||
pezframe-system = { workspace = true, default-features = true }
|
||||
pezpallet-utility = { workspace = true, default-features = true }
|
||||
pezpallet-whitelist = { workspace = true, default-features = true }
|
||||
pezsp-core = { workspace = true, default-features = true }
|
||||
pezsp-runtime = { workspace = true, default-features = true }
|
||||
|
||||
pezpallet-xcm = { workspace = true, default-features = true }
|
||||
xcm = { workspace = true, default-features = true }
|
||||
|
||||
emulated-integration-tests-common = { workspace = true }
|
||||
|
||||
# Local
|
||||
asset-hub-zagros-runtime = { workspace = true }
|
||||
collectives-zagros-runtime = { workspace = true }
|
||||
zagros-runtime = { workspace = true }
|
||||
zagros-system-emulated-network = { workspace = true }
|
||||
|
||||
[features]
|
||||
runtime-benchmarks = [
|
||||
"asset-hub-zagros-runtime/runtime-benchmarks",
|
||||
"collectives-zagros-runtime/runtime-benchmarks",
|
||||
"emulated-integration-tests-common/runtime-benchmarks",
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezframe-system/runtime-benchmarks",
|
||||
"pezpallet-utility/runtime-benchmarks",
|
||||
"pezpallet-whitelist/runtime-benchmarks",
|
||||
"pezpallet-xcm/runtime-benchmarks",
|
||||
"pezsp-runtime/runtime-benchmarks",
|
||||
"xcm/runtime-benchmarks",
|
||||
"zagros-runtime/runtime-benchmarks",
|
||||
"zagros-system-emulated-network/runtime-benchmarks",
|
||||
]
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
// Copyright (C) Parity Technologies and the various Pezkuwi contributors, see Contributions.md
|
||||
// for a list of specific contributors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::imports::*;
|
||||
|
||||
/// CollectivesZagros dispatches `pezpallet_xcm::send` with `OriginKind:Xcm` to the dest with encoded
|
||||
/// whitelist call.
|
||||
#[cfg(test)]
|
||||
pub fn collectives_send_whitelist(
|
||||
dest: Location,
|
||||
encoded_whitelist_call: impl FnOnce() -> Vec<u8>,
|
||||
) {
|
||||
CollectivesZagros::execute_with(|| {
|
||||
type RuntimeEvent = <CollectivesZagros as Chain>::RuntimeEvent;
|
||||
type RuntimeCall = <CollectivesZagros as Chain>::RuntimeCall;
|
||||
type RuntimeOrigin = <CollectivesZagros as Chain>::RuntimeOrigin;
|
||||
type Runtime = <CollectivesZagros as Chain>::Runtime;
|
||||
|
||||
let send_whitelist_call = RuntimeCall::PezkuwiXcm(pezpallet_xcm::Call::<Runtime>::send {
|
||||
dest: bx!(VersionedLocation::from(dest)),
|
||||
message: bx!(VersionedXcm::from(Xcm(vec![
|
||||
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
|
||||
Transact {
|
||||
origin_kind: OriginKind::Xcm,
|
||||
fallback_max_weight: None,
|
||||
call: encoded_whitelist_call().into(),
|
||||
}
|
||||
]))),
|
||||
});
|
||||
|
||||
use collectives_zagros_runtime::fellowship::pezpallet_fellowship_origins::Origin::Fellows as FellowsOrigin;
|
||||
let fellows_origin: RuntimeOrigin = FellowsOrigin.into();
|
||||
assert_ok!(send_whitelist_call.dispatch(fellows_origin));
|
||||
assert_expected_events!(
|
||||
CollectivesZagros,
|
||||
vec![
|
||||
RuntimeEvent::PezkuwiXcm(pezpallet_xcm::Event::Sent { .. }) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright (C) Parity Technologies and the various Pezkuwi contributors, see Contributions.md
|
||||
// for a list of specific contributors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[cfg(test)]
|
||||
mod imports {
|
||||
pub(crate) use codec::Encode;
|
||||
pub(crate) use emulated_integration_tests_common::{
|
||||
impls::{assert_expected_events, bx, TestExt},
|
||||
xcm_emulator::Chain,
|
||||
xcm_helpers::{
|
||||
build_xcm_send_authorize_upgrade_call, call_hash_of,
|
||||
dispatch_whitelisted_call_with_preimage,
|
||||
},
|
||||
};
|
||||
pub(crate) use pezframe_support::{assert_err, assert_ok};
|
||||
pub(crate) use pezsp_runtime::{traits::Dispatchable, DispatchError};
|
||||
pub(crate) use xcm::{latest::prelude::*, VersionedLocation, VersionedXcm};
|
||||
pub(crate) use zagros_system_emulated_network::CollectivesZagrosPara as CollectivesZagros;
|
||||
|
||||
pub(crate) use zagros_system_emulated_network::{
|
||||
AssetHubZagrosPara as AssetHubZagros, BridgeHubZagrosPara as BridgeHubZagros,
|
||||
CoretimeZagrosPara as CoretimeZagros, PeopleZagrosPara as PeopleZagros,
|
||||
ZagrosRelay as Zagros,
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod common;
|
||||
|
||||
#[cfg(test)]
|
||||
mod open_gov_on_relay;
|
||||
|
||||
#[cfg(test)]
|
||||
mod open_gov_on_asset_hub;
|
||||
+287
@@ -0,0 +1,287 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
use crate::{common::*, imports::*};
|
||||
use asset_hub_zagros_runtime::governance::pezpallet_custom_origins::Origin;
|
||||
use emulated_integration_tests_common::impls::Teyrchain;
|
||||
|
||||
#[test]
|
||||
fn assethub_can_authorize_upgrade_for_itself() {
|
||||
let code_hash = [1u8; 32].into();
|
||||
type AssetHubRuntime = <AssetHubZagros as Chain>::Runtime;
|
||||
type AssetHubRuntimeCall = <AssetHubZagros as Chain>::RuntimeCall;
|
||||
type AssetHubRuntimeOrigin = <AssetHubZagros as Chain>::RuntimeOrigin;
|
||||
|
||||
let authorize_upgrade =
|
||||
AssetHubRuntimeCall::Utility(pezpallet_utility::Call::<AssetHubRuntime>::force_batch {
|
||||
calls: vec![AssetHubRuntimeCall::System(pezframe_system::Call::authorize_upgrade {
|
||||
code_hash,
|
||||
})],
|
||||
});
|
||||
|
||||
// bad origin
|
||||
let invalid_origin: AssetHubRuntimeOrigin = Origin::StakingAdmin.into();
|
||||
// ok origin
|
||||
let ok_origin: AssetHubRuntimeOrigin = Origin::WhitelistedCaller.into();
|
||||
|
||||
// store preimage
|
||||
let call_hash = call_hash_of::<AssetHubZagros>(&authorize_upgrade);
|
||||
|
||||
// Err - when dispatch non-whitelisted
|
||||
assert_err!(
|
||||
dispatch_whitelisted_call_with_preimage::<AssetHubZagros>(
|
||||
authorize_upgrade.clone(),
|
||||
ok_origin.clone()
|
||||
),
|
||||
DispatchError::Module(pezsp_runtime::ModuleError {
|
||||
index: 93,
|
||||
error: [3, 0, 0, 0],
|
||||
message: Some("CallIsNotWhitelisted")
|
||||
})
|
||||
);
|
||||
|
||||
// whitelist
|
||||
collectives_send_whitelist(
|
||||
CollectivesZagros::sibling_location_of(<AssetHubZagros as Teyrchain>::para_id()),
|
||||
|| {
|
||||
AssetHubRuntimeCall::Whitelist(
|
||||
pezpallet_whitelist::Call::<AssetHubRuntime>::whitelist_call { call_hash },
|
||||
)
|
||||
.encode()
|
||||
},
|
||||
);
|
||||
|
||||
// Err - when dispatch wrong origin
|
||||
assert_err!(
|
||||
dispatch_whitelisted_call_with_preimage::<AssetHubZagros>(
|
||||
authorize_upgrade.clone(),
|
||||
invalid_origin
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
|
||||
// check before
|
||||
AssetHubZagros::execute_with(|| {
|
||||
assert!(<AssetHubZagros as Chain>::System::authorized_upgrade().is_none())
|
||||
});
|
||||
|
||||
// ok - authorized
|
||||
assert_ok!(dispatch_whitelisted_call_with_preimage::<AssetHubZagros>(
|
||||
authorize_upgrade,
|
||||
ok_origin
|
||||
));
|
||||
|
||||
// check after - authorized
|
||||
AssetHubZagros::execute_with(|| {
|
||||
assert_eq!(
|
||||
<AssetHubZagros as Chain>::System::authorized_upgrade().unwrap().code_hash(),
|
||||
&code_hash
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn assethub_can_authorize_upgrade_for_relay_chain() {
|
||||
let code_hash = [1u8; 32].into();
|
||||
type AssetHubRuntime = <AssetHubZagros as Chain>::Runtime;
|
||||
type AssetHubRuntimeCall = <AssetHubZagros as Chain>::RuntimeCall;
|
||||
type AssetHubRuntimeOrigin = <AssetHubZagros as Chain>::RuntimeOrigin;
|
||||
|
||||
let authorize_upgrade =
|
||||
AssetHubRuntimeCall::Utility(pezpallet_utility::Call::<AssetHubRuntime>::force_batch {
|
||||
calls: vec![build_xcm_send_authorize_upgrade_call::<AssetHubZagros, Zagros>(
|
||||
AssetHubZagros::parent_location(),
|
||||
&code_hash,
|
||||
None,
|
||||
)],
|
||||
});
|
||||
|
||||
// bad origin
|
||||
let invalid_origin: AssetHubRuntimeOrigin = Origin::StakingAdmin.into();
|
||||
// ok origin
|
||||
let ok_origin: AssetHubRuntimeOrigin = Origin::WhitelistedCaller.into();
|
||||
|
||||
let call_hash = call_hash_of::<AssetHubZagros>(&authorize_upgrade);
|
||||
|
||||
// Err - when dispatch non-whitelisted
|
||||
assert_err!(
|
||||
dispatch_whitelisted_call_with_preimage::<AssetHubZagros>(
|
||||
authorize_upgrade.clone(),
|
||||
ok_origin.clone()
|
||||
),
|
||||
DispatchError::Module(pezsp_runtime::ModuleError {
|
||||
index: 93,
|
||||
error: [3, 0, 0, 0],
|
||||
message: Some("CallIsNotWhitelisted")
|
||||
})
|
||||
);
|
||||
|
||||
// whitelist
|
||||
collectives_send_whitelist(
|
||||
CollectivesZagros::sibling_location_of(<AssetHubZagros as Teyrchain>::para_id()),
|
||||
|| {
|
||||
AssetHubRuntimeCall::Whitelist(
|
||||
pezpallet_whitelist::Call::<AssetHubRuntime>::whitelist_call { call_hash },
|
||||
)
|
||||
.encode()
|
||||
},
|
||||
);
|
||||
|
||||
// Err - when dispatch wrong origin
|
||||
assert_err!(
|
||||
dispatch_whitelisted_call_with_preimage::<AssetHubZagros>(
|
||||
authorize_upgrade.clone(),
|
||||
invalid_origin
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
|
||||
// check before
|
||||
Zagros::execute_with(|| assert!(<Zagros as Chain>::System::authorized_upgrade().is_none()));
|
||||
|
||||
// ok - authorized
|
||||
assert_ok!(dispatch_whitelisted_call_with_preimage::<AssetHubZagros>(
|
||||
authorize_upgrade,
|
||||
ok_origin
|
||||
));
|
||||
|
||||
// check after - authorized
|
||||
Zagros::execute_with(|| {
|
||||
assert_eq!(<Zagros as Chain>::System::authorized_upgrade().unwrap().code_hash(), &code_hash)
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn assethub_can_authorize_upgrade_for_system_chains() {
|
||||
type AssetHubRuntime = <AssetHubZagros as Chain>::Runtime;
|
||||
type AssetHubRuntimeCall = <AssetHubZagros as Chain>::RuntimeCall;
|
||||
type AssetHubRuntimeOrigin = <AssetHubZagros as Chain>::RuntimeOrigin;
|
||||
|
||||
let code_hash_bridge_hub = [2u8; 32].into();
|
||||
let code_hash_collectives = [3u8; 32].into();
|
||||
let code_hash_coretime = [4u8; 32].into();
|
||||
let code_hash_people = [5u8; 32].into();
|
||||
|
||||
let authorize_upgrade =
|
||||
AssetHubRuntimeCall::Utility(pezpallet_utility::Call::<AssetHubRuntime>::force_batch {
|
||||
calls: vec![
|
||||
build_xcm_send_authorize_upgrade_call::<AssetHubZagros, BridgeHubZagros>(
|
||||
AssetHubZagros::sibling_location_of(BridgeHubZagros::para_id()),
|
||||
&code_hash_bridge_hub,
|
||||
None,
|
||||
),
|
||||
build_xcm_send_authorize_upgrade_call::<AssetHubZagros, CollectivesZagros>(
|
||||
AssetHubZagros::sibling_location_of(CollectivesZagros::para_id()),
|
||||
&code_hash_collectives,
|
||||
None,
|
||||
),
|
||||
build_xcm_send_authorize_upgrade_call::<AssetHubZagros, CoretimeZagros>(
|
||||
AssetHubZagros::sibling_location_of(CoretimeZagros::para_id()),
|
||||
&code_hash_coretime,
|
||||
None,
|
||||
),
|
||||
build_xcm_send_authorize_upgrade_call::<AssetHubZagros, PeopleZagros>(
|
||||
AssetHubZagros::sibling_location_of(PeopleZagros::para_id()),
|
||||
&code_hash_people,
|
||||
None,
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
// bad origin
|
||||
let invalid_origin: AssetHubRuntimeOrigin = Origin::StakingAdmin.into();
|
||||
// ok origin
|
||||
let ok_origin: AssetHubRuntimeOrigin = Origin::WhitelistedCaller.into();
|
||||
|
||||
let call_hash = call_hash_of::<AssetHubZagros>(&authorize_upgrade);
|
||||
|
||||
// Err - when dispatch non-whitelisted
|
||||
assert_err!(
|
||||
dispatch_whitelisted_call_with_preimage::<AssetHubZagros>(
|
||||
authorize_upgrade.clone(),
|
||||
ok_origin.clone()
|
||||
),
|
||||
DispatchError::Module(pezsp_runtime::ModuleError {
|
||||
index: 93,
|
||||
error: [3, 0, 0, 0],
|
||||
message: Some("CallIsNotWhitelisted")
|
||||
})
|
||||
);
|
||||
|
||||
// whitelist
|
||||
collectives_send_whitelist(
|
||||
CollectivesZagros::sibling_location_of(<AssetHubZagros as Teyrchain>::para_id()),
|
||||
|| {
|
||||
AssetHubRuntimeCall::Whitelist(
|
||||
pezpallet_whitelist::Call::<AssetHubRuntime>::whitelist_call { call_hash },
|
||||
)
|
||||
.encode()
|
||||
},
|
||||
);
|
||||
|
||||
// Err - when dispatch wrong origin
|
||||
assert_err!(
|
||||
dispatch_whitelisted_call_with_preimage::<AssetHubZagros>(
|
||||
authorize_upgrade.clone(),
|
||||
invalid_origin
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
|
||||
// check before
|
||||
BridgeHubZagros::execute_with(|| {
|
||||
assert!(<BridgeHubZagros as Chain>::System::authorized_upgrade().is_none())
|
||||
});
|
||||
CollectivesZagros::execute_with(|| {
|
||||
assert!(<CollectivesZagros as Chain>::System::authorized_upgrade().is_none())
|
||||
});
|
||||
CoretimeZagros::execute_with(|| {
|
||||
assert!(<CoretimeZagros as Chain>::System::authorized_upgrade().is_none())
|
||||
});
|
||||
PeopleZagros::execute_with(|| {
|
||||
assert!(<PeopleZagros as Chain>::System::authorized_upgrade().is_none())
|
||||
});
|
||||
|
||||
// ok - authorized
|
||||
assert_ok!(dispatch_whitelisted_call_with_preimage::<AssetHubZagros>(
|
||||
authorize_upgrade,
|
||||
ok_origin
|
||||
));
|
||||
|
||||
// check after - authorized
|
||||
BridgeHubZagros::execute_with(|| {
|
||||
assert_eq!(
|
||||
<BridgeHubZagros as Chain>::System::authorized_upgrade().unwrap().code_hash(),
|
||||
&code_hash_bridge_hub
|
||||
)
|
||||
});
|
||||
CollectivesZagros::execute_with(|| {
|
||||
assert_eq!(
|
||||
<CollectivesZagros as Chain>::System::authorized_upgrade().unwrap().code_hash(),
|
||||
&code_hash_collectives
|
||||
)
|
||||
});
|
||||
CoretimeZagros::execute_with(|| {
|
||||
assert_eq!(
|
||||
<CoretimeZagros as Chain>::System::authorized_upgrade().unwrap().code_hash(),
|
||||
&code_hash_coretime
|
||||
)
|
||||
});
|
||||
PeopleZagros::execute_with(|| {
|
||||
assert_eq!(
|
||||
<PeopleZagros as Chain>::System::authorized_upgrade().unwrap().code_hash(),
|
||||
&code_hash_people
|
||||
)
|
||||
});
|
||||
}
|
||||
+236
@@ -0,0 +1,236 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
use crate::{common::*, imports::*};
|
||||
use emulated_integration_tests_common::{
|
||||
assert_whitelisted,
|
||||
impls::RelayChain,
|
||||
xcm_emulator::{Chain, TestExt, Teyrchain},
|
||||
};
|
||||
use zagros_runtime::governance::pezpallet_custom_origins::Origin;
|
||||
use zagros_system_emulated_network::{
|
||||
AssetHubZagrosPara as AssetHubZagros, BridgeHubZagrosPara as BridgeHubZagros,
|
||||
CoretimeZagrosPara as CoretimeZagros, PeopleZagrosPara as PeopleZagros, ZagrosRelay as Zagros,
|
||||
};
|
||||
|
||||
use zagros_system_emulated_network::zagros_emulated_chain::zagros_runtime::Dmp;
|
||||
|
||||
#[test]
|
||||
fn relaychain_can_authorize_upgrade_for_itself() {
|
||||
let code_hash = [1u8; 32].into();
|
||||
type ZagrosRuntime = <Zagros as Chain>::Runtime;
|
||||
type ZagrosRuntimeCall = <Zagros as Chain>::RuntimeCall;
|
||||
type ZagrosRuntimeOrigin = <Zagros as Chain>::RuntimeOrigin;
|
||||
|
||||
let authorize_upgrade =
|
||||
ZagrosRuntimeCall::Utility(pezpallet_utility::Call::<ZagrosRuntime>::force_batch {
|
||||
calls: vec![
|
||||
// upgrade the relaychain
|
||||
ZagrosRuntimeCall::System(pezframe_system::Call::authorize_upgrade { code_hash }),
|
||||
],
|
||||
});
|
||||
|
||||
// bad origin
|
||||
let invalid_origin: ZagrosRuntimeOrigin = Origin::StakingAdmin.into();
|
||||
// ok origin
|
||||
let ok_origin: ZagrosRuntimeOrigin = Origin::WhitelistedCaller.into();
|
||||
|
||||
let call_hash = call_hash_of::<Zagros>(&authorize_upgrade);
|
||||
|
||||
// Err - when dispatch non-whitelisted
|
||||
assert_err!(
|
||||
dispatch_whitelisted_call_with_preimage::<Zagros>(
|
||||
authorize_upgrade.clone(),
|
||||
ok_origin.clone()
|
||||
),
|
||||
DispatchError::Module(pezsp_runtime::ModuleError {
|
||||
index: 36,
|
||||
error: [3, 0, 0, 0],
|
||||
message: Some("CallIsNotWhitelisted")
|
||||
})
|
||||
);
|
||||
|
||||
// whitelist
|
||||
collectives_send_whitelist(Location::parent(), || {
|
||||
ZagrosRuntimeCall::Whitelist(pezpallet_whitelist::Call::<ZagrosRuntime>::whitelist_call {
|
||||
call_hash,
|
||||
})
|
||||
.encode()
|
||||
});
|
||||
|
||||
// Err - when dispatch wrong origin
|
||||
assert_err!(
|
||||
dispatch_whitelisted_call_with_preimage::<Zagros>(
|
||||
authorize_upgrade.clone(),
|
||||
invalid_origin
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
|
||||
// check before
|
||||
Zagros::execute_with(|| assert!(<Zagros as Chain>::System::authorized_upgrade().is_none()));
|
||||
|
||||
// ok - authorized
|
||||
assert_ok!(dispatch_whitelisted_call_with_preimage::<Zagros>(authorize_upgrade, ok_origin));
|
||||
|
||||
// check after - authorized
|
||||
Zagros::execute_with(|| {
|
||||
assert_eq!(<Zagros as Chain>::System::authorized_upgrade().unwrap().code_hash(), &code_hash)
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn relaychain_can_authorize_upgrade_for_system_chains() {
|
||||
type ZagrosRuntime = <Zagros as Chain>::Runtime;
|
||||
type ZagrosRuntimeCall = <Zagros as Chain>::RuntimeCall;
|
||||
type ZagrosRuntimeOrigin = <Zagros as Chain>::RuntimeOrigin;
|
||||
|
||||
Zagros::execute_with(|| {
|
||||
Dmp::make_teyrchain_reachable(AssetHubZagros::para_id());
|
||||
Dmp::make_teyrchain_reachable(BridgeHubZagros::para_id());
|
||||
Dmp::make_teyrchain_reachable(CollectivesZagros::para_id());
|
||||
Dmp::make_teyrchain_reachable(CoretimeZagros::para_id());
|
||||
Dmp::make_teyrchain_reachable(PeopleZagros::para_id());
|
||||
});
|
||||
|
||||
let code_hash_asset_hub = [1u8; 32].into();
|
||||
let code_hash_bridge_hub = [2u8; 32].into();
|
||||
let code_hash_collectives = [3u8; 32].into();
|
||||
let code_hash_coretime = [4u8; 32].into();
|
||||
let code_hash_people = [5u8; 32].into();
|
||||
|
||||
let authorize_upgrade =
|
||||
ZagrosRuntimeCall::Utility(pezpallet_utility::Call::<ZagrosRuntime>::force_batch {
|
||||
calls: vec![
|
||||
build_xcm_send_authorize_upgrade_call::<Zagros, AssetHubZagros>(
|
||||
Zagros::child_location_of(AssetHubZagros::para_id()),
|
||||
&code_hash_asset_hub,
|
||||
None,
|
||||
),
|
||||
build_xcm_send_authorize_upgrade_call::<Zagros, BridgeHubZagros>(
|
||||
Zagros::child_location_of(BridgeHubZagros::para_id()),
|
||||
&code_hash_bridge_hub,
|
||||
None,
|
||||
),
|
||||
build_xcm_send_authorize_upgrade_call::<Zagros, CollectivesZagros>(
|
||||
Zagros::child_location_of(CollectivesZagros::para_id()),
|
||||
&code_hash_collectives,
|
||||
None,
|
||||
),
|
||||
build_xcm_send_authorize_upgrade_call::<Zagros, CoretimeZagros>(
|
||||
Zagros::child_location_of(CoretimeZagros::para_id()),
|
||||
&code_hash_coretime,
|
||||
None,
|
||||
),
|
||||
build_xcm_send_authorize_upgrade_call::<Zagros, PeopleZagros>(
|
||||
Zagros::child_location_of(PeopleZagros::para_id()),
|
||||
&code_hash_people,
|
||||
None,
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
// bad origin
|
||||
let invalid_origin: ZagrosRuntimeOrigin = Origin::StakingAdmin.into();
|
||||
// ok origin
|
||||
let ok_origin: ZagrosRuntimeOrigin = Origin::WhitelistedCaller.into();
|
||||
|
||||
let call_hash = call_hash_of::<Zagros>(&authorize_upgrade);
|
||||
|
||||
// Err - when dispatch non-whitelisted
|
||||
assert_err!(
|
||||
dispatch_whitelisted_call_with_preimage::<Zagros>(
|
||||
authorize_upgrade.clone(),
|
||||
ok_origin.clone()
|
||||
),
|
||||
DispatchError::Module(pezsp_runtime::ModuleError {
|
||||
index: 36,
|
||||
error: [3, 0, 0, 0],
|
||||
message: Some("CallIsNotWhitelisted")
|
||||
})
|
||||
);
|
||||
|
||||
// whitelist
|
||||
collectives_send_whitelist(Location::parent(), || {
|
||||
ZagrosRuntimeCall::Whitelist(pezpallet_whitelist::Call::<ZagrosRuntime>::whitelist_call {
|
||||
call_hash,
|
||||
})
|
||||
.encode()
|
||||
});
|
||||
|
||||
Zagros::execute_with(|| {
|
||||
assert_whitelisted!(Zagros, call_hash);
|
||||
});
|
||||
|
||||
// Err - when dispatch wrong origin
|
||||
assert_err!(
|
||||
dispatch_whitelisted_call_with_preimage::<Zagros>(
|
||||
authorize_upgrade.clone(),
|
||||
invalid_origin
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
|
||||
// check before
|
||||
AssetHubZagros::execute_with(|| {
|
||||
assert!(<AssetHubZagros as Chain>::System::authorized_upgrade().is_none())
|
||||
});
|
||||
BridgeHubZagros::execute_with(|| {
|
||||
assert!(<BridgeHubZagros as Chain>::System::authorized_upgrade().is_none())
|
||||
});
|
||||
CollectivesZagros::execute_with(|| {
|
||||
assert!(<CollectivesZagros as Chain>::System::authorized_upgrade().is_none())
|
||||
});
|
||||
CoretimeZagros::execute_with(|| {
|
||||
assert!(<CoretimeZagros as Chain>::System::authorized_upgrade().is_none())
|
||||
});
|
||||
PeopleZagros::execute_with(|| {
|
||||
assert!(<PeopleZagros as Chain>::System::authorized_upgrade().is_none())
|
||||
});
|
||||
|
||||
// ok - authorized
|
||||
assert_ok!(dispatch_whitelisted_call_with_preimage::<Zagros>(authorize_upgrade, ok_origin));
|
||||
|
||||
AssetHubZagros::execute_with(|| {
|
||||
assert_eq!(
|
||||
<AssetHubZagros as Chain>::System::authorized_upgrade().unwrap().code_hash(),
|
||||
&code_hash_asset_hub
|
||||
)
|
||||
});
|
||||
// check after - authorized
|
||||
BridgeHubZagros::execute_with(|| {
|
||||
assert_eq!(
|
||||
<BridgeHubZagros as Chain>::System::authorized_upgrade().unwrap().code_hash(),
|
||||
&code_hash_bridge_hub
|
||||
)
|
||||
});
|
||||
CollectivesZagros::execute_with(|| {
|
||||
assert_eq!(
|
||||
<CollectivesZagros as Chain>::System::authorized_upgrade().unwrap().code_hash(),
|
||||
&code_hash_collectives
|
||||
)
|
||||
});
|
||||
CoretimeZagros::execute_with(|| {
|
||||
assert_eq!(
|
||||
<CoretimeZagros as Chain>::System::authorized_upgrade().unwrap().code_hash(),
|
||||
&code_hash_coretime
|
||||
)
|
||||
});
|
||||
PeopleZagros::execute_with(|| {
|
||||
assert_eq!(
|
||||
<PeopleZagros as Chain>::System::authorized_upgrade().unwrap().code_hash(),
|
||||
&code_hash_people
|
||||
)
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user