emulated_integration_tests_common/
lib.rs1pub mod impls;
17pub mod macros;
18pub mod xcm_helpers;
19
20pub use xcm_emulator;
21
22use frame_support::parameter_types;
24use sc_consensus_grandpa::AuthorityId as GrandpaId;
25use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
26use sp_consensus_babe::AuthorityId as BabeId;
27use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
28use sp_core::{sr25519, storage::Storage, Pair, Public};
29use sp_runtime::{
30 traits::{AccountIdConversion, IdentifyAccount, Verify},
31 BuildStorage, MultiSignature,
32};
33
34use parachains_common::BlockNumber;
36use polkadot_parachain_primitives::primitives::Sibling;
37use polkadot_runtime_parachains::configuration::HostConfiguration;
38
39use parachains_common::{AccountId, AuraId};
41use polkadot_primitives::{AssignmentId, ValidatorId};
42
43pub const XCM_V2: u32 = 2;
44pub const XCM_V3: u32 = 3;
45pub const XCM_V4: u32 = 4;
46pub const REF_TIME_THRESHOLD: u64 = 33;
47pub const PROOF_SIZE_THRESHOLD: u64 = 33;
48
49pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
51
52type AccountPublic = <MultiSignature as Verify>::Signer;
53
54pub const RESERVABLE_ASSET_ID: u32 = 1;
56pub const TELEPORTABLE_ASSET_ID: u32 = 2;
58
59pub const USDT_ID: u32 = 1984;
61
62pub const PENPAL_ID: u32 = 2000;
63pub const PENPAL_B_ID: u32 = 2001;
64pub const ASSETS_PALLET_ID: u8 = 50;
65
66parameter_types! {
67 pub PenpalTeleportableAssetLocation: xcm::v4::Location
68 = xcm::v4::Location::new(1, [
69 xcm::v4::Junction::Parachain(PENPAL_ID),
70 xcm::v4::Junction::PalletInstance(ASSETS_PALLET_ID),
71 xcm::v4::Junction::GeneralIndex(TELEPORTABLE_ASSET_ID.into()),
72 ]
73 );
74 pub PenpalSiblingSovereignAccount: AccountId = Sibling::from(PENPAL_ID).into_account_truncating();
75 pub PenpalBTeleportableAssetLocation: xcm::v4::Location
76 = xcm::v4::Location::new(1, [
77 xcm::v4::Junction::Parachain(PENPAL_B_ID),
78 xcm::v4::Junction::PalletInstance(ASSETS_PALLET_ID),
79 xcm::v4::Junction::GeneralIndex(TELEPORTABLE_ASSET_ID.into()),
80 ]
81 );
82 pub PenpalBSiblingSovereignAccount: AccountId = Sibling::from(PENPAL_B_ID).into_account_truncating();
83}
84
85pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
87 TPublic::Pair::from_string(&format!("//{}", seed), None)
88 .expect("static values are valid; qed")
89 .public()
90}
91
92pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
94where
95 AccountPublic: From<<TPublic::Pair as Pair>::Public>,
96{
97 AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
98}
99
100pub fn get_host_config() -> HostConfiguration<BlockNumber> {
101 HostConfiguration {
102 max_upward_queue_count: 10,
103 max_upward_queue_size: 51200,
104 max_upward_message_size: 51200,
105 max_upward_message_num_per_candidate: 10,
106 max_downward_message_size: 51200,
107 hrmp_sender_deposit: 0,
108 hrmp_recipient_deposit: 0,
109 hrmp_channel_max_capacity: 1000,
110 hrmp_channel_max_message_size: 102400,
111 hrmp_channel_max_total_size: 102400,
112 hrmp_max_parachain_outbound_channels: 30,
113 hrmp_max_parachain_inbound_channels: 30,
114 ..Default::default()
115 }
116}
117
118pub fn build_genesis_storage(builder: &dyn BuildStorage, code: &[u8]) -> Storage {
122 let mut storage = builder.build_storage().unwrap();
123 storage
124 .top
125 .insert(sp_core::storage::well_known_keys::CODE.to_vec(), code.into());
126 storage
127}
128
129pub mod accounts {
130 use super::*;
131 pub const ALICE: &str = "Alice";
132 pub const BOB: &str = "Bob";
133 pub const CHARLIE: &str = "Charlie";
134 pub const DAVE: &str = "Dave";
135 pub const EVE: &str = "Eve";
136 pub const FERDIE: &str = "Ferdie";
137 pub const ALICE_STASH: &str = "Alice//stash";
138 pub const BOB_STASH: &str = "Bob//stash";
139 pub const CHARLIE_STASH: &str = "Charlie//stash";
140 pub const DAVE_STASH: &str = "Dave//stash";
141 pub const EVE_STASH: &str = "Eve//stash";
142 pub const FERDIE_STASH: &str = "Ferdie//stash";
143 pub const FERDIE_BEEFY: &str = "Ferdie//stash";
144 pub const DUMMY_EMPTY: &str = "JohnDoe";
145
146 pub fn init_balances() -> Vec<AccountId> {
147 vec![
148 get_account_id_from_seed::<sr25519::Public>(ALICE),
149 get_account_id_from_seed::<sr25519::Public>(BOB),
150 get_account_id_from_seed::<sr25519::Public>(CHARLIE),
151 get_account_id_from_seed::<sr25519::Public>(DAVE),
152 get_account_id_from_seed::<sr25519::Public>(EVE),
153 get_account_id_from_seed::<sr25519::Public>(FERDIE),
154 get_account_id_from_seed::<sr25519::Public>(ALICE_STASH),
155 get_account_id_from_seed::<sr25519::Public>(BOB_STASH),
156 get_account_id_from_seed::<sr25519::Public>(CHARLIE_STASH),
157 get_account_id_from_seed::<sr25519::Public>(DAVE_STASH),
158 get_account_id_from_seed::<sr25519::Public>(EVE_STASH),
159 get_account_id_from_seed::<sr25519::Public>(FERDIE_STASH),
160 ]
161 }
162}
163
164pub mod collators {
165 use super::*;
166
167 pub fn invulnerables() -> Vec<(AccountId, AuraId)> {
168 vec![
169 (
170 get_account_id_from_seed::<sr25519::Public>("Alice"),
171 get_from_seed::<AuraId>("Alice"),
172 ),
173 (get_account_id_from_seed::<sr25519::Public>("Bob"), get_from_seed::<AuraId>("Bob")),
174 ]
175 }
176}
177
178pub mod validators {
179 use super::*;
180
181 pub fn initial_authorities() -> Vec<(
182 AccountId,
183 AccountId,
184 BabeId,
185 GrandpaId,
186 ValidatorId,
187 AssignmentId,
188 AuthorityDiscoveryId,
189 BeefyId,
190 )> {
191 let seed = "Alice";
192 vec![(
193 get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)),
194 get_account_id_from_seed::<sr25519::Public>(seed),
195 get_from_seed::<BabeId>(seed),
196 get_from_seed::<GrandpaId>(seed),
197 get_from_seed::<ValidatorId>(seed),
198 get_from_seed::<AssignmentId>(seed),
199 get_from_seed::<AuthorityDiscoveryId>(seed),
200 get_from_seed::<BeefyId>(seed),
201 )]
202 }
203}