OSDN Git Service

new repo
[bytom/vapor.git] / vendor / github.com / tendermint / abci / tests / test_app / main.go
1 package main
2
3 import (
4         "fmt"
5         "os"
6
7         "github.com/tendermint/abci/types"
8 )
9
10 var abciType string
11
12 func init() {
13         abciType = os.Getenv("ABCI")
14         if abciType == "" {
15                 abciType = "socket"
16         }
17 }
18
19 func main() {
20         testCounter()
21 }
22
23 func testCounter() {
24         abciApp := os.Getenv("ABCI_APP")
25         if abciApp == "" {
26                 panic("No ABCI_APP specified")
27         }
28
29         fmt.Printf("Running %s test with abci=%s\n", abciApp, abciType)
30         appProc := startApp(abciApp)
31         defer appProc.StopProcess(true)
32         client := startClient(abciType)
33         defer client.Stop()
34
35         setOption(client, "serial", "on")
36         commit(client, nil)
37         deliverTx(client, []byte("abc"), types.CodeType_BadNonce, nil)
38         commit(client, nil)
39         deliverTx(client, []byte{0x00}, types.CodeType_OK, nil)
40         commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 1})
41         deliverTx(client, []byte{0x00}, types.CodeType_BadNonce, nil)
42         deliverTx(client, []byte{0x01}, types.CodeType_OK, nil)
43         deliverTx(client, []byte{0x00, 0x02}, types.CodeType_OK, nil)
44         deliverTx(client, []byte{0x00, 0x03}, types.CodeType_OK, nil)
45         deliverTx(client, []byte{0x00, 0x00, 0x04}, types.CodeType_OK, nil)
46         deliverTx(client, []byte{0x00, 0x00, 0x06}, types.CodeType_BadNonce, nil)
47         commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 5})
48 }