@@ -2,7 +2,7 @@ use super::*;
2
2
use crate :: metadata_state:: subnet_call_context_manager:: SubnetCallContextManager ;
3
3
use ic_constants:: MAX_INGRESS_TTL ;
4
4
use ic_error_types:: { ErrorCode , UserError } ;
5
- use ic_ic00_types:: EcdsaCurve ;
5
+ use ic_ic00_types:: { EcdsaCurve , IC_00 } ;
6
6
use ic_registry_routing_table:: CanisterIdRange ;
7
7
use ic_test_utilities:: {
8
8
mock_time,
@@ -456,15 +456,27 @@ fn system_metadata_split() {
456
456
const SUBNET_B : SubnetId = SUBNET_1 ;
457
457
const SUBNET_C : SubnetId = SUBNET_2 ;
458
458
459
- // Ingress history with 2 Received messages, addressed to canisters 1 and 2.
459
+ // 2 canisters: we will retain `CANISTER_1` on `SUBNET_A` and split off
460
+ // `CANISTER_2` to `SUBNET_B`.
461
+ const CANISTER_1 : CanisterId = CanisterId :: from_u64 ( 1 ) ;
462
+ const CANISTER_2 : CanisterId = CanisterId :: from_u64 ( 2 ) ;
463
+
464
+ // Ingress history with 4 Received messages, addressed to canisters 1 and 2;
465
+ // `IC_00`; and respectively `SUBNET_A`.
460
466
let mut ingress_history = IngressHistoryState :: new ( ) ;
461
467
let time = mock_time ( ) ;
462
- for i in ( 1 ..=2u64 ) . rev ( ) {
468
+ let receivers = [
469
+ CANISTER_1 . get ( ) ,
470
+ CANISTER_2 . get ( ) ,
471
+ IC_00 . get ( ) ,
472
+ SUBNET_A . get ( ) ,
473
+ ] ;
474
+ for ( i, receiver) in receivers. into_iter ( ) . enumerate ( ) . rev ( ) {
463
475
ingress_history. insert (
464
- message_test_id ( i) ,
476
+ message_test_id ( i as u64 ) ,
465
477
IngressStatus :: Known {
466
- receiver : canister_test_id ( i ) . get ( ) ,
467
- user_id : user_test_id ( i) ,
478
+ receiver,
479
+ user_id : user_test_id ( i as u64 ) ,
468
480
time,
469
481
state : IngressState :: Received ,
470
482
} ,
@@ -473,9 +485,17 @@ fn system_metadata_split() {
473
485
) ;
474
486
}
475
487
488
+ // `CANISTER_1` remains on `SUBNET_A`.
489
+ let is_canister_on_subnet_a = |canister_id : & CanisterId | * canister_id == CANISTER_1 ;
490
+ // All ingress messages except the one addressed to `CANISTER_2` (including the
491
+ // ones for `IC_00` and `SUBNET_A`) should remain on `SUBNET_A` after the split.
492
+ let is_receiver_on_subnet_a = |canister_id : & CanisterId | * canister_id != CANISTER_2 ;
493
+ // Only ingress messages for `CANISTER_2` should be retained on `SUBNET_B`.
494
+ let is_canister_on_subnet_b = |canister_id : & CanisterId | * canister_id == CANISTER_2 ;
495
+
476
496
let streams = Streams {
477
497
streams : btreemap ! { SUBNET_C => Stream :: new( StreamIndexedQueue :: with_begin( 13 . into( ) ) , 14 . into( ) ) } ,
478
- responses_size_bytes : btreemap ! { canister_test_id ( 1 ) => 169 } ,
498
+ responses_size_bytes : btreemap ! { CANISTER_1 => 169 } ,
479
499
} ;
480
500
481
501
// Use uncommon `SubnetType::VerifiedApplication` to make it more likely to
@@ -503,14 +523,12 @@ fn system_metadata_split() {
503
523
// Technically some parts of the `SystemMetadata` (such as `prev_state_hash` and
504
524
// `own_subnet_type`) would be replaced during loading. However, we only care
505
525
// that `after_split()` does not touch them.
506
- let is_canister_on_subnet_a = |canister_id : & CanisterId | * canister_id == canister_test_id ( 0 ) ;
507
526
let metadata_a_phase_2 = metadata_a_phase_1. after_split ( is_canister_on_subnet_a) ;
508
527
509
- // Expect same metadata, but with pruned ingress history, no previous hash and
510
- // no split marker.
528
+ // Expect same metadata, but with pruned ingress history and no split marker.
511
529
expected. ingress_history = expected
512
530
. ingress_history
513
- . prune_after_split ( is_canister_on_subnet_a ) ;
531
+ . prune_after_split ( is_receiver_on_subnet_a ) ;
514
532
expected. split_from = None ;
515
533
assert_eq ! ( expected, metadata_a_phase_2) ;
516
534
@@ -528,10 +546,9 @@ fn system_metadata_split() {
528
546
// Technically some parts of the `SystemMetadata` (such as `prev_state_hash` and
529
547
// `own_subnet_type`) would be replaced during loading. However, we only care
530
548
// that `after_split()` does not touch them.
531
- let is_canister_on_subnet_b = |canister_id : & CanisterId | !is_canister_on_subnet_a ( canister_id) ;
532
549
let metadata_b_phase_2 = metadata_b_phase_1. after_split ( is_canister_on_subnet_b) ;
533
550
534
- // Expect pruned ingress history and no previous hash or split marker.
551
+ // Expect pruned ingress history and no split marker.
535
552
expected. split_from = None ;
536
553
expected. ingress_history = expected
537
554
. ingress_history
0 commit comments