Skip to content

Commit

Permalink
First Full Auto-Tutorial Test
Browse files Browse the repository at this point in the history
  • Loading branch information
rigelrozanski committed Jun 29, 2017
1 parent 985665f commit ec7ef41
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dist:
@bash scripts/dist.sh
@bash scripts/publish.sh

test: test_unit test_cli
test: test_unit test_cli test_tutorial

test_unit:
go test `glide novendor`
Expand Down
2 changes: 1 addition & 1 deletion cmd/basecoin/commands/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
//commands
var (
InitCmd = &cobra.Command{
Use: "init",
Use: "init [address]",
Short: "Initialize a basecoin blockchain",
RunE: initCmd,
}
Expand Down
63 changes: 46 additions & 17 deletions docs/guide/basecoin-basics.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,63 @@
<!--- shelldown script template, see github.com/rigelrozanski/shelldown
#!/bin/bash
oneTimeSetup() {
#shelldown[1][2]
testTutorial_BasecoinBasics() {
rm -rf ~/.basecoin 2>/dev/null
rm -rf ~/.basecli 2>/dev/null
KEYPASS=qwertyuiop
(echo $KEYPASS; echo $KEYPASS) | #shelldown[1][3] $1 >/dev/null 2>/dev/null
(echo $KEYPASS; echo $KEYPASS) | #shelldown[1][4] $1 >/dev/null 2>/dev/null
#shelldown[1][2]
RES=$((echo $KEYPASS; echo $KEYPASS) | #shelldown[1][3])
assertTrue "Line $LINENO: Expected to contain safe, got $RES" '[[ $RES == *safe* ]]'
RES=$((echo $KEYPASS; echo $KEYPASS) | #shelldown[1][4])
assertTrue "Line $LINENO: Expected to contain safe, got $RES" '[[ $RES == *safe* ]]'
assertTrue "Expected true for line $LINENO" $?
#shelldown[3][-1]
assertTrue "Expected true for line $LINENO" $?
#shelldown[4][-1] &
#shelldown[4][-1] >>/dev/null 2>&1 &
sleep 5
PID_SERVER=$!
disown
RES=$((echo y) | #shelldown[5][-1] $1)
assertTrue "Line $LINENO: Expected to contain validator, got $RES" '[[ $RES == *validator* ]]'
#shelldown[6][0]
#shelldown[6][1]
RES="$(#shelldown[6][2])"
assertTrue "Line $LINENO: Expected to contain mycoin, got $RES" '[[ $RES == *mycoin* ]]'
RES="$(#shelldown[6][3] 2>&1)"
assertTrue "Line $LINENO: Expected to contain ERROR, got $RES" '[[ $RES == *ERROR* ]]'
RES=$((echo $KEYPASS) | #shelldown[7][-1] | jq '.deliver_tx.code')
assertTrue "Line $LINENO: Expected 0 code deliver_tx, got $RES" '[[ $RES == 0 ]]'
RES=$(#shelldown[8][-1])
assertTrue "Line $LINENO: Expected to contain 1000 mycoin, got $RES" '[[ $RES == *1000* ]]'
assertTrue "Line $LINENO: Expected to not contain Error, got $RES" '[[ $RES != *Error* ]]'
RES=$((echo $KEYPASS) | #shelldown[9][-1] | jq '.deliver_tx.code')
assertTrue "Line $LINENO: Expected 0 code deliver_tx, got $RES" '[[ $RES == 0 ]]'
RES=$((echo $KEYPASS) | #shelldown[10][-1])
assertTrue "Line $LINENO: Expected to contain insufficient funds error, got $RES" \
'[[ $RES == *"insufficient funds"* ]]'
#perform a substitution within the final tests
HASH=$((echo $KEYPASS) | #shelldown[11][-1] | jq '.hash' | tr -d '"')
PRESUB="#shelldown[12][-1]"
RES=$(eval ${PRESUB/<HASH>/$HASH})
assertTrue "Line $LINENO: Expected to not contain Error, got $RES" '[[ $RES != *Error* ]]'
}
oneTimeTearDown() {
kill -9 $PID_SERVER >/dev/null 2>&1
sleep 1
}
test01SendTX() {
#shelldown[5][-1]
#shelldown[6][-1]
#shelldown[7][-1]
#shelldown[8][-1]
#shelldown[9][-1]
#shelldown[10][-1]
#shelldown[11][-1]
}
# load and run these tests with shunit2!
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory
. $DIR/shunit2
Expand Down Expand Up @@ -161,7 +190,7 @@ Note how we use the `--name` flag to select a different account to send from.
If we try to send too much, we'll get an error:

```shelldown[10]
basecli tx send --name=friend --amount=500000mycoin --to=$ME --sequence=1
basecli tx send --name=friend --amount=500000mycoin --to=$ME --sequence=2
```

Let's send another transaction:
Expand Down

0 comments on commit ec7ef41

Please sign in to comment.