From a8992a580d42cbcdea4defbf65a753ef02055639 Mon Sep 17 00:00:00 2001 From: Justin Kaseman Date: Tue, 9 Apr 2024 14:45:03 -0700 Subject: [PATCH] (test): Amend TestCommitReportingPlugin_Report with pricegetter --- GNUmakefile | 2 +- .../ocr2/plugins/ccip/ccipcommit/ocr2_test.go | 26 +++++++++++++++---- .../ccip/internal/pricegetter/evm_test.go | 4 --- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index c6c652ab78..72e02f9ed4 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -149,7 +149,7 @@ telemetry-protobuf: $(telemetry-protobuf) ## Generate telemetry protocol buffers config-docs: ## Generate core node configuration documentation go run ./core/config/docs/cmd/generate -o ./docs/ -.PHONY: golangci-lint +.PHONY: golintlangci- golangci-lint: ## Run golangci-lint for all issues. [ -d "./golangci-lint" ] || mkdir ./golangci-lint && \ docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.56.2 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 > ./golangci-lint/$(shell date +%Y-%m-%d_%H:%M:%S).txt diff --git a/core/services/ocr2/plugins/ccip/ccipcommit/ocr2_test.go b/core/services/ocr2/plugins/ccip/ccipcommit/ocr2_test.go index 2ddbec4667..2cd08c5d8e 100644 --- a/core/services/ocr2/plugins/ccip/ccipcommit/ocr2_test.go +++ b/core/services/ocr2/plugins/ccip/ccipcommit/ocr2_test.go @@ -337,6 +337,7 @@ func TestCommitReportingPlugin_Report(t *testing.T) { name string observations []ccip.CommitObservation f int + priceGetterConfTokens []cciptypes.Address gasPriceUpdates []cciptypes.GasPriceUpdateWithTxMeta tokenDecimals map[cciptypes.Address]uint8 tokenPriceUpdates []cciptypes.TokenPriceUpdateWithTxMeta @@ -348,7 +349,8 @@ func TestCommitReportingPlugin_Report(t *testing.T) { expErr bool }{ { - name: "base", + name: "base", + priceGetterConfTokens: []cciptypes.Address{}, observations: []ccip.CommitObservation{ {Interval: cciptypes.CommitStoreInterval{Min: 1, Max: 1}, SourceGasPriceUSD: gasPrice}, {Interval: cciptypes.CommitStoreInterval{Min: 1, Max: 1}, SourceGasPriceUSD: gasPrice}, @@ -383,6 +385,10 @@ func TestCommitReportingPlugin_Report(t *testing.T) { }, { name: "multiple offRamps report with token prices", + priceGetterConfTokens: []cciptypes.Address{ + ccipcalc.HexToAddress("2000"), + ccipcalc.HexToAddress("3000"), + }, observations: []ccip.CommitObservation{ { Interval: cciptypes.CommitStoreInterval{Min: 1, Max: 1}, @@ -438,7 +444,8 @@ func TestCommitReportingPlugin_Report(t *testing.T) { expErr: false, }, { - name: "empty", + name: "empty", + priceGetterConfTokens: []cciptypes.Address{}, observations: []ccip.CommitObservation{ {Interval: cciptypes.CommitStoreInterval{Min: 0, Max: 0}, SourceGasPriceUSD: big.NewInt(0)}, {Interval: cciptypes.CommitStoreInterval{Min: 0, Max: 0}, SourceGasPriceUSD: big.NewInt(0)}, @@ -458,7 +465,8 @@ func TestCommitReportingPlugin_Report(t *testing.T) { expErr: false, }, { - name: "no leaves", + name: "no leaves", + priceGetterConfTokens: []cciptypes.Address{}, observations: []ccip.CommitObservation{ {Interval: cciptypes.CommitStoreInterval{Min: 2, Max: 2}, SourceGasPriceUSD: big.NewInt(0)}, {Interval: cciptypes.CommitStoreInterval{Min: 2, Max: 2}, SourceGasPriceUSD: big.NewInt(0)}, @@ -469,7 +477,8 @@ func TestCommitReportingPlugin_Report(t *testing.T) { expErr: true, }, { - name: "price reporting disabled base case", + name: "price reporting disabled base case", + priceGetterConfTokens: []cciptypes.Address{}, observations: []ccip.CommitObservation{ {Interval: cciptypes.CommitStoreInterval{Min: 1, Max: 1}, SourceGasPriceUSD: nil}, {Interval: cciptypes.CommitStoreInterval{Min: 1, Max: 1}, SourceGasPriceUSD: nil}, @@ -493,7 +502,8 @@ func TestCommitReportingPlugin_Report(t *testing.T) { expErr: false, }, { - name: "price reporting disabled with invalid observation", + name: "price reporting disabled with invalid observation", + priceGetterConfTokens: []cciptypes.Address{}, observations: []ccip.CommitObservation{ {Interval: cciptypes.CommitStoreInterval{Min: 1, Max: 1}, SourceGasPriceUSD: big.NewInt(0)}, {Interval: cciptypes.CommitStoreInterval{Min: 1, Max: 1}, SourceGasPriceUSD: nil}, @@ -576,6 +586,11 @@ func TestCommitReportingPlugin_Report(t *testing.T) { healthCheck := ccipcachemocks.NewChainHealthcheck(t) healthCheck.On("IsHealthy", ctx).Return(true, nil) + pricegetter := pricegetter.NewMockPriceGetter(t) + for _, confToken := range tc.priceGetterConfTokens { + pricegetter.On("IsTokenConfigured", mock.Anything, confToken).Return(true, nil) + } + p := &CommitReportingPlugin{} p.lggr = logger.TestLogger(t) p.destPriceRegistryReader = destPriceRegistryReader @@ -586,6 +601,7 @@ func TestCommitReportingPlugin_Report(t *testing.T) { p.offchainConfig.GasPriceHeartBeat = gasPriceHeartBeat.Duration() p.commitStoreReader = commitStoreReader p.F = tc.f + p.priceGetter = pricegetter p.metricsCollector = ccip.NoopMetricsCollector p.offchainConfig.PriceReportingDisabled = tc.priceReportingDisabled p.chainHealthcheck = healthCheck diff --git a/core/services/ocr2/plugins/ccip/internal/pricegetter/evm_test.go b/core/services/ocr2/plugins/ccip/internal/pricegetter/evm_test.go index 771237399e..b53c4e7e87 100644 --- a/core/services/ocr2/plugins/ccip/internal/pricegetter/evm_test.go +++ b/core/services/ocr2/plugins/ccip/internal/pricegetter/evm_test.go @@ -72,10 +72,6 @@ func TestDynamicPriceGetter(t *testing.T) { for tk := range test.param.expectedTokenPrices { tokenAddr := cciptypes.Address(tk.String()) tokens = append(tokens, tokenAddr) - // Expect that token is configured - isConfigured, err2 := pg.IsTokenConfigured(ctx, tokenAddr) - require.NoError(t, err2) - assert.True(t, isConfigured) } prices, err := pg.TokenPricesUSD(ctx, tokens) if test.param.priceResolutionErrorExpected {