Skip to content

Commit

Permalink
fix: non-zero default period (#14206)
Browse files Browse the repository at this point in the history
* fix: non-zero default period

* Update eight-bees-speak.md
  • Loading branch information
bukata-sa authored Aug 22, 2024
1 parent 908e96c commit 621e875
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-bees-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#bugfix head reporter non-zero reporting period
11 changes: 6 additions & 5 deletions core/services/headreporter/head_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ type (

func NewHeadReporterService(ds sqlutil.DataSource, lggr logger.Logger, reporters ...HeadReporter) *HeadReporterService {
return &HeadReporterService{
ds: ds,
lggr: lggr.Named("HeadReporter"),
newHeads: mailbox.NewSingle[*evmtypes.Head](),
chStop: make(chan struct{}),
reporters: reporters,
ds: ds,
lggr: lggr.Named("HeadReporter"),
newHeads: mailbox.NewSingle[*evmtypes.Head](),
chStop: make(chan struct{}),
reporters: reporters,
reportPeriod: 15 * time.Second,
}
}

Expand Down
6 changes: 6 additions & 0 deletions core/services/headreporter/head_reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -42,4 +43,9 @@ func Test_HeadReporterService(t *testing.T) {

require.Eventually(t, func() bool { return reportCalls.Load() == 2 }, 5*time.Second, 100*time.Millisecond)
})

t.Run("has default report period", func(t *testing.T) {
service := NewHeadReporterService(pgtest.NewSqlxDB(t), logger.TestLogger(t), NewMockHeadReporter(t))
assert.Equal(t, service.reportPeriod, 15*time.Second)
})
}

0 comments on commit 621e875

Please sign in to comment.