diff --git a/pkg/monitoring/chain_reader.go b/pkg/monitoring/chain_reader.go index 142ded9b3..760f4f88c 100644 --- a/pkg/monitoring/chain_reader.go +++ b/pkg/monitoring/chain_reader.go @@ -8,6 +8,7 @@ import ( pkgSolana "github.com/smartcontractkit/chainlink-solana/pkg/solana" ) +//go:generate mockery --name ChainReader --output ./mocks/ type ChainReader interface { GetState(ctx context.Context, account solana.PublicKey, commitment rpc.CommitmentType) (state pkgSolana.State, blockHeight uint64, err error) GetLatestTransmission(ctx context.Context, account solana.PublicKey, commitment rpc.CommitmentType) (answer pkgSolana.Answer, blockHeight uint64, err error) diff --git a/pkg/monitoring/exporter/prometheus_exporter_test.go b/pkg/monitoring/exporter/prometheus_exporter_test.go index 64f58209d..0d298d121 100644 --- a/pkg/monitoring/exporter/prometheus_exporter_test.go +++ b/pkg/monitoring/exporter/prometheus_exporter_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" commonMonitoring "github.com/smartcontractkit/chainlink-common/pkg/monitoring" - "github.com/smartcontractkit/chainlink-solana/pkg/monitoring/mocks" + "github.com/smartcontractkit/chainlink-solana/pkg/monitoring/metrics/mocks" "github.com/smartcontractkit/chainlink-solana/pkg/monitoring/testutils" "github.com/smartcontractkit/chainlink-solana/pkg/monitoring/types" ) diff --git a/pkg/monitoring/go_generate.go b/pkg/monitoring/go_generate.go deleted file mode 100644 index 51b787e09..000000000 --- a/pkg/monitoring/go_generate.go +++ /dev/null @@ -1,4 +0,0 @@ -package monitoring - -//go:generate mockery --name Metrics --output ./mocks/ -//go:generate mockery --name ChainReader --output ./mocks/ diff --git a/pkg/monitoring/metrics/metrics.go b/pkg/monitoring/metrics/metrics.go index 99a8d65b8..40f7e82be 100644 --- a/pkg/monitoring/metrics/metrics.go +++ b/pkg/monitoring/metrics/metrics.go @@ -41,6 +41,8 @@ func init() { } } +//go:generate mockery --name Metrics --output ./mocks/ + type Metrics interface { SetBalance(balance uint64, balanceAccountName, accountAddress, feedID, chainID, contractStatus, contractType, feedName, feedPath, networkID, networkName string) Cleanup(balanceAccountName, accountAddress, feedID, chainID, contractStatus, contractType, feedName, feedPath, networkID, networkName string) diff --git a/pkg/monitoring/mocks/Metrics.go b/pkg/monitoring/metrics/mocks/Metrics.go similarity index 80% rename from pkg/monitoring/mocks/Metrics.go rename to pkg/monitoring/metrics/mocks/Metrics.go index 3947c1db2..50d571eb4 100644 --- a/pkg/monitoring/mocks/Metrics.go +++ b/pkg/monitoring/metrics/mocks/Metrics.go @@ -1,12 +1,8 @@ -// Code generated by mockery v2.12.0. DO NOT EDIT. +// Code generated by mockery v2.20.0. DO NOT EDIT. package mocks -import ( - mock "github.com/stretchr/testify/mock" - - testing "testing" -) +import mock "github.com/stretchr/testify/mock" // Metrics is an autogenerated mock type for the Metrics type type Metrics struct { @@ -23,8 +19,13 @@ func (_m *Metrics) SetBalance(balance uint64, balanceAccountName string, account _m.Called(balance, balanceAccountName, accountAddress, feedID, chainID, contractStatus, contractType, feedName, feedPath, networkID, networkName) } -// NewMetrics creates a new instance of Metrics. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. -func NewMetrics(t testing.TB) *Metrics { +type mockConstructorTestingTNewMetrics interface { + mock.TestingT + Cleanup(func()) +} + +// NewMetrics creates a new instance of Metrics. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMetrics(t mockConstructorTestingTNewMetrics) *Metrics { mock := &Metrics{} mock.Mock.Test(t) diff --git a/pkg/monitoring/mocks/ChainReader.go b/pkg/monitoring/mocks/ChainReader.go index d1d9498d4..cec4d9d5f 100644 --- a/pkg/monitoring/mocks/ChainReader.go +++ b/pkg/monitoring/mocks/ChainReader.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.12.0. DO NOT EDIT. +// Code generated by mockery v2.20.0. DO NOT EDIT. package mocks @@ -12,8 +12,6 @@ import ( rpc "github.com/gagliardetto/solana-go/rpc" solana "github.com/gagliardetto/solana-go" - - testing "testing" ) // ChainReader is an autogenerated mock type for the ChainReader type @@ -26,6 +24,10 @@ func (_m *ChainReader) GetBalance(ctx context.Context, account solana.PublicKey, ret := _m.Called(ctx, account, commitment) var r0 *rpc.GetBalanceResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, solana.PublicKey, rpc.CommitmentType) (*rpc.GetBalanceResult, error)); ok { + return rf(ctx, account, commitment) + } if rf, ok := ret.Get(0).(func(context.Context, solana.PublicKey, rpc.CommitmentType) *rpc.GetBalanceResult); ok { r0 = rf(ctx, account, commitment) } else { @@ -34,7 +36,6 @@ func (_m *ChainReader) GetBalance(ctx context.Context, account solana.PublicKey, } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, solana.PublicKey, rpc.CommitmentType) error); ok { r1 = rf(ctx, account, commitment) } else { @@ -49,20 +50,23 @@ func (_m *ChainReader) GetLatestTransmission(ctx context.Context, account solana ret := _m.Called(ctx, account, commitment) var r0 pkgsolana.Answer + var r1 uint64 + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, solana.PublicKey, rpc.CommitmentType) (pkgsolana.Answer, uint64, error)); ok { + return rf(ctx, account, commitment) + } if rf, ok := ret.Get(0).(func(context.Context, solana.PublicKey, rpc.CommitmentType) pkgsolana.Answer); ok { r0 = rf(ctx, account, commitment) } else { r0 = ret.Get(0).(pkgsolana.Answer) } - var r1 uint64 if rf, ok := ret.Get(1).(func(context.Context, solana.PublicKey, rpc.CommitmentType) uint64); ok { r1 = rf(ctx, account, commitment) } else { r1 = ret.Get(1).(uint64) } - var r2 error if rf, ok := ret.Get(2).(func(context.Context, solana.PublicKey, rpc.CommitmentType) error); ok { r2 = rf(ctx, account, commitment) } else { @@ -77,6 +81,10 @@ func (_m *ChainReader) GetSignaturesForAddressWithOpts(ctx context.Context, acco ret := _m.Called(ctx, account, opts) var r0 []*rpc.TransactionSignature + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, solana.PublicKey, *rpc.GetSignaturesForAddressOpts) ([]*rpc.TransactionSignature, error)); ok { + return rf(ctx, account, opts) + } if rf, ok := ret.Get(0).(func(context.Context, solana.PublicKey, *rpc.GetSignaturesForAddressOpts) []*rpc.TransactionSignature); ok { r0 = rf(ctx, account, opts) } else { @@ -85,7 +93,6 @@ func (_m *ChainReader) GetSignaturesForAddressWithOpts(ctx context.Context, acco } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, solana.PublicKey, *rpc.GetSignaturesForAddressOpts) error); ok { r1 = rf(ctx, account, opts) } else { @@ -100,20 +107,23 @@ func (_m *ChainReader) GetState(ctx context.Context, account solana.PublicKey, c ret := _m.Called(ctx, account, commitment) var r0 pkgsolana.State + var r1 uint64 + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, solana.PublicKey, rpc.CommitmentType) (pkgsolana.State, uint64, error)); ok { + return rf(ctx, account, commitment) + } if rf, ok := ret.Get(0).(func(context.Context, solana.PublicKey, rpc.CommitmentType) pkgsolana.State); ok { r0 = rf(ctx, account, commitment) } else { r0 = ret.Get(0).(pkgsolana.State) } - var r1 uint64 if rf, ok := ret.Get(1).(func(context.Context, solana.PublicKey, rpc.CommitmentType) uint64); ok { r1 = rf(ctx, account, commitment) } else { r1 = ret.Get(1).(uint64) } - var r2 error if rf, ok := ret.Get(2).(func(context.Context, solana.PublicKey, rpc.CommitmentType) error); ok { r2 = rf(ctx, account, commitment) } else { @@ -128,6 +138,10 @@ func (_m *ChainReader) GetTokenAccountBalance(ctx context.Context, account solan ret := _m.Called(ctx, account, commitment) var r0 *rpc.GetTokenAccountBalanceResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, solana.PublicKey, rpc.CommitmentType) (*rpc.GetTokenAccountBalanceResult, error)); ok { + return rf(ctx, account, commitment) + } if rf, ok := ret.Get(0).(func(context.Context, solana.PublicKey, rpc.CommitmentType) *rpc.GetTokenAccountBalanceResult); ok { r0 = rf(ctx, account, commitment) } else { @@ -136,7 +150,6 @@ func (_m *ChainReader) GetTokenAccountBalance(ctx context.Context, account solan } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, solana.PublicKey, rpc.CommitmentType) error); ok { r1 = rf(ctx, account, commitment) } else { @@ -151,6 +164,10 @@ func (_m *ChainReader) GetTransaction(ctx context.Context, txSig solana.Signatur ret := _m.Called(ctx, txSig, opts) var r0 *rpc.GetTransactionResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, solana.Signature, *rpc.GetTransactionOpts) (*rpc.GetTransactionResult, error)); ok { + return rf(ctx, txSig, opts) + } if rf, ok := ret.Get(0).(func(context.Context, solana.Signature, *rpc.GetTransactionOpts) *rpc.GetTransactionResult); ok { r0 = rf(ctx, txSig, opts) } else { @@ -159,7 +176,6 @@ func (_m *ChainReader) GetTransaction(ctx context.Context, txSig solana.Signatur } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, solana.Signature, *rpc.GetTransactionOpts) error); ok { r1 = rf(ctx, txSig, opts) } else { @@ -169,8 +185,13 @@ func (_m *ChainReader) GetTransaction(ctx context.Context, txSig solana.Signatur return r0, r1 } -// NewChainReader creates a new instance of ChainReader. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations. -func NewChainReader(t testing.TB) *ChainReader { +type mockConstructorTestingTNewChainReader interface { + mock.TestingT + Cleanup(func()) +} + +// NewChainReader creates a new instance of ChainReader. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewChainReader(t mockConstructorTestingTNewChainReader) *ChainReader { mock := &ChainReader{} mock.Mock.Test(t)