-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract
MockTendermintRPC
to testutil/cli
- Loading branch information
1 parent
779c0ac
commit 08be7ee
Showing
17 changed files
with
149 additions
and
511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.