@@ -10,12 +10,14 @@ use candid::{Decode, Encode, Nat};
1010use ic_base_types:: { CanisterId , PrincipalId } ;
1111use ic_crypto_sha2:: Sha256 ;
1212use ic_management_canister_types_private:: { CanisterMetadataRequest , CanisterMetadataResponse } ;
13+ use ic_nervous_system_root:: change_canister:: AddCanisterRequest ;
1314use ic_nns_constants:: { BITCOIN_MAINNET_CANISTER_ID , CYCLES_MINTING_CANISTER_ID } ;
1415use ic_nns_governance_api:: {
1516 SelfDescribingValue ,
1617 bitcoin:: { BitcoinNetwork , BitcoinSetConfigProposal } ,
1718 subnet_rental:: { RentalConditionId , SubnetRentalRequest } ,
1819} ;
20+ use ic_nns_handler_lifeline_interface:: HardResetNnsRootToVersionPayload ;
1921use ic_sns_wasm:: pb:: v1:: { AddWasmRequest , SnsCanisterType , SnsWasm } ;
2022use maplit:: hashmap;
2123use std:: sync:: Arc ;
@@ -122,6 +124,8 @@ fn test_execute_nns_function_try_from_errors() {
122124 }
123125}
124126
127+ // This tests a "normal" NNS function where the payload is translated through a candid file fetched
128+ // by the `canister_metadata` method on the management canister.
125129#[ tokio:: test]
126130async fn test_to_self_describing_update_subnet_type ( ) {
127131 // Minimal CMC candid file with only update_subnet_type method
@@ -419,41 +423,19 @@ fn test_re_encode_payload_to_target_canister_overrides_proposal_id_for_add_wasm(
419423
420424#[ tokio:: test]
421425async fn test_to_self_describing_nns_canister_install ( ) {
422- let root_candid = r#"
423- type AddCanisterRequest = record {
424- arg : blob;
425- initial_cycles : nat64;
426- wasm_module : blob;
427- name : text;
428- memory_allocation : opt nat;
429- compute_allocation : opt nat;
430- };
431-
432- service : {
433- add_nns_canister : (AddCanisterRequest) -> ();
434- }
435- "# ;
436-
437- #[ derive( candid:: CandidType ) ]
438- struct AddCanisterRequest {
439- arg : Vec < u8 > ,
440- initial_cycles : u64 ,
441- wasm_module : Vec < u8 > ,
442- name : String ,
443- memory_allocation : Option < u64 > ,
444- compute_allocation : Option < u64 > ,
445- }
426+ let root_candid =
427+ std:: fs:: read_to_string ( "rs/nns/handlers/root/impl/canister/root.did" ) . unwrap ( ) ;
446428
447429 let wasm_module = vec ! [ 0_u8 , 0x61 , 0x73 , 0x6D , 1_u8 , 0_u8 , 0_u8 , 0_u8 ] ;
448430 let arg = vec ! [ 1_u8 , 2_u8 , 3_u8 ] ;
449431
450432 let request = AddCanisterRequest {
451- arg : arg. clone ( ) ,
452- initial_cycles : 1_000_000_000_000_u64 ,
453- wasm_module : wasm_module. clone ( ) ,
454433 name : "test-canister" . to_string ( ) ,
455- memory_allocation : None ,
434+ wasm_module : wasm_module. clone ( ) ,
435+ arg : arg. clone ( ) ,
456436 compute_allocation : None ,
437+ memory_allocation : None ,
438+ initial_cycles : 1_000_000_000_000_u64 ,
457439 } ;
458440 let payload = Encode ! ( & request) . unwrap ( ) ;
459441
@@ -503,27 +485,13 @@ service : {
503485
504486#[ tokio:: test]
505487async fn test_to_self_describing_hard_reset_nns_root_to_version ( ) {
506- let lifeline_candid = r#"
507- type HardResetRootToVersionPayload = record {
508- wasm_module: blob;
509- init_arg: blob;
510- };
511-
512- service : {
513- hard_reset_root_to_version: (HardResetRootToVersionPayload) -> ();
514- }
515- "# ;
516-
517- #[ derive( candid:: CandidType ) ]
518- struct HardResetRootToVersionPayload {
519- wasm_module : Vec < u8 > ,
520- init_arg : Vec < u8 > ,
521- }
488+ let lifeline_candid =
489+ std:: fs:: read_to_string ( "rs/nns/handlers/lifeline/impl/lifeline.did" ) . unwrap ( ) ;
522490
523491 let wasm_module = vec ! [ 0_u8 , 0x61 , 0x73 , 0x6D , 1_u8 , 0_u8 , 0_u8 , 0_u8 ] ;
524492 let init_arg = vec ! [ 4_u8 , 5_u8 , 6_u8 ] ;
525493
526- let request = HardResetRootToVersionPayload {
494+ let request = HardResetNnsRootToVersionPayload {
527495 wasm_module : wasm_module. clone ( ) ,
528496 init_arg : init_arg. clone ( ) ,
529497 } ;
0 commit comments