First Full Auto-Tutorial Test
This commit is contained in:
parent
985665fb8a
commit
ec7ef41fdc
2
Makefile
2
Makefile
@ -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`
|
||||
|
||||
@ -14,7 +14,7 @@ import (
|
||||
//commands
|
||||
var (
|
||||
InitCmd = &cobra.Command{
|
||||
Use: "init",
|
||||
Use: "init [address]",
|
||||
Short: "Initialize a basecoin blockchain",
|
||||
RunE: initCmd,
|
||||
}
|
||||
|
||||
@ -1,17 +1,56 @@
|
||||
<!--- 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() {
|
||||
@ -19,16 +58,6 @@ oneTimeTearDown() {
|
||||
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
|
||||
@ -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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user