-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: use autocli for comet commands #17389
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9c3b6d8
feat: use autocli for comet commands
julienrbrt 9348497
updates
julienrbrt 82f555b
updates
julienrbrt 6281f57
updates
julienrbrt a735ec8
updates
julienrbrt d361f45
Merge branch 'main' into julien/autocli-comet
julienrbrt 6d2459d
improvements
julienrbrt dbefcaa
updates
julienrbrt cd35433
consistency
julienrbrt ae171fe
updates
julienrbrt 341fb3d
updates
julienrbrt f42d52f
updates
julienrbrt d12790f
updates
julienrbrt 9446210
lint + tests
julienrbrt fa3d43e
simplify tests + doc
julienrbrt a7ad343
add docs and fix lint
julienrbrt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note, in the backport I'll leave this in. |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems confusing, can you add a godoc why this interface is met here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated at line 52, what do you think?
I'm planing to add docs on that as well.