@@ -1264,8 +1264,8 @@ fn cancel_named_periodic_scheduling_works() {
1264
1264
1265
1265
#[ test]
1266
1266
fn scheduler_respects_weight_limits ( ) {
1267
- let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1268
1267
new_test_ext ( ) . execute_with ( || {
1268
+ let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1269
1269
let call = RuntimeCall :: Logger ( LoggerCall :: log { i : 42 , weight : max_weight / 3 * 2 } ) ;
1270
1270
assert_ok ! ( Scheduler :: do_schedule(
1271
1271
DispatchTime :: At ( 4 ) ,
@@ -1292,8 +1292,8 @@ fn scheduler_respects_weight_limits() {
1292
1292
1293
1293
#[ test]
1294
1294
fn retry_respects_weight_limits ( ) {
1295
- let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1296
1295
new_test_ext ( ) . execute_with ( || {
1296
+ let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1297
1297
// schedule 42
1298
1298
let call = RuntimeCall :: Logger ( LoggerCall :: log { i : 42 , weight : max_weight / 3 * 2 } ) ;
1299
1299
assert_ok ! ( Scheduler :: do_schedule(
@@ -1344,8 +1344,8 @@ fn retry_respects_weight_limits() {
1344
1344
1345
1345
#[ test]
1346
1346
fn try_schedule_retry_respects_weight_limits ( ) {
1347
- let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1348
1347
new_test_ext ( ) . execute_with ( || {
1348
+ let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1349
1349
let service_agendas_weight = <Test as Config >:: WeightInfo :: service_agendas_base ( ) ;
1350
1350
let service_agenda_weight = <Test as Config >:: WeightInfo :: service_agenda_base (
1351
1351
<Test as Config >:: MaxScheduledPerBlock :: get ( ) ,
@@ -1404,8 +1404,8 @@ fn try_schedule_retry_respects_weight_limits() {
1404
1404
/// Permanently overweight calls are not deleted but also not executed.
1405
1405
#[ test]
1406
1406
fn scheduler_does_not_delete_permanently_overweight_call ( ) {
1407
- let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1408
1407
new_test_ext ( ) . execute_with ( || {
1408
+ let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1409
1409
let call = RuntimeCall :: Logger ( LoggerCall :: log { i : 42 , weight : max_weight } ) ;
1410
1410
assert_ok ! ( Scheduler :: do_schedule(
1411
1411
DispatchTime :: At ( 4 ) ,
@@ -1430,10 +1430,10 @@ fn scheduler_does_not_delete_permanently_overweight_call() {
1430
1430
1431
1431
#[ test]
1432
1432
fn scheduler_handles_periodic_failure ( ) {
1433
- let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1434
- let max_per_block = <Test as Config >:: MaxScheduledPerBlock :: get ( ) ;
1435
-
1436
1433
new_test_ext ( ) . execute_with ( || {
1434
+ let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1435
+ let max_per_block = <Test as Config >:: MaxScheduledPerBlock :: get ( ) ;
1436
+
1437
1437
let call = RuntimeCall :: Logger ( LoggerCall :: log { i : 42 , weight : ( max_weight / 3 ) * 2 } ) ;
1438
1438
let bound = Preimage :: bound ( call) . unwrap ( ) ;
1439
1439
@@ -1472,9 +1472,9 @@ fn scheduler_handles_periodic_failure() {
1472
1472
1473
1473
#[ test]
1474
1474
fn scheduler_handles_periodic_unavailable_preimage ( ) {
1475
- let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1476
-
1477
1475
new_test_ext ( ) . execute_with ( || {
1476
+ let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1477
+
1478
1478
let call = RuntimeCall :: Logger ( LoggerCall :: log { i : 42 , weight : ( max_weight / 3 ) * 2 } ) ;
1479
1479
let hash = <Test as frame_system:: Config >:: Hashing :: hash_of ( & call) ;
1480
1480
let len = call. using_encoded ( |x| x. len ( ) ) as u32 ;
@@ -1518,8 +1518,8 @@ fn scheduler_handles_periodic_unavailable_preimage() {
1518
1518
1519
1519
#[ test]
1520
1520
fn scheduler_respects_priority_ordering ( ) {
1521
- let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1522
1521
new_test_ext ( ) . execute_with ( || {
1522
+ let max_weight: Weight = <Test as Config >:: MaximumWeight :: get ( ) ;
1523
1523
let call = RuntimeCall :: Logger ( LoggerCall :: log { i : 42 , weight : max_weight / 3 } ) ;
1524
1524
assert_ok ! ( Scheduler :: do_schedule(
1525
1525
DispatchTime :: At ( 4 ) ,
@@ -3039,3 +3039,40 @@ fn unavailable_call_is_detected() {
3039
3039
assert ! ( !Preimage :: is_requested( & hash) ) ;
3040
3040
} ) ;
3041
3041
}
3042
+
3043
+ #[ test]
3044
+ fn postponed_task_is_still_available ( ) {
3045
+ new_test_ext ( ) . execute_with ( || {
3046
+ let service_agendas_weight = <Test as Config >:: WeightInfo :: service_agendas_base ( ) ;
3047
+ let service_agenda_weight = <Test as Config >:: WeightInfo :: service_agenda_base (
3048
+ <Test as Config >:: MaxScheduledPerBlock :: get ( ) ,
3049
+ ) ;
3050
+
3051
+ assert_ok ! ( Scheduler :: schedule(
3052
+ RuntimeOrigin :: root( ) ,
3053
+ 4 ,
3054
+ None ,
3055
+ 128 ,
3056
+ Box :: new( RuntimeCall :: from( frame_system:: Call :: remark {
3057
+ remark: vec![ 0u8 ; 3 * 1024 * 1024 ] ,
3058
+ } ) )
3059
+ ) ) ;
3060
+ System :: run_to_block :: < AllPalletsWithSystem > ( 3 ) ;
3061
+ // Scheduled calls are in the agenda.
3062
+ assert_eq ! ( Agenda :: <Test >:: get( 4 ) . len( ) , 1 ) ;
3063
+
3064
+ let old_weight = MaximumSchedulerWeight :: get ( ) ;
3065
+ MaximumSchedulerWeight :: set ( & service_agenda_weight. saturating_add ( service_agendas_weight) ) ;
3066
+
3067
+ System :: run_to_block :: < AllPalletsWithSystem > ( 4 ) ;
3068
+
3069
+ // The task should still be there.
3070
+ assert_eq ! ( Agenda :: <Test >:: get( 4 ) . iter( ) . filter( |a| a. is_some( ) ) . count( ) , 1 ) ;
3071
+ System :: assert_last_event ( crate :: Event :: AgendaIncomplete { when : 4 } . into ( ) ) ;
3072
+
3073
+ // Now it should get executed
3074
+ MaximumSchedulerWeight :: set ( & old_weight) ;
3075
+ System :: run_to_block :: < AllPalletsWithSystem > ( 5 ) ;
3076
+ assert ! ( Agenda :: <Test >:: get( 4 ) . is_empty( ) ) ;
3077
+ } ) ;
3078
+ }
0 commit comments