diff --git a/src/backend/impl/src/repositories/proposal_repository.rs b/src/backend/impl/src/repositories/proposal_repository.rs index 414756d..ced744e 100644 --- a/src/backend/impl/src/repositories/proposal_repository.rs +++ b/src/backend/impl/src/repositories/proposal_repository.rs @@ -259,7 +259,7 @@ mod tests { use super::*; use crate::{ fixtures::{self, date_time_a, date_time_b, date_time_c}, - repositories::NervousSystem, + repositories::{NervousSystem, PROPOSAL_REVIEW_PERIOD_DURATION}, system_api::get_date_time, }; use chrono::Duration; @@ -401,8 +401,8 @@ mod tests { .get_proposals(Some(ReviewPeriodStateKey::Completed)) .unwrap(); - assert_eq!(in_progress_result.len(), 4); - assert_eq!(completed_result.len(), 2); + assert_eq!(in_progress_result.len(), 5); + assert_eq!(completed_result.len(), 3); } #[fixture] @@ -441,20 +441,42 @@ mod tests { Proposal { state: ReviewPeriodState::InProgress, ..fixtures::nns_replica_version_management_proposal( - Some( - DateTime::new(current_time - Duration::hours(48) - Duration::minutes(1)) - .unwrap(), - ), + Some(DateTime::new(current_time - Duration::hours(48)).unwrap()), Some(130396), ) }, Proposal { state: ReviewPeriodState::InProgress, ..fixtures::nns_replica_version_management_proposal( - Some(DateTime::new(current_time - Duration::hours(60)).unwrap()), + Some(DateTime::new(current_time - PROPOSAL_REVIEW_PERIOD_DURATION).unwrap()), Some(130395), ) }, + Proposal { + state: ReviewPeriodState::InProgress, + ..fixtures::nns_replica_version_management_proposal( + Some( + DateTime::new( + current_time - (PROPOSAL_REVIEW_PERIOD_DURATION + Duration::minutes(1)), + ) + .unwrap(), + ), + Some(130394), + ) + }, + Proposal { + state: ReviewPeriodState::InProgress, + ..fixtures::nns_replica_version_management_proposal( + Some( + DateTime::new( + current_time + - (PROPOSAL_REVIEW_PERIOD_DURATION.checked_mul(2).unwrap()), + ) + .unwrap(), + ), + Some(130393), + ) + }, ] } diff --git a/src/backend/impl/src/repositories/types/proposal.rs b/src/backend/impl/src/repositories/types/proposal.rs index ca74d12..6a370b1 100644 --- a/src/backend/impl/src/repositories/types/proposal.rs +++ b/src/backend/impl/src/repositories/types/proposal.rs @@ -9,6 +9,8 @@ use ic_stable_structures::{ }; use std::{borrow::Cow, ops::RangeBounds}; +pub(crate) const PROPOSAL_REVIEW_PERIOD_DURATION: Duration = Duration::hours(96); + pub type ProposalId = Uuid; pub type NervousSystemProposalId = u64; pub type NeuronId = u64; @@ -135,10 +137,10 @@ impl Storable for Proposal { impl Proposal { /// Checks if the proposal is in [ReviewPeriodState::InProgress] state - /// and was proposed more than **48 hours** ago. + /// and was proposed more than [PROPOSAL_REVIEW_PERIOD_DURATION]. pub fn is_pending(&self, current_time: &DateTime) -> bool { self.state == ReviewPeriodState::InProgress - && self.proposed_at().unwrap() <= current_time.sub(Duration::hours(48)) + && self.proposed_at().unwrap() <= current_time.sub(PROPOSAL_REVIEW_PERIOD_DURATION) } /// Checks if the proposal is in [ReviewPeriodState::Completed] state. @@ -487,8 +489,10 @@ mod tests { state: ReviewPeriodState::InProgress, ..fixtures::nns_replica_version_management_proposal( Some( - DateTime::new(current_time - Duration::hours(48) - Duration::minutes(1)) - .unwrap(), + DateTime::new( + current_time - (PROPOSAL_REVIEW_PERIOD_DURATION + Duration::minutes(1)), + ) + .unwrap(), ), None, ) @@ -496,7 +500,12 @@ mod tests { Proposal { state: ReviewPeriodState::InProgress, ..fixtures::nns_replica_version_management_proposal( - Some(DateTime::new(current_time - Duration::hours(60)).unwrap()), + Some( + DateTime::new( + current_time - PROPOSAL_REVIEW_PERIOD_DURATION.checked_mul(2).unwrap(), + ) + .unwrap(), + ), None, ) }, diff --git a/src/backend/integration/src/support/common.ts b/src/backend/integration/src/support/common.ts index 5e48057..016582d 100644 --- a/src/backend/integration/src/support/common.ts +++ b/src/backend/integration/src/support/common.ts @@ -62,9 +62,9 @@ export async function createProposal( } /** - * The review period is **48 hours** in milliseconds. + * The review period is **96 hours** in milliseconds. */ -export const REVIEW_PERIOD_MS = 48 * 60 * 60 * 1000; +export const PROPOSAL_REVIEW_PERIOD_MS = 96 * 60 * 60 * 1000; /** * Advances PIC's time in order to make the proposal complete. @@ -75,7 +75,7 @@ export async function completeProposal( proposalId: string, ) { // advance time to make the proposal expire - await pic.advanceTime(REVIEW_PERIOD_MS); + await pic.advanceTime(PROPOSAL_REVIEW_PERIOD_MS); // ensure timers run await pic.tick(2); diff --git a/src/backend/integration/src/tests/proposal.spec.ts b/src/backend/integration/src/tests/proposal.spec.ts index 326ac7c..45bd090 100644 --- a/src/backend/integration/src/tests/proposal.spec.ts +++ b/src/backend/integration/src/tests/proposal.spec.ts @@ -1,7 +1,7 @@ import { describe, beforeEach, afterEach, it, expect } from 'bun:test'; import { Governance, - REVIEW_PERIOD_MS, + PROPOSAL_REVIEW_PERIOD_MS, TestDriver, extractErrResponse, extractOkResponse, @@ -31,7 +31,7 @@ describe('Proposal', () => { }; const advanceTimeToCompleteProposals = async () => { - await driver.advanceTime(REVIEW_PERIOD_MS + 1); + await driver.advanceTime(PROPOSAL_REVIEW_PERIOD_MS + 1); }; const createProposalsBatch = async (count: number): Promise => { @@ -180,7 +180,7 @@ describe('Proposal', () => { expectListProposalsResult(resInProgress); // advance time, but do not reach the review deadline - await driver.advanceTime(REVIEW_PERIOD_MS - advancedTimeMs - 1); + await driver.advanceTime(PROPOSAL_REVIEW_PERIOD_MS - advancedTimeMs - 1); const resCompleted = await driver.actor.list_proposals({ state: [{ completed: null }],