Skip to content

Commit

Permalink
feat(mint): add autocli config for mint (#16640)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeancarloBarrios authored Jun 22, 2023
1 parent c63d5fa commit 854978f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 439 deletions.
113 changes: 0 additions & 113 deletions tests/e2e/mint/suite.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package mint

import (
"fmt"
"strings"

"github.com/stretchr/testify/suite"

"github.com/cosmos/cosmos-sdk/client/flags"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/mint/client/cli"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)

Expand Down Expand Up @@ -53,110 +47,3 @@ func (s *E2ETestSuite) TearDownSuite() {
s.T().Log("tearing down e2e test suite")
s.network.Cleanup()
}

func (s *E2ETestSuite) TestGetCmdQueryParams() {
val := s.network.Validators[0]

testCases := []struct {
name string
args []string
expectedOutput string
}{
{
"json output",
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
`{"mint_denom":"stake","inflation_rate_change":"0.130000000000000000","inflation_max":"1.000000000000000000","inflation_min":"1.000000000000000000","goal_bonded":"0.670000000000000000","blocks_per_year":"6311520"}`,
},
{
"text output",
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", flags.FlagOutput)},
`blocks_per_year: "6311520"
goal_bonded: "0.670000000000000000"
inflation_max: "1.000000000000000000"
inflation_min: "1.000000000000000000"
inflation_rate_change: "0.130000000000000000"
mint_denom: stake`,
},
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetCmdQueryParams()
clientCtx := val.ClientCtx

out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
s.Require().NoError(err)
s.Require().Equal(tc.expectedOutput, strings.TrimSpace(out.String()))
})
}
}

func (s *E2ETestSuite) TestGetCmdQueryInflation() {
val := s.network.Validators[0]

testCases := []struct {
name string
args []string
expectedOutput string
}{
{
"json output",
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
`1.000000000000000000`,
},
{
"text output",
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", flags.FlagOutput)},
`1.000000000000000000`,
},
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetCmdQueryInflation()
clientCtx := val.ClientCtx

out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
s.Require().NoError(err)
s.Require().Equal(tc.expectedOutput, strings.TrimSpace(out.String()))
})
}
}

func (s *E2ETestSuite) TestGetCmdQueryAnnualProvisions() {
val := s.network.Validators[0]

testCases := []struct {
name string
args []string
expectedOutput string
}{
{
"json output",
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
`500000000.000000000000000000`,
},
{
"text output",
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", flags.FlagOutput)},
`500000000.000000000000000000`,
},
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetCmdQueryAnnualProvisions()
clientCtx := val.ClientCtx

out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
s.Require().NoError(err)
s.Require().Equal(tc.expectedOutput, strings.TrimSpace(out.String()))
})
}
}
34 changes: 34 additions & 0 deletions x/mint/autocli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package mint

import (
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
mintv1beta1 "cosmossdk.io/api/cosmos/mint/v1beta1"
)

func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
return &autocliv1.ModuleOptions{
Query: &autocliv1.ServiceCommandDescriptor{
Service: mintv1beta1.Query_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "Params",
Use: "params",
Short: "Query the current minting parameters",
},
{
RpcMethod: "Inflation",
Use: "inflation",
Short: "Query the current minting inflation value",
},
{
RpcMethod: "AnnualProvisions",
Use: "annual-provisions",
Short: "Query the current minting annual provisions value",
},
},
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: mintv1beta1.Query_ServiceDesc.ServiceName,
},
}
}
117 changes: 0 additions & 117 deletions x/mint/client/cli/query.go

This file was deleted.

Loading

0 comments on commit 854978f

Please sign in to comment.