Skip to content

Commit

Permalink
core/internal/features/ocr2: parallelize subtests; extend timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Oct 14, 2024
1 parent 37f3132 commit 1d4216a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions core/internal/features/ocr2/features_ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/onsi/gomega"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"

"github.com/smartcontractkit/libocr/commontypes"
"github.com/smartcontractkit/libocr/gethwrappers2/ocr2aggregator"
Expand All @@ -35,6 +36,7 @@ import (
ocrtypes2 "github.com/smartcontractkit/libocr/offchainreporting2plus/types"

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"

"github.com/smartcontractkit/chainlink/v2/core/bridges"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets"
Expand Down Expand Up @@ -133,6 +135,7 @@ func setupNodeOCR2(
c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(5 * time.Second)
c.EVM[0].Transactions.ForwardersEnabled = &useForwarder
})
config.SetLogLevel(zap.WarnLevel)

Check failure on line 138 in core/internal/features/ocr2/features_ocr2_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `config.SetLogLevel` is not checked (errcheck)

app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, b, p2pKey)

Expand Down Expand Up @@ -203,9 +206,11 @@ func testIntegration_OCR2(t *testing.T) {
} {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
owner, b, ocrContractAddress, ocrContract := setupOCR2Contracts(t)

lggr := logger.TestLogger(t)
lggr.SetLogLevel(zap.WarnLevel)
bootstrapNodePort := freeport.GetOne(t)
bootstrapNode := setupNodeOCR2(t, owner, bootstrapNodePort, false /* useForwarders */, b, nil)

Expand Down Expand Up @@ -561,11 +566,13 @@ updateInterval = "1m"

// Trail #1: 4 oracles reporting 0, 10, 20, 30. Answer should be 20 (results[4/2]).
// Trial #2: 4 oracles reporting 0, 20, 40, 60. Answer should be 40 (results[4/2]).
gomega.NewGomegaWithT(t).Eventually(func() string {
if !gomega.NewGomegaWithT(t).Eventually(func() string {
answer, err2 := ocrContract.LatestAnswer(nil)
require.NoError(t, err2)
return answer.String()
}, 1*time.Minute, 200*time.Millisecond).Should(gomega.Equal(fmt.Sprintf("%d", 2*retVal)))
}, tests.WaitTimeout(t), 200*time.Millisecond).Should(gomega.Equal(fmt.Sprintf("%d", 2*retVal))) {
t.Fatal()
}

for _, app := range apps {
jobs, _, err2 := app.JobORM().FindJobs(ctx, 0, 1000)
Expand Down Expand Up @@ -886,11 +893,13 @@ updateInterval = "1m"
wg.Wait()

// 4 oracles reporting 0, 10, 20, 30. Answer should be 20 (results[4/2]).
gomega.NewGomegaWithT(t).Eventually(func() string {
if !gomega.NewGomegaWithT(t).Eventually(func() string {
answer, err := ocrContract.LatestAnswer(nil)
require.NoError(t, err)
return answer.String()
}, 1*time.Minute, 200*time.Millisecond).Should(gomega.Equal("20"))
}, tests.WaitTimeout(t), 200*time.Millisecond).Should(gomega.Equal("20")) {
t.Fatal()
}

for _, app := range apps {
jobs, _, err := app.JobORM().FindJobs(ctx, 0, 1000)
Expand Down
2 changes: 1 addition & 1 deletion tools/bin/go_core_tests
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use_tee() {
cat > "$@"
fi
}
go test -json -ldflags "$GO_LDFLAGS" -tags integration $TEST_FLAGS -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt $1 | use_tee $OUTPUT_FILE
go test -timeout 15m -json -ldflags "$GO_LDFLAGS" -tags integration $TEST_FLAGS -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt $1 | use_tee $OUTPUT_FILE
EXITCODE=${PIPESTATUS[0]}

# Assert no known sensitive strings present in test logger output
Expand Down

0 comments on commit 1d4216a

Please sign in to comment.