From 580a028d697488bc369c75ef2268cbd4cab7c7c4 Mon Sep 17 00:00:00 2001 From: Sergey Shulepov Date: Wed, 24 Nov 2021 13:50:41 +0000 Subject: [PATCH] Add a test for schedule_para_initialize --- runtime/parachains/src/paras.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/runtime/parachains/src/paras.rs b/runtime/parachains/src/paras.rs index c73f92bf97ac..f720ba90a381 100644 --- a/runtime/parachains/src/paras.rs +++ b/runtime/parachains/src/paras.rs @@ -1350,6 +1350,28 @@ mod tests { ParaPastCodeMeta { upgrade_times: Vec::new(), last_pruned: Some(66) } ); } + + #[test] + fn schedule_para_init_rejects_empty_code() { + new_test_ext(MockGenesisConfig::default()).execute_with(||{ + assert_err!( + Paras::schedule_para_initialize(1000.into(), ParaGenesisArgs { + parachain: false, + genesis_head: Default::default(), + validation_code: ValidationCode(vec![]), + }), + Error::::CannotOnboard, + ); + + assert_ok!( + Paras::schedule_para_initialize(1000.into(), ParaGenesisArgs { + parachain: false, + genesis_head: Default::default(), + validation_code: ValidationCode(vec![1]), + }) + ); + }); + } #[test] fn para_past_code_pruning_in_initialize() {