()
| 524 | |
| 525 | #[test] |
| 526 | fn 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 |
nothing calls this directly
no test coverage detected