forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathtm_mocks.go
41 lines (32 loc) · 1.17 KB
/
tm_mocks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cli
import (
"context"
abci "github.com/tendermint/tendermint/abci/types"
tmbytes "github.com/tendermint/tendermint/libs/bytes"
rpcclient "github.com/tendermint/tendermint/rpc/client"
rpcclientmock "github.com/tendermint/tendermint/rpc/client/mock"
coretypes "github.com/tendermint/tendermint/rpc/core/types"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
)
var _ client.TendermintRPC = (*MockTendermintRPC)(nil)
type MockTendermintRPC struct {
rpcclientmock.Client
responseQuery abci.ResponseQuery
}
// NewMockTendermintRPC returns a mock TendermintRPC implementation.
// It is used for CLI testing.
func NewMockTendermintRPC(respQuery abci.ResponseQuery) MockTendermintRPC {
return MockTendermintRPC{responseQuery: respQuery}
}
func (MockTendermintRPC) BroadcastTxSync(context.Context, tmtypes.Tx) (*coretypes.ResultBroadcastTx, error) {
return &coretypes.ResultBroadcastTx{Code: 0}, nil
}
func (m MockTendermintRPC) ABCIQueryWithOptions(
_ context.Context,
_ string,
_ tmbytes.HexBytes,
_ rpcclient.ABCIQueryOptions,
) (*coretypes.ResultABCIQuery, error) {
return &coretypes.ResultABCIQuery{Response: m.responseQuery}, nil
}