Documentation ¶
Overview ¶
package mock returns a Client implementation that accepts various (mock) implementations of the various methods.
This implementation is useful for using in tests, when you don't need a real server, but want a high-level of control about the server response you want to mock (eg. error handling), or if you just want to record the calls to verify in your tests.
For real clients, you probably want the "http" package. If you want to directly call a tendermint node in process, you can use the "local" package.
Index ¶
- type ABCIApp
- func (a ABCIApp) ABCIInfo() (*ctypes.ResultABCIInfo, error)
- func (a ABCIApp) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error)
- func (a ABCIApp) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
- func (a ABCIApp) BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func (a ABCIApp) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
- func (a ABCIApp) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- type ABCIMock
- func (m ABCIMock) ABCIInfo() (*ctypes.ResultABCIInfo, error)
- func (m ABCIMock) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error)
- func (m ABCIMock) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
- func (m ABCIMock) BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func (m ABCIMock) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
- func (m ABCIMock) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- type ABCIRecorder
- func (r *ABCIRecorder) ABCIInfo() (*ctypes.ResultABCIInfo, error)
- func (r *ABCIRecorder) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error)
- func (r *ABCIRecorder) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
- func (r *ABCIRecorder) BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func (r *ABCIRecorder) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
- func (r *ABCIRecorder) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- type Call
- type Client
- func (c Client) ABCIInfo() (*ctypes.ResultABCIInfo, error)
- func (c Client) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error)
- func (c Client) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
- func (c Client) Block(height *int64) (*ctypes.ResultBlock, error)
- func (c Client) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
- func (c Client) BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func (c Client) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
- func (c Client) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func (c Client) Commit(height *int64) (*ctypes.ResultCommit, error)
- func (c Client) DialPeers(peers []string, persistent bool) (*ctypes.ResultDialPeers, error)
- func (c Client) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error)
- func (c Client) Genesis() (*ctypes.ResultGenesis, error)
- func (c Client) NetInfo() (*ctypes.ResultNetInfo, error)
- func (c Client) Status() (*ctypes.ResultStatus, error)
- func (c Client) Validators(height *int64) (*ctypes.ResultValidators, error)
- type QueryArgs
- type StatusMock
- type StatusRecorder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ABCIApp ¶
type ABCIApp struct {
App abci.Application
}
ABCIApp will send all abci related request to the named app, so you can test app behavior from a client without needing an entire tendermint node
func (ABCIApp) ABCIQueryWithOptions ¶ added in v0.15.0
func (a ABCIApp) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
func (ABCIApp) BroadcastTxAsync ¶
func (ABCIApp) BroadcastTxCommit ¶
func (ABCIApp) BroadcastTxSync ¶
type ABCIMock ¶
ABCIMock will send all abci related request to the named app, so you can test app behavior from a client without needing an entire tendermint node
func (ABCIMock) ABCIQueryWithOptions ¶ added in v0.15.0
func (m ABCIMock) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
func (ABCIMock) BroadcastTxAsync ¶
func (ABCIMock) BroadcastTxCommit ¶
func (ABCIMock) BroadcastTxSync ¶
type ABCIRecorder ¶
type ABCIRecorder struct { Client client.ABCIClient Calls []Call }
ABCIRecorder can wrap another type (ABCIApp, ABCIMock, or Client) and record all ABCI related calls.
func NewABCIRecorder ¶
func NewABCIRecorder(client client.ABCIClient) *ABCIRecorder
func (*ABCIRecorder) ABCIInfo ¶
func (r *ABCIRecorder) ABCIInfo() (*ctypes.ResultABCIInfo, error)
func (*ABCIRecorder) ABCIQuery ¶
func (r *ABCIRecorder) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error)
func (*ABCIRecorder) ABCIQueryWithOptions ¶ added in v0.15.0
func (r *ABCIRecorder) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
func (*ABCIRecorder) BroadcastTxAsync ¶
func (r *ABCIRecorder) BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
func (*ABCIRecorder) BroadcastTxCommit ¶
func (r *ABCIRecorder) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
func (*ABCIRecorder) BroadcastTxSync ¶
func (r *ABCIRecorder) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
type Call ¶
Call is used by recorders to save a call and response. It can also be used to configure mock responses.
func (Call) GetResponse ¶
GetResponse will generate the apporiate response for us, when using the Call struct to configure a Mock handler.
When configuring a response, if only one of Response or Error is set then that will always be returned. If both are set, then we return Response if the Args match the set args, Error otherwise.
type Client ¶
type Client struct { client.ABCIClient client.SignClient client.HistoryClient client.StatusClient client.EventsClient cmn.Service }
Client wraps arbitrary implementations of the various interfaces.
We provide a few choices to mock out each one in this package. Nothing hidden here, so no New function, just construct it from some parts, and swap them out them during the tests.
func (Client) ABCIQueryWithOptions ¶ added in v0.15.0
func (c Client) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
func (Client) BlockchainInfo ¶
func (c Client) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
func (Client) BroadcastTxAsync ¶
func (Client) BroadcastTxCommit ¶
func (Client) BroadcastTxSync ¶
func (Client) DialSeeds ¶
func (c Client) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error)
func (Client) Validators ¶
func (c Client) Validators(height *int64) (*ctypes.ResultValidators, error)
type StatusMock ¶
type StatusMock struct {
Call
}
StatusMock returns the result specified by the Call
func (*StatusMock) Status ¶
func (m *StatusMock) Status() (*ctypes.ResultStatus, error)
type StatusRecorder ¶
type StatusRecorder struct { Client client.StatusClient Calls []Call }
StatusRecorder can wrap another type (StatusMock, full client) and record the status calls
func NewStatusRecorder ¶
func NewStatusRecorder(client client.StatusClient) *StatusRecorder
func (*StatusRecorder) Status ¶
func (r *StatusRecorder) Status() (*ctypes.ResultStatus, error)