Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions core/services/fluxmonitorv2/integrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,6 @@ ds1 -> ds1_parse
}

func TestFluxMonitor_HibernationMode(t *testing.T) {
g := gomega.NewWithT(t)
fa := setupFluxAggregatorUniverse(t)

// - add oracles
Expand Down Expand Up @@ -838,12 +837,14 @@ ds1 -> ds1_parse
fa.backend.Commit()

// wait for FM to receive flags raised logs
g.Eventually(func() int {
require.Eventually(t, func() bool {
ilogs, err := fa.flagsContract.FilterFlagRaised(nil, []common.Address{})
require.NoError(t, err)
if err != nil {
return false
}
logs := cltest.GetLogs(t, nil, ilogs)
return len(logs)
}, testutils.WaitTimeout(t), 100*time.Millisecond).Should(gomega.Equal(4))
return len(logs) == 4
}, testutils.WaitTimeout(t), 100*time.Millisecond, "expected 4 FlagRaised logs from flags contract")

// change in price should not trigger run
reportPrice.Store(8)
Expand Down
21 changes: 15 additions & 6 deletions core/services/vrf/v2/integration_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,22 @@ func requestRandomnessAndAssertRandomWordsRequestedEvent(
require.NoError(t, err)
backend.Commit()

iter, err := coordinator.FilterRandomWordsRequested(nil, nil, []*big.Int{subID}, nil)
require.NoError(t, err, "could not filter RandomWordsRequested events")

var events []v22.RandomWordsRequested
for iter.Next() {
events = append(events, iter.Event())
}
require.Eventually(t, func() bool {
iter, err := coordinator.FilterRandomWordsRequested(nil, nil, []*big.Int{subID}, nil)
if err != nil {
return false
}
Comment on lines +722 to +726
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FilterRandomWordsRequested returns a RandomWordsRequestedIterator with a Close() method; inside this require.Eventually loop a new iterator is created on each poll but never closed. This can leak resources/goroutines across retries and make the test flaky. Ensure the iterator is closed on every attempt (including early-return paths), and handle any Close() error appropriately.

Suggested change
require.Eventually(t, func() bool {
iter, err := coordinator.FilterRandomWordsRequested(nil, nil, []*big.Int{subID}, nil)
if err != nil {
return false
}
require.Eventually(t, func() (ok bool) {
iter, err := coordinator.FilterRandomWordsRequested(nil, nil, []*big.Int{subID}, nil)
if err != nil {
return false
}
defer func() {
if closeErr := iter.Close(); closeErr != nil {
t.Logf("failed to close RandomWordsRequested iterator: %v", closeErr)
ok = false
}
}()

Copilot uses AI. Check for mistakes.
var batch []v22.RandomWordsRequested
for iter.Next() {
batch = append(batch, iter.Event())
}
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The iterator's Error() is not checked after the for iter.Next() loop. If iteration stops due to an underlying error, this code can accept a partial batch and proceed as though it succeeded. Check iter.Error() (and treat non-nil as a failed attempt) before assigning events / returning true.

Suggested change
}
}
if err := iter.Error(); err != nil {
return false
}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah true error check was missing

if len(batch) == 0 {
return false
}
events = batch
return true
}, testutils.WaitTimeout(t), 100*time.Millisecond, "could not filter RandomWordsRequested events (simulated backend may need retries)")

requestID, err = vrfConsumerHandle.SRequestId(nil)
require.NoError(t, err)
Expand Down
Loading