mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-14 15:35:45 +00:00
f60486047f
Don't bring the full polkadot node (with all its dependencies) in `emulated-integration-tests-common` crate and deps.
170 lines
5.3 KiB
Rust
170 lines
5.3 KiB
Rust
// 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.
|
|
|
|
pub mod impls;
|
|
pub mod macros;
|
|
pub mod xcm_helpers;
|
|
|
|
pub use xcm_emulator;
|
|
|
|
// Substrate
|
|
use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId;
|
|
use grandpa::AuthorityId as GrandpaId;
|
|
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
|
use sp_consensus_babe::AuthorityId as BabeId;
|
|
use sp_core::{sr25519, storage::Storage, Pair, Public};
|
|
use sp_runtime::{
|
|
traits::{IdentifyAccount, Verify},
|
|
BuildStorage, MultiSignature,
|
|
};
|
|
|
|
// Polakdot
|
|
use parachains_common::BlockNumber;
|
|
use polkadot_runtime_parachains::configuration::HostConfiguration;
|
|
|
|
// Cumulus
|
|
use parachains_common::{AccountId, AuraId};
|
|
use polkadot_primitives::{AssignmentId, ValidatorId};
|
|
|
|
pub const XCM_V2: u32 = 2;
|
|
pub const XCM_V3: u32 = 3;
|
|
pub const XCM_V4: u32 = 4;
|
|
pub const REF_TIME_THRESHOLD: u64 = 33;
|
|
pub const PROOF_SIZE_THRESHOLD: u64 = 33;
|
|
|
|
/// The default XCM version to set in genesis config.
|
|
pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
|
|
|
|
type AccountPublic = <MultiSignature as Verify>::Signer;
|
|
|
|
/// Helper function to generate a crypto pair from seed
|
|
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
|
|
TPublic::Pair::from_string(&format!("//{}", seed), None)
|
|
.expect("static values are valid; qed")
|
|
.public()
|
|
}
|
|
|
|
/// Helper function to generate an account ID from seed.
|
|
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
|
|
where
|
|
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
|
|
{
|
|
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
|
|
}
|
|
|
|
pub fn get_host_config() -> HostConfiguration<BlockNumber> {
|
|
HostConfiguration {
|
|
max_upward_queue_count: 10,
|
|
max_upward_queue_size: 51200,
|
|
max_upward_message_size: 51200,
|
|
max_upward_message_num_per_candidate: 10,
|
|
max_downward_message_size: 51200,
|
|
hrmp_sender_deposit: 0,
|
|
hrmp_recipient_deposit: 0,
|
|
hrmp_channel_max_capacity: 1000,
|
|
hrmp_channel_max_message_size: 102400,
|
|
hrmp_channel_max_total_size: 102400,
|
|
hrmp_max_parachain_outbound_channels: 30,
|
|
hrmp_max_parachain_inbound_channels: 30,
|
|
..Default::default()
|
|
}
|
|
}
|
|
|
|
/// Helper function used in tests to build the genesis storage using given RuntimeGenesisConfig and
|
|
/// code Used in `legacy_vs_json_check` submods to verify storage building with JSON patch against
|
|
/// building with RuntimeGenesisConfig struct.
|
|
pub fn build_genesis_storage(builder: &dyn BuildStorage, code: &[u8]) -> Storage {
|
|
let mut storage = builder.build_storage().unwrap();
|
|
storage
|
|
.top
|
|
.insert(sp_core::storage::well_known_keys::CODE.to_vec(), code.into());
|
|
storage
|
|
}
|
|
|
|
pub mod accounts {
|
|
use super::*;
|
|
pub const ALICE: &str = "Alice";
|
|
pub const BOB: &str = "Bob";
|
|
pub const CHARLIE: &str = "Charlie";
|
|
pub const DAVE: &str = "Dave";
|
|
pub const EVE: &str = "Eve";
|
|
pub const FERDIE: &str = "Ferdie";
|
|
pub const ALICE_STASH: &str = "Alice//stash";
|
|
pub const BOB_STASH: &str = "Bob//stash";
|
|
pub const CHARLIE_STASH: &str = "Charlie//stash";
|
|
pub const DAVE_STASH: &str = "Dave//stash";
|
|
pub const EVE_STASH: &str = "Eve//stash";
|
|
pub const FERDIE_STASH: &str = "Ferdie//stash";
|
|
pub const FERDIE_BEEFY: &str = "Ferdie//stash";
|
|
|
|
pub fn init_balances() -> Vec<AccountId> {
|
|
vec![
|
|
get_account_id_from_seed::<sr25519::Public>(ALICE),
|
|
get_account_id_from_seed::<sr25519::Public>(BOB),
|
|
get_account_id_from_seed::<sr25519::Public>(CHARLIE),
|
|
get_account_id_from_seed::<sr25519::Public>(DAVE),
|
|
get_account_id_from_seed::<sr25519::Public>(EVE),
|
|
get_account_id_from_seed::<sr25519::Public>(FERDIE),
|
|
get_account_id_from_seed::<sr25519::Public>(ALICE_STASH),
|
|
get_account_id_from_seed::<sr25519::Public>(BOB_STASH),
|
|
get_account_id_from_seed::<sr25519::Public>(CHARLIE_STASH),
|
|
get_account_id_from_seed::<sr25519::Public>(DAVE_STASH),
|
|
get_account_id_from_seed::<sr25519::Public>(EVE_STASH),
|
|
get_account_id_from_seed::<sr25519::Public>(FERDIE_STASH),
|
|
]
|
|
}
|
|
}
|
|
|
|
pub mod collators {
|
|
use super::*;
|
|
|
|
pub fn invulnerables() -> Vec<(AccountId, AuraId)> {
|
|
vec![
|
|
(
|
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
get_from_seed::<AuraId>("Alice"),
|
|
),
|
|
(get_account_id_from_seed::<sr25519::Public>("Bob"), get_from_seed::<AuraId>("Bob")),
|
|
]
|
|
}
|
|
}
|
|
|
|
pub mod validators {
|
|
use super::*;
|
|
|
|
pub fn initial_authorities() -> Vec<(
|
|
AccountId,
|
|
AccountId,
|
|
BabeId,
|
|
GrandpaId,
|
|
ValidatorId,
|
|
AssignmentId,
|
|
AuthorityDiscoveryId,
|
|
BeefyId,
|
|
)> {
|
|
let seed = "Alice";
|
|
vec![(
|
|
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)),
|
|
get_account_id_from_seed::<sr25519::Public>(seed),
|
|
get_from_seed::<BabeId>(seed),
|
|
get_from_seed::<GrandpaId>(seed),
|
|
get_from_seed::<ValidatorId>(seed),
|
|
get_from_seed::<AssignmentId>(seed),
|
|
get_from_seed::<AuthorityDiscoveryId>(seed),
|
|
get_from_seed::<BeefyId>(seed),
|
|
)]
|
|
}
|
|
}
|