From 0ed36c739430c8e56b3592cd5beffaa42ac61cea Mon Sep 17 00:00:00 2001 From: egonspace Date: Thu, 8 Jul 2021 17:19:38 +0900 Subject: [PATCH] fix: add more fixing for abci.Client, Async() --- abci/client/mocks/client.go | 39 +++++++++++++++++ light/rpc/client_test.go | 4 -- proxy/app_conn_test.go | 14 +++--- proxy/mocks/app_conn_consensus.go | 10 ++--- proxy/mocks/app_conn_mempool.go | 71 +++++++++++-------------------- 5 files changed, 76 insertions(+), 62 deletions(-) diff --git a/abci/client/mocks/client.go b/abci/client/mocks/client.go index 4ef898247..219c9bf73 100644 --- a/abci/client/mocks/client.go +++ b/abci/client/mocks/client.go @@ -381,6 +381,45 @@ func (_m *Client) Error() error { return r0 } +// FlushAsync provides a mock function with given fields: _a0 +func (_m *Client) FlushAsync(_a0 abcicli.ResponseCallback) *abcicli.ReqRes { + ret := _m.Called(_a0) + + var r0 *abcicli.ReqRes + if rf, ok := ret.Get(0).(func(abcicli.ResponseCallback) *abcicli.ReqRes); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*abcicli.ReqRes) + } + } + + return r0 +} + +// FlushSync provides a mock function with given fields: +func (_m *Client) FlushSync() (*types.ResponseFlush, error) { + ret := _m.Called() + + var r0 *types.ResponseFlush + if rf, ok := ret.Get(0).(func() *types.ResponseFlush); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.ResponseFlush) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetGlobalCallback provides a mock function with given fields: func (_m *Client) GetGlobalCallback() abcicli.GlobalCallback { ret := _m.Called() diff --git a/light/rpc/client_test.go b/light/rpc/client_test.go index a49aba46f..2505fc7bd 100644 --- a/light/rpc/client_test.go +++ b/light/rpc/client_test.go @@ -7,9 +7,6 @@ import ( "testing" ics23 "github.com/confio/ics23/go" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/require" abci "github.com/line/ostracon/abci/types" "github.com/line/ostracon/crypto/merkle" @@ -19,7 +16,6 @@ import ( rpcmock "github.com/line/ostracon/rpc/client/mocks" ctypes "github.com/line/ostracon/rpc/core/types" "github.com/line/ostracon/types" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/proxy/app_conn_test.go b/proxy/app_conn_test.go index 72d9c99f5..f802567e1 100644 --- a/proxy/app_conn_test.go +++ b/proxy/app_conn_test.go @@ -16,7 +16,7 @@ import ( //---------------------------------------- type AppConnTest interface { - FlushSync() error + FlushSync() (*types.ResponseFlush, error) EchoAsync(string, abcicli.ResponseCallback) *abcicli.ReqRes InfoSync(types.RequestInfo) (*types.ResponseInfo, error) } @@ -33,7 +33,7 @@ func (app *appConnTest) EchoAsync(msg string, cb abcicli.ResponseCallback) *abci return app.appConn.EchoAsync(msg, cb) } -func (app *appConnTest) FlushSync() error { +func (app *appConnTest) FlushSync() (*types.ResponseFlush, error) { return app.appConn.FlushSync() } @@ -77,8 +77,9 @@ func TestEcho(t *testing.T) { for i := 0; i < 1000; i++ { proxy.EchoAsync(fmt.Sprintf("echo-%v", i), nil) } - if err := proxy.FlushSync(); err != nil { - t.Error(err) + _, err2 := proxy.FlushSync() + if err2 != nil { + t.Error(err2) } } @@ -117,8 +118,9 @@ func BenchmarkEcho(b *testing.B) { for i := 0; i < b.N; i++ { proxy.EchoAsync(echoString, nil) } - if err := proxy.FlushSync(); err != nil { - b.Error(err) + _, err2 := proxy.FlushSync() + if err2 != nil { + b.Error(err2) } b.StopTimer() diff --git a/proxy/mocks/app_conn_consensus.go b/proxy/mocks/app_conn_consensus.go index 1d66b858b..a21beed72 100644 --- a/proxy/mocks/app_conn_consensus.go +++ b/proxy/mocks/app_conn_consensus.go @@ -60,13 +60,13 @@ func (_m *AppConnConsensus) CommitSync() (*types.ResponseCommit, error) { return r0, r1 } -// DeliverTxAsync provides a mock function with given fields: _a0 -func (_m *AppConnConsensus) DeliverTxAsync(_a0 types.RequestDeliverTx) *abcicli.ReqRes { - ret := _m.Called(_a0) +// DeliverTxAsync provides a mock function with given fields: _a0, _a1 +func (_m *AppConnConsensus) DeliverTxAsync(_a0 types.RequestDeliverTx, _a1 abcicli.ResponseCallback) *abcicli.ReqRes { + ret := _m.Called(_a0, _a1) var r0 *abcicli.ReqRes - if rf, ok := ret.Get(0).(func(types.RequestDeliverTx) *abcicli.ReqRes); ok { - r0 = rf(_a0) + if rf, ok := ret.Get(0).(func(types.RequestDeliverTx, abcicli.ResponseCallback) *abcicli.ReqRes); ok { + r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*abcicli.ReqRes) diff --git a/proxy/mocks/app_conn_mempool.go b/proxy/mocks/app_conn_mempool.go index 4fa331390..24f19bcef 100644 --- a/proxy/mocks/app_conn_mempool.go +++ b/proxy/mocks/app_conn_mempool.go @@ -14,22 +14,6 @@ type AppConnMempool struct { mock.Mock } -// BeginRecheckTxAsync provides a mock function with given fields: _a0 -func (_m *AppConnMempool) BeginRecheckTxAsync(_a0 types.RequestBeginRecheckTx) *abcicli.ReqRes { - ret := _m.Called(_a0) - - var r0 *abcicli.ReqRes - if rf, ok := ret.Get(0).(func(types.RequestBeginRecheckTx) *abcicli.ReqRes); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*abcicli.ReqRes) - } - } - - return r0 -} - // BeginRecheckTxSync provides a mock function with given fields: _a0 func (_m *AppConnMempool) BeginRecheckTxSync(_a0 types.RequestBeginRecheckTx) (*types.ResponseBeginRecheckTx, error) { ret := _m.Called(_a0) @@ -53,13 +37,13 @@ func (_m *AppConnMempool) BeginRecheckTxSync(_a0 types.RequestBeginRecheckTx) (* return r0, r1 } -// CheckTxAsync provides a mock function with given fields: _a0 -func (_m *AppConnMempool) CheckTxAsync(_a0 types.RequestCheckTx) *abcicli.ReqRes { - ret := _m.Called(_a0) +// CheckTxAsync provides a mock function with given fields: _a0, _a1 +func (_m *AppConnMempool) CheckTxAsync(_a0 types.RequestCheckTx, _a1 abcicli.ResponseCallback) *abcicli.ReqRes { + ret := _m.Called(_a0, _a1) var r0 *abcicli.ReqRes - if rf, ok := ret.Get(0).(func(types.RequestCheckTx) *abcicli.ReqRes); ok { - r0 = rf(_a0) + if rf, ok := ret.Get(0).(func(types.RequestCheckTx, abcicli.ResponseCallback) *abcicli.ReqRes); ok { + r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*abcicli.ReqRes) @@ -92,22 +76,6 @@ func (_m *AppConnMempool) CheckTxSync(_a0 types.RequestCheckTx) (*types.Response return r0, r1 } -// EndRecheckTxAsync provides a mock function with given fields: _a0 -func (_m *AppConnMempool) EndRecheckTxAsync(_a0 types.RequestEndRecheckTx) *abcicli.ReqRes { - ret := _m.Called(_a0) - - var r0 *abcicli.ReqRes - if rf, ok := ret.Get(0).(func(types.RequestEndRecheckTx) *abcicli.ReqRes); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*abcicli.ReqRes) - } - } - - return r0 -} - // EndRecheckTxSync provides a mock function with given fields: _a0 func (_m *AppConnMempool) EndRecheckTxSync(_a0 types.RequestEndRecheckTx) (*types.ResponseEndRecheckTx, error) { ret := _m.Called(_a0) @@ -145,13 +113,13 @@ func (_m *AppConnMempool) Error() error { return r0 } -// FlushAsync provides a mock function with given fields: -func (_m *AppConnMempool) FlushAsync() *abcicli.ReqRes { - ret := _m.Called() +// FlushAsync provides a mock function with given fields: _a0 +func (_m *AppConnMempool) FlushAsync(_a0 abcicli.ResponseCallback) *abcicli.ReqRes { + ret := _m.Called(_a0) var r0 *abcicli.ReqRes - if rf, ok := ret.Get(0).(func() *abcicli.ReqRes); ok { - r0 = rf() + if rf, ok := ret.Get(0).(func(abcicli.ResponseCallback) *abcicli.ReqRes); ok { + r0 = rf(_a0) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*abcicli.ReqRes) @@ -162,17 +130,26 @@ func (_m *AppConnMempool) FlushAsync() *abcicli.ReqRes { } // FlushSync provides a mock function with given fields: -func (_m *AppConnMempool) FlushSync() error { +func (_m *AppConnMempool) FlushSync() (*types.ResponseFlush, error) { ret := _m.Called() - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { + var r0 *types.ResponseFlush + if rf, ok := ret.Get(0).(func() *types.ResponseFlush); ok { r0 = rf() } else { - r0 = ret.Error(0) + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.ResponseFlush) + } } - return r0 + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 } // SetGlobalCallback provides a mock function with given fields: _a0