From c10e1cc3d4a213a08b61ed26c3dfd8f1f4fb8ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zdyba=C5=82?= Date: Tue, 5 Nov 2024 23:00:38 +0100 Subject: [PATCH 1/3] refactor: rename Execute interface to Executor --- execution.go | 4 ++-- proxy/grpc/server.go | 4 ++-- proxy/jsonrpc/server.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/execution.go b/execution.go index 0cc3d6c..88574eb 100644 --- a/execution.go +++ b/execution.go @@ -6,8 +6,8 @@ import ( "github.com/rollkit/go-execution/types" ) -// Execute defines a common interface for interacting with the execution client. -type Execute interface { +// Executor defines a common interface for interacting with the execution client. +type Executor interface { // InitChain initializes the blockchain with genesis information. InitChain( genesisTime time.Time, diff --git a/proxy/grpc/server.go b/proxy/grpc/server.go index 9c5fa42..e285179 100644 --- a/proxy/grpc/server.go +++ b/proxy/grpc/server.go @@ -12,12 +12,12 @@ import ( // Server defines a gRPC proxy server type Server struct { pb.UnimplementedExecutionServiceServer - exec execution.Execute + exec execution.Executor config *Config } // NewServer creates a new ExecutionService gRPC server with the given execution client and configuration. -func NewServer(exec execution.Execute, config *Config) pb.ExecutionServiceServer { +func NewServer(exec execution.Executor, config *Config) pb.ExecutionServiceServer { if config == nil { config = DefaultConfig() } diff --git a/proxy/jsonrpc/server.go b/proxy/jsonrpc/server.go index a7e44aa..a5d94ad 100644 --- a/proxy/jsonrpc/server.go +++ b/proxy/jsonrpc/server.go @@ -12,12 +12,12 @@ import ( // Server defines JSON-RPC proxy server for execution API. type Server struct { - exec execution.Execute + exec execution.Executor config *Config } // NewServer initializes and returns a new Server instance with the given execution interface and configuration. -func NewServer(exec execution.Execute, config *Config) *Server { +func NewServer(exec execution.Executor, config *Config) *Server { if config == nil { config = DefaultConfig() } From 6e21956dfb3e176c56716335bb9213de3d846457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zdyba=C5=82?= Date: Tue, 5 Nov 2024 23:02:59 +0100 Subject: [PATCH 2/3] test: rename types to ExecutorSuite and DummyExecutor --- proxy/grpc/proxy_test.go | 4 ++-- proxy/jsonrpc/proxy_test.go | 4 ++-- test/dummy.go | 20 ++++++++++---------- test/dummy_test.go | 4 ++-- test/suite.go | 14 +++++++------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/proxy/grpc/proxy_test.go b/proxy/grpc/proxy_test.go index c74fda1..a88b871 100644 --- a/proxy/grpc/proxy_test.go +++ b/proxy/grpc/proxy_test.go @@ -26,14 +26,14 @@ func dialer(listener *bufconn.Listener) func(context.Context, string) (net.Conn, } type ProxyTestSuite struct { - test.ExecuteSuite + test.ExecutorSuite server *grpc.Server client *grpcproxy.Client cleanup func() } func (s *ProxyTestSuite) SetupTest() { - exec := test.NewExecute() + exec := test.NewDummyExecutor() config := &grpcproxy.Config{ DefaultTimeout: time.Second, MaxRequestSize: bufSize, diff --git a/proxy/jsonrpc/proxy_test.go b/proxy/jsonrpc/proxy_test.go index 7bed78f..cd7b245 100644 --- a/proxy/jsonrpc/proxy_test.go +++ b/proxy/jsonrpc/proxy_test.go @@ -13,14 +13,14 @@ import ( ) type ProxyTestSuite struct { - test.ExecuteSuite + test.ExecutorSuite server *httptest.Server client *jsonrpcproxy.Client cleanup func() } func (s *ProxyTestSuite) SetupTest() { - exec := test.NewExecute() + exec := test.NewDummyExecutor() config := &jsonrpcproxy.Config{ DefaultTimeout: time.Second, MaxRequestSize: 1024 * 1024, diff --git a/test/dummy.go b/test/dummy.go index cf8fc8d..2214aea 100644 --- a/test/dummy.go +++ b/test/dummy.go @@ -6,16 +6,16 @@ import ( "github.com/rollkit/go-execution/types" ) -// Execute is a dummy implementation of the Execute interface for testing -type Execute struct { +// DummyExecutor is a dummy implementation of the DummyExecutor interface for testing +type DummyExecutor struct { stateRoot types.Hash maxBytes uint64 txs []types.Tx } -// NewExecute creates a new dummy Execute instance -func NewExecute() *Execute { - return &Execute{ +// NewDummyExecutor creates a new dummy DummyExecutor instance +func NewDummyExecutor() *DummyExecutor { + return &DummyExecutor{ stateRoot: types.Hash{1, 2, 3}, maxBytes: 1000000, txs: make([]types.Tx, 0), @@ -24,22 +24,22 @@ func NewExecute() *Execute { // InitChain initializes the chain state with the given genesis time, initial height, and chain ID. // It returns the state root hash, the maximum byte size, and an error if the initialization fails. -func (e *Execute) InitChain(genesisTime time.Time, initialHeight uint64, chainID string) (types.Hash, uint64, error) { +func (e *DummyExecutor) InitChain(genesisTime time.Time, initialHeight uint64, chainID string) (types.Hash, uint64, error) { return e.stateRoot, e.maxBytes, nil } -// GetTxs returns the list of transactions (types.Tx) within the Execute instance and an error if any. -func (e *Execute) GetTxs() ([]types.Tx, error) { +// GetTxs returns the list of transactions (types.Tx) within the DummyExecutor instance and an error if any. +func (e *DummyExecutor) GetTxs() ([]types.Tx, error) { return e.txs, nil } // ExecuteTxs simulate execution of transactions. -func (e *Execute) ExecuteTxs(txs []types.Tx, blockHeight uint64, timestamp time.Time, prevStateRoot types.Hash) (types.Hash, uint64, error) { +func (e *DummyExecutor) ExecuteTxs(txs []types.Tx, blockHeight uint64, timestamp time.Time, prevStateRoot types.Hash) (types.Hash, uint64, error) { e.txs = append(e.txs, txs...) return e.stateRoot, e.maxBytes, nil } // SetFinal marks block at given height as finalized. Currently not implemented. -func (e *Execute) SetFinal(blockHeight uint64) error { +func (e *DummyExecutor) SetFinal(blockHeight uint64) error { return nil } diff --git a/test/dummy_test.go b/test/dummy_test.go index 40670ec..94af8b6 100644 --- a/test/dummy_test.go +++ b/test/dummy_test.go @@ -7,11 +7,11 @@ import ( ) type DummyTestSuite struct { - ExecuteSuite + ExecutorSuite } func (s *DummyTestSuite) SetupTest() { - s.Exec = NewExecute() + s.Exec = NewDummyExecutor() } func TestDummySuite(t *testing.T) { diff --git a/test/suite.go b/test/suite.go index ddcf192..244dc90 100644 --- a/test/suite.go +++ b/test/suite.go @@ -9,14 +9,14 @@ import ( "github.com/rollkit/go-execution/types" ) -// ExecuteSuite is a reusable test suite for Execution API implementations. -type ExecuteSuite struct { +// ExecutorSuite is a reusable test suite for Execution API implementations. +type ExecutorSuite struct { suite.Suite - Exec execution.Execute + Exec execution.Executor } // TestInitChain tests InitChain method. -func (s *ExecuteSuite) TestInitChain() { +func (s *ExecutorSuite) TestInitChain() { genesisTime := time.Now().UTC() initialHeight := uint64(1) chainID := "test-chain" @@ -28,14 +28,14 @@ func (s *ExecuteSuite) TestInitChain() { } // TestGetTxs tests GetTxs method. -func (s *ExecuteSuite) TestGetTxs() { +func (s *ExecutorSuite) TestGetTxs() { txs, err := s.Exec.GetTxs() s.Require().NoError(err) s.NotNil(txs) } // TestExecuteTxs tests ExecuteTxs method. -func (s *ExecuteSuite) TestExecuteTxs() { +func (s *ExecutorSuite) TestExecuteTxs() { txs := []types.Tx{[]byte("tx1"), []byte("tx2")} blockHeight := uint64(1) timestamp := time.Now().UTC() @@ -48,7 +48,7 @@ func (s *ExecuteSuite) TestExecuteTxs() { } // TestSetFinal tests SetFinal method. -func (s *ExecuteSuite) TestSetFinal() { +func (s *ExecutorSuite) TestSetFinal() { err := s.Exec.SetFinal(1) s.Require().NoError(err) } From 2965472065163c75aa6ce898260cc85a55308713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zdyba=C5=82?= Date: Tue, 5 Nov 2024 23:04:23 +0100 Subject: [PATCH 3/3] test: rename mock `Execute` to `Executor` Renamed the mock structure from `MockExecute` to `MockExecutor` and updated related test instances and Makefile accordingly. This improves clarity and consistency in naming conventions. --- .mockery.yaml | 2 +- Makefile | 4 +- mocks/mock_Execute.go | 276 --------------------------- mocks/mock_Executor.go | 277 ++++++++++++++++++++++++++++ proxy/grpc/client_server_test.go | 2 +- proxy/jsonrpc/client_server_test.go | 2 +- 6 files changed, 282 insertions(+), 281 deletions(-) delete mode 100644 mocks/mock_Execute.go create mode 100644 mocks/mock_Executor.go diff --git a/.mockery.yaml b/.mockery.yaml index 4d37ea5..4f123f4 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -2,7 +2,7 @@ with-expecter: true packages: github.com/rollkit/go-execution: interfaces: - Execute: + Executor: config: dir: mocks outpkg: mocks diff --git a/Makefile b/Makefile index bee687c..38dbc08 100644 --- a/Makefile +++ b/Makefile @@ -89,8 +89,8 @@ proto-lint: check-proto-deps .PHONY: proto-lint ## mock-gen: Re-generates DA mock -mock-gen: mocks/Execute.go +mock-gen: mocks/mock_Executor.go .PHONY: mock-gen -mocks/Execute.go: execution.go .mockery.yaml +mocks/mock_Executor.go: execution.go .mockery.yaml @mockery \ No newline at end of file diff --git a/mocks/mock_Execute.go b/mocks/mock_Execute.go deleted file mode 100644 index d561d3d..0000000 --- a/mocks/mock_Execute.go +++ /dev/null @@ -1,276 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package mocks - -import ( - time "time" - - mock "github.com/stretchr/testify/mock" - - types "github.com/rollkit/go-execution/types" -) - -// MockExecute is an autogenerated mock type for the Execute type -type MockExecute struct { - mock.Mock -} - -type MockExecute_Expecter struct { - mock *mock.Mock -} - -func (_m *MockExecute) EXPECT() *MockExecute_Expecter { - return &MockExecute_Expecter{mock: &_m.Mock} -} - -// ExecuteTxs provides a mock function with given fields: txs, blockHeight, timestamp, prevStateRoot -func (_m *MockExecute) ExecuteTxs(txs []types.Tx, blockHeight uint64, timestamp time.Time, prevStateRoot types.Hash) (types.Hash, uint64, error) { - ret := _m.Called(txs, blockHeight, timestamp, prevStateRoot) - - if len(ret) == 0 { - panic("no return value specified for ExecuteTxs") - } - - var r0 types.Hash - var r1 uint64 - var r2 error - if rf, ok := ret.Get(0).(func([]types.Tx, uint64, time.Time, types.Hash) (types.Hash, uint64, error)); ok { - return rf(txs, blockHeight, timestamp, prevStateRoot) - } - if rf, ok := ret.Get(0).(func([]types.Tx, uint64, time.Time, types.Hash) types.Hash); ok { - r0 = rf(txs, blockHeight, timestamp, prevStateRoot) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(types.Hash) - } - } - - if rf, ok := ret.Get(1).(func([]types.Tx, uint64, time.Time, types.Hash) uint64); ok { - r1 = rf(txs, blockHeight, timestamp, prevStateRoot) - } else { - r1 = ret.Get(1).(uint64) - } - - if rf, ok := ret.Get(2).(func([]types.Tx, uint64, time.Time, types.Hash) error); ok { - r2 = rf(txs, blockHeight, timestamp, prevStateRoot) - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} - -// MockExecute_ExecuteTxs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExecuteTxs' -type MockExecute_ExecuteTxs_Call struct { - *mock.Call -} - -// ExecuteTxs is a helper method to define mock.On call -// - txs []types.Tx -// - blockHeight uint64 -// - timestamp time.Time -// - prevStateRoot types.Hash -func (_e *MockExecute_Expecter) ExecuteTxs(txs interface{}, blockHeight interface{}, timestamp interface{}, prevStateRoot interface{}) *MockExecute_ExecuteTxs_Call { - return &MockExecute_ExecuteTxs_Call{Call: _e.mock.On("ExecuteTxs", txs, blockHeight, timestamp, prevStateRoot)} -} - -func (_c *MockExecute_ExecuteTxs_Call) Run(run func(txs []types.Tx, blockHeight uint64, timestamp time.Time, prevStateRoot types.Hash)) *MockExecute_ExecuteTxs_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].([]types.Tx), args[1].(uint64), args[2].(time.Time), args[3].(types.Hash)) - }) - return _c -} - -func (_c *MockExecute_ExecuteTxs_Call) Return(updatedStateRoot types.Hash, maxBytes uint64, err error) *MockExecute_ExecuteTxs_Call { - _c.Call.Return(updatedStateRoot, maxBytes, err) - return _c -} - -func (_c *MockExecute_ExecuteTxs_Call) RunAndReturn(run func([]types.Tx, uint64, time.Time, types.Hash) (types.Hash, uint64, error)) *MockExecute_ExecuteTxs_Call { - _c.Call.Return(run) - return _c -} - -// GetTxs provides a mock function with given fields: -func (_m *MockExecute) GetTxs() ([]types.Tx, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetTxs") - } - - var r0 []types.Tx - var r1 error - if rf, ok := ret.Get(0).(func() ([]types.Tx, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() []types.Tx); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.Tx) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockExecute_GetTxs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTxs' -type MockExecute_GetTxs_Call struct { - *mock.Call -} - -// GetTxs is a helper method to define mock.On call -func (_e *MockExecute_Expecter) GetTxs() *MockExecute_GetTxs_Call { - return &MockExecute_GetTxs_Call{Call: _e.mock.On("GetTxs")} -} - -func (_c *MockExecute_GetTxs_Call) Run(run func()) *MockExecute_GetTxs_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockExecute_GetTxs_Call) Return(_a0 []types.Tx, _a1 error) *MockExecute_GetTxs_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockExecute_GetTxs_Call) RunAndReturn(run func() ([]types.Tx, error)) *MockExecute_GetTxs_Call { - _c.Call.Return(run) - return _c -} - -// InitChain provides a mock function with given fields: genesisTime, initialHeight, chainID -func (_m *MockExecute) InitChain(genesisTime time.Time, initialHeight uint64, chainID string) (types.Hash, uint64, error) { - ret := _m.Called(genesisTime, initialHeight, chainID) - - if len(ret) == 0 { - panic("no return value specified for InitChain") - } - - var r0 types.Hash - var r1 uint64 - var r2 error - if rf, ok := ret.Get(0).(func(time.Time, uint64, string) (types.Hash, uint64, error)); ok { - return rf(genesisTime, initialHeight, chainID) - } - if rf, ok := ret.Get(0).(func(time.Time, uint64, string) types.Hash); ok { - r0 = rf(genesisTime, initialHeight, chainID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(types.Hash) - } - } - - if rf, ok := ret.Get(1).(func(time.Time, uint64, string) uint64); ok { - r1 = rf(genesisTime, initialHeight, chainID) - } else { - r1 = ret.Get(1).(uint64) - } - - if rf, ok := ret.Get(2).(func(time.Time, uint64, string) error); ok { - r2 = rf(genesisTime, initialHeight, chainID) - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} - -// MockExecute_InitChain_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'InitChain' -type MockExecute_InitChain_Call struct { - *mock.Call -} - -// InitChain is a helper method to define mock.On call -// - genesisTime time.Time -// - initialHeight uint64 -// - chainID string -func (_e *MockExecute_Expecter) InitChain(genesisTime interface{}, initialHeight interface{}, chainID interface{}) *MockExecute_InitChain_Call { - return &MockExecute_InitChain_Call{Call: _e.mock.On("InitChain", genesisTime, initialHeight, chainID)} -} - -func (_c *MockExecute_InitChain_Call) Run(run func(genesisTime time.Time, initialHeight uint64, chainID string)) *MockExecute_InitChain_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(time.Time), args[1].(uint64), args[2].(string)) - }) - return _c -} - -func (_c *MockExecute_InitChain_Call) Return(stateRoot types.Hash, maxBytes uint64, err error) *MockExecute_InitChain_Call { - _c.Call.Return(stateRoot, maxBytes, err) - return _c -} - -func (_c *MockExecute_InitChain_Call) RunAndReturn(run func(time.Time, uint64, string) (types.Hash, uint64, error)) *MockExecute_InitChain_Call { - _c.Call.Return(run) - return _c -} - -// SetFinal provides a mock function with given fields: blockHeight -func (_m *MockExecute) SetFinal(blockHeight uint64) error { - ret := _m.Called(blockHeight) - - if len(ret) == 0 { - panic("no return value specified for SetFinal") - } - - var r0 error - if rf, ok := ret.Get(0).(func(uint64) error); ok { - r0 = rf(blockHeight) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockExecute_SetFinal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetFinal' -type MockExecute_SetFinal_Call struct { - *mock.Call -} - -// SetFinal is a helper method to define mock.On call -// - blockHeight uint64 -func (_e *MockExecute_Expecter) SetFinal(blockHeight interface{}) *MockExecute_SetFinal_Call { - return &MockExecute_SetFinal_Call{Call: _e.mock.On("SetFinal", blockHeight)} -} - -func (_c *MockExecute_SetFinal_Call) Run(run func(blockHeight uint64)) *MockExecute_SetFinal_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(uint64)) - }) - return _c -} - -func (_c *MockExecute_SetFinal_Call) Return(_a0 error) *MockExecute_SetFinal_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockExecute_SetFinal_Call) RunAndReturn(run func(uint64) error) *MockExecute_SetFinal_Call { - _c.Call.Return(run) - return _c -} - -// NewMockExecute creates a new instance of MockExecute. 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 NewMockExecute(t interface { - mock.TestingT - Cleanup(func()) -}) *MockExecute { - mock := &MockExecute{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/mocks/mock_Executor.go b/mocks/mock_Executor.go new file mode 100644 index 0000000..7245228 --- /dev/null +++ b/mocks/mock_Executor.go @@ -0,0 +1,277 @@ +// Code generated by mockery v2.46.0. DO NOT EDIT. + +package mocks + +import ( + header "github.com/celestiaorg/go-header" + mock "github.com/stretchr/testify/mock" + + time "time" + + types "github.com/rollkit/go-execution/types" +) + +// MockExecutor is an autogenerated mock type for the Executor type +type MockExecutor struct { + mock.Mock +} + +type MockExecutor_Expecter struct { + mock *mock.Mock +} + +func (_m *MockExecutor) EXPECT() *MockExecutor_Expecter { + return &MockExecutor_Expecter{mock: &_m.Mock} +} + +// ExecuteTxs provides a mock function with given fields: txs, blockHeight, timestamp, prevStateRoot +func (_m *MockExecutor) ExecuteTxs(txs []types.Tx, blockHeight uint64, timestamp time.Time, prevStateRoot header.Hash) (header.Hash, uint64, error) { + ret := _m.Called(txs, blockHeight, timestamp, prevStateRoot) + + if len(ret) == 0 { + panic("no return value specified for ExecuteTxs") + } + + var r0 header.Hash + var r1 uint64 + var r2 error + if rf, ok := ret.Get(0).(func([]types.Tx, uint64, time.Time, header.Hash) (header.Hash, uint64, error)); ok { + return rf(txs, blockHeight, timestamp, prevStateRoot) + } + if rf, ok := ret.Get(0).(func([]types.Tx, uint64, time.Time, header.Hash) header.Hash); ok { + r0 = rf(txs, blockHeight, timestamp, prevStateRoot) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(header.Hash) + } + } + + if rf, ok := ret.Get(1).(func([]types.Tx, uint64, time.Time, header.Hash) uint64); ok { + r1 = rf(txs, blockHeight, timestamp, prevStateRoot) + } else { + r1 = ret.Get(1).(uint64) + } + + if rf, ok := ret.Get(2).(func([]types.Tx, uint64, time.Time, header.Hash) error); ok { + r2 = rf(txs, blockHeight, timestamp, prevStateRoot) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockExecutor_ExecuteTxs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExecuteTxs' +type MockExecutor_ExecuteTxs_Call struct { + *mock.Call +} + +// ExecuteTxs is a helper method to define mock.On call +// - txs []types.Tx +// - blockHeight uint64 +// - timestamp time.Time +// - prevStateRoot header.Hash +func (_e *MockExecutor_Expecter) ExecuteTxs(txs interface{}, blockHeight interface{}, timestamp interface{}, prevStateRoot interface{}) *MockExecutor_ExecuteTxs_Call { + return &MockExecutor_ExecuteTxs_Call{Call: _e.mock.On("ExecuteTxs", txs, blockHeight, timestamp, prevStateRoot)} +} + +func (_c *MockExecutor_ExecuteTxs_Call) Run(run func(txs []types.Tx, blockHeight uint64, timestamp time.Time, prevStateRoot header.Hash)) *MockExecutor_ExecuteTxs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]types.Tx), args[1].(uint64), args[2].(time.Time), args[3].(header.Hash)) + }) + return _c +} + +func (_c *MockExecutor_ExecuteTxs_Call) Return(updatedStateRoot header.Hash, maxBytes uint64, err error) *MockExecutor_ExecuteTxs_Call { + _c.Call.Return(updatedStateRoot, maxBytes, err) + return _c +} + +func (_c *MockExecutor_ExecuteTxs_Call) RunAndReturn(run func([]types.Tx, uint64, time.Time, header.Hash) (header.Hash, uint64, error)) *MockExecutor_ExecuteTxs_Call { + _c.Call.Return(run) + return _c +} + +// GetTxs provides a mock function with given fields: +func (_m *MockExecutor) GetTxs() ([]types.Tx, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetTxs") + } + + var r0 []types.Tx + var r1 error + if rf, ok := ret.Get(0).(func() ([]types.Tx, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []types.Tx); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]types.Tx) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockExecutor_GetTxs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTxs' +type MockExecutor_GetTxs_Call struct { + *mock.Call +} + +// GetTxs is a helper method to define mock.On call +func (_e *MockExecutor_Expecter) GetTxs() *MockExecutor_GetTxs_Call { + return &MockExecutor_GetTxs_Call{Call: _e.mock.On("GetTxs")} +} + +func (_c *MockExecutor_GetTxs_Call) Run(run func()) *MockExecutor_GetTxs_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockExecutor_GetTxs_Call) Return(_a0 []types.Tx, _a1 error) *MockExecutor_GetTxs_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockExecutor_GetTxs_Call) RunAndReturn(run func() ([]types.Tx, error)) *MockExecutor_GetTxs_Call { + _c.Call.Return(run) + return _c +} + +// InitChain provides a mock function with given fields: genesisTime, initialHeight, chainID +func (_m *MockExecutor) InitChain(genesisTime time.Time, initialHeight uint64, chainID string) (header.Hash, uint64, error) { + ret := _m.Called(genesisTime, initialHeight, chainID) + + if len(ret) == 0 { + panic("no return value specified for InitChain") + } + + var r0 header.Hash + var r1 uint64 + var r2 error + if rf, ok := ret.Get(0).(func(time.Time, uint64, string) (header.Hash, uint64, error)); ok { + return rf(genesisTime, initialHeight, chainID) + } + if rf, ok := ret.Get(0).(func(time.Time, uint64, string) header.Hash); ok { + r0 = rf(genesisTime, initialHeight, chainID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(header.Hash) + } + } + + if rf, ok := ret.Get(1).(func(time.Time, uint64, string) uint64); ok { + r1 = rf(genesisTime, initialHeight, chainID) + } else { + r1 = ret.Get(1).(uint64) + } + + if rf, ok := ret.Get(2).(func(time.Time, uint64, string) error); ok { + r2 = rf(genesisTime, initialHeight, chainID) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockExecutor_InitChain_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'InitChain' +type MockExecutor_InitChain_Call struct { + *mock.Call +} + +// InitChain is a helper method to define mock.On call +// - genesisTime time.Time +// - initialHeight uint64 +// - chainID string +func (_e *MockExecutor_Expecter) InitChain(genesisTime interface{}, initialHeight interface{}, chainID interface{}) *MockExecutor_InitChain_Call { + return &MockExecutor_InitChain_Call{Call: _e.mock.On("InitChain", genesisTime, initialHeight, chainID)} +} + +func (_c *MockExecutor_InitChain_Call) Run(run func(genesisTime time.Time, initialHeight uint64, chainID string)) *MockExecutor_InitChain_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(time.Time), args[1].(uint64), args[2].(string)) + }) + return _c +} + +func (_c *MockExecutor_InitChain_Call) Return(stateRoot header.Hash, maxBytes uint64, err error) *MockExecutor_InitChain_Call { + _c.Call.Return(stateRoot, maxBytes, err) + return _c +} + +func (_c *MockExecutor_InitChain_Call) RunAndReturn(run func(time.Time, uint64, string) (header.Hash, uint64, error)) *MockExecutor_InitChain_Call { + _c.Call.Return(run) + return _c +} + +// SetFinal provides a mock function with given fields: blockHeight +func (_m *MockExecutor) SetFinal(blockHeight uint64) error { + ret := _m.Called(blockHeight) + + if len(ret) == 0 { + panic("no return value specified for SetFinal") + } + + var r0 error + if rf, ok := ret.Get(0).(func(uint64) error); ok { + r0 = rf(blockHeight) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockExecutor_SetFinal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetFinal' +type MockExecutor_SetFinal_Call struct { + *mock.Call +} + +// SetFinal is a helper method to define mock.On call +// - blockHeight uint64 +func (_e *MockExecutor_Expecter) SetFinal(blockHeight interface{}) *MockExecutor_SetFinal_Call { + return &MockExecutor_SetFinal_Call{Call: _e.mock.On("SetFinal", blockHeight)} +} + +func (_c *MockExecutor_SetFinal_Call) Run(run func(blockHeight uint64)) *MockExecutor_SetFinal_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64)) + }) + return _c +} + +func (_c *MockExecutor_SetFinal_Call) Return(_a0 error) *MockExecutor_SetFinal_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockExecutor_SetFinal_Call) RunAndReturn(run func(uint64) error) *MockExecutor_SetFinal_Call { + _c.Call.Return(run) + return _c +} + +// NewMockExecutor creates a new instance of MockExecutor. 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 NewMockExecutor(t interface { + mock.TestingT + Cleanup(func()) +}) *MockExecutor { + mock := &MockExecutor{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/proxy/grpc/client_server_test.go b/proxy/grpc/client_server_test.go index 0c4e86e..14b22b5 100644 --- a/proxy/grpc/client_server_test.go +++ b/proxy/grpc/client_server_test.go @@ -17,7 +17,7 @@ import ( ) func TestClientServer(t *testing.T) { - mockExec := mocks.NewMockExecute(t) + mockExec := mocks.NewMockExecutor(t) config := &grpcproxy.Config{ DefaultTimeout: 5 * time.Second, MaxRequestSize: bufSize, diff --git a/proxy/jsonrpc/client_server_test.go b/proxy/jsonrpc/client_server_test.go index 02b82b7..2295663 100644 --- a/proxy/jsonrpc/client_server_test.go +++ b/proxy/jsonrpc/client_server_test.go @@ -14,7 +14,7 @@ import ( ) func TestClientServer(t *testing.T) { - mockExec := mocks.NewMockExecute(t) + mockExec := mocks.NewMockExecutor(t) config := &jsonrpcproxy.Config{ DefaultTimeout: 5 * time.Second, MaxRequestSize: 1024 * 1024,