mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-05 03:22:13 +00:00
Spell out the package explicitly. This commit is totally textual, and does not change any logic. The swiss-army knife package may serve a kick-start in early stage development. But as the codebase growing, we might want to retire it gradually: For simple wrapping functions, just inline it on the call site. For larger pice of code, make it an independent package.
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/tendermint/abci/client"
|
|
"github.com/tendermint/abci/server"
|
|
"github.com/tendermint/abci/types"
|
|
common "github.com/tendermint/go-common"
|
|
)
|
|
|
|
func TestChainAware(t *testing.T) {
|
|
|
|
app := NewChainAwareApplication()
|
|
|
|
// Start the listener
|
|
srv, err := server.NewServer("unix://test.sock", "socket", app)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer srv.Stop()
|
|
|
|
// Connect to the socket
|
|
client, err := abcicli.NewSocketClient("unix://test.sock", false)
|
|
if err != nil {
|
|
common.Exit(Fmt("Error starting socket client: %v", err.Error()))
|
|
}
|
|
client.Start()
|
|
defer client.Stop()
|
|
|
|
n := uint64(5)
|
|
hash := []byte("fake block hash")
|
|
header := &types.Header{}
|
|
for i := uint64(0); i < n; i++ {
|
|
client.BeginBlockSync(hash, header)
|
|
client.EndBlockSync(i)
|
|
client.CommitSync()
|
|
}
|
|
|
|
r := app.Query(nil)
|
|
spl := strings.Split(string(r.Data), ",")
|
|
if len(spl) != 2 {
|
|
t.Fatal("expected %d,%d ; got %s", n, n, string(r.Data))
|
|
}
|
|
beginCount, _ := strconv.Atoi(spl[0])
|
|
endCount, _ := strconv.Atoi(spl[1])
|
|
if uint64(beginCount) != n {
|
|
t.Fatalf("expected beginCount of %d, got %d", n, beginCount)
|
|
} else if uint64(endCount) != n {
|
|
t.Fatalf("expected endCount of %d, got %d", n, endCount)
|
|
}
|
|
}
|