From bd8dcfd3843add2f9b1c0dbeb1f3429c05e87fce Mon Sep 17 00:00:00 2001 From: Domino Valdano <2644901+reductionista@users.noreply.github.com> Date: Wed, 29 Mar 2023 13:06:35 -0700 Subject: [PATCH] Move evm/mocks/client.go to evm/client/mocks/client.go (#8868) --- core/chains/evm/chain_set_test.go | 6 +-- core/chains/evm/client/client.go | 4 +- core/chains/evm/{ => client}/mocks/client.go | 0 core/chains/evm/client/mocks/subscription.go | 46 +++++++++++++++++++ core/chains/evm/log/helpers_test.go | 4 +- core/chains/evm/log/integration_test.go | 6 +-- core/chains/evm/monitor/balance_test.go | 6 +-- core/cmd/remote_client_test.go | 6 +-- core/internal/cltest/cltest.go | 13 +++--- .../internal/cltest/contract_mock_receiver.go | 6 +-- core/internal/testutils/evmtest/evmtest.go | 14 +++--- core/services/blockhashstore/delegate_test.go | 2 +- .../keeper/registry1_1_synchronizer_test.go | 4 +- .../keeper/registry1_2_synchronizer_test.go | 4 +- .../keeper/registry1_3_synchronizer_test.go | 4 +- .../registry_synchronizer_helper_test.go | 4 +- core/services/keeper/upkeep_executer_test.go | 4 +- core/services/ocr/contract_tracker_test.go | 4 +- .../ocr2vrf/coordinator/coordinator_test.go | 12 ++--- core/services/pipeline/task.eth_call_test.go | 26 +++++------ .../pipeline/task.eth_get_block_test.go | 5 +- .../relay/evm/contract_transmitter_test.go | 4 +- .../relay/evm/request_round_tracker_test.go | 6 +-- core/services/vrf/delegate_test.go | 6 +-- core/web/resolver/resolver_test.go | 5 +- 25 files changed, 125 insertions(+), 76 deletions(-) rename core/chains/evm/{ => client}/mocks/client.go (100%) create mode 100644 core/chains/evm/client/mocks/subscription.go diff --git a/core/chains/evm/chain_set_test.go b/core/chains/evm/chain_set_test.go index b263051e875..ad441ed9518 100644 --- a/core/chains/evm/chain_set_test.go +++ b/core/chains/evm/chain_set_test.go @@ -9,8 +9,8 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm" evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" v2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/v2" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" @@ -53,8 +53,8 @@ func TestAddClose(t *testing.T) { chainSet.Close() - chains[0].Client().(*evmmocks.Client).AssertCalled(t, "Close") - chains[1].Client().(*evmmocks.Client).AssertCalled(t, "Close") + chains[0].Client().(*evmclimocks.Client).AssertCalled(t, "Close") + chains[1].Client().(*evmclimocks.Client).AssertCalled(t, "Close") assert.Error(t, chains[0].Ready()) assert.Error(t, chains[1].Ready()) diff --git a/core/chains/evm/client/client.go b/core/chains/evm/client/client.go index d31a81ac831..9ac5638854c 100644 --- a/core/chains/evm/client/client.go +++ b/core/chains/evm/client/client.go @@ -21,8 +21,8 @@ import ( const queryTimeout = 10 * time.Second -//go:generate mockery --quiet --name Client --output ../mocks/ --case=underscore -//go:generate mockery --quiet --name Subscription --output ../mocks/ --case=underscore +//go:generate mockery --quiet --name Client --output ./mocks/ --case=underscore +//go:generate mockery --quiet --name Subscription --output ./mocks/ --case=underscore // Client is the interface used to interact with an ethereum node. type Client interface { diff --git a/core/chains/evm/mocks/client.go b/core/chains/evm/client/mocks/client.go similarity index 100% rename from core/chains/evm/mocks/client.go rename to core/chains/evm/client/mocks/client.go diff --git a/core/chains/evm/client/mocks/subscription.go b/core/chains/evm/client/mocks/subscription.go new file mode 100644 index 00000000000..f430250ddeb --- /dev/null +++ b/core/chains/evm/client/mocks/subscription.go @@ -0,0 +1,46 @@ +// Code generated by mockery v2.22.1. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// Subscription is an autogenerated mock type for the Subscription type +type Subscription struct { + mock.Mock +} + +// Err provides a mock function with given fields: +func (_m *Subscription) Err() <-chan error { + ret := _m.Called() + + var r0 <-chan error + if rf, ok := ret.Get(0).(func() <-chan error); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(<-chan error) + } + } + + return r0 +} + +// Unsubscribe provides a mock function with given fields: +func (_m *Subscription) Unsubscribe() { + _m.Called() +} + +type mockConstructorTestingTNewSubscription interface { + mock.TestingT + Cleanup(func()) +} + +// NewSubscription creates a new instance of Subscription. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewSubscription(t mockConstructorTestingTNewSubscription) *Subscription { + mock := &Subscription{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/core/chains/evm/log/helpers_test.go b/core/chains/evm/log/helpers_test.go index 68c14b5aebc..7a515fc9369 100644 --- a/core/chains/evm/log/helpers_test.go +++ b/core/chains/evm/log/helpers_test.go @@ -21,10 +21,10 @@ import ( "github.com/smartcontractkit/sqlx" evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log" logmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log/mocks" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated" @@ -381,7 +381,7 @@ type mockEthClientExpectedCalls struct { } func newMockEthClient(t *testing.T, chchRawLogs chan<- evmtest.RawSub[types.Log], blockHeight int64, expectedCalls mockEthClientExpectedCalls) *evmtest.MockEth { - ethClient := evmmocks.NewClient(t) + ethClient := evmclimocks.NewClient(t) mockEth := &evmtest.MockEth{EthClient: ethClient} mockEth.EthClient.On("ChainID", mock.Anything).Return(&cltest.FixtureChainID) mockEth.EthClient.On("SubscribeFilterLogs", mock.Anything, mock.Anything, mock.Anything). diff --git a/core/chains/evm/log/integration_test.go b/core/chains/evm/log/integration_test.go index 83d70c62449..de36874dc3b 100644 --- a/core/chains/evm/log/integration_test.go +++ b/core/chains/evm/log/integration_test.go @@ -15,9 +15,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" httypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/flux_aggregator_wrapper" @@ -1135,7 +1135,7 @@ func TestBroadcaster_Register_ResubscribesToMostRecentlySeenBlock(t *testing.T) expectedBlock = 5 ) var ( - ethClient = evmmocks.NewClient(t) + ethClient = evmclimocks.NewClient(t) contract0 = newMockContract() contract1 = newMockContract() contract2 = newMockContract() @@ -1683,7 +1683,7 @@ func TestBroadcaster_BroadcastsWithZeroConfirmations(t *testing.T) { testutils.SkipShortDB(t) gm := gomega.NewWithT(t) - ethClient := evmmocks.NewClient(t) + ethClient := evmclimocks.NewClient(t) mockEth := &evmtest.MockEth{EthClient: ethClient} ethClient.On("ChainID").Return(big.NewInt(0)).Maybe() logsChCh := make(chan evmtest.RawSub[types.Log]) diff --git a/core/chains/evm/monitor/balance_test.go b/core/chains/evm/monitor/balance_test.go index b21a2ede76b..b3c8f29926c 100644 --- a/core/chains/evm/monitor/balance_test.go +++ b/core/chains/evm/monitor/balance_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/assets" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/monitor" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" @@ -25,8 +25,8 @@ import ( var nilBigInt *big.Int -func newEthClientMock(t *testing.T) *evmmocks.Client { - mockEth := evmmocks.NewClient(t) +func newEthClientMock(t *testing.T) *evmclimocks.Client { + mockEth := evmclimocks.NewClient(t) mockEth.On("ChainID").Maybe().Return(big.NewInt(0)) return mockEth } diff --git a/core/cmd/remote_client_test.go b/core/cmd/remote_client_test.go index 0de20f44b22..eeccb1d5bc8 100644 --- a/core/cmd/remote_client_test.go +++ b/core/cmd/remote_client_test.go @@ -20,7 +20,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/auth" "github.com/smartcontractkit/chainlink/v2/core/bridges" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/cmd" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" @@ -87,12 +87,12 @@ func withKey() func(opts *startOptions) { } } -func newEthMock(t *testing.T) *evmmocks.Client { +func newEthMock(t *testing.T) *evmclimocks.Client { t.Helper() return cltest.NewEthMocksWithStartupAssertions(t) } -func newEthMockWithTransactionsOnBlocksAssertions(t *testing.T) *evmmocks.Client { +func newEthMockWithTransactionsOnBlocksAssertions(t *testing.T) *evmclimocks.Client { t.Helper() return cltest.NewEthMocksWithTransactionsOnBlocksAssertions(t) diff --git a/core/internal/cltest/cltest.go b/core/internal/cltest/cltest.go index 34c0196ccb7..f4b2213f068 100644 --- a/core/internal/cltest/cltest.go +++ b/core/internal/cltest/cltest.go @@ -48,6 +48,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/cosmos" "github.com/smartcontractkit/chainlink/v2/core/chains/evm" evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" httypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/types" @@ -522,18 +523,18 @@ func NewApplicationWithConfig(t testing.TB, cfg chainlink.GeneralConfig, flagsAn return ta } -func NewEthMocksWithDefaultChain(t testing.TB) (c *evmMocks.Client) { +func NewEthMocksWithDefaultChain(t testing.TB) (c *evmclimocks.Client) { testutils.SkipShortDB(t) c = NewEthMocks(t) c.On("ChainID").Return(&FixtureChainID).Maybe() return } -func NewEthMocks(t testing.TB) *evmMocks.Client { - return evmMocks.NewClient(t) +func NewEthMocks(t testing.TB) *evmclimocks.Client { + return evmclimocks.NewClient(t) } -func NewEthMocksWithStartupAssertions(t testing.TB) *evmMocks.Client { +func NewEthMocksWithStartupAssertions(t testing.TB) *evmclimocks.Client { testutils.SkipShort(t, "long test") c := NewEthMocks(t) c.On("Dial", mock.Anything).Maybe().Return(nil) @@ -555,7 +556,7 @@ func NewEthMocksWithStartupAssertions(t testing.TB) *evmMocks.Client { } // NewEthMocksWithTransactionsOnBlocksAssertions sets an Eth mock with transactions on blocks -func NewEthMocksWithTransactionsOnBlocksAssertions(t testing.TB) *evmMocks.Client { +func NewEthMocksWithTransactionsOnBlocksAssertions(t testing.TB) *evmclimocks.Client { testutils.SkipShort(t, "long test") c := NewEthMocks(t) c.On("Dial", mock.Anything).Maybe().Return(nil) @@ -1309,7 +1310,7 @@ func MustBytesToConfigDigest(t *testing.T, b []byte) ocrtypes.ConfigDigest { // MockApplicationEthCalls mocks all calls made by the chainlink application as // standard when starting and stopping -func MockApplicationEthCalls(t *testing.T, app *TestApplication, ethClient *evmMocks.Client, sub *evmMocks.Subscription) { +func MockApplicationEthCalls(t *testing.T, app *TestApplication, ethClient *evmclimocks.Client, sub *evmMocks.Subscription) { t.Helper() // Start diff --git a/core/internal/cltest/contract_mock_receiver.go b/core/internal/cltest/contract_mock_receiver.go index af32252d331..2a0fc5a50f5 100644 --- a/core/internal/cltest/contract_mock_receiver.go +++ b/core/internal/cltest/contract_mock_receiver.go @@ -12,14 +12,14 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" ) // funcSigLength is the length of the function signature (including the 0x) // ex: 0x1234ABCD const funcSigLength = 10 -func NewContractMockReceiver(t *testing.T, ethMock *evmmocks.Client, abi abi.ABI, address common.Address) contractMockReceiver { +func NewContractMockReceiver(t *testing.T, ethMock *evmclimocks.Client, abi abi.ABI, address common.Address) contractMockReceiver { return contractMockReceiver{ t: t, ethMock: ethMock, @@ -30,7 +30,7 @@ func NewContractMockReceiver(t *testing.T, ethMock *evmmocks.Client, abi abi.ABI type contractMockReceiver struct { t *testing.T - ethMock *evmmocks.Client + ethMock *evmclimocks.Client abi abi.ABI address common.Address } diff --git a/core/internal/testutils/evmtest/evmtest.go b/core/internal/testutils/evmtest/evmtest.go index f088006d95e..fb06735499c 100644 --- a/core/internal/testutils/evmtest/evmtest.go +++ b/core/internal/testutils/evmtest/evmtest.go @@ -16,13 +16,13 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains" "github.com/smartcontractkit/chainlink/v2/core/chains/evm" evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" v2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/v2" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" httypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" - evmMocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" @@ -231,22 +231,22 @@ func (mo *MockORM) NodesForChain(chainID utils.Big, offset int, limit int) ([]ev panic("not implemented") } -func NewEthClientMock(t *testing.T) *evmMocks.Client { - return evmMocks.NewClient(t) +func NewEthClientMock(t *testing.T) *evmclimocks.Client { + return evmclimocks.NewClient(t) } -func NewEthClientMockWithDefaultChain(t *testing.T) *evmMocks.Client { +func NewEthClientMockWithDefaultChain(t *testing.T) *evmclimocks.Client { c := NewEthClientMock(t) c.On("ChainID").Return(testutils.FixtureChainID).Maybe() return c } type MockEth struct { - EthClient *evmMocks.Client + EthClient *evmclimocks.Client CheckFilterLogs func(int64, int64) subsMu sync.RWMutex - subs []*evmMocks.Subscription + subs []*evmmocks.Subscription errChs []chan error subscribeCalls atomic.Int32 unsubscribeCalls atomic.Int32 @@ -262,7 +262,7 @@ func (m *MockEth) UnsubscribeCallCount() int32 { func (m *MockEth) NewSub(t *testing.T) ethereum.Subscription { m.subscribeCalls.Add(1) - sub := evmMocks.NewSubscription(t) + sub := evmmocks.NewSubscription(t) errCh := make(chan error) sub.On("Err"). Return(func() <-chan error { return errCh }).Maybe() diff --git a/core/services/blockhashstore/delegate_test.go b/core/services/blockhashstore/delegate_test.go index 20c7a996b08..6ccb3e1d98c 100644 --- a/core/services/blockhashstore/delegate_test.go +++ b/core/services/blockhashstore/delegate_test.go @@ -11,7 +11,7 @@ import ( "go.uber.org/zap/zaptest/observer" "github.com/smartcontractkit/chainlink/v2/core/chains/evm" - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" diff --git a/core/services/keeper/registry1_1_synchronizer_test.go b/core/services/keeper/registry1_1_synchronizer_test.go index d3a250336cc..8929505954a 100644 --- a/core/services/keeper/registry1_1_synchronizer_test.go +++ b/core/services/keeper/registry1_1_synchronizer_test.go @@ -12,8 +12,8 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" logmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log/mocks" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" registry1_1 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_1" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" @@ -47,7 +47,7 @@ var upkeepConfig1_1 = registry1_1.GetUpkeep{ func mockRegistry1_1( t *testing.T, - ethMock *evmmocks.Client, + ethMock *evmclimocks.Client, contractAddress common.Address, config registry1_1.GetConfig, keeperList []common.Address, diff --git a/core/services/keeper/registry1_2_synchronizer_test.go b/core/services/keeper/registry1_2_synchronizer_test.go index 68625efc95b..0ef6da13b12 100644 --- a/core/services/keeper/registry1_2_synchronizer_test.go +++ b/core/services/keeper/registry1_2_synchronizer_test.go @@ -12,8 +12,8 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" logmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log/mocks" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" registry1_2 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_2" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" @@ -60,7 +60,7 @@ var upkeepConfig1_2 = registry1_2.GetUpkeep{ func mockRegistry1_2( t *testing.T, - ethMock *evmmocks.Client, + ethMock *evmclimocks.Client, contractAddress common.Address, config registry1_2.Config, activeUpkeepIDs []*big.Int, diff --git a/core/services/keeper/registry1_3_synchronizer_test.go b/core/services/keeper/registry1_3_synchronizer_test.go index 5fc44c0c761..35425c4c69b 100644 --- a/core/services/keeper/registry1_3_synchronizer_test.go +++ b/core/services/keeper/registry1_3_synchronizer_test.go @@ -12,12 +12,12 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" registry1_3 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_3" configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" "github.com/smartcontractkit/chainlink/v2/core/utils" logmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log/mocks" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" @@ -62,7 +62,7 @@ var upkeepConfig1_3 = registry1_3.GetUpkeep{ func mockRegistry1_3( t *testing.T, - ethMock *evmmocks.Client, + ethMock *evmclimocks.Client, contractAddress common.Address, config registry1_3.Config, activeUpkeepIDs []*big.Int, diff --git a/core/services/keeper/registry_synchronizer_helper_test.go b/core/services/keeper/registry_synchronizer_helper_test.go index 026868be2e3..d1996cf5c53 100644 --- a/core/services/keeper/registry_synchronizer_helper_test.go +++ b/core/services/keeper/registry_synchronizer_helper_test.go @@ -9,9 +9,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log" logmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log/mocks" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" configtest "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest/v2" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" @@ -29,7 +29,7 @@ const syncUpkeepQueueSize = 10 func setupRegistrySync(t *testing.T, version keeper.RegistryVersion) ( *sqlx.DB, *keeper.RegistrySynchronizer, - *evmmocks.Client, + *evmclimocks.Client, *logmocks.Broadcaster, job.Job, ) { diff --git a/core/services/keeper/upkeep_executer_test.go b/core/services/keeper/upkeep_executer_test.go index bb0f3e48e1f..3c326c9aa7a 100644 --- a/core/services/keeper/upkeep_executer_test.go +++ b/core/services/keeper/upkeep_executer_test.go @@ -17,8 +17,8 @@ import ( txmgrmocks "github.com/smartcontractkit/chainlink/v2/common/txmgr/types/mocks" "github.com/smartcontractkit/chainlink/v2/core/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" txmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" @@ -53,7 +53,7 @@ func mockEstimator(t *testing.T) (estimator *txmgrmocks.FeeEstimator[*evmtypes.H func setup(t *testing.T, estimator *txmgrmocks.FeeEstimator[*evmtypes.Head, gas.EvmFee, *assets.Wei, common.Hash], overrideFn func(c *chainlink.Config, s *chainlink.Secrets)) ( *sqlx.DB, chainlink.GeneralConfig, - *evmmocks.Client, + *evmclimocks.Client, *keeper.UpkeepExecuter, keeper.Registry, keeper.UpkeepRegistration, diff --git a/core/services/ocr/contract_tracker_test.go b/core/services/ocr/contract_tracker_test.go index fe24ac7dc6f..58de41f279c 100644 --- a/core/services/ocr/contract_tracker_test.go +++ b/core/services/ocr/contract_tracker_test.go @@ -14,10 +14,10 @@ import ( "github.com/smartcontractkit/libocr/gethwrappers/offchainaggregator" ocrtypes "github.com/smartcontractkit/libocr/offchainreporting/types" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" htmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/mocks" logmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log/mocks" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/offchain_aggregator_wrapper" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" @@ -49,7 +49,7 @@ type contractTrackerUni struct { db *ocrmocks.OCRContractTrackerDB lb *logmocks.Broadcaster hb *htmocks.HeadBroadcaster - ec *evmmocks.Client + ec *evmclimocks.Client tracker *ocr.OCRContractTracker } diff --git a/core/services/ocr2/plugins/ocr2vrf/coordinator/coordinator_test.go b/core/services/ocr2/plugins/ocr2vrf/coordinator/coordinator_test.go index 1d89ef9cb40..3b3203b63ab 100644 --- a/core/services/ocr2/plugins/ocr2vrf/coordinator/coordinator_test.go +++ b/core/services/ocr2/plugins/ocr2vrf/coordinator/coordinator_test.go @@ -23,9 +23,9 @@ import ( "github.com/smartcontractkit/ocr2vrf/ocr2vrf" ocr2vrftypes "github.com/smartcontractkit/ocr2vrf/types" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" lp_mocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" - evm_mocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" dkg_wrapper "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ocr2vrf/generated/dkg" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ocr2vrf/generated/vrf_beacon" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ocr2vrf/generated/vrf_coordinator" @@ -67,7 +67,7 @@ func TestCoordinator_BeaconPeriod(t *testing.T) { func TestCoordinator_DKGVRFCommittees(t *testing.T) { t.Parallel() - evmClient := evm_mocks.NewClient(t) + evmClient := evmclimocks.NewClient(t) evmClient.On("ChainID").Return(big.NewInt(1)) t.Run("happy path", func(t *testing.T) { @@ -209,7 +209,7 @@ func TestCoordinator_ReportBlocks(t *testing.T) { lggr := logger.TestLogger(t) proofG1X := big.NewInt(1) proofG1Y := big.NewInt(2) - evmClient := evm_mocks.NewClient(t) + evmClient := evmclimocks.NewClient(t) evmClient.On("ChainID").Return(big.NewInt(1)) t.Run("happy path, beacon requests", func(t *testing.T) { beaconAddress := newAddress(t) @@ -1074,7 +1074,7 @@ func TestCoordinator_ReportBlocks(t *testing.T) { } func TestCoordinator_ReportWillBeTransmitted(t *testing.T) { - evmClient := evm_mocks.NewClient(t) + evmClient := evmclimocks.NewClient(t) evmClient.On("ChainID").Return(big.NewInt(1)) t.Run("happy path", func(t *testing.T) { lookbackBlocks := uint64(0) @@ -1116,7 +1116,7 @@ func TestCoordinator_MarshalUnmarshal(t *testing.T) { proofG1X := big.NewInt(1) proofG1Y := big.NewInt(2) lggr := logger.TestLogger(t) - evmClient := evm_mocks.NewClient(t) + evmClient := evmclimocks.NewClient(t) coordinatorAddress := newAddress(t) beaconAddress := newAddress(t) @@ -1184,7 +1184,7 @@ func TestCoordinator_MarshalUnmarshal(t *testing.T) { } func TestCoordinator_ReportIsOnchain(t *testing.T) { - evmClient := evm_mocks.NewClient(t) + evmClient := evmclimocks.NewClient(t) evmClient.On("ChainID").Return(big.NewInt(1)) t.Run("report is on-chain", func(t *testing.T) { diff --git a/core/services/pipeline/task.eth_call_test.go b/core/services/pipeline/task.eth_call_test.go index e495aa1fc15..1745b0d4497 100644 --- a/core/services/pipeline/task.eth_call_test.go +++ b/core/services/pipeline/task.eth_call_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/chains/evm" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" txmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" @@ -44,7 +44,7 @@ func TestETHCallTask(t *testing.T) { specGasLimit *uint32 vars pipeline.Vars inputs []pipeline.Result - setupClientMocks func(ethClient *evmmocks.Client, config *pipelinemocks.Config) + setupClientMocks func(ethClient *evmclimocks.Client, config *pipelinemocks.Config) expected interface{} expectedErrorCause error expectedErrorContains string @@ -61,7 +61,7 @@ func TestETHCallTask(t *testing.T) { "foo": []byte("foo bar"), }), nil, - func(ethClient *evmmocks.Client, config *pipelinemocks.Config) { + func(ethClient *evmclimocks.Client, config *pipelinemocks.Config) { contractAddr := common.HexToAddress("0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF") ethClient. On("CallContract", mock.Anything, ethereum.CallMsg{To: &contractAddr, Gas: uint64(drJobTypeGasLimit), Data: []byte("foo bar")}, (*big.Int)(nil)). @@ -82,7 +82,7 @@ func TestETHCallTask(t *testing.T) { "gasLimit": 100_000, }), nil, - func(ethClient *evmmocks.Client, config *pipelinemocks.Config) { + func(ethClient *evmclimocks.Client, config *pipelinemocks.Config) { contractAddr := common.HexToAddress("0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF") ethClient. On("CallContract", mock.Anything, ethereum.CallMsg{To: &contractAddr, Gas: 100_000, Data: []byte("foo bar")}, (*big.Int)(nil)). @@ -102,7 +102,7 @@ func TestETHCallTask(t *testing.T) { "foo": []byte("foo bar"), }), nil, - func(ethClient *evmmocks.Client, config *pipelinemocks.Config) { + func(ethClient *evmclimocks.Client, config *pipelinemocks.Config) { contractAddr := common.HexToAddress("0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF") ethClient. On("CallContract", mock.Anything, ethereum.CallMsg{To: &contractAddr, Gas: uint64(specGasLimit), Data: []byte("foo bar")}, (*big.Int)(nil)). @@ -122,7 +122,7 @@ func TestETHCallTask(t *testing.T) { "foo": []byte("foo bar"), }), nil, - func(ethClient *evmmocks.Client, config *pipelinemocks.Config) { + func(ethClient *evmclimocks.Client, config *pipelinemocks.Config) { contractAddr := common.HexToAddress("0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF") fromAddr := common.HexToAddress("0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF") ethClient. @@ -143,7 +143,7 @@ func TestETHCallTask(t *testing.T) { "foo": []byte("foo bar"), }), nil, - func(ethClient *evmmocks.Client, config *pipelinemocks.Config) {}, + func(ethClient *evmclimocks.Client, config *pipelinemocks.Config) {}, nil, pipeline.ErrBadInput, "from", }, { @@ -158,7 +158,7 @@ func TestETHCallTask(t *testing.T) { "foo": []byte("foo bar"), }), nil, - func(ethClient *evmmocks.Client, config *pipelinemocks.Config) {}, + func(ethClient *evmclimocks.Client, config *pipelinemocks.Config) {}, nil, pipeline.ErrBadInput, "contract", }, { @@ -173,7 +173,7 @@ func TestETHCallTask(t *testing.T) { "zork": []byte("foo bar"), }), nil, - func(ethClient *evmmocks.Client, config *pipelinemocks.Config) {}, + func(ethClient *evmclimocks.Client, config *pipelinemocks.Config) {}, nil, pipeline.ErrKeypathNotFound, "data", }, { @@ -188,7 +188,7 @@ func TestETHCallTask(t *testing.T) { "foo": []byte(nil), }), nil, - func(ethClient *evmmocks.Client, config *pipelinemocks.Config) {}, + func(ethClient *evmclimocks.Client, config *pipelinemocks.Config) {}, nil, pipeline.ErrBadInput, "data", }, { @@ -203,7 +203,7 @@ func TestETHCallTask(t *testing.T) { "foo": []byte("foo bar"), }), []pipeline.Result{{Error: errors.New("uh oh")}}, - func(ethClient *evmmocks.Client, config *pipelinemocks.Config) {}, + func(ethClient *evmclimocks.Client, config *pipelinemocks.Config) {}, nil, pipeline.ErrTooManyErrors, "task inputs", }, { @@ -219,7 +219,7 @@ func TestETHCallTask(t *testing.T) { "evmChainID": "123", }), nil, - func(ethClient *evmmocks.Client, config *pipelinemocks.Config) { + func(ethClient *evmclimocks.Client, config *pipelinemocks.Config) { contractAddr := common.HexToAddress("0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF") ethClient. On("CallContract", mock.Anything, ethereum.CallMsg{To: &contractAddr, Data: []byte("foo bar")}, (*big.Int)(nil)). @@ -241,7 +241,7 @@ func TestETHCallTask(t *testing.T) { Gas: test.gas, } - ethClient := evmmocks.NewClient(t) + ethClient := evmclimocks.NewClient(t) config := pipelinemocks.NewConfig(t) test.setupClientMocks(ethClient, config) diff --git a/core/services/pipeline/task.eth_get_block_test.go b/core/services/pipeline/task.eth_get_block_test.go index 0a40f21c9b5..601d0a52f52 100644 --- a/core/services/pipeline/task.eth_get_block_test.go +++ b/core/services/pipeline/task.eth_get_block_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/assets" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" htmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/mocks" evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" @@ -72,7 +73,7 @@ func Test_ETHGetBlockTask(t *testing.T) { }) t.Run("if headtracker returns nil head and eth call succeeds", func(t *testing.T) { - ethClient := evmmocks.NewClient(t) + ethClient := evmclimocks.NewClient(t) headTracker := htmocks.NewHeadTracker(t) chain := evmmocks.NewChain(t) chain.On("Client").Return(ethClient) @@ -108,7 +109,7 @@ func Test_ETHGetBlockTask(t *testing.T) { }) t.Run("if headtracker returns nil head and eth call fails", func(t *testing.T) { - ethClient := evmmocks.NewClient(t) + ethClient := evmclimocks.NewClient(t) headTracker := htmocks.NewHeadTracker(t) chain := evmmocks.NewChain(t) chain.On("Client").Return(ethClient) diff --git a/core/services/relay/evm/contract_transmitter_test.go b/core/services/relay/evm/contract_transmitter_test.go index 1b4c12dddb8..78713cacaa6 100644 --- a/core/services/relay/evm/contract_transmitter_test.go +++ b/core/services/relay/evm/contract_transmitter_test.go @@ -14,9 +14,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" lpmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" @@ -35,7 +35,7 @@ func TestContractTransmitter(t *testing.T) { t.Parallel() lggr := logger.TestLogger(t) - c := evmmocks.NewClient(t) + c := evmclimocks.NewClient(t) lp := lpmocks.NewLogPoller(t) // scanLogs = false digestAndEpochDontScanLogs, _ := hex.DecodeString( diff --git a/core/services/relay/evm/request_round_tracker_test.go b/core/services/relay/evm/request_round_tracker_test.go index 1a68c0a3013..d03d3ec6671 100644 --- a/core/services/relay/evm/request_round_tracker_test.go +++ b/core/services/relay/evm/request_round_tracker_test.go @@ -12,10 +12,10 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" htmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/mocks" logmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log/mocks" - evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" offchain_aggregator_wrapper "github.com/smartcontractkit/chainlink/v2/core/internal/gethwrappers2/generated/offchainaggregator" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" @@ -44,7 +44,7 @@ type contractTrackerUni struct { db *mocks.RequestRoundDB lb *logmocks.Broadcaster hb *htmocks.HeadBroadcaster - ec *evmmocks.Client + ec *evmclimocks.Client requestRoundTracker *evm.RequestRoundTracker } @@ -76,7 +76,7 @@ func newContractTrackerUni(t *testing.T, opts ...interface{}) (uni contractTrack uni.db = mocks.NewRequestRoundDB(t) uni.lb = logmocks.NewBroadcaster(t) uni.hb = htmocks.NewHeadBroadcaster(t) - uni.ec = evmmocks.NewClient(t) + uni.ec = evmclimocks.NewClient(t) db := pgtest.NewSqlxDB(t) lggr := logger.TestLogger(t) diff --git a/core/services/vrf/delegate_test.go b/core/services/vrf/delegate_test.go index 8a5b6d3f0f3..1a2b8ef3e4e 100644 --- a/core/services/vrf/delegate_test.go +++ b/core/services/vrf/delegate_test.go @@ -11,11 +11,11 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/assets" "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/chains/evm" + evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker" httypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log" log_mocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log/mocks" - eth_mocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" txmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" @@ -50,7 +50,7 @@ type vrfUniverse struct { pr pipeline.Runner prm pipeline.ORM lb *log_mocks.Broadcaster - ec *eth_mocks.Client + ec *evmclimocks.Client ks keystore.Master vrfkey vrfkey.KeyV2 submitter common.Address @@ -64,7 +64,7 @@ func buildVrfUni(t *testing.T, db *sqlx.DB, cfg chainlink.GeneralConfig) vrfUniv // Mock all chain interactions lb := log_mocks.NewBroadcaster(t) lb.On("AddDependents", 1).Maybe() - ec := eth_mocks.NewClient(t) + ec := evmclimocks.NewClient(t) ec.On("ChainID").Return(testutils.FixtureChainID) lggr := logger.TestLogger(t) hb := headtracker.NewHeadBroadcaster(lggr) diff --git a/core/web/resolver/resolver_test.go b/core/web/resolver/resolver_test.go index f840eb61202..9ead6cc6cff 100644 --- a/core/web/resolver/resolver_test.go +++ b/core/web/resolver/resolver_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/mock" bridgeORMMocks "github.com/smartcontractkit/chainlink/v2/core/bridges/mocks" + evmClientMocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" evmConfigMocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/mocks" evmORMMocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks" txmgrMocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr/mocks" @@ -50,7 +51,7 @@ type mocks struct { solana *keystoreMocks.Solana chain *evmORMMocks.Chain chainSet *evmORMMocks.ChainSet - ethClient *evmORMMocks.Client + ethClient *evmClientMocks.Client eIMgr *webhookmocks.ExternalInitiatorManager balM *evmORMMocks.BalanceMonitor txmORM *txmgrMocks.ORM @@ -108,7 +109,7 @@ func setupFramework(t *testing.T) *gqlTestFramework { solana: keystoreMocks.NewSolana(t), chain: evmORMMocks.NewChain(t), chainSet: evmORMMocks.NewChainSet(t), - ethClient: evmORMMocks.NewClient(t), + ethClient: evmClientMocks.NewClient(t), eIMgr: webhookmocks.NewExternalInitiatorManager(t), balM: evmORMMocks.NewBalanceMonitor(t), txmORM: txmgrMocks.NewORM(t),