mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-24 16:51:58 +00:00
Revert "delete everything" (includes everything non-go-crypto)
This reverts commit 96a3502
This commit is contained in:
52
rpc/client/mock/status.go
Normal file
52
rpc/client/mock/status.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package mock
|
||||
|
||||
import (
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
)
|
||||
|
||||
// StatusMock returns the result specified by the Call
|
||||
type StatusMock struct {
|
||||
Call
|
||||
}
|
||||
|
||||
var (
|
||||
_ client.StatusClient = (*StatusMock)(nil)
|
||||
_ client.StatusClient = (*StatusRecorder)(nil)
|
||||
)
|
||||
|
||||
func (m *StatusMock) Status() (*ctypes.ResultStatus, error) {
|
||||
res, err := m.GetResponse(nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.(*ctypes.ResultStatus), nil
|
||||
}
|
||||
|
||||
// StatusRecorder can wrap another type (StatusMock, full client)
|
||||
// and record the status calls
|
||||
type StatusRecorder struct {
|
||||
Client client.StatusClient
|
||||
Calls []Call
|
||||
}
|
||||
|
||||
func NewStatusRecorder(client client.StatusClient) *StatusRecorder {
|
||||
return &StatusRecorder{
|
||||
Client: client,
|
||||
Calls: []Call{},
|
||||
}
|
||||
}
|
||||
|
||||
func (r *StatusRecorder) addCall(call Call) {
|
||||
r.Calls = append(r.Calls, call)
|
||||
}
|
||||
|
||||
func (r *StatusRecorder) Status() (*ctypes.ResultStatus, error) {
|
||||
res, err := r.Client.Status()
|
||||
r.addCall(Call{
|
||||
Name: "status",
|
||||
Response: res,
|
||||
Error: err,
|
||||
})
|
||||
return res, err
|
||||
}
|
Reference in New Issue
Block a user