Update glide.yaml and fix tests

This commit is contained in:
Jae Kwon
2017-12-26 00:45:31 -08:00
parent ff65421324
commit a861d68a31
9 changed files with 46 additions and 55 deletions
+3 -6
View File
@@ -6,7 +6,6 @@ import (
"github.com/tendermint/abci/example/code"
"github.com/tendermint/abci/types"
wire "github.com/tendermint/go-wire"
"github.com/tendermint/iavl"
dbm "github.com/tendermint/tmlibs/db"
)
@@ -20,7 +19,7 @@ type DummyApplication struct {
}
func NewDummyApplication() *DummyApplication {
state := iavl.NewVersionedTree(0, dbm.NewMemDB())
state := iavl.NewVersionedTree(dbm.NewMemDB(), 0)
return &DummyApplication{state: state}
}
@@ -56,9 +55,7 @@ func (app *DummyApplication) Commit() types.ResponseCommit {
var err error
if app.state.Size() > 0 {
// just add one more to height (kind of arbitrarily stupid)
height := app.state.LatestVersion() + 1
hash, err = app.state.SaveVersion(height)
hash, _, err = app.state.SaveVersion()
if err != nil {
// if this wasn't a dummy app, we'd do something smarter
panic(err)
@@ -78,7 +75,7 @@ func (app *DummyApplication) Query(reqQuery types.RequestQuery) (resQuery types.
resQuery.Index = -1 // TODO make Proof return index
resQuery.Key = reqQuery.Data
resQuery.Value = value
resQuery.Proof = wire.BinaryBytes(proof)
resQuery.Proof = proof.Bytes()
if value != nil {
resQuery.Log = "exists"
} else {
+8 -8
View File
@@ -41,9 +41,9 @@ func testDummy(t *testing.T, app types.Application, tx []byte, key, value string
})
require.EqualValues(t, code.CodeTypeOK, resQuery.Code)
require.Equal(t, value, string(resQuery.Value))
proof, err := iavl.ReadKeyExistsProof(resQuery.Proof)
proof, err := iavl.ReadKeyProof(resQuery.Proof)
require.Nil(t, err)
err = proof.Verify([]byte(key), resQuery.Value, proof.RootHash)
err = proof.Verify([]byte(key), resQuery.Value, proof.Root())
require.Nil(t, err, "%+v", err) // NOTE: we have no way to verify the RootHash
}
@@ -215,14 +215,14 @@ func makeSocketClientServer(app types.Application, name string) (abcicli.Client,
server := abciserver.NewSocketServer(socket, app)
server.SetLogger(logger.With("module", "abci-server"))
if err := server.Start(); err != nil {
if _, err := server.Start(); err != nil {
return nil, nil, err
}
// Connect to the socket
client := abcicli.NewSocketClient(socket, false)
client.SetLogger(logger.With("module", "abci-client"))
if err := client.Start(); err != nil {
if _, err := client.Start(); err != nil {
server.Stop()
return nil, nil, err
}
@@ -238,13 +238,13 @@ func makeGRPCClientServer(app types.Application, name string) (abcicli.Client, c
gapp := types.NewGRPCApplication(app)
server := abciserver.NewGRPCServer(socket, gapp)
server.SetLogger(logger.With("module", "abci-server"))
if err := server.Start(); err != nil {
if _, err := server.Start(); err != nil {
return nil, nil, err
}
client := abcicli.NewGRPCClient(socket, true)
client.SetLogger(logger.With("module", "abci-client"))
if err := client.Start(); err != nil {
if _, err := client.Start(); err != nil {
server.Stop()
return nil, nil, err
}
@@ -310,8 +310,8 @@ func testClient(t *testing.T, app abcicli.Client, tx []byte, key, value string)
require.Nil(t, err)
require.Equal(t, code.CodeTypeOK, resQuery.Code)
require.Equal(t, value, string(resQuery.Value))
proof, err := iavl.ReadKeyExistsProof(resQuery.Proof)
proof, err := iavl.ReadKeyProof(resQuery.Proof)
require.Nil(t, err)
err = proof.Verify([]byte(key), resQuery.Value, proof.RootHash)
err = proof.Verify([]byte(key), resQuery.Value, proof.Root())
require.Nil(t, err, "%+v", err) // NOTE: we have no way to verify the RootHash
}
+4 -5
View File
@@ -40,7 +40,7 @@ func NewPersistentDummyApplication(dbDir string) *PersistentDummyApplication {
panic(err)
}
stateTree := iavl.NewVersionedTree(500, db)
stateTree := iavl.NewVersionedTree(db, 500)
stateTree.Load()
return &PersistentDummyApplication{
@@ -55,8 +55,7 @@ func (app *PersistentDummyApplication) SetLogger(l log.Logger) {
func (app *PersistentDummyApplication) Info(req types.RequestInfo) types.ResponseInfo {
res := app.app.Info(req)
var latestVersion uint64 = app.app.state.LatestVersion() // TODO: change to int64
res.LastBlockHeight = int64(latestVersion)
res.LastBlockHeight = app.app.state.Version64()
res.LastBlockAppHash = app.app.state.Hash()
return res
}
@@ -87,11 +86,11 @@ func (app *PersistentDummyApplication) CheckTx(tx []byte) types.ResponseCheckTx
func (app *PersistentDummyApplication) Commit() types.ResponseCommit {
// Save a new version for next height
height := app.app.state.LatestVersion() + 1
var height int64
var appHash []byte
var err error
appHash, err = app.app.state.SaveVersion(height)
appHash, height, err = app.app.state.SaveVersion()
if err != nil {
// if this wasn't a dummy app, we'd do something smarter
panic(err)
+3 -3
View File
@@ -42,7 +42,7 @@ func testStream(t *testing.T, app types.Application) {
// Start the listener
server := abciserver.NewSocketServer("unix://test.sock", app)
server.SetLogger(log.TestingLogger().With("module", "abci-server"))
if err := server.Start(); err != nil {
if _, err := server.Start(); err != nil {
t.Fatalf("Error starting socket server: %v", err.Error())
}
defer server.Stop()
@@ -50,7 +50,7 @@ func testStream(t *testing.T, app types.Application) {
// Connect to the socket
client := abcicli.NewSocketClient("unix://test.sock", false)
client.SetLogger(log.TestingLogger().With("module", "abci-client"))
if err := client.Start(); err != nil {
if _, err := client.Start(); err != nil {
t.Fatalf("Error starting socket client: %v", err.Error())
}
defer client.Stop()
@@ -115,7 +115,7 @@ func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
// Start the listener
server := abciserver.NewGRPCServer("unix://test.sock", app)
server.SetLogger(log.TestingLogger().With("module", "abci-server"))
if err := server.Start(); err != nil {
if _, err := server.Start(); err != nil {
t.Fatalf("Error starting GRPC server: %v", err.Error())
}
defer server.Stop()