diff --git a/client/commands/init.go b/client/commands/init.go index fe0109372a..a54dbb6993 100644 --- a/client/commands/init.go +++ b/client/commands/init.go @@ -29,9 +29,10 @@ var ( //nolint const ( - SeedFlag = "seed" - HashFlag = "valhash" - GenesisFlag = "genesis" + SeedFlag = "seed" + HashFlag = "valhash" + GenesisFlag = "genesis" + FlagTrustNode = "trust-node" ConfigFile = "config.toml" ) @@ -125,6 +126,11 @@ type Runable func(cmd *cobra.Command, args []string) error // and the root command sets up viper, which is needed to find the home dir. func RequireInit(run Runable) Runable { return func(cmd *cobra.Command, args []string) error { + // otherwise, run the wrappped command + if viper.GetBool(FlagTrustNode) { + return run(cmd, args) + } + // first check if we were Init'ed and if not, return an error root := viper.GetString(cli.HomeFlag) init, err := WasInited(root) diff --git a/client/commands/proofs/root.go b/client/commands/proofs/root.go index 65691980b3..7a136025ad 100644 --- a/client/commands/proofs/root.go +++ b/client/commands/proofs/root.go @@ -1,6 +1,9 @@ package proofs -import "github.com/spf13/cobra" +import ( + "github.com/spf13/cobra" + "github.com/tendermint/basecoin/client/commands" +) // nolint const ( @@ -22,5 +25,6 @@ data to other peers as needed. func init() { RootCmd.Flags().Int(FlagHeight, 0, "Height to query (skip to use latest block)") - RootCmd.Flags().Bool(FlagTrustNode, false, "DANGEROUS: blindly trust all results from the server") + RootCmd.Flags().Bool(commands.FlagTrustNode, false, + "DANGEROUS: blindly trust all results from the server") } diff --git a/tests/cli/basictx.sh b/tests/cli/basictx.sh index 767b097fea..101bb04aaf 100755 --- a/tests/cli/basictx.sh +++ b/tests/cli/basictx.sh @@ -66,21 +66,10 @@ test02SendTxWithFee() { # Make sure tx is indexed checkSendFeeTx $HASH $TX_HEIGHT $SENDER "90" "10" - # make sure this works without trust also - export BCTRUST_NODE=1 - checkSendFeeTx $HASH $TX_HEIGHT $SENDER "90" "10" - unset BCTRUST_NODE - # assert replay protection TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=90mycoin --fee=10mycoin --sequence=2 --to=$RECV --name=$RICH 2>/dev/null) assertFalse "line=${LINENO}, replay: $TX" $? - # make sure this works without trust also - export BCTRUST_NODE=1 - checkAccount $SENDER "9007199254739900" - checkAccount $RECV "1082" - unset BCTRUST_NODE - # checking normally checkAccount $SENDER "9007199254739900" checkAccount $RECV "1082" @@ -93,6 +82,18 @@ test02SendTxWithFee() { if assertTrue "line=${LINENO}, no nonce query" $?; then assertEquals "line=${LINENO}, proper nonce" "2" $(echo $NONCE | jq .data) fi + + # make sure this works without trust also + OLD_BC_HOME=$BC_HOME + export BC_HOME=/foo + export BCTRUST_NODE=1 + export BCNODE=localhost:46657 + checkSendFeeTx $HASH $TX_HEIGHT $SENDER "90" "10" + checkAccount $SENDER "9007199254739900" + checkAccount $RECV "1082" + unset BCTRUST_NODE + unset BCNODE + export BC_HOME=$OLD_BC_HOME }