Skip to content

Commit

Permalink
Fix chain reader test & logpoller test
Browse files Browse the repository at this point in the history
This failing chainreader test had FinalityDepth set to 0, so LogPoller was starting after
the block where the logs were emitted. It was only passing due to
Backup LogPoller.  With Backup LogPoller disabled, we have to increase
the finality depth so that LogPoller will start a few blocks back (at
the first unfinalized block).

The failing logpoller test was looking for an extra log entry emitted by BackupLogPoller.
Now we can run it with BackupLogPoller disabled (leading to a more robust test) and stop
looking for that
  • Loading branch information
reductionista committed Jan 24, 2024
1 parent 0b22029 commit 7fd561e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions core/chains/evm/logpoller/log_poller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,6 @@ func TestLogPoller_DBErrorHandling(t *testing.T) {
BackfillBatchSize: 3,
RpcBatchSize: 2,
KeepFinalizedBlocksDepth: 1000,
BackupPollerBlockDelay: 0,
}
lp := logpoller.NewLogPoller(o, client.NewSimulatedBackendClient(t, ec, chainID2), lggr, lpOpts)

Expand All @@ -1399,7 +1398,7 @@ func TestLogPoller_DBErrorHandling(t *testing.T) {
time.Sleep(100 * time.Millisecond)
require.NoError(t, lp.Start(ctx))
require.Eventually(t, func() bool {
return observedLogs.Len() >= 5
return observedLogs.Len() >= 4
}, 2*time.Second, 20*time.Millisecond)
lp.Close()

Expand All @@ -1416,7 +1415,6 @@ func TestLogPoller_DBErrorHandling(t *testing.T) {
assert.Contains(t, logMsgs, "SQL ERROR")
assert.Contains(t, logMsgs, "Failed loading filters in main logpoller loop, retrying later")
assert.Contains(t, logMsgs, "Error executing replay, could not get fromBlock")
assert.Contains(t, logMsgs, "Backup log poller ran before filters loaded, skipping")
}

type getLogErrData struct {
Expand Down
5 changes: 3 additions & 2 deletions core/services/relay/evm/chain_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ func (it *chainReaderInterfaceTester) MaxWaitTimeForEvents() time.Duration {
maxWaitTime := time.Second * 20
maxWaitTimeStr, ok := os.LookupEnv("MAX_WAIT_TIME_FOR_EVENTS_S")
if ok {
wiatS, err := strconv.ParseInt(maxWaitTimeStr, 10, 64)
waitS, err := strconv.ParseInt(maxWaitTimeStr, 10, 64)
if err != nil {
fmt.Printf("Error parsing MAX_WAIT_TIME_FOR_EVENTS_S: %v, defaulting to %v\n", err, maxWaitTime)
}
maxWaitTime = time.Second * time.Duration(wiatS)
maxWaitTime = time.Second * time.Duration(waitS)
}

return maxWaitTime
Expand Down Expand Up @@ -259,6 +259,7 @@ func (it *chainReaderInterfaceTester) GetChainReader(t *testing.T) clcommontypes
db := pgtest.NewSqlxDB(t)
lpOpts := logpoller.Opts{
PollPeriod: time.Millisecond,
FinalityDepth: 4,
BackfillBatchSize: 1,
RpcBatchSize: 1,
KeepFinalizedBlocksDepth: 10000,
Expand Down

0 comments on commit 7fd561e

Please sign in to comment.