github.com/vipernet-xyz/tendermint-core@v0.32.0/rpc/client/mock/status.go (about) 1 package mock 2 3 import ( 4 "github.com/tendermint/tendermint/rpc/client" 5 ctypes "github.com/tendermint/tendermint/rpc/core/types" 6 ) 7 8 // StatusMock returns the result specified by the Call 9 type StatusMock struct { 10 Call 11 } 12 13 var ( 14 _ client.StatusClient = (*StatusMock)(nil) 15 _ client.StatusClient = (*StatusRecorder)(nil) 16 ) 17 18 func (m *StatusMock) Status() (*ctypes.ResultStatus, error) { 19 res, err := m.GetResponse(nil) 20 if err != nil { 21 return nil, err 22 } 23 return res.(*ctypes.ResultStatus), nil 24 } 25 26 // StatusRecorder can wrap another type (StatusMock, full client) 27 // and record the status calls 28 type StatusRecorder struct { 29 Client client.StatusClient 30 Calls []Call 31 } 32 33 func NewStatusRecorder(client client.StatusClient) *StatusRecorder { 34 return &StatusRecorder{ 35 Client: client, 36 Calls: []Call{}, 37 } 38 } 39 40 func (r *StatusRecorder) addCall(call Call) { 41 r.Calls = append(r.Calls, call) 42 } 43 44 func (r *StatusRecorder) Status() (*ctypes.ResultStatus, error) { 45 res, err := r.Client.Status() 46 r.addCall(Call{ 47 Name: "status", 48 Response: res, 49 Error: err, 50 }) 51 return res, err 52 }