mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-25 18:51:39 +00:00
better testing. cli test for tutorial
This commit is contained in:
48
tests/test_app/main.go
Normal file
48
tests/test_app/main.go
Normal file
@ -0,0 +1,48 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/tendermint/tmsp/types"
|
||||
)
|
||||
|
||||
var tmspType string
|
||||
|
||||
func init() {
|
||||
tmspType = os.Getenv("TMSP")
|
||||
if tmspType == "" {
|
||||
tmspType = "socket"
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
testCounter()
|
||||
}
|
||||
|
||||
func testCounter() {
|
||||
tmspApp := os.Getenv("TMSP_APP")
|
||||
if tmspApp == "" {
|
||||
panic("No TMSP_APP specified")
|
||||
}
|
||||
|
||||
fmt.Printf("Running %s test with tmsp=%s\n", tmspApp, tmspType)
|
||||
appProc := StartApp(tmspApp)
|
||||
defer appProc.StopProcess(true)
|
||||
client := StartClient(tmspType)
|
||||
defer client.Stop()
|
||||
|
||||
SetOption(client, "serial", "on")
|
||||
Commit(client, nil)
|
||||
AppendTx(client, []byte("abc"), types.CodeType_BadNonce, nil)
|
||||
Commit(client, nil)
|
||||
AppendTx(client, []byte{0x00}, types.CodeType_OK, nil)
|
||||
Commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 1})
|
||||
AppendTx(client, []byte{0x00}, types.CodeType_BadNonce, nil)
|
||||
AppendTx(client, []byte{0x01}, types.CodeType_OK, nil)
|
||||
AppendTx(client, []byte{0x00, 0x02}, types.CodeType_OK, nil)
|
||||
AppendTx(client, []byte{0x00, 0x03}, types.CodeType_OK, nil)
|
||||
AppendTx(client, []byte{0x00, 0x00, 0x04}, types.CodeType_OK, nil)
|
||||
AppendTx(client, []byte{0x00, 0x00, 0x06}, types.CodeType_BadNonce, nil)
|
||||
Commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 5})
|
||||
}
|
Reference in New Issue
Block a user