@@ -4,7 +4,10 @@ use soroban_sdk::{
44 Address , Env , Vec ,
55} ;
66
7- use crate :: { LedgerLensScoreContract , LedgerLensScoreContractClient } ;
7+ use crate :: {
8+ constants:: DEFAULT_PARAM_CHANGE_DELAY_SECS , LedgerLensScoreContract ,
9+ LedgerLensScoreContractClient ,
10+ } ;
811use std:: vec;
912
1013fn setup < ' a > ( ) -> ( Env , LedgerLensScoreContractClient < ' a > , Address , Address ) {
@@ -35,10 +38,14 @@ fn test_history_max_depth_no_overflow() {
3538
3639 // Set max history depth to 5
3740 client. set_history_max_depth ( & Vec :: new ( & env) , & 5 ) ;
41+ env. ledger ( ) . with_mut ( |l| l. timestamp += DEFAULT_PARAM_CHANGE_DELAY_SECS ) ;
42+ client. apply_param_change ( & symbol_short ! ( "hist_dep" ) ) ;
3843
3944 // Submit 10 scores
4045 for i in 0 ..10 {
41- env. ledger ( ) . with_mut ( |l| l. timestamp = 1_000_000 + ( i as u64 * 3_601 ) ) ;
46+ env. ledger ( ) . with_mut ( |l| {
47+ l. timestamp = 1_000_000 + DEFAULT_PARAM_CHANGE_DELAY_SECS + ( i as u64 * 3_601 )
48+ } ) ;
4249 client. submit_score (
4350 & Vec :: new ( & env) ,
4451 & wallet,
@@ -76,9 +83,13 @@ fn test_history_respects_max_depth_boundary() {
7683
7784 // Exact boundary: max_depth = 3, submit 3 scores
7885 client. set_history_max_depth ( & Vec :: new ( & env) , & 3 ) ;
86+ env. ledger ( ) . with_mut ( |l| l. timestamp += DEFAULT_PARAM_CHANGE_DELAY_SECS ) ;
87+ client. apply_param_change ( & symbol_short ! ( "hist_dep" ) ) ;
7988
8089 for i in 0 ..3 {
81- env. ledger ( ) . with_mut ( |l| l. timestamp = 1_000_000 + ( i as u64 * 3_601 ) ) ;
90+ env. ledger ( ) . with_mut ( |l| {
91+ l. timestamp = 1_000_000 + DEFAULT_PARAM_CHANGE_DELAY_SECS + ( i as u64 * 3_601 )
92+ } ) ;
8293 client. submit_score (
8394 & Vec :: new ( & env) ,
8495 & wallet,
@@ -326,8 +337,12 @@ fn test_history_max_depth_change_takes_effect() {
326337
327338 // Submit 5 scores with max_depth = 10
328339 client. set_history_max_depth ( & Vec :: new ( & env) , & 10 ) ;
340+ env. ledger ( ) . with_mut ( |l| l. timestamp += DEFAULT_PARAM_CHANGE_DELAY_SECS ) ;
341+ client. apply_param_change ( & symbol_short ! ( "hist_dep" ) ) ;
329342 for i in 0 ..5 {
330- env. ledger ( ) . with_mut ( |l| l. timestamp = 1_000_000 + ( i as u64 * 3_601 ) ) ;
343+ env. ledger ( ) . with_mut ( |l| {
344+ l. timestamp = 1_000_000 + DEFAULT_PARAM_CHANGE_DELAY_SECS + ( i as u64 * 3_601 )
345+ } ) ;
331346 client. submit_score (
332347 & Vec :: new ( & env) ,
333348 & wallet,
@@ -347,8 +362,10 @@ fn test_history_max_depth_change_takes_effect() {
347362
348363 // Reduce max_depth to 3 and submit 2 more scores
349364 client. set_history_max_depth ( & Vec :: new ( & env) , & 3 ) ;
365+ env. ledger ( ) . with_mut ( |l| l. timestamp += DEFAULT_PARAM_CHANGE_DELAY_SECS ) ;
366+ client. apply_param_change ( & symbol_short ! ( "hist_dep" ) ) ;
350367 for i in 5 ..7 {
351- env. ledger ( ) . with_mut ( |l| l. timestamp = 1_000_000 + ( i as u64 * 3_601 ) ) ;
368+ env. ledger ( ) . with_mut ( |l| l. timestamp += 3_601 ) ;
352369 client. submit_score (
353370 & Vec :: new ( & env) ,
354371 & wallet,
@@ -419,9 +436,13 @@ fn test_history_no_metadata_leakage() {
419436 env. ledger ( ) . with_mut ( |l| l. timestamp = 1_000_000 ) ;
420437
421438 client. set_history_max_depth ( & Vec :: new ( & env) , & 5 ) ;
439+ env. ledger ( ) . with_mut ( |l| l. timestamp += DEFAULT_PARAM_CHANGE_DELAY_SECS ) ;
440+ client. apply_param_change ( & symbol_short ! ( "hist_dep" ) ) ;
422441
423442 for i in 0 ..7 {
424- env. ledger ( ) . with_mut ( |l| l. timestamp = 1_000_000 + ( i as u64 * 3_601 ) ) ;
443+ env. ledger ( ) . with_mut ( |l| {
444+ l. timestamp = 1_000_000 + DEFAULT_PARAM_CHANGE_DELAY_SECS + ( i as u64 * 3_601 )
445+ } ) ;
425446 client. submit_score (
426447 & Vec :: new ( & env) ,
427448 & wallet,
0 commit comments