MCPcopy Create free account
hub / github.com/dfinity/orbit / backup_snapshot

Function backup_snapshot

tests/integration/src/system_upgrade_tests.rs:526–696  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

524
525#[test]
526fn backup_snapshot() {
527 let TestEnv {
528 env, canister_ids, ..
529 } = setup_new_env();
530
531 let system_info = get_system_info(&env, WALLET_ADMIN_USER, canister_ids.station);
532 let upgrader_id = system_info.upgrader_id;
533
534 let station_init_arg = SystemInstall::Upgrade(SystemUpgrade { name: None });
535 let station_init_arg_bytes = Encode!(&station_init_arg).unwrap();
536 let upgrader_init_arg = InitArg {
537 target_canister: canister_ids.station,
538 };
539 let upgrader_init_arg_bytes = Encode!(&upgrader_init_arg).unwrap();
540
541 let upgrade = |system_upgrade_operation_input: SystemUpgradeOperationInput| {
542 let extra_ticks = match system_upgrade_operation_input.target {
543 SystemUpgradeTargetDTO::UpgradeStation => STATION_UPGRADE_EXTRA_TICKS,
544 SystemUpgradeTargetDTO::UpgradeUpgrader => 0,
545 };
546 execute_request_with_extra_ticks(
547 &env,
548 WALLET_ADMIN_USER,
549 canister_ids.station,
550 RequestOperationInput::SystemUpgrade(system_upgrade_operation_input),
551 extra_ticks,
552 )
553 };
554
555 let snapshot = |target: &SystemUpgradeTargetDTO| -> Option<Vec<u8>> {
556 let (canister_id, caller) = match target {
557 SystemUpgradeTargetDTO::UpgradeStation => (canister_ids.station, upgrader_id),
558 SystemUpgradeTargetDTO::UpgradeUpgrader => (upgrader_id, canister_ids.station),
559 };
560 let snapshots: Vec<_> = env
561 .list_canister_snapshots(canister_id, Some(caller))
562 .unwrap();
563 if snapshots.is_empty() {
564 None
565 } else {
566 assert_eq!(snapshots.len(), 1);
567 Some(snapshots[0].id.clone())
568 }
569 };
570
571 let check_snapshots = |target: &SystemUpgradeTargetDTO, snapshot_id: Option<Vec<u8>>| {
572 match target {
573 SystemUpgradeTargetDTO::UpgradeStation => {
574 let snapshots_via_upgrader =
575 update_candid_as::<_, (ApiResult<Vec<upgrader_api::Snapshot>>,)>(
576 &env,
577 upgrader_id,
578 WALLET_ADMIN_USER,
579 "canister_snapshots",
580 (),
581 )
582 .unwrap()
583 .0

Callers

nothing calls this directly

Calls 9

setup_new_envFunction · 0.85
get_system_infoFunction · 0.85
UpgradeInterface · 0.85
get_canister_wasmFunction · 0.85
to_vecMethod · 0.80
SystemUpgradeClass · 0.50
is_emptyMethod · 0.45

Tested by

no test coverage detected