8 abcicli "github.com/tendermint/abci/client"
9 "github.com/tendermint/abci/server"
10 "github.com/tendermint/abci/types"
11 "github.com/tendermint/tmlibs/log"
14 func TestChainAware(t *testing.T) {
15 app := NewChainAwareApplication()
18 srv, err := server.NewServer("unix://test.sock", "socket", app)
22 srv.SetLogger(log.TestingLogger().With("module", "abci-server"))
23 if _, err := srv.Start(); err != nil {
28 // Connect to the socket
29 client := abcicli.NewSocketClient("unix://test.sock", false)
30 client.SetLogger(log.TestingLogger().With("module", "abci-client"))
31 if _, err := client.Start(); err != nil {
32 t.Fatalf("Error starting socket client: %v", err.Error())
37 hash := []byte("fake block hash")
38 header := &types.Header{}
39 for i := uint64(0); i < n; i++ {
40 client.BeginBlockSync(types.RequestBeginBlock{hash, header})
41 client.EndBlockSync(i)
45 r := app.Query(types.RequestQuery{})
46 spl := strings.Split(string(r.Value), ",")
48 t.Fatal("expected %d,%d ; got %s", n, n, string(r.Value))
50 beginCount, _ := strconv.Atoi(spl[0])
51 endCount, _ := strconv.Atoi(spl[1])
52 if uint64(beginCount) != n {
53 t.Fatalf("expected beginCount of %d, got %d", n, beginCount)
54 } else if uint64(endCount) != n {
55 t.Fatalf("expected endCount of %d, got %d", n, endCount)