From 2d37be1968b7748d631b58780f660bbcf59342b5 Mon Sep 17 00:00:00 2001 From: Tomasz Polaczyk Date: Fri, 19 Jul 2024 11:20:59 +0200 Subject: [PATCH 1/6] Allow registering parathreads in pallet_registrar genesis --- node/src/chain_spec/dancebox.rs | 2 +- node/src/chain_spec/flashbox.rs | 2 +- pallets/registrar/src/lib.rs | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/node/src/chain_spec/dancebox.rs b/node/src/chain_spec/dancebox.rs index 681f15936..fb71fadc6 100644 --- a/node/src/chain_spec/dancebox.rs +++ b/node/src/chain_spec/dancebox.rs @@ -216,7 +216,7 @@ fn testnet_genesis( .collect(); let para_ids: Vec<_> = para_ids .into_iter() - .map(|(para_id, genesis_data, _boot_nodes)| (para_id, genesis_data)) + .map(|(para_id, genesis_data, _boot_nodes)| (para_id, genesis_data, None)) .collect(); let accounts_with_ed = [ diff --git a/node/src/chain_spec/flashbox.rs b/node/src/chain_spec/flashbox.rs index c4559a0e6..abe02ef81 100644 --- a/node/src/chain_spec/flashbox.rs +++ b/node/src/chain_spec/flashbox.rs @@ -217,7 +217,7 @@ fn testnet_genesis( let para_ids: Vec<_> = para_ids .into_iter() - .map(|(para_id, genesis_data, _boot_nodes)| (para_id, genesis_data)) + .map(|(para_id, genesis_data, _boot_nodes)| (para_id, genesis_data, None)) .collect(); let accounts_with_ed = [ diff --git a/pallets/registrar/src/lib.rs b/pallets/registrar/src/lib.rs index 39d8c3bff..bfa23bf44 100644 --- a/pallets/registrar/src/lib.rs +++ b/pallets/registrar/src/lib.rs @@ -77,7 +77,11 @@ pub mod pallet { #[derive(DefaultNoBound)] pub struct GenesisConfig { /// Para ids - pub para_ids: Vec<(ParaId, ContainerChainGenesisData)>, + pub para_ids: Vec<( + ParaId, + ContainerChainGenesisData, + Option, + )>, } #[pallet::genesis_build] @@ -97,7 +101,7 @@ pub mod pallet { let mut bounded_para_ids = BoundedVec::default(); - for (para_id, genesis_data) in para_ids { + for (para_id, genesis_data, parathread_params) in para_ids { bounded_para_ids .try_push(*para_id) .expect("too many para ids in genesis: bounded vec full"); @@ -112,6 +116,10 @@ pub mod pallet { ); } >::insert(para_id, genesis_data); + + if let Some(parathread_params) = parathread_params { + >::insert(para_id, parathread_params); + } } >::put(bounded_para_ids); From fbbfc7a9d108efd7e5ed18e9a15e1523f2216361 Mon Sep 17 00:00:00 2001 From: Tomasz Polaczyk Date: Fri, 19 Jul 2024 12:21:18 +0200 Subject: [PATCH 2/6] Fix tests --- pallets/registrar/src/mock.rs | 8 ++++-- pallets/registrar/src/tests.rs | 26 +++++++++---------- runtime/dancebox/tests/common/mod.rs | 8 +++++- runtime/flashbox/tests/common/mod.rs | 8 +++++- .../runtime/starlight/tests/common/mod.rs | 8 +++++- 5 files changed, 40 insertions(+), 18 deletions(-) diff --git a/pallets/registrar/src/mock.rs b/pallets/registrar/src/mock.rs index c89f16747..ff734b8e2 100644 --- a/pallets/registrar/src/mock.rs +++ b/pallets/registrar/src/mock.rs @@ -15,7 +15,7 @@ // along with Tanssi. If not, see use { - crate::{self as pallet_registrar, RegistrarHooks}, + crate::{self as pallet_registrar, ParathreadParamsTy, RegistrarHooks}, frame_support::{ traits::{ConstU16, ConstU64}, weights::Weight, @@ -312,7 +312,11 @@ pub fn new_test_ext() -> sp_io::TestExternalities { // Build genesis storage according to the mock runtime. pub fn new_test_ext_with_genesis( - para_ids: Vec<(ParaId, ContainerChainGenesisData)>, + para_ids: Vec<( + ParaId, + ContainerChainGenesisData, + Option, + )>, ) -> sp_io::TestExternalities { RuntimeGenesisConfig { system: Default::default(), diff --git a/pallets/registrar/src/tests.rs b/pallets/registrar/src/tests.rs index f0ef67f46..8dd10b7f5 100644 --- a/pallets/registrar/src/tests.rs +++ b/pallets/registrar/src/tests.rs @@ -536,10 +536,10 @@ fn unpause_para_id_42_fails_not_registered() { #[test] fn genesis_loads_para_ids() { new_test_ext_with_genesis(vec![ - (1.into(), empty_genesis_data()), - (2.into(), empty_genesis_data()), - (3.into(), empty_genesis_data()), - (4.into(), empty_genesis_data()), + (1.into(), empty_genesis_data(), None), + (2.into(), empty_genesis_data(), None), + (3.into(), empty_genesis_data(), None), + (4.into(), empty_genesis_data(), None), ]) .execute_with(|| { run_to_block(1); @@ -553,10 +553,10 @@ fn genesis_loads_para_ids() { #[test] fn genesis_sorts_para_ids() { new_test_ext_with_genesis(vec![ - (4.into(), empty_genesis_data()), - (2.into(), empty_genesis_data()), - (3.into(), empty_genesis_data()), - (1.into(), empty_genesis_data()), + (4.into(), empty_genesis_data(), None), + (2.into(), empty_genesis_data(), None), + (3.into(), empty_genesis_data(), None), + (1.into(), empty_genesis_data(), None), ]) .execute_with(|| { run_to_block(1); @@ -571,10 +571,10 @@ fn genesis_sorts_para_ids() { #[should_panic = "Duplicate para_id: 2"] fn genesis_error_on_duplicate() { new_test_ext_with_genesis(vec![ - (2.into(), empty_genesis_data()), - (3.into(), empty_genesis_data()), - (4.into(), empty_genesis_data()), - (2.into(), empty_genesis_data()), + (2.into(), empty_genesis_data(), None), + (3.into(), empty_genesis_data(), None), + (4.into(), empty_genesis_data(), None), + (2.into(), empty_genesis_data(), None), ]) .execute_with(|| { run_to_block(1); @@ -592,7 +592,7 @@ fn genesis_error_genesis_data_size_too_big() { extensions: Default::default(), properties: Default::default(), }; - new_test_ext_with_genesis(vec![(2.into(), genesis_data)]).execute_with(|| { + new_test_ext_with_genesis(vec![(2.into(), genesis_data, None)]).execute_with(|| { run_to_block(1); }); } diff --git a/runtime/dancebox/tests/common/mod.rs b/runtime/dancebox/tests/common/mod.rs index edd438fbd..fe2012316 100644 --- a/runtime/dancebox/tests/common/mod.rs +++ b/runtime/dancebox/tests/common/mod.rs @@ -308,6 +308,7 @@ pub struct ParaRegistrationParams { genesis_data: ContainerChainGenesisData, block_production_credits: u32, collator_assignment_credits: u32, + parathread_params: Option, } impl @@ -331,6 +332,7 @@ impl genesis_data: value.1, block_production_credits: value.2, collator_assignment_credits: value.3, + parathread_params: None, } } } @@ -438,7 +440,11 @@ impl ExtBuilder { .iter() .cloned() .map(|registered_para| { - (registered_para.para_id.into(), registered_para.genesis_data) + ( + registered_para.para_id.into(), + registered_para.genesis_data, + registered_para.parathread_params, + ) }) .collect(), } diff --git a/runtime/flashbox/tests/common/mod.rs b/runtime/flashbox/tests/common/mod.rs index 0a0df2d8c..f64de3a60 100644 --- a/runtime/flashbox/tests/common/mod.rs +++ b/runtime/flashbox/tests/common/mod.rs @@ -295,6 +295,7 @@ pub struct ParaRegistrationParams { genesis_data: ContainerChainGenesisData, block_production_credits: u32, collator_assignment_credits: u32, + parathread_params: Option, } impl @@ -318,6 +319,7 @@ impl genesis_data: value.1, block_production_credits: value.2, collator_assignment_credits: value.3, + parathread_params: None, } } } @@ -413,7 +415,11 @@ impl ExtBuilder { .iter() .cloned() .map(|registered_para| { - (registered_para.para_id.into(), registered_para.genesis_data) + ( + registered_para.para_id.into(), + registered_para.genesis_data, + registered_para.parathread_params, + ) }) .collect(), } diff --git a/solo-chains/runtime/starlight/tests/common/mod.rs b/solo-chains/runtime/starlight/tests/common/mod.rs index 80b2c7427..156473949 100644 --- a/solo-chains/runtime/starlight/tests/common/mod.rs +++ b/solo-chains/runtime/starlight/tests/common/mod.rs @@ -204,6 +204,7 @@ pub struct ParaRegistrationParams { genesis_data: ContainerChainGenesisData, block_production_credits: u32, collator_assignment_credits: u32, + parathread_params: Option, } impl @@ -227,6 +228,7 @@ impl genesis_data: value.1, block_production_credits: value.2, collator_assignment_credits: value.3, + parathread_params: None, } } } @@ -345,7 +347,11 @@ impl ExtBuilder { .iter() .cloned() .map(|registered_para| { - (registered_para.para_id.into(), registered_para.genesis_data) + ( + registered_para.para_id.into(), + registered_para.genesis_data, + registered_para.parathread_params, + ) }) .collect(), } From 4d6fda780adbe288c5f31e08af60c398a18e3fb5 Mon Sep 17 00:00:00 2001 From: Tomasz Polaczyk Date: Fri, 19 Jul 2024 18:08:16 +0200 Subject: [PATCH 3/6] WIP --- runtime/flashbox/tests/common/mod.rs | 39 ++--- runtime/flashbox/tests/integration_test.rs | 166 ++++++++++----------- 2 files changed, 96 insertions(+), 109 deletions(-) diff --git a/runtime/flashbox/tests/common/mod.rs b/runtime/flashbox/tests/common/mod.rs index f64de3a60..856e5bed9 100644 --- a/runtime/flashbox/tests/common/mod.rs +++ b/runtime/flashbox/tests/common/mod.rs @@ -298,32 +298,6 @@ pub struct ParaRegistrationParams { parathread_params: Option, } -impl - From<( - u32, - ContainerChainGenesisData, - u32, - u32, - )> for ParaRegistrationParams -{ - fn from( - value: ( - u32, - ContainerChainGenesisData, - u32, - u32, - ), - ) -> Self { - Self { - para_id: value.0, - genesis_data: value.1, - block_production_credits: value.2, - collator_assignment_credits: value.3, - parathread_params: None, - } - } -} - pub fn default_config() -> pallet_configuration::HostConfiguration { pallet_configuration::HostConfiguration { max_collators: 100, @@ -390,6 +364,19 @@ impl ExtBuilder { self } + /// Helper function like `with_para_ids` but it registers parachains with an empty genesis data, + /// and max amount of credits. + pub fn with_empty_parachains(mut self, para_ids: Vec) -> Self { + self.para_ids = para_ids.into_iter().map(|para_id| ParaRegistrationParams { + para_id, + genesis_data: empty_genesis_data(), + block_production_credits: u32::MAX, + collator_assignment_credits: u32::MAX, + parathread_params: None, + }).collect(); + self + } + pub fn with_config(mut self, config: pallet_configuration::HostConfiguration) -> Self { self.config = config; self diff --git a/runtime/flashbox/tests/integration_test.rs b/runtime/flashbox/tests/integration_test.rs index 67bfb0d80..f718a8b5a 100644 --- a/runtime/flashbox/tests/integration_test.rs +++ b/runtime/flashbox/tests/integration_test.rs @@ -117,9 +117,9 @@ fn genesis_balances() { #[test] fn genesis_para_registrar() { ExtBuilder::default() - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -133,9 +133,9 @@ fn genesis_para_registrar() { #[test] fn genesis_para_registrar_deregister() { ExtBuilder::default() - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -172,9 +172,9 @@ fn genesis_para_registrar_deregister() { #[test] fn genesis_para_registrar_runtime_api() { ExtBuilder::default() - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -213,9 +213,9 @@ fn genesis_para_registrar_container_chain_genesis_data_runtime_api() { properties: Default::default(), }; ExtBuilder::default() - .with_para_ids(vec![ - (1001, genesis_data_1001.clone(), u32::MAX, u32::MAX).into(), - (1002, genesis_data_1002.clone(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -277,9 +277,9 @@ fn genesis_para_registrar_container_chain_genesis_data_runtime_api() { #[test] fn test_author_collation_aura() { ExtBuilder::default() - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -307,9 +307,9 @@ fn test_author_collation_aura_change_of_authorities_on_session() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -383,7 +383,7 @@ fn test_author_collation_aura_add_assigned_to_paras() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ + .with_empty_parachains(vec![ (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), ]) @@ -899,9 +899,9 @@ fn test_parachains_deregister_collators_re_assigned() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -961,9 +961,9 @@ fn test_parachains_deregister_collators_config_change_reassigned() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -1027,9 +1027,9 @@ fn test_orchestrator_collators_with_non_sufficient_collators() { (AccountId::from(ALICE), 210_000 * UNIT), ]) .with_collators(vec![(AccountId::from(ALICE), 210 * UNIT)]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -1096,9 +1096,9 @@ fn test_author_collation_aura_add_assigned_to_paras_runtime_api() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -1253,9 +1253,9 @@ fn test_consensus_runtime_api() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -1344,9 +1344,9 @@ fn test_consensus_runtime_api_session_changes() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -1456,9 +1456,9 @@ fn test_consensus_runtime_api_next_session() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -1658,9 +1658,9 @@ fn test_author_noting_not_self_para() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -1718,9 +1718,9 @@ fn test_author_noting_set_author_and_kill_author_data() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -1765,9 +1765,9 @@ fn test_author_noting_set_author_and_kill_author_data_bad_origin() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -1807,9 +1807,9 @@ fn test_author_noting_runtime_api() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -1875,9 +1875,9 @@ fn test_session_keys_with_authority_mapping() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -1955,9 +1955,9 @@ fn test_session_keys_with_authority_assignment() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -2273,7 +2273,7 @@ fn test_reward_to_invulnerable() { (AccountId::from(BOB), 100 * UNIT), (AccountId::from(CHARLIE), 100 * UNIT), ]) - .with_para_ids(vec![ + .with_empty_parachains(vec![ (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), ]) @@ -2326,9 +2326,9 @@ fn test_reward_to_invulnerable_with_key_change() { (AccountId::from(DAVE), 100_000 * UNIT), ]) .with_collators(vec![(AccountId::from(ALICE), 210 * UNIT)]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() .execute_with(|| { @@ -3542,7 +3542,7 @@ fn test_max_collators_uses_pending_value() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![(1001, empty_genesis_data(), u32::MAX, u32::MAX).into()]) + .with_empty_parachains(vec![1001]) .with_config(pallet_configuration::HostConfiguration { max_collators: 100, min_orchestrator_collators: 1, @@ -3643,10 +3643,10 @@ fn test_collator_assignment_tip_priority_on_congestion() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1003, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, + 1003, ]) .build() .execute_with(|| { @@ -3698,10 +3698,10 @@ fn test_collator_assignment_tip_charged_on_congestion() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1003, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, + 1003, ]) .build() .execute_with(|| { @@ -3746,10 +3746,10 @@ fn test_collator_assignment_tip_not_assigned_on_insufficient_balance() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1003, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, + 1003, ]) .build() .execute_with(|| { @@ -3799,10 +3799,10 @@ fn test_collator_assignment_tip_only_charge_willing_paras() { (AccountId::from(EVE), 100 * UNIT), (AccountId::from(FERDIE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1003, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, + 1003, ]) .build() .execute_with(|| { @@ -3871,10 +3871,10 @@ fn test_collator_assignment_tip_withdraw_min_tip() { (AccountId::from(EVE), 100 * UNIT), (AccountId::from(FERDIE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1003, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, + 1003, ]) .build() .execute_with(|| { From e210c4d942cd2eb1f10a1bf377cae04ecb00594a Mon Sep 17 00:00:00 2001 From: Tomasz Polaczyk Date: Mon, 22 Jul 2024 11:33:38 +0200 Subject: [PATCH 4/6] WIP2? --- runtime/dancebox/tests/common/mod.rs | 52 ++-- runtime/dancebox/tests/integration_test.rs | 293 +++++++----------- runtime/flashbox/tests/common/mod.rs | 29 +- runtime/flashbox/tests/integration_test.rs | 197 +++++------- .../tests/collator_assignment_tests.rs | 6 +- .../runtime/starlight/tests/common/mod.rs | 42 +-- .../starlight/tests/integration_test.rs | 30 +- 7 files changed, 263 insertions(+), 386 deletions(-) diff --git a/runtime/dancebox/tests/common/mod.rs b/runtime/dancebox/tests/common/mod.rs index fe2012316..0d053d742 100644 --- a/runtime/dancebox/tests/common/mod.rs +++ b/runtime/dancebox/tests/common/mod.rs @@ -304,37 +304,11 @@ pub fn set_parachain_inherent_data_random_seed(random_seed: [u8; 32]) { #[derive(Default, Clone)] pub struct ParaRegistrationParams { - para_id: u32, - genesis_data: ContainerChainGenesisData, - block_production_credits: u32, - collator_assignment_credits: u32, - parathread_params: Option, -} - -impl - From<( - u32, - ContainerChainGenesisData, - u32, - u32, - )> for ParaRegistrationParams -{ - fn from( - value: ( - u32, - ContainerChainGenesisData, - u32, - u32, - ), - ) -> Self { - Self { - para_id: value.0, - genesis_data: value.1, - block_production_credits: value.2, - collator_assignment_credits: value.3, - parathread_params: None, - } - } + pub para_id: u32, + pub genesis_data: ContainerChainGenesisData, + pub block_production_credits: u32, + pub collator_assignment_credits: u32, + pub parathread_params: Option, } pub fn default_config() -> pallet_configuration::HostConfiguration { @@ -405,6 +379,22 @@ impl ExtBuilder { self } + /// Helper function like `with_para_ids` but registering parachains with an empty genesis data, + /// and max amount of credits. + pub fn with_empty_parachains(mut self, para_ids: Vec) -> Self { + self.para_ids = para_ids + .into_iter() + .map(|para_id| ParaRegistrationParams { + para_id, + genesis_data: empty_genesis_data(), + block_production_credits: u32::MAX, + collator_assignment_credits: u32::MAX, + parathread_params: None, + }) + .collect(); + self + } + pub fn with_config(mut self, config: pallet_configuration::HostConfiguration) -> Self { self.config = config; self diff --git a/runtime/dancebox/tests/integration_test.rs b/runtime/dancebox/tests/integration_test.rs index a30cf852f..036beb7e8 100644 --- a/runtime/dancebox/tests/integration_test.rs +++ b/runtime/dancebox/tests/integration_test.rs @@ -102,10 +102,7 @@ fn genesis_balances() { #[test] fn genesis_para_registrar() { ExtBuilder::default() - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { assert_eq!( @@ -118,10 +115,7 @@ fn genesis_para_registrar() { #[test] fn genesis_para_registrar_deregister() { ExtBuilder::default() - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { assert_eq!( @@ -157,10 +151,7 @@ fn genesis_para_registrar_deregister() { #[test] fn genesis_para_registrar_runtime_api() { ExtBuilder::default() - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { assert_eq!( @@ -199,8 +190,19 @@ fn genesis_para_registrar_container_chain_genesis_data_runtime_api() { }; ExtBuilder::default() .with_para_ids(vec![ - (1001, genesis_data_1001.clone(), u32::MAX, u32::MAX).into(), - (1002, genesis_data_1002.clone(), u32::MAX, u32::MAX).into(), + ParaRegistrationParams { + para_id: 1001, + genesis_data: genesis_data_1001.clone(), + block_production_credits: u32::MAX, + collator_assignment_credits: u32::MAX, + parathread_params: None, + },ParaRegistrationParams { + para_id: 1002, + genesis_data: genesis_data_1002.clone(), + block_production_credits: u32::MAX, + collator_assignment_credits: u32::MAX, + parathread_params: None, + }, ]) .build() .execute_with(|| { @@ -262,10 +264,7 @@ fn genesis_para_registrar_container_chain_genesis_data_runtime_api() { #[test] fn test_author_collation_aura() { ExtBuilder::default() - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(5); @@ -292,10 +291,7 @@ fn test_author_collation_aura_change_of_authorities_on_session() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -368,10 +364,7 @@ fn test_author_collation_aura_add_assigned_to_paras() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -884,10 +877,7 @@ fn test_parachains_deregister_collators_re_assigned() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -946,10 +936,7 @@ fn test_parachains_deregister_collators_config_change_reassigned() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1012,10 +999,7 @@ fn test_orchestrator_collators_with_non_sufficient_collators() { (AccountId::from(ALICE), 210_000 * UNIT), ]) .with_collators(vec![(AccountId::from(ALICE), 210 * UNIT)]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1081,10 +1065,7 @@ fn test_author_collation_aura_add_assigned_to_paras_runtime_api() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1238,10 +1219,7 @@ fn test_consensus_runtime_api() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1329,10 +1307,7 @@ fn test_consensus_runtime_api_session_changes() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1441,10 +1416,7 @@ fn test_consensus_runtime_api_next_session() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1643,10 +1615,7 @@ fn test_author_noting_not_self_para() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { let mut sproof = ParaHeaderSproofBuilder::default(); @@ -1703,10 +1672,7 @@ fn test_author_noting_set_author_and_kill_author_data() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { let other_para: ParaId = 1001u32.into(); @@ -1750,10 +1716,7 @@ fn test_author_noting_set_author_and_kill_author_data_bad_origin() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { let other_para: ParaId = 1001u32.into(); @@ -1792,10 +1755,7 @@ fn test_author_noting_runtime_api() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { let mut sproof = ParaHeaderSproofBuilder::default(); @@ -1858,10 +1818,7 @@ fn test_collator_assignment_rotation() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { // Charlie and Dave to 1001 @@ -1913,10 +1870,7 @@ fn test_session_keys_with_authority_mapping() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1993,10 +1947,7 @@ fn test_session_keys_with_authority_assignment() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -2317,10 +2268,7 @@ fn test_staking_no_candidates_in_genesis() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -2348,10 +2296,7 @@ fn test_staking_join() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -2400,9 +2345,9 @@ fn test_staking_join_no_keys_registered() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() @@ -2456,9 +2401,9 @@ fn test_staking_register_keys_after_joining() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), + .with_empty_parachains(vec![ + 1001, + 1002, ]) .build() @@ -2545,10 +2490,7 @@ fn test_staking_join_bad_origin() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -2582,10 +2524,7 @@ fn test_staking_join_below_self_delegation_min() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -2654,10 +2593,7 @@ fn test_staking_join_no_self_delegation() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -2693,10 +2629,7 @@ fn test_staking_join_before_self_delegation() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -2763,10 +2696,7 @@ fn test_staking_join_twice_in_same_block() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -2832,10 +2762,7 @@ fn test_staking_join_execute_before_time() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -2907,10 +2834,7 @@ fn test_staking_join_execute_any_origin() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -2966,10 +2890,7 @@ fn test_staking_join_execute_bad_origin() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -3034,10 +2955,7 @@ fn setup_staking_join_and_execute(ops: Vec, f: impl FnOnce() -> R) { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -3470,10 +3388,7 @@ fn test_pallet_session_takes_validators_from_invulnerables_and_staking() { (AccountId::from(BOB), 100 * UNIT), (AccountId::from(CHARLIE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -3560,10 +3475,7 @@ fn test_pallet_session_limits_num_validators() { (AccountId::from(BOB), 100 * UNIT), (AccountId::from(CHARLIE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .with_config(pallet_configuration::HostConfiguration { max_collators: 2, min_orchestrator_collators: 2, @@ -3649,10 +3561,7 @@ fn test_pallet_session_limits_num_validators_from_staking() { (AccountId::from(DAVE), 100_000 * UNIT), ]) .with_collators(vec![(AccountId::from(ALICE), 210 * UNIT)]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .with_config(pallet_configuration::HostConfiguration { max_collators: 2, min_orchestrator_collators: 2, @@ -3761,10 +3670,7 @@ fn test_reward_to_staking_candidate() { (AccountId::from(DAVE), 100_000 * UNIT), ]) .with_collators(vec![(AccountId::from(ALICE), 210 * UNIT)]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -3868,10 +3774,7 @@ fn test_reward_to_invulnerable() { (AccountId::from(BOB), 100 * UNIT), (AccountId::from(CHARLIE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -3958,10 +3861,7 @@ fn test_reward_to_invulnerable_with_key_change() { (AccountId::from(DAVE), 100_000 * UNIT), ]) .with_collators(vec![(AccountId::from(ALICE), 210 * UNIT)]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -4099,10 +3999,7 @@ fn test_collator_assignment_gives_priority_to_invulnerables() { (AccountId::from(ALICE), 210 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -4608,6 +4505,50 @@ fn test_register_parathread() { }); } +#[test] +fn test_register_parathread_genesis() { + let parathread_params = tp_traits::ParathreadParams { + slot_frequency: SlotFrequency { min: 1, max: 1 }, + }; + ExtBuilder::default() + .with_balances(vec![ + // Alice gets 10k extra tokens for her mapping deposit + (AccountId::from(ALICE), 210_000 * UNIT), + (AccountId::from(BOB), 100_000 * UNIT), + (AccountId::from(CHARLIE), 100_000 * UNIT), + (AccountId::from(DAVE), 100_000 * UNIT), + ]) + .with_collators(vec![ + (AccountId::from(ALICE), 210 * UNIT), + (AccountId::from(BOB), 100 * UNIT), + (AccountId::from(CHARLIE), 100 * UNIT), + (AccountId::from(DAVE), 100 * UNIT), + ]) + .with_para_ids(vec![ParaRegistrationParams { + para_id: 3001, + genesis_data: empty_genesis_data(), + block_production_credits: u32::MAX, + collator_assignment_credits: u32::MAX, + parathread_params: Some(parathread_params.clone()), + }]) + .build() + .execute_with(|| { + run_to_block(2); + + assert_eq!(Registrar::registered_para_ids(), vec![3001.into()]); + assert_eq!( + pallet_registrar::ParathreadParams::::get(ParaId::from(3001)), + Some(parathread_params) + ); + + let assignment = CollatorAssignment::collator_container_chain(); + assert_eq!( + assignment.container_chains[&ParaId::from(3001)], + vec![CHARLIE.into()] + ); + }); +} + #[test] fn test_ed_plus_block_credit_session_purchase_works() { ExtBuilder::default() @@ -5615,7 +5556,7 @@ fn test_max_collators_uses_pending_value() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![(1001, empty_genesis_data(), u32::MAX, u32::MAX).into()]) + .with_empty_parachains(vec![1001]) .with_config(pallet_configuration::HostConfiguration { max_collators: 100, min_orchestrator_collators: 1, @@ -5716,11 +5657,7 @@ fn test_collator_assignment_tip_priority_on_congestion() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1003, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002, 1003]) .build() .execute_with(|| { let para_id = 1003u32; @@ -5771,11 +5708,7 @@ fn test_collator_assignment_tip_charged_on_congestion() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1003, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002, 1003]) .build() .execute_with(|| { let tank_funds = 100 * UNIT; @@ -5819,11 +5752,7 @@ fn test_collator_assignment_tip_not_assigned_on_insufficient_balance() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1003, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002, 1003]) .build() .execute_with(|| { let tank_funds = 1 * UNIT; @@ -5872,11 +5801,7 @@ fn test_collator_assignment_tip_only_charge_willing_paras() { (AccountId::from(EVE), 100 * UNIT), (AccountId::from(FERDIE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1003, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002, 1003]) .build() .execute_with(|| { let tank_funds = 100 * UNIT; @@ -5944,11 +5869,7 @@ fn test_collator_assignment_tip_withdraw_min_tip() { (AccountId::from(EVE), 100 * UNIT), (AccountId::from(FERDIE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1003, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002, 1003]) .build() .execute_with(|| { let tank_funds = 100 * UNIT; diff --git a/runtime/flashbox/tests/common/mod.rs b/runtime/flashbox/tests/common/mod.rs index 856e5bed9..0dd21b9f4 100644 --- a/runtime/flashbox/tests/common/mod.rs +++ b/runtime/flashbox/tests/common/mod.rs @@ -291,11 +291,11 @@ pub fn set_parachain_inherent_data(mock_inherent_data: MockInherentData) { #[derive(Default, Clone)] pub struct ParaRegistrationParams { - para_id: u32, - genesis_data: ContainerChainGenesisData, - block_production_credits: u32, - collator_assignment_credits: u32, - parathread_params: Option, + pub para_id: u32, + pub genesis_data: ContainerChainGenesisData, + pub block_production_credits: u32, + pub collator_assignment_credits: u32, + pub parathread_params: Option, } pub fn default_config() -> pallet_configuration::HostConfiguration { @@ -364,16 +364,19 @@ impl ExtBuilder { self } - /// Helper function like `with_para_ids` but it registers parachains with an empty genesis data, + /// Helper function like `with_para_ids` but registering parachains with an empty genesis data, /// and max amount of credits. pub fn with_empty_parachains(mut self, para_ids: Vec) -> Self { - self.para_ids = para_ids.into_iter().map(|para_id| ParaRegistrationParams { - para_id, - genesis_data: empty_genesis_data(), - block_production_credits: u32::MAX, - collator_assignment_credits: u32::MAX, - parathread_params: None, - }).collect(); + self.para_ids = para_ids + .into_iter() + .map(|para_id| ParaRegistrationParams { + para_id, + genesis_data: empty_genesis_data(), + block_production_credits: u32::MAX, + collator_assignment_credits: u32::MAX, + parathread_params: None, + }) + .collect(); self } diff --git a/runtime/flashbox/tests/integration_test.rs b/runtime/flashbox/tests/integration_test.rs index f718a8b5a..cd26b2968 100644 --- a/runtime/flashbox/tests/integration_test.rs +++ b/runtime/flashbox/tests/integration_test.rs @@ -117,10 +117,7 @@ fn genesis_balances() { #[test] fn genesis_para_registrar() { ExtBuilder::default() - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { assert_eq!( @@ -133,10 +130,7 @@ fn genesis_para_registrar() { #[test] fn genesis_para_registrar_deregister() { ExtBuilder::default() - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { assert_eq!( @@ -172,10 +166,7 @@ fn genesis_para_registrar_deregister() { #[test] fn genesis_para_registrar_runtime_api() { ExtBuilder::default() - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { assert_eq!( @@ -213,10 +204,20 @@ fn genesis_para_registrar_container_chain_genesis_data_runtime_api() { properties: Default::default(), }; ExtBuilder::default() - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_para_ids(vec![ + ParaRegistrationParams { + para_id: 1001, + genesis_data: genesis_data_1001.clone(), + block_production_credits: u32::MAX, + collator_assignment_credits: u32::MAX, + parathread_params: None, + },ParaRegistrationParams { + para_id: 1002, + genesis_data: genesis_data_1002.clone(), + block_production_credits: u32::MAX, + collator_assignment_credits: u32::MAX, + parathread_params: None, + }, ]) .build() .execute_with(|| { assert_eq!( @@ -277,10 +278,7 @@ fn genesis_para_registrar_container_chain_genesis_data_runtime_api() { #[test] fn test_author_collation_aura() { ExtBuilder::default() - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(5); @@ -307,10 +305,7 @@ fn test_author_collation_aura_change_of_authorities_on_session() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -383,10 +378,7 @@ fn test_author_collation_aura_add_assigned_to_paras() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_empty_parachains(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -899,10 +891,7 @@ fn test_parachains_deregister_collators_re_assigned() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -961,10 +950,7 @@ fn test_parachains_deregister_collators_config_change_reassigned() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1027,10 +1013,7 @@ fn test_orchestrator_collators_with_non_sufficient_collators() { (AccountId::from(ALICE), 210_000 * UNIT), ]) .with_collators(vec![(AccountId::from(ALICE), 210 * UNIT)]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1096,10 +1079,7 @@ fn test_author_collation_aura_add_assigned_to_paras_runtime_api() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1253,10 +1233,7 @@ fn test_consensus_runtime_api() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1344,10 +1321,7 @@ fn test_consensus_runtime_api_session_changes() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1456,10 +1430,7 @@ fn test_consensus_runtime_api_next_session() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1658,10 +1629,7 @@ fn test_author_noting_not_self_para() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { let mut sproof = ParaHeaderSproofBuilder::default(); @@ -1718,10 +1686,7 @@ fn test_author_noting_set_author_and_kill_author_data() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { let other_para: ParaId = 1001u32.into(); @@ -1765,10 +1730,7 @@ fn test_author_noting_set_author_and_kill_author_data_bad_origin() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { let other_para: ParaId = 1001u32.into(); @@ -1807,10 +1769,7 @@ fn test_author_noting_runtime_api() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { let mut sproof = ParaHeaderSproofBuilder::default(); @@ -1875,10 +1834,7 @@ fn test_session_keys_with_authority_mapping() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -1955,10 +1911,7 @@ fn test_session_keys_with_authority_assignment() { (AccountId::from(CHARLIE), 100_000 * UNIT), (AccountId::from(DAVE), 100_000 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -2273,10 +2226,7 @@ fn test_reward_to_invulnerable() { (AccountId::from(BOB), 100 * UNIT), (AccountId::from(CHARLIE), 100 * UNIT), ]) - .with_empty_parachains(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -2326,10 +2276,7 @@ fn test_reward_to_invulnerable_with_key_change() { (AccountId::from(DAVE), 100_000 * UNIT), ]) .with_collators(vec![(AccountId::from(ALICE), 210 * UNIT)]) - .with_empty_parachains(vec![ - 1001, - 1002, - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { run_to_block(2); @@ -2623,6 +2570,50 @@ fn test_register_parathread() { }); } +#[test] +fn test_register_parathread_genesis() { + let parathread_params = tp_traits::ParathreadParams { + slot_frequency: SlotFrequency { min: 1, max: 1 }, + }; + ExtBuilder::default() + .with_balances(vec![ + // Alice gets 10k extra tokens for her mapping deposit + (AccountId::from(ALICE), 210_000 * UNIT), + (AccountId::from(BOB), 100_000 * UNIT), + (AccountId::from(CHARLIE), 100_000 * UNIT), + (AccountId::from(DAVE), 100_000 * UNIT), + ]) + .with_collators(vec![ + (AccountId::from(ALICE), 210 * UNIT), + (AccountId::from(BOB), 100 * UNIT), + (AccountId::from(CHARLIE), 100 * UNIT), + (AccountId::from(DAVE), 100 * UNIT), + ]) + .with_para_ids(vec![ParaRegistrationParams { + para_id: 3001, + genesis_data: empty_genesis_data(), + block_production_credits: u32::MAX, + collator_assignment_credits: u32::MAX, + parathread_params: Some(parathread_params.clone()), + }]) + .build() + .execute_with(|| { + run_to_block(2); + + assert_eq!(Registrar::registered_para_ids(), vec![3001.into()]); + assert_eq!( + pallet_registrar::ParathreadParams::::get(ParaId::from(3001)), + Some(parathread_params) + ); + + let assignment = CollatorAssignment::collator_container_chain(); + assert_eq!( + assignment.container_chains[&ParaId::from(3001)], + vec![CHARLIE.into()] + ); + }); +} + #[test] fn test_ed_plus_block_credit_session_purchase_works() { ExtBuilder::default() @@ -3643,11 +3634,7 @@ fn test_collator_assignment_tip_priority_on_congestion() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - 1003, - ]) + .with_empty_parachains(vec![1001, 1002, 1003]) .build() .execute_with(|| { let para_id = 1003u32; @@ -3698,11 +3685,7 @@ fn test_collator_assignment_tip_charged_on_congestion() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - 1003, - ]) + .with_empty_parachains(vec![1001, 1002, 1003]) .build() .execute_with(|| { let tank_funds = 100 * UNIT; @@ -3746,11 +3729,7 @@ fn test_collator_assignment_tip_not_assigned_on_insufficient_balance() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - 1003, - ]) + .with_empty_parachains(vec![1001, 1002, 1003]) .build() .execute_with(|| { let tank_funds = 1 * UNIT; @@ -3799,11 +3778,7 @@ fn test_collator_assignment_tip_only_charge_willing_paras() { (AccountId::from(EVE), 100 * UNIT), (AccountId::from(FERDIE), 100 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - 1003, - ]) + .with_empty_parachains(vec![1001, 1002, 1003]) .build() .execute_with(|| { let tank_funds = 100 * UNIT; @@ -3871,11 +3846,7 @@ fn test_collator_assignment_tip_withdraw_min_tip() { (AccountId::from(EVE), 100 * UNIT), (AccountId::from(FERDIE), 100 * UNIT), ]) - .with_empty_parachains(vec![ - 1001, - 1002, - 1003, - ]) + .with_empty_parachains(vec![1001, 1002, 1003]) .build() .execute_with(|| { let tank_funds = 100 * UNIT; diff --git a/solo-chains/runtime/starlight/tests/collator_assignment_tests.rs b/solo-chains/runtime/starlight/tests/collator_assignment_tests.rs index b0a4ae296..b3a793c0f 100644 --- a/solo-chains/runtime/starlight/tests/collator_assignment_tests.rs +++ b/solo-chains/runtime/starlight/tests/collator_assignment_tests.rs @@ -50,7 +50,7 @@ fn test_author_collation_aura_change_of_authorities_on_session() { collators_per_container: 2, ..Default::default() }) - .with_para_ids(vec![(1000, empty_genesis_data(), u32::MAX, u32::MAX).into()]) + .with_empty_parachains(vec![1000]) .build() .execute_with(|| { run_to_block(2); @@ -155,7 +155,7 @@ fn test_collators_per_container() { collators_per_container: 2, ..Default::default() }) - .with_para_ids(vec![(1000, empty_genesis_data(), u32::MAX, u32::MAX).into()]) + .with_empty_parachains(vec![1000]) .build() .execute_with(|| { run_to_block(2); @@ -236,7 +236,7 @@ fn test_session_keys_with_authority_assignment() { collators_per_container: 2, ..Default::default() }) - .with_para_ids(vec![(1000, empty_genesis_data(), u32::MAX, u32::MAX).into()]) + .with_empty_parachains(vec![1000]) .build() .execute_with(|| { run_to_block(2); diff --git a/solo-chains/runtime/starlight/tests/common/mod.rs b/solo-chains/runtime/starlight/tests/common/mod.rs index 156473949..cca2f1947 100644 --- a/solo-chains/runtime/starlight/tests/common/mod.rs +++ b/solo-chains/runtime/starlight/tests/common/mod.rs @@ -207,32 +207,6 @@ pub struct ParaRegistrationParams { parathread_params: Option, } -impl - From<( - u32, - ContainerChainGenesisData, - u32, - u32, - )> for ParaRegistrationParams -{ - fn from( - value: ( - u32, - ContainerChainGenesisData, - u32, - u32, - ), - ) -> Self { - Self { - para_id: value.0, - genesis_data: value.1, - block_production_credits: value.2, - collator_assignment_credits: value.3, - parathread_params: None, - } - } -} - pub fn default_config() -> pallet_configuration::HostConfiguration { pallet_configuration::HostConfiguration { max_collators: 100, @@ -309,6 +283,22 @@ impl ExtBuilder { self } + /// Helper function like `with_para_ids` but registering parachains with an empty genesis data, + /// and max amount of credits. + pub fn with_empty_parachains(mut self, para_ids: Vec) -> Self { + self.para_ids = para_ids + .into_iter() + .map(|para_id| ParaRegistrationParams { + para_id, + genesis_data: empty_genesis_data(), + block_production_credits: u32::MAX, + collator_assignment_credits: u32::MAX, + parathread_params: None, + }) + .collect(); + self + } + // Maybe change to with_collators_config? pub fn with_config(mut self, config: pallet_configuration::HostConfiguration) -> Self { self.config = config; diff --git a/solo-chains/runtime/starlight/tests/integration_test.rs b/solo-chains/runtime/starlight/tests/integration_test.rs index 83b54b23e..e8284e0c1 100644 --- a/solo-chains/runtime/starlight/tests/integration_test.rs +++ b/solo-chains/runtime/starlight/tests/integration_test.rs @@ -56,10 +56,7 @@ fn genesis_balances() { #[test] fn genesis_para_registrar() { ExtBuilder::default() - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { assert_eq!( @@ -72,10 +69,7 @@ fn genesis_para_registrar() { #[test] fn genesis_para_registrar_deregister() { ExtBuilder::default() - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { assert_eq!( @@ -114,10 +108,7 @@ fn genesis_para_registrar_deregister() { #[test] fn genesis_para_registrar_runtime_api() { ExtBuilder::default() - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { assert_eq!( @@ -159,8 +150,19 @@ fn genesis_para_registrar_container_chain_genesis_data_runtime_api() { }; ExtBuilder::default() .with_para_ids(vec![ - (1001, genesis_data_1001.clone(), u32::MAX, u32::MAX).into(), - (1002, genesis_data_1002.clone(), u32::MAX, u32::MAX).into(), + ParaRegistrationParams { + para_id: 1001, + genesis_data: genesis_data_1001.clone(), + block_production_credits: u32::MAX, + collator_assignment_credits: u32::MAX, + parathread_params: None, + },ParaRegistrationParams { + para_id: 1002, + genesis_data: genesis_data_1002.clone(), + block_production_credits: u32::MAX, + collator_assignment_credits: u32::MAX, + parathread_params: None, + }, ]) .build() .execute_with(|| { From b265d604dabbbadee11f449ecd5ab8204accc76d Mon Sep 17 00:00:00 2001 From: Tomasz Polaczyk Date: Mon, 22 Jul 2024 13:40:19 +0200 Subject: [PATCH 5/6] WIP3 --- solo-chains/runtime/starlight/tests/common/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/solo-chains/runtime/starlight/tests/common/mod.rs b/solo-chains/runtime/starlight/tests/common/mod.rs index cca2f1947..638241503 100644 --- a/solo-chains/runtime/starlight/tests/common/mod.rs +++ b/solo-chains/runtime/starlight/tests/common/mod.rs @@ -200,11 +200,11 @@ pub fn run_block() { #[derive(Default, Clone)] pub struct ParaRegistrationParams { - para_id: u32, - genesis_data: ContainerChainGenesisData, - block_production_credits: u32, - collator_assignment_credits: u32, - parathread_params: Option, + pub para_id: u32, + pub genesis_data: ContainerChainGenesisData, + pub block_production_credits: u32, + pub collator_assignment_credits: u32, + pub parathread_params: Option, } pub fn default_config() -> pallet_configuration::HostConfiguration { From a8b0bb6af089faf81c92a4d39aab1577415f7353 Mon Sep 17 00:00:00 2001 From: Tomasz Polaczyk Date: Tue, 30 Jul 2024 11:16:57 +0200 Subject: [PATCH 6/6] Forgot to commit --- .../starlight/tests/author_noting_tests.rs | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/solo-chains/runtime/starlight/tests/author_noting_tests.rs b/solo-chains/runtime/starlight/tests/author_noting_tests.rs index 3b4df2261..ac0b69a8c 100644 --- a/solo-chains/runtime/starlight/tests/author_noting_tests.rs +++ b/solo-chains/runtime/starlight/tests/author_noting_tests.rs @@ -52,10 +52,7 @@ fn test_author_noting_not_self_para() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { let mut sproof = ParaHeaderSproofBuilder::default(); @@ -113,10 +110,7 @@ fn test_author_noting_set_author_and_kill_author_data() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { let other_para: ParaId = 1001u32.into(); @@ -160,10 +154,7 @@ fn test_author_noting_set_author_and_kill_author_data_bad_origin() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { let other_para: ParaId = 1001u32.into(); @@ -202,10 +193,7 @@ fn test_author_noting_runtime_api() { (AccountId::from(CHARLIE), 100 * UNIT), (AccountId::from(DAVE), 100 * UNIT), ]) - .with_para_ids(vec![ - (1001, empty_genesis_data(), u32::MAX, u32::MAX).into(), - (1002, empty_genesis_data(), u32::MAX, u32::MAX).into(), - ]) + .with_empty_parachains(vec![1001, 1002]) .build() .execute_with(|| { let mut sproof = ParaHeaderSproofBuilder::default();