@@ -446,6 +446,70 @@ func TestGetLogsBlockHashIsNotZero(t *testing.T) {
446446 }
447447}
448448
449+ func TestFilterGetLogsBlockHashNotYetAvailable (t * testing.T ) {
450+ t .Parallel ()
451+ // Query for a block hash that corresponds to a block height (200)
452+ // that is greater than the latest receipt version (103)
453+ // This should return an error saying the block hash isn't available yet
454+
455+ filterCriteria := map [string ]interface {}{
456+ "blockHash" : FutureBlockHash ,
457+ }
458+ resObj := sendRequestGood (t , "getLogs" , filterCriteria )
459+
460+ // Should return an error
461+ errorObj , hasError := resObj ["error" ]
462+ require .True (t , hasError , "Expected an error when querying for block hash with height > latest receipt version" )
463+
464+ errorMap := errorObj .(map [string ]interface {})
465+ errorMessage := errorMap ["message" ].(string )
466+ require .Contains (t , errorMessage , "isn't available yet" , "Error message should indicate block hash isn't available yet" )
467+ }
468+
469+ func TestFilterGetLogsBlockRangeIncludesUnavailableBlock (t * testing.T ) {
470+ t .Parallel ()
471+ // Query for a block range where toBlock (200) is greater than the latest receipt version (103)
472+ // This tests that querying a range with unavailable blocks doesn't cause issues
473+ // and returns logs only for available blocks or returns an appropriate error
474+
475+ filterCriteria := map [string ]interface {}{
476+ "fromBlock" : "0x64" , // 100 in hex - this block exists
477+ "toBlock" : "0xc8" , // 200 in hex - this block height > latest receipt version
478+ }
479+ resObj := sendRequestGood (t , "getLogs" , filterCriteria )
480+
481+ // The behavior could be either:
482+ // 1. Return an error indicating the range includes unavailable blocks
483+ // 2. Return empty results (no logs found in the unavailable range)
484+ // We check for both possibilities
485+
486+ errorObj , hasError := resObj ["error" ]
487+ require .True (t , hasError , "Expected an error when querying for block range with unavailable block" )
488+ // If there's an error, it should mention the block range or unavailability
489+ errorMap := errorObj .(map [string ]interface {})
490+ errorMessage := errorMap ["message" ].(string )
491+ // The error could be about block range, system overload, or unavailability
492+ require .Contains (t , errorMessage , "unavailable block(s)" , "Error message should indicate block range includes unavailable block(s)" )
493+ }
494+
495+ func TestFilterGetLogsBlockRangePartiallyAvailable (t * testing.T ) {
496+ t .Parallel ()
497+ // Query for a block range that spans both available and unavailable blocks
498+ // fromBlock: 100 (available), toBlock: 105 (should be available since it's < 200)
499+
500+ filterCriteria := map [string ]interface {}{
501+ "fromBlock" : "0x64" , // 100 in hex
502+ "toBlock" : "0x69" , // 105 in hex - still within available range
503+ }
504+ resObj := sendRequestGood (t , "getLogs" , filterCriteria )
505+
506+ // Success case - should return a valid array
507+ result , ok := resObj ["result" ]
508+ require .True (t , ok , "Result should exist" )
509+ _ , isArray := result .([]interface {})
510+ require .True (t , isArray , "Result should be an array" )
511+ }
512+
449513func TestGetLogsTransactionIndexConsistency (t * testing.T ) {
450514 t .Parallel ()
451515
0 commit comments