From 73daab1933b5cfc51de53b7c7e8512420e7907c0 Mon Sep 17 00:00:00 2001 From: Agusrodri Date: Tue, 3 Sep 2024 14:02:52 -0700 Subject: [PATCH] pr comments --- solo-chains/runtime/starlight/src/lib.rs | 8 +- .../starlight/src/tests/relay_registrar.rs | 79 +++++-------------- 2 files changed, 24 insertions(+), 63 deletions(-) diff --git a/solo-chains/runtime/starlight/src/lib.rs b/solo-chains/runtime/starlight/src/lib.rs index bb23dc9b2..4344d70cf 100644 --- a/solo-chains/runtime/starlight/src/lib.rs +++ b/solo-chains/runtime/starlight/src/lib.rs @@ -1634,13 +1634,11 @@ where None => return Err(ContainerRegistrarError::::HeadDataNecessary.into()), }; - let key_values: Vec<(Vec, Vec)> = - genesis_storage.into_iter().map(Into::into).collect(); - // Check if the wasm code is present in storage - let validation_code = match key_values + let validation_code = match genesis_storage .into_iter() - .find(|(key, _)| key == &StorageWellKnownKeys::CODE.to_vec()) + .map(Into::into) + .find(|(key, _): &(Vec, Vec)| key == &StorageWellKnownKeys::CODE) { Some((_, code)) => ValidationCode(code), None => return Err(ContainerRegistrarError::::WasmCodeNecessary.into()), diff --git a/solo-chains/runtime/starlight/src/tests/relay_registrar.rs b/solo-chains/runtime/starlight/src/tests/relay_registrar.rs index 1a0c8a38e..e9dc4e45a 100644 --- a/solo-chains/runtime/starlight/src/tests/relay_registrar.rs +++ b/solo-chains/runtime/starlight/src/tests/relay_registrar.rs @@ -17,7 +17,7 @@ #![cfg(test)] use { - crate::{tests::common::*, Configuration, ContainerRegistrar, Paras, Registrar, System}, + crate::{tests::common::*, ContainerRegistrar, Paras, Registrar, System}, cumulus_primitives_core::relay_chain::HeadData, frame_support::{assert_noop, assert_ok}, pallet_registrar::Event as ContainerRegistrarEvent, @@ -116,14 +116,7 @@ fn register_para_via_container_registrar() { assert_eq!(Runtime::registered_paras(), vec![1001.into(), 1002.into()]); assert_eq!(Runtime::genesis_data(1003.into()).as_ref(), None); - run_to_session(1u32); - - // Change max_head_data_size config. - assert_ok!( - Configuration::set_max_head_data_size(root_origin(), 20500), - () - ); - run_to_session(4u32); + run_to_session(2u32); assert_eq!( parachains_configuration::ActiveConfig::::get().max_head_data_size, 20500 @@ -152,7 +145,7 @@ fn register_para_via_container_registrar() { // Now let's check if the para was preoperly registered in the relay. // Run to next session. - run_to_session(5); + run_to_session(3); assert!(Paras::lifecycle(1003.into()) .expect("para should be onboarding") .is_onboarding()); @@ -162,7 +155,7 @@ fn register_para_via_container_registrar() { root_origin(), validation_code.into() )); - run_to_session(7); + run_to_session(5); // Now the para should be a parathread. assert!(Paras::lifecycle(1003.into()) @@ -185,14 +178,7 @@ fn cannot_register_para_twice_in_relay() { assert_eq!(Runtime::registered_paras(), vec![1001.into(), 1002.into()]); assert_eq!(Runtime::genesis_data(1003.into()).as_ref(), None); - run_to_session(1u32); - - // Change max_head_data_size config. - assert_ok!( - Configuration::set_max_head_data_size(root_origin(), 20500), - () - ); - run_to_session(4u32); + run_to_session(2u32); assert_eq!( parachains_configuration::ActiveConfig::::get().max_head_data_size, 20500 @@ -221,7 +207,7 @@ fn cannot_register_para_twice_in_relay() { // Now let's check if the para was preoperly registered in the relay. // Run to next session. - run_to_session(5); + run_to_session(3); assert!(Paras::lifecycle(1003.into()) .expect("para should be onboarding") .is_onboarding()); @@ -231,7 +217,7 @@ fn cannot_register_para_twice_in_relay() { root_origin(), validation_code.clone().into() )); - run_to_session(7); + run_to_session(5); // Now the para should be a parathread. assert!(Paras::lifecycle(1003.into()) @@ -266,14 +252,7 @@ fn mark_valid_for_collating_converts_to_parachain() { assert_eq!(Runtime::registered_paras(), vec![1001.into(), 1002.into()]); assert_eq!(Runtime::genesis_data(1003.into()).as_ref(), None); - run_to_session(1u32); - - // Change max_head_data_size config. - assert_ok!( - Configuration::set_max_head_data_size(root_origin(), 20500), - () - ); - run_to_session(4u32); + run_to_session(2u32); assert_eq!( parachains_configuration::ActiveConfig::::get().max_head_data_size, 20500 @@ -302,7 +281,7 @@ fn mark_valid_for_collating_converts_to_parachain() { // Now let's check if the para was preoperly registered in the relay. // Run to next session. - run_to_session(5); + run_to_session(3); assert!(Paras::lifecycle(1003.into()) .expect("para should be onboarding") .is_onboarding()); @@ -312,7 +291,7 @@ fn mark_valid_for_collating_converts_to_parachain() { root_origin(), validation_code.into() )); - run_to_session(7); + run_to_session(5); // Now the para should be a parathread. assert!(Paras::lifecycle(1003.into()) @@ -328,7 +307,7 @@ fn mark_valid_for_collating_converts_to_parachain() { ); // The change should be applied after 2 sessions. - run_to_session(9); + run_to_session(7); assert!(Paras::lifecycle(1003.into()) .expect("para should be parachain") .is_parachain()); @@ -349,15 +328,7 @@ fn deregister_calls_schedule_para_cleanup() { assert_eq!(Runtime::registered_paras(), vec![1001.into(), 1002.into()]); assert_eq!(Runtime::genesis_data(1003.into()).as_ref(), None); - run_to_session(1u32); - - // Change max_head_data_size config. - assert_ok!( - Configuration::set_max_head_data_size(root_origin(), 20500), - () - ); - - run_to_session(4u32); + run_to_session(2u32); assert_eq!( parachains_configuration::ActiveConfig::::get().max_head_data_size, 20500 @@ -386,7 +357,7 @@ fn deregister_calls_schedule_para_cleanup() { // Now let's check if the para was preoperly registered in the relay. // Run to next session. - run_to_session(5); + run_to_session(3); assert!(Paras::lifecycle(1003.into()) .expect("para should be onboarding") .is_onboarding()); @@ -397,7 +368,7 @@ fn deregister_calls_schedule_para_cleanup() { validation_code.into() )); - run_to_session(7); + run_to_session(5); // Now the para should be a parathread. assert!(Paras::lifecycle(1003.into()) @@ -413,7 +384,7 @@ fn deregister_calls_schedule_para_cleanup() { ); // The change should be applied after 2 sessions. - run_to_session(9); + run_to_session(7); assert!(Paras::lifecycle(1003.into()) .expect("para should be parachain") .is_parachain()); @@ -433,7 +404,7 @@ fn deregister_calls_schedule_para_cleanup() { .into(), ); - run_to_session(11); + run_to_session(9); end_block(); assert_eq!(Runtime::genesis_data(1003.into()).as_ref(), None); @@ -460,15 +431,7 @@ fn deregister_two_paras_in_the_same_block() { assert_eq!(Runtime::registered_paras(), vec![1001.into(), 1002.into()]); assert_eq!(Runtime::genesis_data(1003.into()).as_ref(), None); assert_eq!(Runtime::genesis_data(1004.into()).as_ref(), None); - run_to_session(1u32); - - // Change max_head_data_size config. - assert_ok!( - Configuration::set_max_head_data_size(root_origin(), 20500), - () - ); - - run_to_session(4u32); + run_to_session(2u32); assert_eq!( parachains_configuration::ActiveConfig::::get().max_head_data_size, 20500 @@ -509,7 +472,7 @@ fn deregister_two_paras_in_the_same_block() { // Now let's check if the paras were preoperly registered in the relay. // Run to next session. - run_to_session(5); + run_to_session(3); assert!(Paras::lifecycle(1003.into()) .expect("para should be onboarding") .is_onboarding()); @@ -524,7 +487,7 @@ fn deregister_two_paras_in_the_same_block() { validation_code.into() )); - run_to_session(7); + run_to_session(5); // Now paras should be parathreads. assert!(Paras::lifecycle(1003.into()) @@ -549,7 +512,7 @@ fn deregister_two_paras_in_the_same_block() { ); // The change should be applied after 2 sessions. - run_to_session(9); + run_to_session(7); assert!(Paras::lifecycle(1003.into()) .expect("para should be parachain") .is_parachain()); @@ -586,7 +549,7 @@ fn deregister_two_paras_in_the_same_block() { .into(), ); - run_to_session(11); + run_to_session(9); end_block(); assert_eq!(Runtime::genesis_data(1003.into()).as_ref(), None);