@@ -775,16 +775,17 @@ pub mod node_tests {
775775 } ;
776776 use hotshot_types:: {
777777 data:: { vid_commitment, VidCommitment , VidShare } ,
778- traits:: { block_contents:: EncodeBytes , node_implementation:: Versions } ,
778+ traits:: {
779+ block_contents:: { BlockHeader , EncodeBytes } ,
780+ node_implementation:: Versions ,
781+ } ,
779782 vid:: advz:: { advz_scheme, ADVZScheme } ,
780783 } ;
781784 use jf_vid:: VidScheme ;
782785 use vbs:: version:: StaticVersionType ;
783786
784787 use crate :: {
785- availability:: {
786- BlockInfo , BlockQueryData , LeafQueryData , QueryableHeader , VidCommonQueryData ,
787- } ,
788+ availability:: { BlockInfo , BlockQueryData , LeafQueryData , VidCommonQueryData } ,
788789 data_source:: {
789790 storage:: { NodeStorage , UpdateAvailabilityStorage } ,
790791 update:: Transaction ,
@@ -799,6 +800,10 @@ pub mod node_tests {
799800 Header , VidCommon ,
800801 } ;
801802
803+ fn block_header_timestamp ( header : & Header < MockTypes > ) -> u64 {
804+ <TestBlockHeader as BlockHeader < MockTypes > >:: timestamp ( header)
805+ }
806+
802807 #[ tokio:: test( flavor = "multi_thread" ) ]
803808 pub async fn test_sync_status < D : TestableDataSource > ( )
804809 where
@@ -1232,7 +1237,9 @@ pub mod node_tests {
12321237 let leaf = leaves. next ( ) . await . unwrap ( ) ;
12331238 let header = leaf. header ( ) . clone ( ) ;
12341239 if let Some ( last_timestamp) = test_blocks. last_mut ( ) {
1235- if last_timestamp[ 0 ] . timestamp ( ) == header. timestamp ( ) {
1240+ if <TestBlockHeader as BlockHeader < MockTypes > >:: timestamp ( & last_timestamp[ 0 ] )
1241+ == <TestBlockHeader as BlockHeader < MockTypes > >:: timestamp ( & header)
1242+ {
12361243 last_timestamp. push ( header) ;
12371244 } else {
12381245 test_blocks. push ( vec ! [ header] ) ;
@@ -1249,26 +1256,29 @@ pub mod node_tests {
12491256 let mut prev = res. prev . as_ref ( ) ;
12501257 if let Some ( prev) = prev {
12511258 if check_prev {
1252- assert ! ( prev . timestamp ( ) < start) ;
1259+ assert ! ( block_header_timestamp ( prev ) < start) ;
12531260 }
12541261 } else {
12551262 // `prev` can only be `None` if the first block in the window is the genesis
12561263 // block.
12571264 assert_eq ! ( res. from( ) . unwrap( ) , 0 ) ;
12581265 } ;
12591266 for header in & res. window {
1260- assert ! ( start <= header . timestamp ( ) ) ;
1261- assert ! ( header . timestamp ( ) < end) ;
1267+ assert ! ( start <= block_header_timestamp ( header ) ) ;
1268+ assert ! ( block_header_timestamp ( header ) < end) ;
12621269 if let Some ( prev) = prev {
1263- assert ! ( prev. timestamp( ) <= header. timestamp( ) ) ;
1270+ assert ! (
1271+ <TestBlockHeader as BlockHeader <MockTypes >>:: timestamp( prev)
1272+ <= <TestBlockHeader as BlockHeader <MockTypes >>:: timestamp( header)
1273+ ) ;
12641274 }
12651275 prev = Some ( header) ;
12661276 }
12671277 if let Some ( next) = & res. next {
1268- assert ! ( next . timestamp( ) >= end) ;
1278+ assert ! ( < TestBlockHeader as BlockHeader < MockTypes >> :: timestamp( next ) >= end) ;
12691279 // If there is a `next`, there must be at least one previous block (either `prev`
12701280 // itself or the last block if the window is nonempty), so we can `unwrap` here.
1271- assert ! ( next . timestamp ( ) >= prev. unwrap( ) . timestamp ( ) ) ;
1281+ assert ! ( block_header_timestamp ( next ) >= block_header_timestamp ( prev. unwrap( ) ) ) ;
12721282 }
12731283 } ;
12741284
@@ -1286,7 +1296,7 @@ pub mod node_tests {
12861296 } ;
12871297
12881298 // Case 0: happy path. All blocks are available, including prev and next.
1289- let start = test_blocks[ 1 ] [ 0 ] . timestamp ( ) ;
1299+ let start = < TestBlockHeader as BlockHeader < MockTypes > > :: timestamp ( & test_blocks[ 1 ] [ 0 ] ) ;
12901300 let end = start + 1 ;
12911301 let res = get_window ( start, end) . await ;
12921302 assert_eq ! ( res. prev. unwrap( ) , * test_blocks[ 0 ] . last( ) . unwrap( ) ) ;
@@ -1295,14 +1305,14 @@ pub mod node_tests {
12951305
12961306 // Case 1: no `prev`, start of window is before genesis.
12971307 let start = 0 ;
1298- let end = test_blocks[ 0 ] [ 0 ] . timestamp ( ) + 1 ;
1308+ let end = < TestBlockHeader as BlockHeader < MockTypes > > :: timestamp ( & test_blocks[ 0 ] [ 0 ] ) + 1 ;
12991309 let res = get_window ( start, end) . await ;
13001310 assert_eq ! ( res. prev, None ) ;
13011311 assert_eq ! ( res. window, test_blocks[ 0 ] ) ;
13021312 assert_eq ! ( res. next. unwrap( ) , test_blocks[ 1 ] [ 0 ] ) ;
13031313
13041314 // Case 2: no `next`, end of window is after the most recently sequenced block.
1305- let start = test_blocks[ 2 ] [ 0 ] . timestamp ( ) ;
1315+ let start = < TestBlockHeader as BlockHeader < MockTypes > > :: timestamp ( & test_blocks[ 2 ] [ 0 ] ) ;
13061316 let end = i64:: MAX as u64 ;
13071317 let res = get_window ( start, end) . await ;
13081318 assert_eq ! ( res. prev. unwrap( ) , * test_blocks[ 1 ] . last( ) . unwrap( ) ) ;
@@ -1344,7 +1354,7 @@ pub mod node_tests {
13441354 assert_eq ! ( more2. window[ ..more. window. len( ) ] , more. window) ;
13451355
13461356 // Case 3: the window is empty.
1347- let start = test_blocks[ 1 ] [ 0 ] . timestamp ( ) ;
1357+ let start = < TestBlockHeader as BlockHeader < MockTypes > > :: timestamp ( & test_blocks[ 1 ] [ 0 ] ) ;
13481358 let end = start;
13491359 let res = get_window ( start, end) . await ;
13501360 assert_eq ! ( res. prev. unwrap( ) , * test_blocks[ 0 ] . last( ) . unwrap( ) ) ;
@@ -1366,8 +1376,8 @@ pub mod node_tests {
13661376 . flatten ( )
13671377 . collect :: < Vec < _ > > ( ) ;
13681378 // Make a query that would return everything, but gets limited.
1369- let start = blocks[ 0 ] . timestamp ( ) ;
1370- let end = test_blocks[ 2 ] [ 0 ] . timestamp ( ) ;
1379+ let start = block_header_timestamp ( & blocks[ 0 ] ) ;
1380+ let end = block_header_timestamp ( & test_blocks[ 2 ] [ 0 ] ) ;
13711381 let res = ds
13721382 . get_header_window ( WindowStart :: Time ( start) , end, 1 )
13731383 . await
0 commit comments