From 33f717fa052c664af5818776c82624ac423d628d Mon Sep 17 00:00:00 2001 From: Sergei Drugalev Date: Mon, 20 Jun 2022 03:13:30 +0200 Subject: [PATCH] Fixing tests + cleanup --- pkg/chainlink/ocr2/client_test.go | 6 +++--- pkg/chainlink/ocr2/contract_cache.go | 6 +++--- pkg/chainlink/ocr2/contract_reader.go | 4 ++-- pkg/chainlink/ocr2/providers.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/chainlink/ocr2/client_test.go b/pkg/chainlink/ocr2/client_test.go index 6d54e0f4b..cae7a0bd4 100644 --- a/pkg/chainlink/ocr2/client_test.go +++ b/pkg/chainlink/ocr2/client_test.go @@ -20,15 +20,15 @@ func TestOCR2Client(t *testing.T) { assert.NoError(t, err) t.Run("get billing details", func(t *testing.T) { - _, err := client.OCR2BillingDetails(context.Background(), ocr2ContractAddress) + _, err := client.BillingDetails(context.Background(), ocr2ContractAddress) assert.NoError(t, err) }) t.Run("get latest config details", func(t *testing.T) { - details, err := client.OCR2LatestConfigDetails(context.Background(), ocr2ContractAddress) + details, err := client.LatestConfigDetails(context.Background(), ocr2ContractAddress) assert.NoError(t, err) - _, err = client.OCR2LatestConfig(context.Background(), ocr2ContractAddress, details.Block) + _, err = client.ConfigFromEventAt(context.Background(), ocr2ContractAddress, details.Block) assert.NoError(t, err) }) } diff --git a/pkg/chainlink/ocr2/contract_cache.go b/pkg/chainlink/ocr2/contract_cache.go index 5612ca67f..d6722821e 100644 --- a/pkg/chainlink/ocr2/contract_cache.go +++ b/pkg/chainlink/ocr2/contract_cache.go @@ -52,11 +52,11 @@ func (c *contractCache) updateConfig(ctx context.Context) error { } c.ccLock.RLock() - isSameConfig := c.contractConfig.ConfigBlock == configBlock && c.contractConfig.Config.ConfigDigest == configDigest + isSame := c.contractConfig.ConfigBlock == configBlock && c.contractConfig.Config.ConfigDigest == configDigest c.ccLock.RUnlock() var newConfig types.ContractConfig - if !isSameConfig { + if !isSame { newConfig, err = c.reader.LatestConfig(ctx, configBlock) if err != nil { return errors.Wrap(err, "couldn't fetch latest config") @@ -66,7 +66,7 @@ func (c *contractCache) updateConfig(ctx context.Context) error { c.ccLock.Lock() defer c.ccLock.Unlock() c.ccLastCheckedAt = time.Now() - if !isSameConfig { + if !isSame { c.contractConfig = ContractConfig{ Config: newConfig, ConfigBlock: configBlock, diff --git a/pkg/chainlink/ocr2/contract_reader.go b/pkg/chainlink/ocr2/contract_reader.go index 2d5ab6170..7643c2d02 100644 --- a/pkg/chainlink/ocr2/contract_reader.go +++ b/pkg/chainlink/ocr2/contract_reader.go @@ -20,10 +20,10 @@ type contractReader struct { lggr logger.Logger } -func NewContractReader(address string, chainReader OCR2Reader, lggr logger.Logger) *contractReader { +func NewContractReader(address string, reader OCR2Reader, lggr logger.Logger) *contractReader { return &contractReader{ address: address, - reader: chainReader, + reader: reader, lggr: lggr, } } diff --git a/pkg/chainlink/ocr2/providers.go b/pkg/chainlink/ocr2/providers.go index 364db24df..b5817bd3d 100644 --- a/pkg/chainlink/ocr2/providers.go +++ b/pkg/chainlink/ocr2/providers.go @@ -62,7 +62,7 @@ func (p *configProvider) Close() error { } func (p *configProvider) ContractConfigTracker() types.ContractConfigTracker { - return p.reader + return p.contractCache } func (p *configProvider) OffchainConfigDigester() types.OffchainConfigDigester {