fix cmd/bascoin/commands/init old flags

This commit is contained in:
rigel rozanski 2017-07-05 07:08:56 -04:00
parent 5044032a23
commit 35845a958f
2 changed files with 8 additions and 10 deletions

View File

@ -7,6 +7,7 @@ import (
"path"
"github.com/spf13/cobra"
"github.com/spf13/viper"
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
)
@ -18,16 +19,13 @@ var InitCmd = &cobra.Command{
RunE: initCmd,
}
//flags
//nolint - flags
var (
flagChainID string
FlagChainID = "chain-id" //TODO group with other flags or remove? is this already a flag here?
)
func init() {
flags := []Flag2Register{
{&flagChainID, "chain-id", "test_chain_id", "Chain ID"},
}
RegisterFlags(InitCmd, flags)
InitCmd.Flags().String(FlagChainID, "test_chain_id", "Chain ID")
}
// returns 1 iff it set a file, otherwise 0 (so we can add them)
@ -60,7 +58,7 @@ func initCmd(cmd *cobra.Command, args []string) error {
privValFile := cfg.PrivValidatorFile()
keyFile := path.Join(cfg.RootDir, "key.json")
mod1, err := setupFile(genesisFile, GetGenesisJSON(flagChainID, userAddr), 0644)
mod1, err := setupFile(genesisFile, GetGenesisJSON(viper.GetString(FlagChainID), userAddr), 0644)
if err != nil {
return err
}

View File

@ -39,7 +39,7 @@ func TestCounterPlugin(t *testing.T) {
// Seed Basecoin with account
test1Acc := test1PrivAcc.Account
test1Acc.Balance = types.Coins{{"", 1000}, {"gold", 1000}} //nolint
test1Acc.Balance = types.Coins{{"", 1000}, {"gold", 1000}}
accOpt, err := json.Marshal(test1Acc)
require.Nil(t, err)
log := bcApp.SetOption("coin/account", string(accOpt))
@ -64,10 +64,10 @@ func TestCounterPlugin(t *testing.T) {
assert.True(res.IsErr(), res.String())
// Test the fee (increments sequence)
res = DeliverCounterTx(true, types.Coins{{"gold", 100}}, 1) //nolint
res = DeliverCounterTx(true, types.Coins{{"gold", 100}}, 1)
assert.True(res.IsOK(), res.String())
// Test unsupported fee
res = DeliverCounterTx(true, types.Coins{{"silver", 100}}, 2) //nolint
res = DeliverCounterTx(true, types.Coins{{"silver", 100}}, 2)
assert.True(res.IsErr(), res.String())
}