Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use cycles_minting_canister::CyclesCanisterInitPayload;
use ic_base_types::{CanisterId, PrincipalId};
use ic_crypto_sha2::Sha256;
use ic_nervous_system_clients::canister_status::CanisterStatusType;
use ic_nervous_system_common::ONE_MONTH_SECONDS;
use ic_nns_common::pb::v1::NeuronId;
use ic_nns_constants::{
CYCLES_LEDGER_CANISTER_ID, CYCLES_MINTING_CANISTER_ID, GENESIS_TOKEN_CANISTER_ID,
Expand Down Expand Up @@ -403,6 +402,7 @@ fn check_canisters_are_all_protocol_canisters(state_machine: &StateMachine) {

mod sanity_check {
use super::*;
use ic_nns_governance::governance::NODE_PROVIDER_REWARD_PERIOD_SECONDS;

/// Metrics fetched from canisters either before or after testing.
pub struct Metrics {
Expand All @@ -428,14 +428,24 @@ mod sanity_check {
state_machine: &StateMachine,
before: Metrics,
) {
advance_time(state_machine);
advance_time(
state_machine,
before
.governance_most_recent_monthly_node_provider_rewards
.timestamp,
);
let after = fetch_metrics(state_machine);
MetricsBeforeAndAfter { before, after }.check_all();
}

fn advance_time(state_machine: &StateMachine) {
// This duration is picked so that node rewards will definitely be distributed.
state_machine.advance_time(std::time::Duration::from_secs(ONE_MONTH_SECONDS));
fn advance_time(state_machine: &StateMachine, before_timestamp: u64) {
// Advance time in the state machine to just before the next rewards distribution time.
state_machine.advance_time(std::time::Duration::from_secs(
before_timestamp + NODE_PROVIDER_REWARD_PERIOD_SECONDS
- state_machine.get_time().as_secs_since_unix_epoch()
- 1,
));

for _ in 0..100 {
state_machine.advance_time(std::time::Duration::from_secs(1));
state_machine.tick();
Expand Down
Loading