diff --git a/.github/workflows/relayer.yml b/.github/workflows/relayer.yml index b2afbd4d8..8a1b6b6cd 100644 --- a/.github/workflows/relayer.yml +++ b/.github/workflows/relayer.yml @@ -57,3 +57,21 @@ jobs: ./relayer/coverage.txt ./relayer/race_coverage.txt + check-tidy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - name: Set up Go + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + with: + go-version-file: "relayer/go.mod" + - name: Ensure "make gomodtidy" has been run + run: | + make gomodtidy + git diff --exit-code + - name: Ensure "make generate" has been run + run: | + make rm-mocked + make generate + git diff --exit-code diff --git a/Makefile b/Makefile index 8f5c73532..7cdd24af0 100644 --- a/Makefile +++ b/Makefile @@ -130,12 +130,25 @@ format-go-fmt: cd ./ops && go fmt ./... cd ./integration-tests && go fmt ./... +.PHONY: gomods +gomods: ## Install gomods + go install github.com/jmank88/gomods@v0.1.3 + .PHONY: gomodtidy -gomodtidy: - cd ./relayer && go mod tidy - cd ./monitoring && go mod tidy - cd ./ops && go mod tidy - cd ./integration-tests && go mod tidy +gomodtidy: gomods + gomods tidy + +.PHONY: mockery +mockery: $(mockery) ## Install mockery. + go install github.com/vektra/mockery/v2@v2.43.2 + +.PHONY: rm-mocked +rm-mocked: + grep -rl "^// Code generated by mockery" | grep .go$ | xargs -r rm + +.PHONY: generate +generate: mockery gomods + gomods -w go generate -x ./... .PHONY: format-cairo format-cairo: diff --git a/monitoring/pkg/monitoring/mocks/Metrics.go b/monitoring/pkg/monitoring/mocks/Metrics.go index 9606ea96e..fa9e1bbd0 100644 --- a/monitoring/pkg/monitoring/mocks/Metrics.go +++ b/monitoring/pkg/monitoring/mocks/Metrics.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.22.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -54,13 +54,12 @@ func (_m *Metrics) SetTransmissionGasPrice(answer float64, contractAddress strin _m.Called(answer, contractAddress, feedID, chainID, contractStatus, contractType, feedName, feedPath, networkID, networkName) } -type mockConstructorTestingTNewMetrics interface { +// 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. +// The first argument is typically a *testing.T value. +func NewMetrics(t 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 { +}) *Metrics { mock := &Metrics{} mock.Mock.Test(t) diff --git a/relayer/pkg/chainlink/erc20/mocks/ERC20Reader.go b/relayer/pkg/chainlink/erc20/mocks/ERC20Reader.go index 1559fbb4b..80a7c75ab 100644 --- a/relayer/pkg/chainlink/erc20/mocks/ERC20Reader.go +++ b/relayer/pkg/chainlink/erc20/mocks/ERC20Reader.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.0. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks diff --git a/relayer/pkg/chainlink/ocr2/mocks/OCR2Reader.go b/relayer/pkg/chainlink/ocr2/mocks/OCR2Reader.go index 859d0e5fc..d16b02f58 100644 --- a/relayer/pkg/chainlink/ocr2/mocks/OCR2Reader.go +++ b/relayer/pkg/chainlink/ocr2/mocks/OCR2Reader.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.0. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks diff --git a/relayer/pkg/chainlink/txm/mocks/config.go b/relayer/pkg/chainlink/txm/mocks/config.go index 2b4e616f0..d66b14251 100644 --- a/relayer/pkg/chainlink/txm/mocks/config.go +++ b/relayer/pkg/chainlink/txm/mocks/config.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.29.0. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -17,6 +17,10 @@ type Config struct { func (_m *Config) ConfirmationPoll() time.Duration { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for ConfirmationPoll") + } + var r0 time.Duration if rf, ok := ret.Get(0).(func() time.Duration); ok { r0 = rf() @@ -31,6 +35,10 @@ func (_m *Config) ConfirmationPoll() time.Duration { func (_m *Config) TxTimeout() time.Duration { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for TxTimeout") + } + var r0 time.Duration if rf, ok := ret.Get(0).(func() time.Duration); ok { r0 = rf() @@ -41,13 +49,12 @@ func (_m *Config) TxTimeout() time.Duration { return r0 } -type mockConstructorTestingTNewConfig interface { +// NewConfig creates a new instance of Config. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewConfig(t interface { mock.TestingT Cleanup(func()) -} - -// NewConfig creates a new instance of Config. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewConfig(t mockConstructorTestingTNewConfig) *Config { +}) *Config { mock := &Config{} mock.Mock.Test(t) diff --git a/relayer/pkg/starknet/mocks/Reader.go b/relayer/pkg/starknet/mocks/Reader.go index cb88175c1..4d43319bf 100644 --- a/relayer/pkg/starknet/mocks/Reader.go +++ b/relayer/pkg/starknet/mocks/Reader.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.29.0. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -22,6 +22,10 @@ type Reader struct { func (_m *Reader) AccountNonce(_a0 context.Context, _a1 *felt.Felt) (*felt.Felt, error) { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for AccountNonce") + } + var r0 *felt.Felt var r1 error if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (*felt.Felt, error)); ok { @@ -48,6 +52,10 @@ func (_m *Reader) AccountNonce(_a0 context.Context, _a1 *felt.Felt) (*felt.Felt, func (_m *Reader) BlockWithTxHashes(ctx context.Context, blockID rpc.BlockID) (*rpc.Block, error) { ret := _m.Called(ctx, blockID) + if len(ret) == 0 { + panic("no return value specified for BlockWithTxHashes") + } + var r0 *rpc.Block var r1 error if rf, ok := ret.Get(0).(func(context.Context, rpc.BlockID) (*rpc.Block, error)); ok { @@ -74,6 +82,10 @@ func (_m *Reader) BlockWithTxHashes(ctx context.Context, blockID rpc.BlockID) (* func (_m *Reader) Call(_a0 context.Context, _a1 rpc.FunctionCall, _a2 rpc.BlockID) ([]*felt.Felt, error) { ret := _m.Called(_a0, _a1, _a2) + if len(ret) == 0 { + panic("no return value specified for Call") + } + var r0 []*felt.Felt var r1 error if rf, ok := ret.Get(0).(func(context.Context, rpc.FunctionCall, rpc.BlockID) ([]*felt.Felt, error)); ok { @@ -100,6 +112,10 @@ func (_m *Reader) Call(_a0 context.Context, _a1 rpc.FunctionCall, _a2 rpc.BlockI func (_m *Reader) CallContract(_a0 context.Context, _a1 starknet.CallOps) ([]*felt.Felt, error) { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for CallContract") + } + var r0 []*felt.Felt var r1 error if rf, ok := ret.Get(0).(func(context.Context, starknet.CallOps) ([]*felt.Felt, error)); ok { @@ -126,6 +142,10 @@ func (_m *Reader) CallContract(_a0 context.Context, _a1 starknet.CallOps) ([]*fe func (_m *Reader) Events(ctx context.Context, input rpc.EventsInput) (*rpc.EventChunk, error) { ret := _m.Called(ctx, input) + if len(ret) == 0 { + panic("no return value specified for Events") + } + var r0 *rpc.EventChunk var r1 error if rf, ok := ret.Get(0).(func(context.Context, rpc.EventsInput) (*rpc.EventChunk, error)); ok { @@ -152,6 +172,10 @@ func (_m *Reader) Events(ctx context.Context, input rpc.EventsInput) (*rpc.Event func (_m *Reader) LatestBlockHeight(_a0 context.Context) (uint64, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for LatestBlockHeight") + } + var r0 uint64 var r1 error if rf, ok := ret.Get(0).(func(context.Context) (uint64, error)); ok { @@ -176,6 +200,10 @@ func (_m *Reader) LatestBlockHeight(_a0 context.Context) (uint64, error) { func (_m *Reader) TransactionByHash(_a0 context.Context, _a1 *felt.Felt) (rpc.Transaction, error) { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for TransactionByHash") + } + var r0 rpc.Transaction var r1 error if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (rpc.Transaction, error)); ok { @@ -202,6 +230,10 @@ func (_m *Reader) TransactionByHash(_a0 context.Context, _a1 *felt.Felt) (rpc.Tr func (_m *Reader) TransactionReceipt(_a0 context.Context, _a1 *felt.Felt) (rpc.TransactionReceipt, error) { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for TransactionReceipt") + } + var r0 rpc.TransactionReceipt var r1 error if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (rpc.TransactionReceipt, error)); ok { @@ -224,13 +256,12 @@ func (_m *Reader) TransactionReceipt(_a0 context.Context, _a1 *felt.Felt) (rpc.T return r0, r1 } -type mockConstructorTestingTNewReader interface { +// NewReader creates a new instance of Reader. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewReader(t interface { mock.TestingT Cleanup(func()) -} - -// NewReader creates a new instance of Reader. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewReader(t mockConstructorTestingTNewReader) *Reader { +}) *Reader { mock := &Reader{} mock.Mock.Test(t)