Merge pull request #242 from cosmos/feature/move_to_examples
Move all binaries to examples
This commit is contained in:
commit
c94500f269
|
@ -3,6 +3,5 @@ vendor
|
|||
.vagrant
|
||||
merkleeyes.db
|
||||
build
|
||||
shunit2
|
||||
docs/guide/*.sh
|
||||
keys/
|
||||
|
|
37
Makefile
37
Makefile
|
@ -3,6 +3,10 @@ GOTOOLS = github.com/mitchellh/gox \
|
|||
github.com/rigelrozanski/shelldown/cmd/shelldown
|
||||
TUTORIALS=$(shell find docs/guide -name "*md" -type f)
|
||||
|
||||
EXAMPLES := counter eyes basecoin
|
||||
INSTALL_EXAMPLES := $(addprefix install_,${EXAMPLES})
|
||||
TEST_EXAMPLES := $(addprefix testex_,${EXAMPLES})
|
||||
|
||||
LINKER_FLAGS:="-X github.com/cosmos/cosmos-sdk/client/commands.CommitHash=`git rev-parse --short HEAD`"
|
||||
|
||||
all: get_vendor_deps install test
|
||||
|
@ -10,9 +14,14 @@ all: get_vendor_deps install test
|
|||
build:
|
||||
@go build ./cmd/...
|
||||
|
||||
install:
|
||||
$(INSTALL_EXAMPLES): install_%:
|
||||
cd ./examples/$* && make install
|
||||
|
||||
$(TEST_EXAMPLES): testex_%:
|
||||
cd ./examples/$* && make test_cli
|
||||
|
||||
install: $(INSTALL_EXAMPLES)
|
||||
@go install -ldflags $(LINKER_FLAGS) ./cmd/...
|
||||
@go install -ldflags $(LINKER_FLAGS) ./docs/guide/counter/cmd/...
|
||||
|
||||
dist:
|
||||
@bash publish/dist.sh
|
||||
|
@ -26,35 +35,17 @@ test: test_unit test_cli
|
|||
|
||||
test_unit:
|
||||
@go test `glide novendor`
|
||||
#go run tests/tendermint/*.go
|
||||
|
||||
test_cli: tests/cli/shunit2
|
||||
test_cli: $(TEST_EXAMPLES)
|
||||
# sudo apt-get install jq
|
||||
./tests/cli/keys.sh
|
||||
./tests/cli/rpc.sh
|
||||
./tests/cli/init.sh
|
||||
./tests/cli/basictx.sh
|
||||
./tests/cli/eyes.sh
|
||||
./tests/cli/roles.sh
|
||||
./tests/cli/counter.sh
|
||||
./tests/cli/restart.sh
|
||||
./tests/cli/rest.sh
|
||||
./tests/cli/ibc.sh
|
||||
# wget "https://raw.githubusercontent.com/kward/shunit2/master/source/2.1/src/shunit2"
|
||||
|
||||
test_tutorial: docs/guide/shunit2
|
||||
test_tutorial:
|
||||
@shelldown ${TUTORIALS}
|
||||
@for script in docs/guide/*.sh ; do \
|
||||
bash $$script ; \
|
||||
done
|
||||
|
||||
tests/cli/shunit2:
|
||||
@wget "https://raw.githubusercontent.com/kward/shunit2/master/source/2.1/src/shunit2" \
|
||||
-q -O tests/cli/shunit2
|
||||
|
||||
docs/guide/shunit2:
|
||||
@wget "https://raw.githubusercontent.com/kward/shunit2/master/source/2.1/src/shunit2" \
|
||||
-q -O docs/guide/shunit2
|
||||
|
||||
get_vendor_deps: tools
|
||||
@glide install
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package commands
|
||||
|
||||
// import "github.com/cosmos/cosmos-sdk/plugins/ibc"
|
||||
|
||||
// // returns a new IBC plugin to be registered with Basecoin
|
||||
// func NewIBCPlugin() *ibc.IBCPlugin {
|
||||
// return ibc.New()
|
||||
// }
|
|
@ -1,43 +0,0 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
tmflags "github.com/tendermint/tmlibs/cli/flags"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
)
|
||||
|
||||
//nolint
|
||||
const (
|
||||
defaultLogLevel = "error"
|
||||
FlagLogLevel = "log_level"
|
||||
)
|
||||
|
||||
var (
|
||||
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "main")
|
||||
)
|
||||
|
||||
// RootCmd - main node command
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "basecoin",
|
||||
Short: "A cryptocurrency framework in Golang based on Tendermint-Core",
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
level := viper.GetString(FlagLogLevel)
|
||||
logger, err = tmflags.ParseLogLevel(level, logger, defaultLogLevel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if viper.GetBool(cli.TraceFlag) {
|
||||
logger = log.NewTracingLogger(logger)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
RootCmd.PersistentFlags().String(FlagLogLevel, defaultLogLevel, "Log level")
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,21 @@
|
|||
LINKER_FLAGS:="-X github.com/cosmos/cosmos-sdk/client/commands.CommitHash=`git rev-parse --short HEAD`"
|
||||
|
||||
install:
|
||||
@go install -ldflags $(LINKER_FLAGS) ./cmd/...
|
||||
|
||||
test: test_unit test_cli
|
||||
|
||||
test_unit:
|
||||
@go test `glide novendor`
|
||||
|
||||
test_cli:
|
||||
./tests/cli/keys.sh
|
||||
./tests/cli/rpc.sh
|
||||
./tests/cli/init.sh
|
||||
./tests/cli/basictx.sh
|
||||
./tests/cli/roles.sh
|
||||
./tests/cli/restart.sh
|
||||
./tests/cli/rest.sh
|
||||
./tests/cli/ibc.sh
|
||||
|
||||
.PHONY: install test test_unit test_cli
|
|
@ -3,11 +3,11 @@ package main
|
|||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
client "github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/cmd/basecoin/commands"
|
||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||
"github.com/cosmos/cosmos-sdk/modules/base"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
|
@ -15,9 +15,16 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/modules/ibc"
|
||||
"github.com/cosmos/cosmos-sdk/modules/nonce"
|
||||
"github.com/cosmos/cosmos-sdk/modules/roles"
|
||||
"github.com/cosmos/cosmos-sdk/server/commands"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
)
|
||||
|
||||
// RootCmd is the entry point for this binary
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "basecoin",
|
||||
Short: "A cryptocurrency framework in Golang based on Tendermint-Core",
|
||||
}
|
||||
|
||||
// BuildApp constructs the stack we want to use for this app
|
||||
func BuildApp(feeDenom string) sdk.Handler {
|
||||
return stack.New(
|
||||
|
@ -42,19 +49,18 @@ func BuildApp(feeDenom string) sdk.Handler {
|
|||
}
|
||||
|
||||
func main() {
|
||||
rt := commands.RootCmd
|
||||
|
||||
// require all fees in mycoin - change this in your app!
|
||||
commands.Handler = BuildApp("mycoin")
|
||||
|
||||
rt.AddCommand(
|
||||
RootCmd.AddCommand(
|
||||
commands.InitCmd,
|
||||
commands.StartCmd,
|
||||
//commands.RelayCmd,
|
||||
commands.UnsafeResetAllCmd,
|
||||
client.VersionCmd,
|
||||
)
|
||||
commands.SetUpRoot(RootCmd)
|
||||
|
||||
cmd := cli.PrepareMainCmd(rt, "BC", os.ExpandEnv("$HOME/.basecoin"))
|
||||
cmd := cli.PrepareMainCmd(RootCmd, "BC", os.ExpandEnv("$HOME/.basecoin"))
|
||||
cmd.Execute()
|
||||
}
|
|
@ -116,5 +116,7 @@ test03CreditTx() {
|
|||
|
||||
# Load common then run these tests with shunit2!
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory
|
||||
. $DIR/common.sh
|
||||
. $DIR/shunit2
|
||||
CLI_DIR=$GOPATH/src/github.com/cosmos/cosmos-sdk/tests/cli
|
||||
|
||||
. $CLI_DIR/common.sh
|
||||
. $CLI_DIR/shunit2
|
|
@ -353,5 +353,7 @@ assertNewHeight() {
|
|||
|
||||
# Load common then run these tests with shunit2!
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory
|
||||
. $DIR/common.sh
|
||||
. $DIR/shunit2
|
||||
CLI_DIR=$GOPATH/src/github.com/cosmos/cosmos-sdk/tests/cli
|
||||
|
||||
. $CLI_DIR/common.sh
|
||||
. $CLI_DIR/shunit2
|
|
@ -105,4 +105,6 @@ checkDir() {
|
|||
|
||||
# load and run these tests with shunit2!
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory
|
||||
. $DIR/shunit2
|
||||
CLI_DIR=$GOPATH/src/github.com/cosmos/cosmos-sdk/tests/cli
|
||||
|
||||
. $CLI_DIR/shunit2
|
|
@ -26,4 +26,6 @@ testMakeKeys() {
|
|||
|
||||
# load and run these tests with shunit2!
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory
|
||||
. $DIR/shunit2
|
||||
CLI_DIR=$GOPATH/src/github.com/cosmos/cosmos-sdk/tests/cli
|
||||
|
||||
. $CLI_DIR/shunit2
|
|
@ -17,6 +17,7 @@ oneTimeSetUp() {
|
|||
baseserver serve --port $BPORT >/dev/null &
|
||||
PID_PROXY=$!
|
||||
disown
|
||||
sleep 0.1 # for startup
|
||||
}
|
||||
|
||||
oneTimeTearDown() {
|
||||
|
@ -29,7 +30,8 @@ oneTimeTearDown() {
|
|||
restAddr() {
|
||||
assertNotNull "line=${LINENO}, keyname required" "$1"
|
||||
ADDR=$(curl ${URL}/keys/${1} 2>/dev/null | jq .address | tr -d \")
|
||||
assertNotEquals "line=${LINENO}, no key" "null" $ADDR
|
||||
assertNotEquals "line=${LINENO}, null key" "null" "$ADDR"
|
||||
assertNotEquals "line=${LINENO}, no key" "" "$ADDR"
|
||||
echo $ADDR
|
||||
}
|
||||
|
||||
|
@ -49,13 +51,39 @@ restNoAccount() {
|
|||
}
|
||||
|
||||
test00GetAccount() {
|
||||
RECV=$(restAddr $POOR)
|
||||
SENDER=$(restAddr $RICH)
|
||||
|
||||
restNoAccount $RECV
|
||||
restAccount $SENDER "9007199254740992"
|
||||
}
|
||||
|
||||
test01SendTx() {
|
||||
SENDER=$(restAddr $RICH)
|
||||
RECV=$(restAddr $POOR)
|
||||
|
||||
restAccount $SENDER "9007199254740992"
|
||||
restNoAccount $RECV
|
||||
CMD="{\"from\": {\"app\": \"sigs\", \"addr\": \"$SENDER\"}, \"to\": {\"app\": \"sigs\", \"addr\": \"$RECV\"}, \"amount\": [{\"denom\": \"mycoin\", \"amount\": 992}], \"sequence\": 1}"
|
||||
|
||||
UNSIGNED=$(curl -XPOST ${URL}/build/send -d "$CMD" 2>/dev/null)
|
||||
if [ -n "$DEBUG" ]; then echo $UNSIGNED; echo; fi
|
||||
|
||||
TOSIGN="{\"name\": \"$RICH\", \"password\": \"qwertyuiop\", \"tx\": $UNSIGNED}"
|
||||
SIGNED=$(curl -XPOST ${URL}/sign -d "$TOSIGN" 2>/dev/null)
|
||||
TX=$(curl -XPOST ${URL}/tx -d "$SIGNED" 2>/dev/null)
|
||||
if [ -n "$DEBUG" ]; then echo $TX; echo; fi
|
||||
|
||||
txSucceeded $? "$TX" "$RECV"
|
||||
HASH=$(echo $TX | jq .hash | tr -d \")
|
||||
TX_HEIGHT=$(echo $TX | jq .height)
|
||||
|
||||
restAccount $SENDER "9007199254740000"
|
||||
restAccount $RECV "992"
|
||||
|
||||
# Make sure tx is indexed
|
||||
checkSendTx $HASH $TX_HEIGHT $SENDER "992"
|
||||
}
|
||||
|
||||
|
||||
# XXX Ex Usage: restCreateRole $PAYLOAD $EXPECTED
|
||||
# Desc: Tests that the first returned signer.addr matches the expected
|
||||
restCreateRole() {
|
||||
|
@ -86,30 +114,6 @@ test04CreateRoleInvalid() {
|
|||
assertEquals "line=${LINENO}, should report validation failed" 0 $(echo $ERROR | grep "invalid hex" > /dev/null && echo 0 || echo 1)
|
||||
}
|
||||
|
||||
test01SendTx() {
|
||||
SENDER=$(restAddr $RICH)
|
||||
RECV=$(restAddr $POOR)
|
||||
|
||||
CMD="{\"from\": {\"app\": \"sigs\", \"addr\": \"$SENDER\"}, \"to\": {\"app\": \"sigs\", \"addr\": \"$RECV\"}, \"amount\": [{\"denom\": \"mycoin\", \"amount\": 992}], \"sequence\": 1}"
|
||||
|
||||
UNSIGNED=$(curl -XPOST ${URL}/build/send -d "$CMD" 2>/dev/null)
|
||||
if [ -n "$DEBUG" ]; then echo $UNSIGNED; echo; fi
|
||||
|
||||
TOSIGN="{\"name\": \"$RICH\", \"password\": \"qwertyuiop\", \"tx\": $UNSIGNED}"
|
||||
SIGNED=$(curl -XPOST ${URL}/sign -d "$TOSIGN" 2>/dev/null)
|
||||
TX=$(curl -XPOST ${URL}/tx -d "$SIGNED" 2>/dev/null)
|
||||
if [ -n "$DEBUG" ]; then echo $TX; echo; fi
|
||||
|
||||
txSucceeded $? "$TX" "$RECV"
|
||||
HASH=$(echo $TX | jq .hash | tr -d \")
|
||||
TX_HEIGHT=$(echo $TX | jq .height)
|
||||
|
||||
restAccount $SENDER "9007199254740000"
|
||||
restAccount $RECV "992"
|
||||
|
||||
# Make sure tx is indexed
|
||||
checkSendTx $HASH $TX_HEIGHT $SENDER "992"
|
||||
}
|
||||
|
||||
# test02SendTxWithFee() {
|
||||
# SENDER=$(getAddr $RICH)
|
||||
|
@ -147,5 +151,7 @@ test01SendTx() {
|
|||
|
||||
# Load common then run these tests with shunit2!
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory
|
||||
. $DIR/common.sh
|
||||
. $DIR/shunit2
|
||||
CLI_DIR=$GOPATH/src/github.com/cosmos/cosmos-sdk/tests/cli
|
||||
|
||||
. $CLI_DIR/common.sh
|
||||
. $CLI_DIR/shunit2
|
|
@ -78,6 +78,8 @@ test01OnRestart() {
|
|||
|
||||
# Load common then run these tests with shunit2!
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory
|
||||
. $DIR/common.sh
|
||||
. $DIR/shunit2
|
||||
CLI_DIR=$GOPATH/src/github.com/cosmos/cosmos-sdk/tests/cli
|
||||
|
||||
. $CLI_DIR/common.sh
|
||||
. $CLI_DIR/shunit2
|
||||
|
|
@ -90,5 +90,7 @@ test03SendMultiFromRole() {
|
|||
|
||||
# Load common then run these tests with shunit2!
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory
|
||||
. $DIR/common.sh
|
||||
. $DIR/shunit2
|
||||
CLI_DIR=$GOPATH/src/github.com/cosmos/cosmos-sdk/tests/cli
|
||||
|
||||
. $CLI_DIR/common.sh
|
||||
. $CLI_DIR/shunit2
|
|
@ -127,4 +127,6 @@ test03Waiting() {
|
|||
|
||||
# load and run these tests with shunit2!
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory
|
||||
. $DIR/shunit2
|
||||
CLI_DIR=$GOPATH/src/github.com/cosmos/cosmos-sdk/tests/cli
|
||||
|
||||
. $CLI_DIR/shunit2
|
|
@ -0,0 +1,14 @@
|
|||
LINKER_FLAGS:="-X github.com/cosmos/cosmos-sdk/client/commands.CommitHash=`git rev-parse --short HEAD`"
|
||||
|
||||
install:
|
||||
@go install -ldflags $(LINKER_FLAGS) ./cmd/...
|
||||
|
||||
test: test_unit test_cli
|
||||
|
||||
test_unit:
|
||||
@go test `glide novendor`
|
||||
|
||||
test_cli:
|
||||
./tests/cli/counter.sh
|
||||
|
||||
.PHONY: install test test_unit test_cli
|
|
@ -8,15 +8,17 @@ import (
|
|||
"github.com/tendermint/tmlibs/cli"
|
||||
|
||||
client "github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/cmd/basecoin/commands"
|
||||
"github.com/cosmos/cosmos-sdk/docs/guide/counter/plugins/counter"
|
||||
"github.com/cosmos/cosmos-sdk/examples/counter/plugins/counter"
|
||||
"github.com/cosmos/cosmos-sdk/server/commands"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var RootCmd = &cobra.Command{
|
||||
// RootCmd is the entry point for this binary
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "counter",
|
||||
Short: "demo plugin for basecoin",
|
||||
}
|
||||
Short: "demo application for cosmos sdk",
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
// TODO: register the counter here
|
||||
commands.Handler = counter.NewHandler("mycoin")
|
||||
|
@ -27,6 +29,7 @@ func main() {
|
|||
commands.UnsafeResetAllCmd,
|
||||
client.VersionCmd,
|
||||
)
|
||||
commands.SetUpRoot(RootCmd)
|
||||
|
||||
cmd := cli.PrepareMainCmd(RootCmd, "CT", os.ExpandEnv("$HOME/.counter"))
|
||||
cmd.Execute()
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs"
|
||||
"github.com/cosmos/cosmos-sdk/docs/guide/counter/plugins/counter"
|
||||
"github.com/cosmos/cosmos-sdk/examples/counter/plugins/counter"
|
||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||
)
|
||||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/client/commands/query"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/docs/guide/counter/plugins/counter"
|
||||
"github.com/cosmos/cosmos-sdk/examples/counter/plugins/counter"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
)
|
||||
|
|
@ -14,7 +14,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/client/commands/seeds"
|
||||
|
||||
txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs"
|
||||
bcount "github.com/cosmos/cosmos-sdk/docs/guide/counter/cmd/countercli/commands"
|
||||
bcount "github.com/cosmos/cosmos-sdk/examples/counter/cmd/countercli/commands"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/modules/auth/commands"
|
||||
basecmd "github.com/cosmos/cosmos-sdk/modules/base/commands"
|
||||
coincmd "github.com/cosmos/cosmos-sdk/modules/coin/commands"
|
|
@ -112,5 +112,7 @@ test03AddCount() {
|
|||
|
||||
# Load common then run these tests with shunit2!
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory
|
||||
. $DIR/common.sh
|
||||
. $DIR/shunit2
|
||||
CLI_DIR=$GOPATH/src/github.com/cosmos/cosmos-sdk/tests/cli
|
||||
|
||||
. $CLI_DIR/common.sh
|
||||
. $CLI_DIR/shunit2
|
|
@ -0,0 +1,14 @@
|
|||
LINKER_FLAGS:="-X github.com/cosmos/cosmos-sdk/client/commands.CommitHash=`git rev-parse --short HEAD`"
|
||||
|
||||
install:
|
||||
@go install -ldflags $(LINKER_FLAGS) ./cmd/...
|
||||
|
||||
test: test_unit test_cli
|
||||
|
||||
test_unit:
|
||||
@go test `glide novendor`
|
||||
|
||||
test_cli:
|
||||
./tests/cli/eyes.sh
|
||||
|
||||
.PHONY: install test test_unit test_cli
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/cmd/basecoin/commands"
|
||||
"github.com/cosmos/cosmos-sdk/server/commands"
|
||||
)
|
||||
|
||||
// InitCmd - node initialization command
|
|
@ -3,16 +3,24 @@ package main
|
|||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
client "github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/cosmos/cosmos-sdk/cmd/basecoin/commands"
|
||||
"github.com/cosmos/cosmos-sdk/modules/base"
|
||||
"github.com/cosmos/cosmos-sdk/modules/eyes"
|
||||
"github.com/cosmos/cosmos-sdk/server/commands"
|
||||
"github.com/cosmos/cosmos-sdk/stack"
|
||||
)
|
||||
|
||||
// RootCmd is the entry point for this binary
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "eyes",
|
||||
Short: "key-value store",
|
||||
Long: "A demo app to show key-value store with proofs over abci",
|
||||
}
|
||||
|
||||
// BuildApp constructs the stack we want to use for this app
|
||||
func BuildApp() sdk.Handler {
|
||||
return stack.New(
|
||||
|
@ -26,20 +34,17 @@ func BuildApp() sdk.Handler {
|
|||
}
|
||||
|
||||
func main() {
|
||||
rt := commands.RootCmd
|
||||
rt.Short = "eyes"
|
||||
rt.Long = "A demo app to show key-value store with proofs over abci"
|
||||
|
||||
commands.Handler = BuildApp()
|
||||
|
||||
rt.AddCommand(
|
||||
RootCmd.AddCommand(
|
||||
// out own init command to not require argument
|
||||
InitCmd,
|
||||
commands.StartCmd,
|
||||
commands.UnsafeResetAllCmd,
|
||||
client.VersionCmd,
|
||||
)
|
||||
commands.SetUpRoot(RootCmd)
|
||||
|
||||
cmd := cli.PrepareMainCmd(rt, "EYE", os.ExpandEnv("$HOME/.eyes"))
|
||||
cmd := cli.PrepareMainCmd(RootCmd, "EYE", os.ExpandEnv("$HOME/.eyes"))
|
||||
cmd.Execute()
|
||||
}
|
|
@ -66,6 +66,8 @@ test00SetGetRemove() {
|
|||
|
||||
# Load common then run these tests with shunit2!
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory
|
||||
. $DIR/common.sh
|
||||
. $DIR/shunit2
|
||||
CLI_DIR=$GOPATH/src/github.com/cosmos/cosmos-sdk/tests/cli
|
||||
|
||||
. $CLI_DIR/common.sh
|
||||
. $CLI_DIR/shunit2
|
||||
|
|
@ -18,7 +18,7 @@ import (
|
|||
// InitCmd - node initialization command
|
||||
var InitCmd = &cobra.Command{
|
||||
Use: "init [address]",
|
||||
Short: "Initialize a basecoin blockchain",
|
||||
Short: "Initialize genesis files for a blockchain",
|
||||
RunE: initCmd,
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
tmflags "github.com/tendermint/tmlibs/cli/flags"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
)
|
||||
|
||||
//nolint
|
||||
const (
|
||||
defaultLogLevel = "error"
|
||||
FlagLogLevel = "log_level"
|
||||
)
|
||||
|
||||
var (
|
||||
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "main")
|
||||
)
|
||||
|
||||
// preRunSetup should be set as PersistentPreRunE on the root command to
|
||||
// properly handle the logging and the tracer
|
||||
func preRunSetup(cmd *cobra.Command, args []string) (err error) {
|
||||
level := viper.GetString(FlagLogLevel)
|
||||
logger, err = tmflags.ParseLogLevel(level, logger, defaultLogLevel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if viper.GetBool(cli.TraceFlag) {
|
||||
logger = log.NewTracingLogger(logger)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetUpRoot(cmd *cobra.Command) {
|
||||
cmd.PersistentPreRunE = preRunSetup
|
||||
cmd.PersistentFlags().String(FlagLogLevel, defaultLogLevel, "Log level")
|
||||
}
|
|
@ -9,8 +9,8 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/tendermint/abci/server"
|
||||
sdk "github.com/cosmos/cosmos-sdk"
|
||||
"github.com/tendermint/abci/server"
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
|
||||
|
@ -22,10 +22,10 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/app"
|
||||
)
|
||||
|
||||
// StartCmd - command to start running the basecoin node!
|
||||
// StartCmd - command to start running the abci app (and tendermint)!
|
||||
var StartCmd = &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Start basecoin",
|
||||
Short: "Start this full node",
|
||||
RunE: startCmd,
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ var (
|
|||
func init() {
|
||||
flags := StartCmd.Flags()
|
||||
flags.String(FlagAddress, "tcp://0.0.0.0:46658", "Listen address")
|
||||
flags.Bool(FlagWithoutTendermint, false, "Only run basecoin abci app, assume external tendermint process")
|
||||
flags.Bool(FlagWithoutTendermint, false, "Only run abci app, assume external tendermint process")
|
||||
// add all standard 'tendermint node' flags
|
||||
tcmd.AddNodeFlags(StartCmd)
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue