@@ -71,7 +71,7 @@ func TestSearch_TransactionHash(t *testing.T) {
7171 txHash := "0x1234567890123456789012345678901234567890123456789012345678901234"
7272
7373 // Mock the 3 GetTransactions calls for different time ranges
74- // 1. Past 5 days (startOffsetDays=5, endOffsetDays=0)
74+ // 1. Past 5 days (startOffsetDays=5, endOffsetDays=0) - This should always be called first and return a result
7575 mockStorage .EXPECT ().GetTransactions (mock .MatchedBy (func (filter storage.QueryFilter ) bool {
7676 return filter .ChainId .Cmp (big .NewInt (1 )) == 0 &&
7777 filter .FilterParams ["hash" ] == txHash &&
@@ -88,33 +88,33 @@ func TestSearch_TransactionHash(t *testing.T) {
8888 }},
8989 }, nil )
9090
91- // 2. 5-30 days (startOffsetDays=30, endOffsetDays=5)
92- mockStorage .EXPECT (). GetTransactions ( mock .MatchedBy (func (filter storage.QueryFilter ) bool {
91+ // 2. 5-30 days (startOffsetDays=30, endOffsetDays=5) - This might not be called due to race conditions
92+ mockStorage .On ( " GetTransactions" , mock .MatchedBy (func (filter storage.QueryFilter ) bool {
9393 return filter .ChainId .Cmp (big .NewInt (1 )) == 0 &&
9494 filter .FilterParams ["hash" ] == txHash &&
9595 filter .FilterParams ["block_timestamp_gte" ] != "" &&
9696 filter .FilterParams ["block_timestamp_lte" ] != ""
97- })).Return (storage.QueryResult [common.Transaction ]{}, nil )
97+ })).Return (storage.QueryResult [common.Transaction ]{}, nil ). Maybe ()
9898
99- // 3. More than 30 days (startOffsetDays=0, endOffsetDays=30)
100- mockStorage .EXPECT (). GetTransactions ( mock .MatchedBy (func (filter storage.QueryFilter ) bool {
99+ // 3. More than 30 days (startOffsetDays=0, endOffsetDays=30) - This might not be called due to race conditions
100+ mockStorage .On ( " GetTransactions" , mock .MatchedBy (func (filter storage.QueryFilter ) bool {
101101 return filter .ChainId .Cmp (big .NewInt (1 )) == 0 &&
102102 filter .FilterParams ["hash" ] == txHash &&
103103 filter .FilterParams ["block_timestamp_gte" ] == "" &&
104104 filter .FilterParams ["block_timestamp_lte" ] != ""
105- })).Return (storage.QueryResult [common.Transaction ]{}, nil )
105+ })).Return (storage.QueryResult [common.Transaction ]{}, nil ). Maybe ()
106106
107- // Mock the GetBlocks call for block hash search
108- mockStorage .EXPECT (). GetBlocks ( mock .MatchedBy (func (filter storage.QueryFilter ) bool {
107+ // Mock the GetBlocks call for block hash search - This might not be called due to race conditions
108+ mockStorage .On ( " GetBlocks" , mock .MatchedBy (func (filter storage.QueryFilter ) bool {
109109 return filter .ChainId .Cmp (big .NewInt (1 )) == 0 &&
110110 filter .FilterParams ["hash" ] == txHash
111- })).Return (storage.QueryResult [common.Block ]{}, nil )
111+ })).Return (storage.QueryResult [common.Block ]{}, nil ). Maybe ()
112112
113- // Mock the GetLogs call for topic_0 search
114- mockStorage .EXPECT (). GetLogs ( mock .MatchedBy (func (filter storage.QueryFilter ) bool {
113+ // Mock the GetLogs call for topic_0 search - This might not be called due to race conditions
114+ mockStorage .On ( " GetLogs" , mock .MatchedBy (func (filter storage.QueryFilter ) bool {
115115 return filter .ChainId .Cmp (big .NewInt (1 )) == 0 &&
116116 filter .Signature == txHash
117- })).Return (storage.QueryResult [common.Log ]{}, nil )
117+ })).Return (storage.QueryResult [common.Log ]{}, nil ). Maybe ()
118118
119119 w := httptest .NewRecorder ()
120120 req , _ := http .NewRequest ("GET" , "/v1/search/1/" + txHash , nil )
0 commit comments