diff --git a/Makefile b/Makefile index 61ecd51871..02cd94cc2c 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ GOTOOLS = github.com/mitchellh/gox \ github.com/rigelrozanski/shelldown/cmd/shelldown TUTORIALS=$(shell find docs/guide -name "*md" -type f) -EXAMPLES := counter eyes +EXAMPLES := counter eyes basecoin INSTALL_EXAMPLES := $(addprefix install_,${EXAMPLES}) TEST_EXAMPLES := $(addprefix testex_,${EXAMPLES}) @@ -39,14 +39,6 @@ test_unit: test_cli: $(TEST_EXAMPLES) # sudo apt-get install jq # wget "https://raw.githubusercontent.com/kward/shunit2/master/source/2.1/src/shunit2" - ./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 test_tutorial: @shelldown ${TUTORIALS} diff --git a/examples/basecoin/Makefile b/examples/basecoin/Makefile new file mode 100644 index 0000000000..a2557acfe3 --- /dev/null +++ b/examples/basecoin/Makefile @@ -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 diff --git a/cmd/basecli/LIGHT_NODE.md b/examples/basecoin/cmd/basecli/LIGHT_NODE.md similarity index 100% rename from cmd/basecli/LIGHT_NODE.md rename to examples/basecoin/cmd/basecli/LIGHT_NODE.md diff --git a/cmd/basecli/README.md b/examples/basecoin/cmd/basecli/README.md similarity index 100% rename from cmd/basecli/README.md rename to examples/basecoin/cmd/basecli/README.md diff --git a/cmd/basecli/main.go b/examples/basecoin/cmd/basecli/main.go similarity index 100% rename from cmd/basecli/main.go rename to examples/basecoin/cmd/basecli/main.go diff --git a/cmd/basecoin/commands/ibc.go b/examples/basecoin/cmd/basecoin/commands/ibc.go similarity index 100% rename from cmd/basecoin/commands/ibc.go rename to examples/basecoin/cmd/basecoin/commands/ibc.go diff --git a/cmd/basecoin/commands/init.go b/examples/basecoin/cmd/basecoin/commands/init.go similarity index 100% rename from cmd/basecoin/commands/init.go rename to examples/basecoin/cmd/basecoin/commands/init.go diff --git a/cmd/basecoin/commands/key.go b/examples/basecoin/cmd/basecoin/commands/key.go similarity index 100% rename from cmd/basecoin/commands/key.go rename to examples/basecoin/cmd/basecoin/commands/key.go diff --git a/cmd/basecoin/commands/relay.go b/examples/basecoin/cmd/basecoin/commands/relay.go similarity index 100% rename from cmd/basecoin/commands/relay.go rename to examples/basecoin/cmd/basecoin/commands/relay.go diff --git a/cmd/basecoin/commands/reset.go b/examples/basecoin/cmd/basecoin/commands/reset.go similarity index 100% rename from cmd/basecoin/commands/reset.go rename to examples/basecoin/cmd/basecoin/commands/reset.go diff --git a/cmd/basecoin/commands/root.go b/examples/basecoin/cmd/basecoin/commands/root.go similarity index 100% rename from cmd/basecoin/commands/root.go rename to examples/basecoin/cmd/basecoin/commands/root.go diff --git a/cmd/basecoin/commands/start.go b/examples/basecoin/cmd/basecoin/commands/start.go similarity index 100% rename from cmd/basecoin/commands/start.go rename to examples/basecoin/cmd/basecoin/commands/start.go diff --git a/cmd/basecoin/main.go b/examples/basecoin/cmd/basecoin/main.go similarity index 95% rename from cmd/basecoin/main.go rename to examples/basecoin/cmd/basecoin/main.go index c14eacca69..d41c8d34a4 100644 --- a/cmd/basecoin/main.go +++ b/examples/basecoin/cmd/basecoin/main.go @@ -7,7 +7,7 @@ import ( 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/examples/basecoin/cmd/basecoin/commands" "github.com/cosmos/cosmos-sdk/modules/auth" "github.com/cosmos/cosmos-sdk/modules/base" "github.com/cosmos/cosmos-sdk/modules/coin" diff --git a/cmd/baseserver/README.md b/examples/basecoin/cmd/baseserver/README.md similarity index 100% rename from cmd/baseserver/README.md rename to examples/basecoin/cmd/baseserver/README.md diff --git a/cmd/baseserver/main.go b/examples/basecoin/cmd/baseserver/main.go similarity index 100% rename from cmd/baseserver/main.go rename to examples/basecoin/cmd/baseserver/main.go diff --git a/tests/cli/basictx.sh b/examples/basecoin/tests/cli/basictx.sh similarity index 96% rename from tests/cli/basictx.sh rename to examples/basecoin/tests/cli/basictx.sh index 1831f76f7d..ac9305c0fb 100755 --- a/tests/cli/basictx.sh +++ b/examples/basecoin/tests/cli/basictx.sh @@ -116,5 +116,9 @@ 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 + +# TODO: how to handle this if we are not in the same directory +CLI_DIR=${DIR}/../../../../tests/cli + +. $CLI_DIR/common.sh +. $CLI_DIR/shunit2 diff --git a/tests/cli/ibc.sh b/examples/basecoin/tests/cli/ibc.sh similarity index 99% rename from tests/cli/ibc.sh rename to examples/basecoin/tests/cli/ibc.sh index 849516cf20..7bf70f10d2 100755 --- a/tests/cli/ibc.sh +++ b/examples/basecoin/tests/cli/ibc.sh @@ -353,5 +353,9 @@ 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 + +# TODO: how to handle this if we are not in the same directory +CLI_DIR=${DIR}/../../../../tests/cli + +. $CLI_DIR/common.sh +. $CLI_DIR/shunit2 diff --git a/tests/cli/init.sh b/examples/basecoin/tests/cli/init.sh similarity index 96% rename from tests/cli/init.sh rename to examples/basecoin/tests/cli/init.sh index 9de8057c45..62d50fb8e8 100755 --- a/tests/cli/init.sh +++ b/examples/basecoin/tests/cli/init.sh @@ -105,4 +105,8 @@ checkDir() { # load and run these tests with shunit2! DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory -. $DIR/shunit2 + +# TODO: how to handle this if we are not in the same directory +CLI_DIR=${DIR}/../../../../tests/cli + +. $CLI_DIR/shunit2 diff --git a/tests/cli/keys.sh b/examples/basecoin/tests/cli/keys.sh similarity index 85% rename from tests/cli/keys.sh rename to examples/basecoin/tests/cli/keys.sh index 89e1ee5385..36cbcbb9bc 100755 --- a/tests/cli/keys.sh +++ b/examples/basecoin/tests/cli/keys.sh @@ -26,4 +26,8 @@ testMakeKeys() { # load and run these tests with shunit2! DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory -. $DIR/shunit2 + +# TODO: how to handle this if we are not in the same directory +CLI_DIR=${DIR}/../../../../tests/cli + +. $CLI_DIR/shunit2 diff --git a/tests/cli/rest.sh b/examples/basecoin/tests/cli/rest.sh similarity index 97% rename from tests/cli/rest.sh rename to examples/basecoin/tests/cli/rest.sh index 163f26ebb3..672fb32d1e 100755 --- a/tests/cli/rest.sh +++ b/examples/basecoin/tests/cli/rest.sh @@ -151,5 +151,9 @@ test04CreateRoleInvalid() { # Load common then run these tests with shunit2! DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory -. $DIR/common.sh -. $DIR/shunit2 + +# TODO: how to handle this if we are not in the same directory +CLI_DIR=${DIR}/../../../../tests/cli + +. $CLI_DIR/common.sh +. $CLI_DIR/shunit2 diff --git a/tests/cli/restart.sh b/examples/basecoin/tests/cli/restart.sh similarity index 94% rename from tests/cli/restart.sh rename to examples/basecoin/tests/cli/restart.sh index c6c6a500ba..37ccb35cef 100755 --- a/tests/cli/restart.sh +++ b/examples/basecoin/tests/cli/restart.sh @@ -78,6 +78,10 @@ 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 + +# TODO: how to handle this if we are not in the same directory +CLI_DIR=${DIR}/../../../../tests/cli + +. $CLI_DIR/common.sh +. $CLI_DIR/shunit2 diff --git a/tests/cli/roles.sh b/examples/basecoin/tests/cli/roles.sh similarity index 95% rename from tests/cli/roles.sh rename to examples/basecoin/tests/cli/roles.sh index e29c3c47f8..8a690d617d 100755 --- a/tests/cli/roles.sh +++ b/examples/basecoin/tests/cli/roles.sh @@ -90,5 +90,9 @@ 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 + +# TODO: how to handle this if we are not in the same directory +CLI_DIR=${DIR}/../../../../tests/cli + +. $CLI_DIR/common.sh +. $CLI_DIR/shunit2 diff --git a/tests/cli/rpc.sh b/examples/basecoin/tests/cli/rpc.sh similarity index 97% rename from tests/cli/rpc.sh rename to examples/basecoin/tests/cli/rpc.sh index c600ff8f67..9d611e4cc5 100755 --- a/tests/cli/rpc.sh +++ b/examples/basecoin/tests/cli/rpc.sh @@ -127,4 +127,7 @@ test03Waiting() { # load and run these tests with shunit2! DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory -. $DIR/shunit2 + +# TODO: how to handle this if we are not in the same directory +CLI_DIR=${DIR}/../../../../tests/cli +. $CLI_DIR/shunit2 diff --git a/examples/counter/cmd/counter/main.go b/examples/counter/cmd/counter/main.go index 9768ef276a..789067ad5f 100644 --- a/examples/counter/cmd/counter/main.go +++ b/examples/counter/cmd/counter/main.go @@ -8,7 +8,7 @@ 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/examples/basecoin/cmd/basecoin/commands" "github.com/cosmos/cosmos-sdk/examples/counter/plugins/counter" ) diff --git a/examples/eyes/cmd/eyes/init.go b/examples/eyes/cmd/eyes/init.go index 87f05daf80..8c1cba1a26 100644 --- a/examples/eyes/cmd/eyes/init.go +++ b/examples/eyes/cmd/eyes/init.go @@ -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/examples/basecoin/cmd/basecoin/commands" ) // InitCmd - node initialization command diff --git a/examples/eyes/cmd/eyes/main.go b/examples/eyes/cmd/eyes/main.go index 8216eb658d..9595306889 100644 --- a/examples/eyes/cmd/eyes/main.go +++ b/examples/eyes/cmd/eyes/main.go @@ -7,7 +7,7 @@ import ( 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/examples/basecoin/cmd/basecoin/commands" "github.com/cosmos/cosmos-sdk/modules/base" "github.com/cosmos/cosmos-sdk/modules/eyes" "github.com/cosmos/cosmos-sdk/stack"