Merge branch 'develop' into sunny/get_all_delegations_validator_querier
This commit is contained in:
commit
695395aca8
|
@ -5,6 +5,7 @@ BREAKING CHANGES
|
||||||
* Gaia REST API (`gaiacli advanced rest-server`)
|
* Gaia REST API (`gaiacli advanced rest-server`)
|
||||||
|
|
||||||
* Gaia CLI (`gaiacli`)
|
* Gaia CLI (`gaiacli`)
|
||||||
|
* [cli] [\#2728](https://github.com/cosmos/cosmos-sdk/pull/2728) Seperate `tx` and `query` subcommands by module
|
||||||
* [cli] [\#2727](https://github.com/cosmos/cosmos-sdk/pull/2727) Fix unbonding command flow
|
* [cli] [\#2727](https://github.com/cosmos/cosmos-sdk/pull/2727) Fix unbonding command flow
|
||||||
* [cli] [\#2786](https://github.com/cosmos/cosmos-sdk/pull/2786) Fix redelegation command flow
|
* [cli] [\#2786](https://github.com/cosmos/cosmos-sdk/pull/2786) Fix redelegation command flow
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ IMPROVEMENTS
|
||||||
* [\#2749](https://github.com/cosmos/cosmos-sdk/pull/2749) Add --chain-id flag to gaiad testnet
|
* [\#2749](https://github.com/cosmos/cosmos-sdk/pull/2749) Add --chain-id flag to gaiad testnet
|
||||||
|
|
||||||
* Gaia
|
* Gaia
|
||||||
|
- #2773 Require moniker to be provided on `gaiad init`.
|
||||||
- #2672 [Makefile] Updated for better Windows compatibility and ledger support logic, get_tools was rewritten as a cross-compatible Makefile.
|
- #2672 [Makefile] Updated for better Windows compatibility and ledger support logic, get_tools was rewritten as a cross-compatible Makefile.
|
||||||
|
|
||||||
* SDK
|
* SDK
|
||||||
|
|
|
@ -3,20 +3,20 @@ package client
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/types"
|
"github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
"github.com/pelletier/go-toml"
|
"github.com/pelletier/go-toml"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type cliConfig struct {
|
type cliConfig struct {
|
||||||
Home string `toml:"home"`
|
Home string `toml:"home"`
|
||||||
ChainID string `toml:"chain_id"`
|
ChainID string `toml:"chain_id"`
|
||||||
TrustNode bool `toml:"trust_node"`
|
TrustNode bool `toml:"trust_node"`
|
||||||
Encoding string `toml:"encoding"`
|
|
||||||
Output string `toml:"output"`
|
Output string `toml:"output"`
|
||||||
Node string `toml:"node"`
|
Node string `toml:"node"`
|
||||||
Trace bool `toml:"trace"`
|
Trace bool `toml:"trace"`
|
||||||
|
@ -41,23 +41,24 @@ func runConfigCmd(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
stdin := BufferStdin()
|
stdin := BufferStdin()
|
||||||
|
|
||||||
gaiaCLIHome, err := handleGaiaCLIHome(home, stdin)
|
gaiaCLIHome, err := handleGaiaCLIHome(home, stdin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
node, err := handleNode(stdin)
|
node, err := handleNode(stdin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
trustNode, err := handleTrustNode(stdin)
|
trustNode, err := handleTrustNode(stdin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
encoding := "btc"
|
chainID, err := types.DefaultChainID()
|
||||||
output := "text"
|
|
||||||
var chainID string
|
|
||||||
chainID, err = types.DefaultChainID()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Couldn't populate ChainID, so using an empty one.")
|
fmt.Println("Couldn't populate ChainID, so using an empty one.")
|
||||||
}
|
}
|
||||||
|
@ -66,8 +67,7 @@ func runConfigCmd(cmd *cobra.Command, args []string) error {
|
||||||
Home: gaiaCLIHome,
|
Home: gaiaCLIHome,
|
||||||
ChainID: chainID,
|
ChainID: chainID,
|
||||||
TrustNode: trustNode,
|
TrustNode: trustNode,
|
||||||
Encoding: encoding,
|
Output: "text",
|
||||||
Output: output,
|
|
||||||
Node: node,
|
Node: node,
|
||||||
Trace: false,
|
Trace: false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,15 +22,8 @@ func todoNotImplemented(_ *cobra.Command, _ []string) error {
|
||||||
return errors.New("todo: Command not yet implemented")
|
return errors.New("todo: Command not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddCommands adds a number of rpc-related subcommands
|
// InitClientCommand initializes client commands
|
||||||
func AddCommands(cmd *cobra.Command) {
|
func InitClientCommand() *cobra.Command {
|
||||||
cmd.AddCommand(
|
|
||||||
initClientCommand(),
|
|
||||||
statusCommand(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func initClientCommand() *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "init",
|
Use: "init",
|
||||||
Short: "Initialize light client",
|
Short: "Initialize light client",
|
||||||
|
|
|
@ -14,7 +14,8 @@ import (
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func statusCommand() *cobra.Command {
|
// StatusCommand returns the status of the network
|
||||||
|
func StatusCommand() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "status",
|
Use: "status",
|
||||||
Short: "Query remote node for status",
|
Short: "Query remote node for status",
|
||||||
|
|
|
@ -2,20 +2,11 @@ package tx
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddCommands adds a number of tx-query related subcommands
|
|
||||||
func AddCommands(cmd *cobra.Command, cdc *codec.Codec) {
|
|
||||||
cmd.AddCommand(
|
|
||||||
SearchTxCmd(cdc),
|
|
||||||
QueryTxCmd(cdc),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// register REST routes
|
// register REST routes
|
||||||
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec) {
|
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec) {
|
||||||
r.HandleFunc("/txs/{hash}", QueryTxRequestHandlerFn(cdc, cliCtx)).Methods("GET")
|
r.HandleFunc("/txs/{hash}", QueryTxRequestHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||||
|
|
|
@ -237,7 +237,7 @@ func TestGaiaCLICreateValidator(t *testing.T) {
|
||||||
initialPool.BondedTokens = initialPool.BondedTokens.Add(sdk.NewDec(100)) // Delegate tx on GaiaAppGenState
|
initialPool.BondedTokens = initialPool.BondedTokens.Add(sdk.NewDec(100)) // Delegate tx on GaiaAppGenState
|
||||||
|
|
||||||
// create validator
|
// create validator
|
||||||
cvStr := fmt.Sprintf("gaiacli tx create-validator %v", flags)
|
cvStr := fmt.Sprintf("gaiacli tx stake create-validator %v", flags)
|
||||||
cvStr += fmt.Sprintf(" --from=%s", "bar")
|
cvStr += fmt.Sprintf(" --from=%s", "bar")
|
||||||
cvStr += fmt.Sprintf(" --pubkey=%s", barCeshPubKey)
|
cvStr += fmt.Sprintf(" --pubkey=%s", barCeshPubKey)
|
||||||
cvStr += fmt.Sprintf(" --amount=%v", fmt.Sprintf("2%s", stakeTypes.DefaultBondDenom))
|
cvStr += fmt.Sprintf(" --amount=%v", fmt.Sprintf("2%s", stakeTypes.DefaultBondDenom))
|
||||||
|
@ -268,7 +268,7 @@ func TestGaiaCLICreateValidator(t *testing.T) {
|
||||||
barAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", barAddr, flags))
|
barAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", barAddr, flags))
|
||||||
require.Equal(t, int64(8), barAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64(), "%v", barAcc)
|
require.Equal(t, int64(8), barAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64(), "%v", barAcc)
|
||||||
|
|
||||||
validator := executeGetValidator(t, fmt.Sprintf("gaiacli query validator %s --output=json %v", sdk.ValAddress(barAddr), flags))
|
validator := executeGetValidator(t, fmt.Sprintf("gaiacli query stake validator %s --output=json %v", sdk.ValAddress(barAddr), flags))
|
||||||
require.Equal(t, validator.OperatorAddr, sdk.ValAddress(barAddr))
|
require.Equal(t, validator.OperatorAddr, sdk.ValAddress(barAddr))
|
||||||
require.True(sdk.DecEq(t, sdk.NewDec(2), validator.Tokens))
|
require.True(sdk.DecEq(t, sdk.NewDec(2), validator.Tokens))
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ func TestGaiaCLICreateValidator(t *testing.T) {
|
||||||
require.NotZero(t, validatorDelegations[0].Shares)
|
require.NotZero(t, validatorDelegations[0].Shares)
|
||||||
|
|
||||||
// unbond a single share
|
// unbond a single share
|
||||||
unbondStr := fmt.Sprintf("gaiacli tx unbond begin %v", flags)
|
unbondStr := fmt.Sprintf("gaiacli tx stake unbond begin %v", flags)
|
||||||
unbondStr += fmt.Sprintf(" --from=%s", "bar")
|
unbondStr += fmt.Sprintf(" --from=%s", "bar")
|
||||||
unbondStr += fmt.Sprintf(" --validator=%s", sdk.ValAddress(barAddr))
|
unbondStr += fmt.Sprintf(" --validator=%s", sdk.ValAddress(barAddr))
|
||||||
unbondStr += fmt.Sprintf(" --shares-amount=%v", "1")
|
unbondStr += fmt.Sprintf(" --shares-amount=%v", "1")
|
||||||
|
@ -290,19 +290,19 @@ func TestGaiaCLICreateValidator(t *testing.T) {
|
||||||
barAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %v %v", barCech, flags))
|
barAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %v %v", barCech, flags))
|
||||||
require.Equal(t, int64(9), barAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64(), "%v", barAcc)
|
require.Equal(t, int64(9), barAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64(), "%v", barAcc)
|
||||||
*/
|
*/
|
||||||
validator = executeGetValidator(t, fmt.Sprintf("gaiacli query validator %s --output=json %v", sdk.ValAddress(barAddr), flags))
|
validator = executeGetValidator(t, fmt.Sprintf("gaiacli query stake validator %s --output=json %v", sdk.ValAddress(barAddr), flags))
|
||||||
require.Equal(t, "1.0000000000", validator.Tokens.String())
|
require.Equal(t, "1.0000000000", validator.Tokens.String())
|
||||||
|
|
||||||
validatorUbds := executeGetValidatorUnbondingDelegations(t,
|
validatorUbds := executeGetValidatorUnbondingDelegations(t,
|
||||||
fmt.Sprintf("gaiacli query unbonding-delegations-from %s --output=json %v",
|
fmt.Sprintf("gaiacli query stake unbonding-delegations-from %s --output=json %v",
|
||||||
sdk.ValAddress(barAddr), flags))
|
sdk.ValAddress(barAddr), flags))
|
||||||
require.Len(t, validatorUbds, 1)
|
require.Len(t, validatorUbds, 1)
|
||||||
require.Equal(t, "1", validatorUbds[0].Balance.Amount.String())
|
require.Equal(t, "1", validatorUbds[0].Balance.Amount.String())
|
||||||
|
|
||||||
params := executeGetParams(t, fmt.Sprintf("gaiacli query parameters --output=json %v", flags))
|
params := executeGetParams(t, fmt.Sprintf("gaiacli query stake parameters --output=json %v", flags))
|
||||||
require.True(t, defaultParams.Equal(params))
|
require.True(t, defaultParams.Equal(params))
|
||||||
|
|
||||||
pool := executeGetPool(t, fmt.Sprintf("gaiacli query pool --output=json %v", flags))
|
pool := executeGetPool(t, fmt.Sprintf("gaiacli query stake pool --output=json %v", flags))
|
||||||
require.Equal(t, initialPool.BondedTokens, pool.BondedTokens)
|
require.Equal(t, initialPool.BondedTokens, pool.BondedTokens)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,11 +322,11 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
||||||
fooAcc := executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", fooAddr, flags))
|
fooAcc := executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", fooAddr, flags))
|
||||||
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
||||||
|
|
||||||
proposalsQuery, _ := tests.ExecuteT(t, fmt.Sprintf("gaiacli query proposals %v", flags), "")
|
proposalsQuery, _ := tests.ExecuteT(t, fmt.Sprintf("gaiacli query gov proposals %v", flags), "")
|
||||||
require.Equal(t, "No matching proposals found", proposalsQuery)
|
require.Equal(t, "No matching proposals found", proposalsQuery)
|
||||||
|
|
||||||
// submit a test proposal
|
// submit a test proposal
|
||||||
spStr := fmt.Sprintf("gaiacli tx submit-proposal %v", flags)
|
spStr := fmt.Sprintf("gaiacli tx gov submit-proposal %v", flags)
|
||||||
spStr += fmt.Sprintf(" --from=%s", "foo")
|
spStr += fmt.Sprintf(" --from=%s", "foo")
|
||||||
spStr += fmt.Sprintf(" --deposit=%s", fmt.Sprintf("5%s", stakeTypes.DefaultBondDenom))
|
spStr += fmt.Sprintf(" --deposit=%s", fmt.Sprintf("5%s", stakeTypes.DefaultBondDenom))
|
||||||
spStr += fmt.Sprintf(" --type=%s", "Text")
|
spStr += fmt.Sprintf(" --type=%s", "Text")
|
||||||
|
@ -353,19 +353,19 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
||||||
fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", fooAddr, flags))
|
fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", fooAddr, flags))
|
||||||
require.Equal(t, int64(45), fooAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
require.Equal(t, int64(45), fooAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
||||||
|
|
||||||
proposal1 := executeGetProposal(t, fmt.Sprintf("gaiacli query proposal --proposal-id=1 --output=json %v", flags))
|
proposal1 := executeGetProposal(t, fmt.Sprintf("gaiacli query gov proposal --proposal-id=1 --output=json %v", flags))
|
||||||
require.Equal(t, uint64(1), proposal1.GetProposalID())
|
require.Equal(t, uint64(1), proposal1.GetProposalID())
|
||||||
require.Equal(t, gov.StatusDepositPeriod, proposal1.GetStatus())
|
require.Equal(t, gov.StatusDepositPeriod, proposal1.GetStatus())
|
||||||
|
|
||||||
proposalsQuery, _ = tests.ExecuteT(t, fmt.Sprintf("gaiacli query proposals %v", flags), "")
|
proposalsQuery, _ = tests.ExecuteT(t, fmt.Sprintf("gaiacli query gov proposals %v", flags), "")
|
||||||
require.Equal(t, " 1 - Test", proposalsQuery)
|
require.Equal(t, " 1 - Test", proposalsQuery)
|
||||||
|
|
||||||
deposit := executeGetDeposit(t,
|
deposit := executeGetDeposit(t,
|
||||||
fmt.Sprintf("gaiacli query deposit --proposal-id=1 --depositer=%s --output=json %v",
|
fmt.Sprintf("gaiacli query gov deposit --proposal-id=1 --depositer=%s --output=json %v",
|
||||||
fooAddr, flags))
|
fooAddr, flags))
|
||||||
require.Equal(t, int64(5), deposit.Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
require.Equal(t, int64(5), deposit.Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
||||||
|
|
||||||
depositStr := fmt.Sprintf("gaiacli tx deposit %v", flags)
|
depositStr := fmt.Sprintf("gaiacli tx gov deposit %v", flags)
|
||||||
depositStr += fmt.Sprintf(" --from=%s", "foo")
|
depositStr += fmt.Sprintf(" --from=%s", "foo")
|
||||||
depositStr += fmt.Sprintf(" --deposit=%s", fmt.Sprintf("10%s", stakeTypes.DefaultBondDenom))
|
depositStr += fmt.Sprintf(" --deposit=%s", fmt.Sprintf("10%s", stakeTypes.DefaultBondDenom))
|
||||||
depositStr += fmt.Sprintf(" --proposal-id=%s", "1")
|
depositStr += fmt.Sprintf(" --proposal-id=%s", "1")
|
||||||
|
@ -385,22 +385,23 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
||||||
|
|
||||||
// test query deposit
|
// test query deposit
|
||||||
deposits := executeGetDeposits(t,
|
deposits := executeGetDeposits(t,
|
||||||
fmt.Sprintf("gaiacli query deposits --proposal-id=1 --output=json %v", flags))
|
fmt.Sprintf("gaiacli query gov deposits --proposal-id=1 --output=json %v", flags))
|
||||||
require.Len(t, deposits, 1)
|
require.Len(t, deposits, 1)
|
||||||
require.Equal(t, int64(15), deposits[0].Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
require.Equal(t, int64(15), deposits[0].Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
||||||
|
|
||||||
deposit = executeGetDeposit(t,
|
deposit = executeGetDeposit(t,
|
||||||
fmt.Sprintf("gaiacli query deposit --proposal-id=1 --depositer=%s --output=json %v",
|
fmt.Sprintf("gaiacli query gov deposit --proposal-id=1 --depositer=%s --output=json %v",
|
||||||
fooAddr, flags))
|
fooAddr, flags))
|
||||||
require.Equal(t, int64(15), deposit.Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
require.Equal(t, int64(15), deposit.Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
||||||
|
|
||||||
fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", fooAddr, flags))
|
fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", fooAddr, flags))
|
||||||
|
|
||||||
require.Equal(t, int64(35), fooAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
require.Equal(t, int64(35), fooAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64())
|
||||||
proposal1 = executeGetProposal(t, fmt.Sprintf("gaiacli query proposal --proposal-id=1 --output=json %v", flags))
|
proposal1 = executeGetProposal(t, fmt.Sprintf("gaiacli query gov proposal --proposal-id=1 --output=json %v", flags))
|
||||||
require.Equal(t, uint64(1), proposal1.GetProposalID())
|
require.Equal(t, uint64(1), proposal1.GetProposalID())
|
||||||
require.Equal(t, gov.StatusVotingPeriod, proposal1.GetStatus())
|
require.Equal(t, gov.StatusVotingPeriod, proposal1.GetStatus())
|
||||||
|
|
||||||
voteStr := fmt.Sprintf("gaiacli tx vote %v", flags)
|
voteStr := fmt.Sprintf("gaiacli tx gov vote %v", flags)
|
||||||
voteStr += fmt.Sprintf(" --from=%s", "foo")
|
voteStr += fmt.Sprintf(" --from=%s", "foo")
|
||||||
voteStr += fmt.Sprintf(" --proposal-id=%s", "1")
|
voteStr += fmt.Sprintf(" --proposal-id=%s", "1")
|
||||||
voteStr += fmt.Sprintf(" --option=%s", "Yes")
|
voteStr += fmt.Sprintf(" --option=%s", "Yes")
|
||||||
|
@ -418,23 +419,23 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
||||||
executeWrite(t, voteStr, app.DefaultKeyPass)
|
executeWrite(t, voteStr, app.DefaultKeyPass)
|
||||||
tests.WaitForNextNBlocksTM(2, port)
|
tests.WaitForNextNBlocksTM(2, port)
|
||||||
|
|
||||||
vote := executeGetVote(t, fmt.Sprintf("gaiacli query vote --proposal-id=1 --voter=%s --output=json %v", fooAddr, flags))
|
vote := executeGetVote(t, fmt.Sprintf("gaiacli query gov vote --proposal-id=1 --voter=%s --output=json %v", fooAddr, flags))
|
||||||
require.Equal(t, uint64(1), vote.ProposalID)
|
require.Equal(t, uint64(1), vote.ProposalID)
|
||||||
require.Equal(t, gov.OptionYes, vote.Option)
|
require.Equal(t, gov.OptionYes, vote.Option)
|
||||||
|
|
||||||
votes := executeGetVotes(t, fmt.Sprintf("gaiacli query votes --proposal-id=1 --output=json %v", flags))
|
votes := executeGetVotes(t, fmt.Sprintf("gaiacli query gov votes --proposal-id=1 --output=json %v", flags))
|
||||||
require.Len(t, votes, 1)
|
require.Len(t, votes, 1)
|
||||||
require.Equal(t, uint64(1), votes[0].ProposalID)
|
require.Equal(t, uint64(1), votes[0].ProposalID)
|
||||||
require.Equal(t, gov.OptionYes, votes[0].Option)
|
require.Equal(t, gov.OptionYes, votes[0].Option)
|
||||||
|
|
||||||
proposalsQuery, _ = tests.ExecuteT(t, fmt.Sprintf("gaiacli query proposals --status=DepositPeriod %v", flags), "")
|
proposalsQuery, _ = tests.ExecuteT(t, fmt.Sprintf("gaiacli query gov proposals --status=DepositPeriod %v", flags), "")
|
||||||
require.Equal(t, "No matching proposals found", proposalsQuery)
|
require.Equal(t, "No matching proposals found", proposalsQuery)
|
||||||
|
|
||||||
proposalsQuery, _ = tests.ExecuteT(t, fmt.Sprintf("gaiacli query proposals --status=VotingPeriod %v", flags), "")
|
proposalsQuery, _ = tests.ExecuteT(t, fmt.Sprintf("gaiacli query gov proposals --status=VotingPeriod %v", flags), "")
|
||||||
require.Equal(t, " 1 - Test", proposalsQuery)
|
require.Equal(t, " 1 - Test", proposalsQuery)
|
||||||
|
|
||||||
// submit a second test proposal
|
// submit a second test proposal
|
||||||
spStr = fmt.Sprintf("gaiacli tx submit-proposal %v", flags)
|
spStr = fmt.Sprintf("gaiacli tx gov submit-proposal %v", flags)
|
||||||
spStr += fmt.Sprintf(" --from=%s", "foo")
|
spStr += fmt.Sprintf(" --from=%s", "foo")
|
||||||
spStr += fmt.Sprintf(" --deposit=%s", fmt.Sprintf("5%s", stakeTypes.DefaultBondDenom))
|
spStr += fmt.Sprintf(" --deposit=%s", fmt.Sprintf("5%s", stakeTypes.DefaultBondDenom))
|
||||||
spStr += fmt.Sprintf(" --type=%s", "Text")
|
spStr += fmt.Sprintf(" --type=%s", "Text")
|
||||||
|
@ -444,7 +445,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
||||||
executeWrite(t, spStr, app.DefaultKeyPass)
|
executeWrite(t, spStr, app.DefaultKeyPass)
|
||||||
tests.WaitForNextNBlocksTM(2, port)
|
tests.WaitForNextNBlocksTM(2, port)
|
||||||
|
|
||||||
proposalsQuery, _ = tests.ExecuteT(t, fmt.Sprintf("gaiacli query proposals --limit=1 %v", flags), "")
|
proposalsQuery, _ = tests.ExecuteT(t, fmt.Sprintf("gaiacli query gov proposals --limit=1 %v", flags), "")
|
||||||
require.Equal(t, " 2 - Apples", proposalsQuery)
|
require.Equal(t, " 2 - Apples", proposalsQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,7 +558,6 @@ func TestGaiaCLIConfig(t *testing.T) {
|
||||||
config, err := ioutil.ReadFile(path.Join(gaiacliHome, "config", "config.toml"))
|
config, err := ioutil.ReadFile(path.Join(gaiacliHome, "config", "config.toml"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expectedConfig := fmt.Sprintf(`chain_id = "%s"
|
expectedConfig := fmt.Sprintf(`chain_id = "%s"
|
||||||
encoding = "btc"
|
|
||||||
home = "%s"
|
home = "%s"
|
||||||
node = "%s"
|
node = "%s"
|
||||||
output = "text"
|
output = "text"
|
||||||
|
@ -576,7 +576,6 @@ trust_node = true
|
||||||
|
|
||||||
// ensure it works without an initialized gaiad state
|
// ensure it works without an initialized gaiad state
|
||||||
expectedConfig = fmt.Sprintf(`chain_id = ""
|
expectedConfig = fmt.Sprintf(`chain_id = ""
|
||||||
encoding = "btc"
|
|
||||||
home = "%s"
|
home = "%s"
|
||||||
node = "%s"
|
node = "%s"
|
||||||
output = "text"
|
output = "text"
|
||||||
|
|
|
@ -13,18 +13,10 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/client/keys"
|
"github.com/cosmos/cosmos-sdk/client/keys"
|
||||||
"github.com/cosmos/cosmos-sdk/client/lcd"
|
"github.com/cosmos/cosmos-sdk/client/lcd"
|
||||||
"github.com/cosmos/cosmos-sdk/client/rpc"
|
"github.com/cosmos/cosmos-sdk/client/rpc"
|
||||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
|
||||||
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
|
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/version"
|
"github.com/cosmos/cosmos-sdk/version"
|
||||||
|
|
||||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
|
||||||
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
|
||||||
distrcmd "github.com/cosmos/cosmos-sdk/x/distribution/client/cli"
|
|
||||||
govcmd "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
|
||||||
slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
|
|
||||||
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli"
|
|
||||||
|
|
||||||
_ "github.com/cosmos/cosmos-sdk/client/lcd/statik"
|
_ "github.com/cosmos/cosmos-sdk/client/lcd/statik"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,7 +32,7 @@ const (
|
||||||
var (
|
var (
|
||||||
rootCmd = &cobra.Command{
|
rootCmd = &cobra.Command{
|
||||||
Use: "gaiacli",
|
Use: "gaiacli",
|
||||||
Short: "Gaia light-client",
|
Short: "Command line interface for interacting with gaiad",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -57,91 +49,23 @@ func main() {
|
||||||
// TODO: setup keybase, viper object, etc. to be passed into
|
// TODO: setup keybase, viper object, etc. to be passed into
|
||||||
// the below functions and eliminate global vars, like we do
|
// the below functions and eliminate global vars, like we do
|
||||||
// with the cdc
|
// with the cdc
|
||||||
rootCmd.AddCommand(client.ConfigCmd())
|
|
||||||
|
|
||||||
// add standard rpc commands
|
// Construct Root Command
|
||||||
rpc.AddCommands(rootCmd)
|
|
||||||
|
|
||||||
//Add query commands
|
|
||||||
queryCmd := &cobra.Command{
|
|
||||||
Use: "query",
|
|
||||||
Aliases: []string{"q"},
|
|
||||||
Short: "Querying subcommands",
|
|
||||||
}
|
|
||||||
queryCmd.AddCommand(
|
|
||||||
rpc.BlockCommand(),
|
|
||||||
rpc.ValidatorCommand(),
|
|
||||||
)
|
|
||||||
tx.AddCommands(queryCmd, cdc)
|
|
||||||
queryCmd.AddCommand(client.LineBreak)
|
|
||||||
queryCmd.AddCommand(client.GetCommands(
|
|
||||||
authcmd.GetAccountCmd(storeAcc, cdc, authcmd.GetAccountDecoder(cdc)),
|
|
||||||
stakecmd.GetCmdQueryDelegation(storeStake, cdc),
|
|
||||||
stakecmd.GetCmdQueryDelegations(storeStake, cdc),
|
|
||||||
stakecmd.GetCmdQueryUnbondingDelegation(storeStake, cdc),
|
|
||||||
stakecmd.GetCmdQueryUnbondingDelegations(storeStake, cdc),
|
|
||||||
stakecmd.GetCmdQueryRedelegation(storeStake, cdc),
|
|
||||||
stakecmd.GetCmdQueryRedelegations(storeStake, cdc),
|
|
||||||
stakecmd.GetCmdQueryValidator(storeStake, cdc),
|
|
||||||
stakecmd.GetCmdQueryValidators(storeStake, cdc),
|
|
||||||
stakecmd.GetCmdQueryValidatorDelegations(queryRouteStake, cdc),
|
|
||||||
stakecmd.GetCmdQueryValidatorUnbondingDelegations(queryRouteStake, cdc),
|
|
||||||
stakecmd.GetCmdQueryValidatorRedelegations(queryRouteStake, cdc),
|
|
||||||
stakecmd.GetCmdQueryParams(storeStake, cdc),
|
|
||||||
stakecmd.GetCmdQueryPool(storeStake, cdc),
|
|
||||||
govcmd.GetCmdQueryProposal(storeGov, cdc),
|
|
||||||
govcmd.GetCmdQueryProposals(storeGov, cdc),
|
|
||||||
govcmd.GetCmdQueryVote(storeGov, cdc),
|
|
||||||
govcmd.GetCmdQueryVotes(storeGov, cdc),
|
|
||||||
govcmd.GetCmdQueryDeposit(storeGov, cdc),
|
|
||||||
govcmd.GetCmdQueryDeposits(storeGov, cdc),
|
|
||||||
slashingcmd.GetCmdQuerySigningInfo(storeSlashing, cdc),
|
|
||||||
)...)
|
|
||||||
|
|
||||||
//Add query commands
|
|
||||||
txCmd := &cobra.Command{
|
|
||||||
Use: "tx",
|
|
||||||
Short: "Transactions subcommands",
|
|
||||||
}
|
|
||||||
|
|
||||||
//Add auth and bank commands
|
|
||||||
txCmd.AddCommand(
|
|
||||||
client.PostCommands(
|
|
||||||
bankcmd.GetBroadcastCommand(cdc),
|
|
||||||
authcmd.GetSignCommand(cdc, authcmd.GetAccountDecoder(cdc)),
|
|
||||||
)...)
|
|
||||||
txCmd.AddCommand(client.LineBreak)
|
|
||||||
|
|
||||||
txCmd.AddCommand(
|
|
||||||
client.PostCommands(
|
|
||||||
stakecmd.GetCmdCreateValidator(cdc),
|
|
||||||
stakecmd.GetCmdEditValidator(cdc),
|
|
||||||
stakecmd.GetCmdDelegate(cdc),
|
|
||||||
stakecmd.GetCmdRedelegate(storeStake, cdc),
|
|
||||||
stakecmd.GetCmdUnbond(storeStake, cdc),
|
|
||||||
distrcmd.GetCmdWithdrawRewards(cdc),
|
|
||||||
distrcmd.GetCmdSetWithdrawAddr(cdc),
|
|
||||||
govcmd.GetCmdDeposit(cdc),
|
|
||||||
bankcmd.SendTxCmd(cdc),
|
|
||||||
govcmd.GetCmdSubmitProposal(cdc),
|
|
||||||
slashingcmd.GetCmdUnjail(cdc),
|
|
||||||
govcmd.GetCmdVote(cdc),
|
|
||||||
)...)
|
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
queryCmd,
|
rpc.InitClientCommand(),
|
||||||
txCmd,
|
rpc.StatusCommand(),
|
||||||
|
client.ConfigCmd(),
|
||||||
|
queryCmd(cdc),
|
||||||
|
txCmd(cdc),
|
||||||
|
client.LineBreak,
|
||||||
lcd.ServeCommand(cdc),
|
lcd.ServeCommand(cdc),
|
||||||
client.LineBreak,
|
client.LineBreak,
|
||||||
)
|
|
||||||
|
|
||||||
// add proxy, version and key info
|
|
||||||
rootCmd.AddCommand(
|
|
||||||
keys.Commands(),
|
keys.Commands(),
|
||||||
client.LineBreak,
|
client.LineBreak,
|
||||||
version.VersionCmd,
|
version.VersionCmd,
|
||||||
)
|
)
|
||||||
|
|
||||||
// prepare and add flags
|
// Add flags and prefix all env exposed with GA
|
||||||
executor := cli.PrepareMainCmd(rootCmd, "GA", app.DefaultCLIHome)
|
executor := cli.PrepareMainCmd(rootCmd, "GA", app.DefaultCLIHome)
|
||||||
err := initConfig(rootCmd)
|
err := initConfig(rootCmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/rpc"
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
|
govcmd "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||||
|
slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
|
||||||
|
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli"
|
||||||
|
amino "github.com/tendermint/go-amino"
|
||||||
|
)
|
||||||
|
|
||||||
|
func queryCmd(cdc *amino.Codec) *cobra.Command {
|
||||||
|
//Add query commands
|
||||||
|
queryCmd := &cobra.Command{
|
||||||
|
Use: "query",
|
||||||
|
Aliases: []string{"q"},
|
||||||
|
Short: "Querying subcommands",
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group staking queries under a subcommand
|
||||||
|
stakeQueryCmd := &cobra.Command{
|
||||||
|
Use: "stake",
|
||||||
|
Short: "Querying commands for the staking module",
|
||||||
|
}
|
||||||
|
|
||||||
|
stakeQueryCmd.AddCommand(client.GetCommands(
|
||||||
|
stakecmd.GetCmdQueryDelegation(storeStake, cdc),
|
||||||
|
stakecmd.GetCmdQueryDelegations(storeStake, cdc),
|
||||||
|
stakecmd.GetCmdQueryUnbondingDelegation(storeStake, cdc),
|
||||||
|
stakecmd.GetCmdQueryUnbondingDelegations(storeStake, cdc),
|
||||||
|
stakecmd.GetCmdQueryRedelegation(storeStake, cdc),
|
||||||
|
stakecmd.GetCmdQueryRedelegations(storeStake, cdc),
|
||||||
|
stakecmd.GetCmdQueryValidator(storeStake, cdc),
|
||||||
|
stakecmd.GetCmdQueryValidators(storeStake, cdc),
|
||||||
|
stakecmd.GetCmdQueryValidatorUnbondingDelegations(queryRouteStake, cdc),
|
||||||
|
stakecmd.GetCmdQueryValidatorRedelegations(queryRouteStake, cdc),
|
||||||
|
stakecmd.GetCmdQueryParams(storeStake, cdc),
|
||||||
|
stakecmd.GetCmdQueryPool(storeStake, cdc))...)
|
||||||
|
|
||||||
|
// Group gov queries under a subcommand
|
||||||
|
govQueryCmd := &cobra.Command{
|
||||||
|
Use: "gov",
|
||||||
|
Short: "Querying commands for the governance module",
|
||||||
|
}
|
||||||
|
|
||||||
|
govQueryCmd.AddCommand(client.GetCommands(
|
||||||
|
govcmd.GetCmdQueryProposal(storeGov, cdc),
|
||||||
|
govcmd.GetCmdQueryProposals(storeGov, cdc),
|
||||||
|
govcmd.GetCmdQueryVote(storeGov, cdc),
|
||||||
|
govcmd.GetCmdQueryVotes(storeGov, cdc),
|
||||||
|
govcmd.GetCmdQueryDeposit(storeGov, cdc),
|
||||||
|
govcmd.GetCmdQueryDeposits(storeGov, cdc))...)
|
||||||
|
|
||||||
|
// Group slashing queries under a subcommand
|
||||||
|
slashingQueryCmd := &cobra.Command{
|
||||||
|
Use: "slashing",
|
||||||
|
Short: "Querying commands for the slashing module",
|
||||||
|
}
|
||||||
|
|
||||||
|
slashingQueryCmd.AddCommand(client.GetCommands(
|
||||||
|
slashingcmd.GetCmdQuerySigningInfo(storeSlashing, cdc))...)
|
||||||
|
|
||||||
|
// Query commcmmand structure
|
||||||
|
queryCmd.AddCommand(
|
||||||
|
rpc.BlockCommand(),
|
||||||
|
rpc.ValidatorCommand(),
|
||||||
|
tx.SearchTxCmd(cdc),
|
||||||
|
tx.QueryTxCmd(cdc),
|
||||||
|
client.LineBreak,
|
||||||
|
client.GetCommands(authcmd.GetAccountCmd(storeAcc, cdc, authcmd.GetAccountDecoder(cdc)))[0],
|
||||||
|
stakeQueryCmd,
|
||||||
|
govQueryCmd,
|
||||||
|
slashingQueryCmd,
|
||||||
|
)
|
||||||
|
|
||||||
|
return queryCmd
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
|
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
||||||
|
distrcmd "github.com/cosmos/cosmos-sdk/x/distribution/client/cli"
|
||||||
|
govcmd "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||||
|
slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
|
||||||
|
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli"
|
||||||
|
amino "github.com/tendermint/go-amino"
|
||||||
|
)
|
||||||
|
|
||||||
|
func txCmd(cdc *amino.Codec) *cobra.Command {
|
||||||
|
//Add transaction generation commands
|
||||||
|
txCmd := &cobra.Command{
|
||||||
|
Use: "tx",
|
||||||
|
Short: "Transactions subcommands",
|
||||||
|
}
|
||||||
|
|
||||||
|
stakeTxCmd := &cobra.Command{
|
||||||
|
Use: "stake",
|
||||||
|
Short: "Staking transaction subcommands",
|
||||||
|
}
|
||||||
|
|
||||||
|
stakeTxCmd.AddCommand(client.PostCommands(
|
||||||
|
stakecmd.GetCmdCreateValidator(cdc),
|
||||||
|
stakecmd.GetCmdEditValidator(cdc),
|
||||||
|
stakecmd.GetCmdDelegate(cdc),
|
||||||
|
stakecmd.GetCmdRedelegate(storeStake, cdc),
|
||||||
|
stakecmd.GetCmdUnbond(storeStake, cdc),
|
||||||
|
)...)
|
||||||
|
|
||||||
|
distTxCmd := &cobra.Command{
|
||||||
|
Use: "dist",
|
||||||
|
Short: "Distribution transactions subcommands",
|
||||||
|
}
|
||||||
|
|
||||||
|
distTxCmd.AddCommand(client.PostCommands(
|
||||||
|
distrcmd.GetCmdWithdrawRewards(cdc),
|
||||||
|
distrcmd.GetCmdSetWithdrawAddr(cdc),
|
||||||
|
)...)
|
||||||
|
|
||||||
|
govTxCmd := &cobra.Command{
|
||||||
|
Use: "gov",
|
||||||
|
Short: "Governance transactions subcommands",
|
||||||
|
}
|
||||||
|
|
||||||
|
govTxCmd.AddCommand(client.PostCommands(
|
||||||
|
govcmd.GetCmdDeposit(cdc),
|
||||||
|
govcmd.GetCmdVote(cdc),
|
||||||
|
govcmd.GetCmdSubmitProposal(cdc),
|
||||||
|
)...)
|
||||||
|
|
||||||
|
slashingTxCmd := &cobra.Command{
|
||||||
|
Use: "slashing",
|
||||||
|
Short: "Slashing transactions subcommands",
|
||||||
|
}
|
||||||
|
|
||||||
|
slashingTxCmd.AddCommand(client.PostCommands(
|
||||||
|
slashingcmd.GetCmdUnjail(cdc),
|
||||||
|
)...)
|
||||||
|
|
||||||
|
txCmd.AddCommand(
|
||||||
|
//Add auth and bank commands
|
||||||
|
client.PostCommands(
|
||||||
|
bankcmd.SendTxCmd(cdc),
|
||||||
|
bankcmd.GetBroadcastCommand(cdc),
|
||||||
|
authcmd.GetSignCommand(cdc, authcmd.GetAccountDecoder(cdc)),
|
||||||
|
)...)
|
||||||
|
|
||||||
|
txCmd.AddCommand(
|
||||||
|
client.LineBreak,
|
||||||
|
stakeTxCmd,
|
||||||
|
distTxCmd,
|
||||||
|
govTxCmd,
|
||||||
|
slashingTxCmd,
|
||||||
|
)
|
||||||
|
|
||||||
|
return txCmd
|
||||||
|
}
|
|
@ -51,25 +51,27 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec, appInit server.AppInit) *cob
|
||||||
RunE: func(_ *cobra.Command, _ []string) error {
|
RunE: func(_ *cobra.Command, _ []string) error {
|
||||||
config := ctx.Config
|
config := ctx.Config
|
||||||
config.SetRoot(viper.GetString(cli.HomeFlag))
|
config.SetRoot(viper.GetString(cli.HomeFlag))
|
||||||
|
|
||||||
chainID := viper.GetString(client.FlagChainID)
|
chainID := viper.GetString(client.FlagChainID)
|
||||||
if chainID == "" {
|
if chainID == "" {
|
||||||
chainID = fmt.Sprintf("test-chain-%v", common.RandStr(6))
|
chainID = fmt.Sprintf("test-chain-%v", common.RandStr(6))
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeID, _, err := InitializeNodeValidatorFiles(config)
|
nodeID, _, err := InitializeNodeValidatorFiles(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if viper.GetString(flagMoniker) != "" {
|
config.Moniker = viper.GetString(flagMoniker)
|
||||||
config.Moniker = viper.GetString(flagMoniker)
|
|
||||||
}
|
|
||||||
|
|
||||||
var appState json.RawMessage
|
var appState json.RawMessage
|
||||||
genFile := config.GenesisFile()
|
genFile := config.GenesisFile()
|
||||||
|
|
||||||
if appState, err = initializeEmptyGenesis(cdc, genFile, chainID,
|
if appState, err = initializeEmptyGenesis(cdc, genFile, chainID,
|
||||||
viper.GetBool(flagOverwrite)); err != nil {
|
viper.GetBool(flagOverwrite)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = ExportGenesisFile(genFile, chainID, nil, appState); err != nil {
|
if err = ExportGenesisFile(genFile, chainID, nil, appState); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -91,5 +93,7 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec, appInit server.AppInit) *cob
|
||||||
cmd.Flags().BoolP(flagOverwrite, "o", false, "overwrite the genesis.json file")
|
cmd.Flags().BoolP(flagOverwrite, "o", false, "overwrite the genesis.json file")
|
||||||
cmd.Flags().String(client.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
|
cmd.Flags().String(client.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
|
||||||
cmd.Flags().String(flagMoniker, "", "set the validator's moniker")
|
cmd.Flags().String(flagMoniker, "", "set the validator's moniker")
|
||||||
|
cmd.MarkFlagRequired(flagMoniker)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,16 @@ package init
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
|
||||||
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
|
|
||||||
"github.com/tendermint/tendermint/libs/cli"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
|
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
|
||||||
|
"github.com/tendermint/tendermint/libs/cli"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
"github.com/cosmos/cosmos-sdk/server/mock"
|
"github.com/cosmos/cosmos-sdk/server/mock"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -28,12 +29,16 @@ func TestInitCmd(t *testing.T) {
|
||||||
logger := log.NewNopLogger()
|
logger := log.NewNopLogger()
|
||||||
cfg, err := tcmd.ParseConfig()
|
cfg, err := tcmd.ParseConfig()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
ctx := server.NewContext(cfg, logger)
|
ctx := server.NewContext(cfg, logger)
|
||||||
cdc := app.MakeCodec()
|
cdc := app.MakeCodec()
|
||||||
appInit := server.AppInit{
|
appInit := server.AppInit{
|
||||||
AppGenState: mock.AppGenState,
|
AppGenState: mock.AppGenState,
|
||||||
}
|
}
|
||||||
cmd := InitCmd(ctx, cdc, appInit)
|
cmd := InitCmd(ctx, cdc, appInit)
|
||||||
|
|
||||||
|
viper.Set(flagMoniker, "gaianode-test")
|
||||||
|
|
||||||
err = cmd.RunE(nil, nil)
|
err = cmd.RunE(nil, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
@ -53,14 +58,19 @@ func setupClientHome(t *testing.T) func() {
|
||||||
func TestEmptyState(t *testing.T) {
|
func TestEmptyState(t *testing.T) {
|
||||||
defer server.SetupViper(t)()
|
defer server.SetupViper(t)()
|
||||||
defer setupClientHome(t)()
|
defer setupClientHome(t)()
|
||||||
|
|
||||||
logger := log.NewNopLogger()
|
logger := log.NewNopLogger()
|
||||||
cfg, err := tcmd.ParseConfig()
|
cfg, err := tcmd.ParseConfig()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
ctx := server.NewContext(cfg, logger)
|
ctx := server.NewContext(cfg, logger)
|
||||||
cdc := app.MakeCodec()
|
cdc := app.MakeCodec()
|
||||||
appInit := server.AppInit{
|
appInit := server.AppInit{
|
||||||
AppGenState: mock.AppGenStateEmpty,
|
AppGenState: mock.AppGenStateEmpty,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viper.Set(flagMoniker, "gaianode-test")
|
||||||
|
|
||||||
cmd := InitCmd(ctx, cdc, appInit)
|
cmd := InitCmd(ctx, cdc, appInit)
|
||||||
err = cmd.RunE(nil, nil)
|
err = cmd.RunE(nil, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -69,6 +79,7 @@ func TestEmptyState(t *testing.T) {
|
||||||
r, w, _ := os.Pipe()
|
r, w, _ := os.Pipe()
|
||||||
os.Stdout = w
|
os.Stdout = w
|
||||||
cmd = server.ExportCmd(ctx, cdc, nil)
|
cmd = server.ExportCmd(ctx, cdc, nil)
|
||||||
|
|
||||||
err = cmd.RunE(nil, nil)
|
err = cmd.RunE(nil, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,14 @@ func main() {
|
||||||
// with the cdc.
|
// with the cdc.
|
||||||
|
|
||||||
// add standard rpc, and tx commands
|
// add standard rpc, and tx commands
|
||||||
rpc.AddCommands(rootCmd)
|
rootCmd.AddCommand(
|
||||||
rootCmd.AddCommand(client.LineBreak)
|
rpc.InitClientCommand(),
|
||||||
tx.AddCommands(rootCmd, cdc)
|
rpc.StatusCommand(),
|
||||||
rootCmd.AddCommand(client.LineBreak)
|
client.LineBreak,
|
||||||
|
tx.SearchTxCmd(cdc),
|
||||||
|
tx.QueryTxCmd(cdc),
|
||||||
|
client.LineBreak,
|
||||||
|
)
|
||||||
|
|
||||||
// add query/post commands (custom to binary)
|
// add query/post commands (custom to binary)
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
|
|
|
@ -52,10 +52,15 @@ func main() {
|
||||||
// with the cdc
|
// with the cdc
|
||||||
|
|
||||||
// add standard rpc, and tx commands
|
// add standard rpc, and tx commands
|
||||||
rpc.AddCommands(rootCmd)
|
|
||||||
rootCmd.AddCommand(client.LineBreak)
|
rootCmd.AddCommand(
|
||||||
tx.AddCommands(rootCmd, cdc)
|
rpc.InitClientCommand(),
|
||||||
rootCmd.AddCommand(client.LineBreak)
|
rpc.StatusCommand(),
|
||||||
|
client.LineBreak,
|
||||||
|
tx.SearchTxCmd(cdc),
|
||||||
|
tx.QueryTxCmd(cdc),
|
||||||
|
client.LineBreak,
|
||||||
|
)
|
||||||
|
|
||||||
// add query/post commands (custom to binary)
|
// add query/post commands (custom to binary)
|
||||||
// start with commands common to basecoin
|
// start with commands common to basecoin
|
||||||
|
|
Loading…
Reference in New Issue