--- a/pallets/scheduler-v2/src/mock.rs +++ b/pallets/scheduler-v2/src/mock.rs @@ -187,9 +187,9 @@ fn service_task_named() -> Weight { Weight::from_ref_time(0b0001_0100) } - fn service_task_fetched(s: u32) -> Weight { - Weight::from_ref_time((s << 8) as u64 + 0b0010_0100) - } + // fn service_task_fetched(s: u32) -> Weight { + // Weight::from_ref_time((s << 8) as u64 + 0b0010_0100) + // } fn execute_dispatch_signed() -> Weight { Weight::from_ref_time(0b0100_0000) } @@ -265,6 +265,8 @@ pub type LoggerCall = logger::Call; +pub type SystemCall = frame_system::Call; + pub fn new_test_ext() -> sp_io::TestExternalities { let t = system::GenesisConfig::default() .build_storage::() --- a/pallets/scheduler-v2/src/tests.rs +++ b/pallets/scheduler-v2/src/tests.rs @@ -40,7 +40,7 @@ }; use frame_support::{ assert_noop, assert_ok, - traits::{Contains, OnInitialize}, + traits::{Contains, OnInitialize}, assert_err, }; #[test] @@ -871,3 +871,20 @@ assert_eq!(logger::log().len() as u32, max); }); } + +#[test] +fn cannot_schedule_too_big_tasks() { + new_test_ext().execute_with(|| { + let call = Box::new(<::RuntimeCall>::from(SystemCall::remark { + remark: vec![0; EncodedCall::bound() - 4], + })); + + assert_ok!(Scheduler::schedule(RuntimeOrigin::root(), 4, None, Some(127), call)); + + let call = Box::new(<::RuntimeCall>::from(SystemCall::remark { + remark: vec![0; EncodedCall::bound() - 3], + })); + + assert_err!(Scheduler::schedule(RuntimeOrigin::root(), 4, None, Some(127), call), >::TooBigScheduledCall); + }); +}