Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(ICRC_Ledger): FI-1580: Preemptively top of canisters in golden state test #2659

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions rs/ledger_suite/icrc1/tests/golden_state_upgrade_downgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ impl LedgerSuiteConfig {
CanisterId::unchecked_from_principal(PrincipalId::from_str(self.ledger_id).unwrap());
let index_canister_id =
CanisterId::unchecked_from_principal(PrincipalId::from_str(self.index_id).unwrap());
// Top up the ledger suite canisters so that they do not risk running out of cycles as
// part of the upgrade/downgrade testing.
top_up_canisters(state_machine, ledger_canister_id, index_canister_id);
let mut previous_ledger_state = None;
if self.extended_testing {
previous_ledger_state = Some(LedgerState::verify_state_and_generate_transactions(
Expand Down Expand Up @@ -778,6 +781,22 @@ fn archive_wasm() -> Vec<u8> {
load_wasm_using_env_var("IC_ICRC1_ARCHIVE_WASM_PATH")
}

fn top_up_canisters(
state_machine: &StateMachine,
ledger_canister_id: CanisterId,
index_canister_id: CanisterId,
) {
const TOP_UP_AMOUNT: u128 = 2_000_000_000_000_000; // 2_000 T cycles
let archives = list_archives(state_machine, ledger_canister_id);
for archive in archives {
let archive_canister_id =
CanisterId::unchecked_from_principal(PrincipalId(archive.canister_id));
state_machine.add_cycles(archive_canister_id, TOP_UP_AMOUNT);
}
state_machine.add_cycles(ledger_canister_id, TOP_UP_AMOUNT);
state_machine.add_cycles(index_canister_id, TOP_UP_AMOUNT);
}

mod index {
use super::*;
use candid::Decode;
Expand Down