-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use autocli for comet commands (#17389)
- Loading branch information
1 parent
53f804d
commit 208219a
Showing
24 changed files
with
254 additions
and
175 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
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,71 @@ | ||
package cmtservice | ||
|
||
import ( | ||
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" | ||
cmtv1beta1 "cosmossdk.io/api/cosmos/base/tendermint/v1beta1" | ||
) | ||
|
||
var CometBFTAutoCLIDescriptor = &autocliv1.ServiceCommandDescriptor{ | ||
Service: cmtv1beta1.Service_ServiceDesc.ServiceName, | ||
RpcCommandOptions: []*autocliv1.RpcCommandOptions{ | ||
{ | ||
RpcMethod: "GetNodeInfo", | ||
Use: "node-info", | ||
Short: "Query the current node info", | ||
}, | ||
{ | ||
RpcMethod: "GetSyncing", | ||
Use: "syncing", | ||
Short: "Query node syncing status", | ||
}, | ||
{ | ||
RpcMethod: "GetLatestBlock", | ||
Use: "block-latest", | ||
Short: "Query for the latest committed block", | ||
}, | ||
{ | ||
RpcMethod: "GetBlockByHeight", | ||
Use: "block-by-height [height]", | ||
Short: "Query for a committed block by height", | ||
Long: "Query for a specific committed block using the CometBFT RPC `block_by_height` method", | ||
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "height"}}, | ||
}, | ||
{ | ||
RpcMethod: "GetLatestValidatorSet", | ||
Use: "validator-set", | ||
Alias: []string{"validator-set-latest", "comet-validator-set", "cometbft-validator-set", "tendermint-validator-set"}, | ||
Short: "Query for the latest validator set", | ||
}, | ||
{ | ||
RpcMethod: "GetValidatorSetByHeight", | ||
Use: "validator-set-by-height [height]", | ||
Short: "Query for a validator set by height", | ||
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "height"}}, | ||
}, | ||
{ | ||
RpcMethod: "ABCIQuery", | ||
Skip: true, | ||
}, | ||
}, | ||
} | ||
|
||
// NewCometBFTCommands is a fake `appmodule.Module` to be considered as a module | ||
// and be added in AutoCLI. | ||
func NewCometBFTCommands() *cometModule { | ||
return &cometModule{} | ||
} | ||
|
||
type cometModule struct{} | ||
|
||
func (m cometModule) IsOnePerModuleType() {} | ||
func (m cometModule) IsAppModule() {} | ||
|
||
func (m cometModule) Name() string { | ||
return "comet" | ||
} | ||
|
||
func (m cometModule) AutoCLIOptions() *autocliv1.ModuleOptions { | ||
return &autocliv1.ModuleOptions{ | ||
Query: CometBFTAutoCLIDescriptor, | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package cmtservice_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cosmos/cosmos-sdk/server" | ||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" | ||
"github.com/cosmos/cosmos-sdk/testutil/network" | ||
) | ||
|
||
func TestStatusCommand(t *testing.T) { | ||
cfg, err := network.DefaultConfigWithAppConfig(network.MinimumAppConfig()) | ||
require.NoError(t, err) | ||
|
||
network, err := network.New(t, t.TempDir(), cfg) | ||
require.NoError(t, err) | ||
require.NoError(t, network.WaitForNextBlock()) | ||
|
||
val0 := network.Validators[0] | ||
cmd := server.StatusCommand() | ||
|
||
out, err := clitestutil.ExecTestCLICmd(val0.ClientCtx, cmd, []string{}) | ||
require.NoError(t, err) | ||
|
||
// Make sure the output has the validator moniker. | ||
require.Contains(t, out.String(), fmt.Sprintf("\"moniker\":\"%s\"", val0.Moniker)) | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package autocli | ||
|
||
var flagNoIndent = "no-indent" |
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
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.