1c0e57d984
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.
203 lines
6.7 KiB
Rust
203 lines
6.7 KiB
Rust
// Copyright (C) Parity Technologies (UK) Ltd.
|
|
// This file is part of Pezcumulus.
|
|
// 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)]
|
|
|
|
use collectives_zagros_runtime::{
|
|
xcm_config::{GovernanceLocation, LocationToAccountId},
|
|
Block, Runtime, RuntimeCall, RuntimeOrigin,
|
|
};
|
|
use pezframe_support::{assert_err, assert_ok};
|
|
use pezsp_core::crypto::Ss58Codec;
|
|
use pezsp_runtime::Either;
|
|
use testnet_teyrchains_constants::zagros::fee::WeightToFee;
|
|
use teyrchains_common::AccountId;
|
|
use teyrchains_runtimes_test_utils::GovernanceOrigin;
|
|
use xcm::latest::prelude::*;
|
|
use xcm_runtime_apis::conversions::LocationToAccountHelper;
|
|
|
|
const ALICE: [u8; 32] = [1u8; 32];
|
|
|
|
#[test]
|
|
fn location_conversion_works() {
|
|
// the purpose of hardcoded values is to catch an unintended location conversion logic change.
|
|
struct TestCase {
|
|
description: &'static str,
|
|
location: Location,
|
|
expected_account_id_str: &'static str,
|
|
}
|
|
|
|
let test_cases = vec![
|
|
// DescribeTerminus
|
|
TestCase {
|
|
description: "DescribeTerminus Parent",
|
|
location: Location::new(1, Here),
|
|
expected_account_id_str: "5Dt6dpkWPwLaH4BBCKJwjiWrFVAGyYk3tLUabvyn4v7KtESG",
|
|
},
|
|
TestCase {
|
|
description: "DescribeTerminus Sibling",
|
|
location: Location::new(1, [Teyrchain(1111)]),
|
|
expected_account_id_str: "5Eg2fnssmmJnF3z1iZ1NouAuzciDaaDQH7qURAy3w15jULDk",
|
|
},
|
|
// DescribePalletTerminal
|
|
TestCase {
|
|
description: "DescribePalletTerminal Parent",
|
|
location: Location::new(1, [PalletInstance(50)]),
|
|
expected_account_id_str: "5CnwemvaAXkWFVwibiCvf2EjqwiqBi29S5cLLydZLEaEw6jZ",
|
|
},
|
|
TestCase {
|
|
description: "DescribePalletTerminal Sibling",
|
|
location: Location::new(1, [Teyrchain(1111), PalletInstance(50)]),
|
|
expected_account_id_str: "5GFBgPjpEQPdaxEnFirUoa51u5erVx84twYxJVuBRAT2UP2g",
|
|
},
|
|
// DescribeAccountId32Terminal
|
|
TestCase {
|
|
description: "DescribeAccountId32Terminal Parent",
|
|
location: Location::new(
|
|
1,
|
|
[Junction::AccountId32 { network: None, id: AccountId::from(ALICE).into() }],
|
|
),
|
|
expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
|
|
},
|
|
TestCase {
|
|
description: "DescribeAccountId32Terminal Sibling",
|
|
location: Location::new(
|
|
1,
|
|
[
|
|
Teyrchain(1111),
|
|
Junction::AccountId32 { network: None, id: AccountId::from(ALICE).into() },
|
|
],
|
|
),
|
|
expected_account_id_str: "5DGRXLYwWGce7wvm14vX1Ms4Vf118FSWQbJkyQigY2pfm6bg",
|
|
},
|
|
// DescribeAccountKey20Terminal
|
|
TestCase {
|
|
description: "DescribeAccountKey20Terminal Parent",
|
|
location: Location::new(1, [AccountKey20 { network: None, key: [0u8; 20] }]),
|
|
expected_account_id_str: "5F5Ec11567pa919wJkX6VHtv2ZXS5W698YCW35EdEbrg14cg",
|
|
},
|
|
TestCase {
|
|
description: "DescribeAccountKey20Terminal Sibling",
|
|
location: Location::new(
|
|
1,
|
|
[Teyrchain(1111), AccountKey20 { network: None, key: [0u8; 20] }],
|
|
),
|
|
expected_account_id_str: "5CB2FbUds2qvcJNhDiTbRZwiS3trAy6ydFGMSVutmYijpPAg",
|
|
},
|
|
// DescribeTreasuryVoiceTerminal
|
|
TestCase {
|
|
description: "DescribeTreasuryVoiceTerminal Parent",
|
|
location: Location::new(1, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]),
|
|
expected_account_id_str: "5CUjnE2vgcUCuhxPwFoQ5r7p1DkhujgvMNDHaF2bLqRp4D5F",
|
|
},
|
|
TestCase {
|
|
description: "DescribeTreasuryVoiceTerminal Sibling",
|
|
location: Location::new(
|
|
1,
|
|
[Teyrchain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
|
|
),
|
|
expected_account_id_str: "5G6TDwaVgbWmhqRUKjBhRRnH4ry9L9cjRymUEmiRsLbSE4gB",
|
|
},
|
|
// DescribeBodyTerminal
|
|
TestCase {
|
|
description: "DescribeBodyTerminal Parent",
|
|
location: Location::new(1, [Plurality { id: BodyId::Unit, part: BodyPart::Voice }]),
|
|
expected_account_id_str: "5EBRMTBkDisEXsaN283SRbzx9Xf2PXwUxxFCJohSGo4jYe6B",
|
|
},
|
|
TestCase {
|
|
description: "DescribeBodyTerminal Sibling",
|
|
location: Location::new(
|
|
1,
|
|
[Teyrchain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
|
|
),
|
|
expected_account_id_str: "5DBoExvojy8tYnHgLL97phNH975CyT45PWTZEeGoBZfAyRMH",
|
|
},
|
|
];
|
|
|
|
for tc in test_cases {
|
|
let expected =
|
|
AccountId::from_string(tc.expected_account_id_str).expect("Invalid AccountId string");
|
|
|
|
let got = LocationToAccountHelper::<AccountId, LocationToAccountId>::convert_location(
|
|
tc.location.into(),
|
|
)
|
|
.unwrap();
|
|
|
|
assert_eq!(got, expected, "{}", tc.description);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn xcm_payment_api_works() {
|
|
teyrchains_runtimes_test_utils::test_cases::xcm_payment_api_with_native_token_works::<
|
|
Runtime,
|
|
RuntimeCall,
|
|
RuntimeOrigin,
|
|
Block,
|
|
WeightToFee,
|
|
>();
|
|
}
|
|
|
|
#[test]
|
|
fn governance_authorize_upgrade_works() {
|
|
use zagros_runtime_constants::system_teyrchain::{ASSET_HUB_ID, COLLECTIVES_ID};
|
|
|
|
// no - random para
|
|
assert_err!(
|
|
teyrchains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
|
|
Runtime,
|
|
RuntimeOrigin,
|
|
>(GovernanceOrigin::Location(Location::new(1, Teyrchain(12334)))),
|
|
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
|
|
);
|
|
// ok - AssetHub
|
|
assert_ok!(teyrchains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
|
|
Runtime,
|
|
RuntimeOrigin,
|
|
>(GovernanceOrigin::Location(Location::new(1, Teyrchain(ASSET_HUB_ID)))));
|
|
// no - Collectives
|
|
assert_err!(
|
|
teyrchains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
|
|
Runtime,
|
|
RuntimeOrigin,
|
|
>(GovernanceOrigin::Location(Location::new(1, Teyrchain(COLLECTIVES_ID)))),
|
|
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
|
|
);
|
|
// no - Collectives Voice of Fellows plurality
|
|
assert_err!(
|
|
teyrchains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
|
|
Runtime,
|
|
RuntimeOrigin,
|
|
>(GovernanceOrigin::LocationAndDescendOrigin(
|
|
Location::new(1, Teyrchain(COLLECTIVES_ID)),
|
|
Plurality { id: BodyId::Technical, part: BodyPart::Voice }.into()
|
|
)),
|
|
Either::Right(InstructionError { index: 0, error: XcmError::Barrier })
|
|
);
|
|
|
|
// ok - relaychain
|
|
assert_ok!(teyrchains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
|
|
Runtime,
|
|
RuntimeOrigin,
|
|
>(GovernanceOrigin::Location(Location::parent())));
|
|
|
|
// ok - governance location
|
|
assert_ok!(teyrchains_runtimes_test_utils::test_cases::can_governance_authorize_upgrade::<
|
|
Runtime,
|
|
RuntimeOrigin,
|
|
>(GovernanceOrigin::Location(GovernanceLocation::get())));
|
|
}
|