@@ -115,7 +115,7 @@ fn scope_rejects_ancestors_that_skip_blocks() {
115
115
storage_root: Hash :: repeat_byte( 69 ) ,
116
116
} ] ;
117
117
118
- let max_depth = 2 ;
118
+ let max_depth = 3 ;
119
119
let base_constraints = make_constraints ( 8 , vec ! [ 8 , 9 ] , vec ! [ 1 , 2 , 3 ] . into ( ) ) ;
120
120
let pending_availability = Vec :: new ( ) ;
121
121
@@ -145,7 +145,7 @@ fn scope_rejects_ancestor_for_0_block() {
145
145
storage_root: Hash :: repeat_byte( 69 ) ,
146
146
} ] ;
147
147
148
- let max_depth = 2 ;
148
+ let max_depth = 3 ;
149
149
let base_constraints = make_constraints ( 0 , vec ! [ ] , vec ! [ 1 , 2 , 3 ] . into ( ) ) ;
150
150
let pending_availability = Vec :: new ( ) ;
151
151
@@ -187,7 +187,7 @@ fn scope_only_takes_ancestors_up_to_min() {
187
187
} ,
188
188
] ;
189
189
190
- let max_depth = 2 ;
190
+ let max_depth = 3 ;
191
191
let base_constraints = make_constraints ( 3 , vec ! [ 2 ] , vec ! [ 1 , 2 , 3 ] . into ( ) ) ;
192
192
let pending_availability = Vec :: new ( ) ;
193
193
@@ -230,7 +230,7 @@ fn scope_rejects_unordered_ancestors() {
230
230
} ,
231
231
] ;
232
232
233
- let max_depth = 2 ;
233
+ let max_depth = 3 ;
234
234
let base_constraints = make_constraints ( 0 , vec ! [ 2 ] , vec ! [ 1 , 2 , 3 ] . into ( ) ) ;
235
235
let pending_availability = Vec :: new ( ) ;
236
236
@@ -496,7 +496,7 @@ fn test_populate_and_check_potential() {
496
496
relay_parent_z_info. clone ( ) ,
497
497
wrong_constraints. clone ( ) ,
498
498
vec ! [ ] ,
499
- 4 ,
499
+ 5 ,
500
500
ancestors. clone ( ) ,
501
501
)
502
502
. unwrap ( ) ;
@@ -529,7 +529,7 @@ fn test_populate_and_check_potential() {
529
529
530
530
// Various depths
531
531
{
532
- // Depth is 0, only allows one candidate, but the others will be kept as potential.
532
+ // Depth is 0, doesn't allow any candidate, but the others will be kept as potential.
533
533
let scope = Scope :: with_ancestors (
534
534
relay_parent_z_info. clone ( ) ,
535
535
base_constraints. clone ( ) ,
@@ -543,19 +543,40 @@ fn test_populate_and_check_potential() {
543
543
assert ! ( chain. can_add_candidate_as_potential( & candidate_b_entry) . is_ok( ) ) ;
544
544
assert ! ( chain. can_add_candidate_as_potential( & candidate_c_entry) . is_ok( ) ) ;
545
545
546
+ let chain = populate_chain_from_previous_storage ( & scope, & storage) ;
547
+ assert ! ( chain. best_chain_vec( ) . is_empty( ) ) ;
548
+ assert_eq ! (
549
+ chain. unconnected( ) . map( |c| c. candidate_hash) . collect:: <HashSet <_>>( ) ,
550
+ [ candidate_a_hash, candidate_b_hash, candidate_c_hash] . into_iter( ) . collect( )
551
+ ) ;
552
+
553
+ // Depth is 1, only allows one candidate, but the others will be kept as potential.
554
+ let scope = Scope :: with_ancestors (
555
+ relay_parent_z_info. clone ( ) ,
556
+ base_constraints. clone ( ) ,
557
+ vec ! [ ] ,
558
+ 1 ,
559
+ ancestors. clone ( ) ,
560
+ )
561
+ . unwrap ( ) ;
562
+ let chain = FragmentChain :: init ( scope. clone ( ) , CandidateStorage :: default ( ) ) ;
563
+ assert ! ( chain. can_add_candidate_as_potential( & candidate_a_entry) . is_ok( ) ) ;
564
+ assert ! ( chain. can_add_candidate_as_potential( & candidate_b_entry) . is_ok( ) ) ;
565
+ assert ! ( chain. can_add_candidate_as_potential( & candidate_c_entry) . is_ok( ) ) ;
566
+
546
567
let chain = populate_chain_from_previous_storage ( & scope, & storage) ;
547
568
assert_eq ! ( chain. best_chain_vec( ) , vec![ candidate_a_hash] ) ;
548
569
assert_eq ! (
549
570
chain. unconnected( ) . map( |c| c. candidate_hash) . collect:: <HashSet <_>>( ) ,
550
571
[ candidate_b_hash, candidate_c_hash] . into_iter( ) . collect( )
551
572
) ;
552
573
553
- // depth is 1 , allows two candidates
574
+ // depth is 2 , allows two candidates
554
575
let scope = Scope :: with_ancestors (
555
576
relay_parent_z_info. clone ( ) ,
556
577
base_constraints. clone ( ) ,
557
578
vec ! [ ] ,
558
- 1 ,
579
+ 2 ,
559
580
ancestors. clone ( ) ,
560
581
)
561
582
. unwrap ( ) ;
@@ -571,8 +592,8 @@ fn test_populate_and_check_potential() {
571
592
[ candidate_c_hash] . into_iter( ) . collect( )
572
593
) ;
573
594
574
- // depth is larger than 2 , allows all three candidates
575
- for depth in 2 ..6 {
595
+ // depth is at least 3 , allows all three candidates
596
+ for depth in 3 ..6 {
576
597
let scope = Scope :: with_ancestors (
577
598
relay_parent_z_info. clone ( ) ,
578
599
base_constraints. clone ( ) ,
@@ -604,7 +625,7 @@ fn test_populate_and_check_potential() {
604
625
relay_parent_z_info. clone ( ) ,
605
626
base_constraints. clone ( ) ,
606
627
vec ! [ ] ,
607
- 4 ,
628
+ 5 ,
608
629
ancestors_without_x,
609
630
)
610
631
. unwrap ( ) ;
@@ -627,7 +648,7 @@ fn test_populate_and_check_potential() {
627
648
relay_parent_z_info. clone ( ) ,
628
649
base_constraints. clone ( ) ,
629
650
vec ! [ ] ,
630
- 4 ,
651
+ 5 ,
631
652
vec ! [ ] ,
632
653
)
633
654
. unwrap ( ) ;
@@ -673,7 +694,7 @@ fn test_populate_and_check_potential() {
673
694
relay_parent_z_info. clone ( ) ,
674
695
base_constraints. clone ( ) ,
675
696
vec ! [ ] ,
676
- 4 ,
697
+ 5 ,
677
698
ancestors. clone ( ) ,
678
699
)
679
700
. unwrap ( ) ;
@@ -715,7 +736,7 @@ fn test_populate_and_check_potential() {
715
736
relay_parent_z_info. clone ( ) ,
716
737
base_constraints. clone ( ) ,
717
738
vec ! [ ] ,
718
- 4 ,
739
+ 5 ,
719
740
ancestors. clone ( ) ,
720
741
)
721
742
. unwrap ( ) ;
@@ -757,7 +778,7 @@ fn test_populate_and_check_potential() {
757
778
relay_parent_z_info. clone ( ) ,
758
779
base_constraints. clone ( ) ,
759
780
vec ! [ ] ,
760
- 4 ,
781
+ 5 ,
761
782
ancestors. clone ( ) ,
762
783
)
763
784
. unwrap ( ) ;
@@ -986,7 +1007,7 @@ fn test_populate_and_check_potential() {
986
1007
relay_parent_z_info. clone ( ) ,
987
1008
base_constraints. clone ( ) ,
988
1009
vec ! [ ] ,
989
- 2 ,
1010
+ 3 ,
990
1011
ancestors. clone ( ) ,
991
1012
)
992
1013
. unwrap ( ) ;
@@ -1301,7 +1322,7 @@ fn test_populate_and_check_potential() {
1301
1322
relay_parent: relay_parent_z_info. clone( ) ,
1302
1323
} ,
1303
1324
] ,
1304
- 2 ,
1325
+ 0 ,
1305
1326
ancestors. clone ( ) ,
1306
1327
)
1307
1328
. unwrap ( ) ;
@@ -1326,7 +1347,7 @@ fn test_populate_and_check_potential() {
1326
1347
relay_parent_z_info. clone ( ) ,
1327
1348
base_constraints. clone ( ) ,
1328
1349
vec ! [ ] ,
1329
- 2 ,
1350
+ 3 ,
1330
1351
ancestors. clone ( ) ,
1331
1352
)
1332
1353
. unwrap ( ) ;
@@ -1355,7 +1376,7 @@ fn test_populate_and_check_potential() {
1355
1376
fn test_find_ancestor_path_and_find_backable_chain_empty_best_chain ( ) {
1356
1377
let relay_parent = Hash :: repeat_byte ( 1 ) ;
1357
1378
let required_parent: HeadData = vec ! [ 0xff ] . into ( ) ;
1358
- let max_depth = 10 ;
1379
+ let max_depth = 11 ;
1359
1380
1360
1381
// Empty chain
1361
1382
let base_constraints = make_constraints ( 0 , vec ! [ 0 ] , required_parent. clone ( ) ) ;
@@ -1382,7 +1403,7 @@ fn test_find_ancestor_path_and_find_backable_chain() {
1382
1403
let para_id = ParaId :: from ( 5u32 ) ;
1383
1404
let relay_parent = Hash :: repeat_byte ( 1 ) ;
1384
1405
let required_parent: HeadData = vec ! [ 0xff ] . into ( ) ;
1385
- let max_depth = 5 ;
1406
+ let max_depth = 6 ;
1386
1407
let relay_parent_number = 0 ;
1387
1408
let relay_parent_storage_root = Hash :: zero ( ) ;
1388
1409
@@ -1567,7 +1588,7 @@ fn test_find_ancestor_path_and_find_backable_chain() {
1567
1588
candidate_hash: candidates[ 3 ] ,
1568
1589
relay_parent: relay_parent_info,
1569
1590
} ] ,
1570
- max_depth,
1591
+ max_depth - 1 ,
1571
1592
vec ! [ ] ,
1572
1593
)
1573
1594
. unwrap ( ) ;
0 commit comments