Merge remote-tracking branch 'origin/update-for-new-abci-api' into develop

This commit is contained in:
Ethan Buchman 2017-05-16 23:58:48 +02:00
commit 9d7d8075d1
6 changed files with 72 additions and 34 deletions

View File

@ -388,6 +388,7 @@ func newMockProxyApp(appHash []byte, abciResponses *sm.ABCIResponses) proxy.AppC
abciResponses: abciResponses, abciResponses: abciResponses,
}) })
cli, _ := clientCreator.NewABCIClient() cli, _ := clientCreator.NewABCIClient()
cli.Start()
return proxy.NewAppConnConsensus(cli) return proxy.NewAppConnConsensus(cli)
} }

19
glide.lock generated
View File

@ -1,12 +1,10 @@
hash: aa1fd2f52c45db131460b9dedf558ce2d2119ae9f313424578c65cf8efbf38e3 hash: 9caff08aa026986b239e4aeb9d876bdddfacadc64a660ee8109e77a211e53436
updated: 2017-05-16T10:38:37.077880616Z updated: 2017-05-16T16:19:50.278000355Z
imports: imports:
- name: github.com/btcsuite/btcd - name: github.com/btcsuite/btcd
version: 1ae306021e323ae11c71ffb8546fbd9019e6cb6f version: 1ae306021e323ae11c71ffb8546fbd9019e6cb6f
subpackages: subpackages:
- btcec - btcec
- name: github.com/clipperhouse/typewriter
version: c1a48da378ebb7db1db9f35981b5cc24bf2e5b85
- name: github.com/davecgh/go-spew - name: github.com/davecgh/go-spew
version: 04cdfd42973bb9c8589fd6a731800cf222fde1a9 version: 04cdfd42973bb9c8589fd6a731800cf222fde1a9
subpackages: subpackages:
@ -104,7 +102,7 @@ imports:
- leveldb/table - leveldb/table
- leveldb/util - leveldb/util
- name: github.com/tendermint/abci - name: github.com/tendermint/abci
version: b662bc7d3439b3c2cce615e8c3502b762e133dbf version: 5dabeffb35c027d7087a12149685daa68989168b
subpackages: subpackages:
- client - client
- example/counter - example/counter
@ -117,9 +115,9 @@ imports:
- edwards25519 - edwards25519
- extra25519 - extra25519
- name: github.com/tendermint/go-crypto - name: github.com/tendermint/go-crypto
version: e71bbb2509b586f0b24f120b6ba57f32aefa1579 version: 438b16f1f84ef002d7408ecd6fc3a3974cbc9559
- name: github.com/tendermint/go-wire - name: github.com/tendermint/go-wire
version: 8b47d1a9dd4e94ee0e099216c382847342405ab9 version: 97beaedf0f4dbc035309157c92be3b30cc6e5d74
subpackages: subpackages:
- data - data
- data/base58 - data/base58
@ -131,7 +129,7 @@ imports:
- iavl - iavl
- testutil - testutil
- name: github.com/tendermint/tmlibs - name: github.com/tendermint/tmlibs
version: d0cae7b6edb4896390fd5ff82aea1bac98994bd0 version: 812d9f9b84d1dfe4cb46ce021b3a2d97b48d1292
subpackages: subpackages:
- autofile - autofile
- cli - cli
@ -175,11 +173,6 @@ imports:
- transform - transform
- unicode/bidi - unicode/bidi
- unicode/norm - unicode/norm
- name: golang.org/x/tools
version: 144c6642b5d832d6c44a53dad6ee61665dd432ce
subpackages:
- go/ast/astutil
- imports
- name: google.golang.org/genproto - name: google.golang.org/genproto
version: 411e09b969b1170a9f0c467558eb4c4c110d9c77 version: 411e09b969b1170a9f0c467558eb4c4c110d9c77
subpackages: subpackages:

View File

@ -18,7 +18,15 @@ func TestSerialReap(t *testing.T) {
app.SetOption("serial", "on") app.SetOption("serial", "on")
cc := proxy.NewLocalClientCreator(app) cc := proxy.NewLocalClientCreator(app)
appConnMem, _ := cc.NewABCIClient() appConnMem, _ := cc.NewABCIClient()
appConnMem.SetLogger(log.TestingLogger().With("module", "abci-client", "connection", "mempool"))
if _, err := appConnMem.Start(); err != nil {
t.Fatalf("Error starting ABCI client: %v", err.Error())
}
appConnCon, _ := cc.NewABCIClient() appConnCon, _ := cc.NewABCIClient()
appConnCon.SetLogger(log.TestingLogger().With("module", "abci-client", "connection", "consensus"))
if _, err := appConnCon.Start(); err != nil {
t.Fatalf("Error starting ABCI client: %v", err.Error())
}
mempool := NewMempool(config.Mempool, appConnMem) mempool := NewMempool(config.Mempool, appConnMem)
mempool.SetLogger(log.TestingLogger()) mempool.SetLogger(log.TestingLogger())

View File

@ -9,6 +9,7 @@ import (
"github.com/tendermint/abci/server" "github.com/tendermint/abci/server"
"github.com/tendermint/abci/types" "github.com/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
) )
//---------------------------------------- //----------------------------------------
@ -48,16 +49,23 @@ func TestEcho(t *testing.T) {
clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true) clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true)
// Start server // Start server
s, err := server.NewSocketServer(sockPath, dummy.NewDummyApplication()) s := server.NewSocketServer(sockPath, dummy.NewDummyApplication())
if err != nil { s.SetLogger(log.TestingLogger().With("module", "abci-server"))
cmn.Exit(err.Error()) if _, err := s.Start(); err != nil {
t.Fatalf("Error starting socket server: %v", err.Error())
} }
defer s.Stop() defer s.Stop()
// Start client // Start client
cli, err := clientCreator.NewABCIClient() cli, err := clientCreator.NewABCIClient()
if err != nil { if err != nil {
cmn.Exit(err.Error()) t.Fatalf("Error creating ABCI client: %v", err.Error())
} }
cli.SetLogger(log.TestingLogger().With("module", "abci-client"))
if _, err := cli.Start(); err != nil {
t.Fatalf("Error starting ABCI client: %v", err.Error())
}
proxy := NewAppConnTest(cli) proxy := NewAppConnTest(cli)
t.Log("Connected") t.Log("Connected")
@ -71,17 +79,25 @@ func BenchmarkEcho(b *testing.B) {
b.StopTimer() // Initialize b.StopTimer() // Initialize
sockPath := cmn.Fmt("unix:///tmp/echo_%v.sock", cmn.RandStr(6)) sockPath := cmn.Fmt("unix:///tmp/echo_%v.sock", cmn.RandStr(6))
clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true) clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true)
// Start server // Start server
s, err := server.NewSocketServer(sockPath, dummy.NewDummyApplication()) s := server.NewSocketServer(sockPath, dummy.NewDummyApplication())
if err != nil { s.SetLogger(log.TestingLogger().With("module", "abci-server"))
cmn.Exit(err.Error()) if _, err := s.Start(); err != nil {
b.Fatalf("Error starting socket server: %v", err.Error())
} }
defer s.Stop() defer s.Stop()
// Start client // Start client
cli, err := clientCreator.NewABCIClient() cli, err := clientCreator.NewABCIClient()
if err != nil { if err != nil {
cmn.Exit(err.Error()) b.Fatalf("Error creating ABCI client: %v", err.Error())
} }
cli.SetLogger(log.TestingLogger().With("module", "abci-client"))
if _, err := cli.Start(); err != nil {
b.Fatalf("Error starting ABCI client: %v", err.Error())
}
proxy := NewAppConnTest(cli) proxy := NewAppConnTest(cli)
b.Log("Connected") b.Log("Connected")
echoString := strings.Repeat(" ", 200) echoString := strings.Repeat(" ", 200)
@ -100,17 +116,25 @@ func BenchmarkEcho(b *testing.B) {
func TestInfo(t *testing.T) { func TestInfo(t *testing.T) {
sockPath := cmn.Fmt("unix:///tmp/echo_%v.sock", cmn.RandStr(6)) sockPath := cmn.Fmt("unix:///tmp/echo_%v.sock", cmn.RandStr(6))
clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true) clientCreator := NewRemoteClientCreator(sockPath, SOCKET, true)
// Start server // Start server
s, err := server.NewSocketServer(sockPath, dummy.NewDummyApplication()) s := server.NewSocketServer(sockPath, dummy.NewDummyApplication())
if err != nil { s.SetLogger(log.TestingLogger().With("module", "abci-server"))
cmn.Exit(err.Error()) if _, err := s.Start(); err != nil {
t.Fatalf("Error starting socket server: %v", err.Error())
} }
defer s.Stop() defer s.Stop()
// Start client // Start client
cli, err := clientCreator.NewABCIClient() cli, err := clientCreator.NewABCIClient()
if err != nil { if err != nil {
cmn.Exit(err.Error()) t.Fatalf("Error creating ABCI client: %v", err.Error())
} }
cli.SetLogger(log.TestingLogger().With("module", "abci-client"))
if _, err := cli.Start(); err != nil {
t.Fatalf("Error starting ABCI client: %v", err.Error())
}
proxy := NewAppConnTest(cli) proxy := NewAppConnTest(cli)
t.Log("Connected") t.Log("Connected")

View File

@ -1,9 +1,10 @@
package proxy package proxy
import ( import (
"fmt"
"sync" "sync"
"github.com/pkg/errors"
abcicli "github.com/tendermint/abci/client" abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/dummy" "github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/types" "github.com/tendermint/abci/types"
@ -51,10 +52,9 @@ func NewRemoteClientCreator(addr, transport string, mustConnect bool) ClientCrea
} }
func (r *remoteClientCreator) NewABCIClient() (abcicli.Client, error) { func (r *remoteClientCreator) NewABCIClient() (abcicli.Client, error) {
// Run forever in a loop
remoteApp, err := abcicli.NewClient(r.addr, r.transport, r.mustConnect) remoteApp, err := abcicli.NewClient(r.addr, r.transport, r.mustConnect)
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to connect to proxy: %v", err) return nil, errors.Wrap(err, "Failed to connect to proxy")
} }
return remoteApp, nil return remoteApp, nil
} }

View File

@ -1,6 +1,8 @@
package proxy package proxy
import ( import (
"github.com/pkg/errors"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
) )
@ -70,25 +72,34 @@ func (app *multiAppConn) Query() AppConnQuery {
func (app *multiAppConn) OnStart() error { func (app *multiAppConn) OnStart() error {
// query connection // query connection
querycli, err := app.clientCreator.NewABCIClient() querycli, err := app.clientCreator.NewABCIClient()
querycli.SetLogger(app.Logger.With("module", "abci-client", "connection", "query"))
if err != nil { if err != nil {
return err return errors.Wrap(err, "Error creating ABCI client (query connection)")
}
querycli.SetLogger(app.Logger.With("module", "abci-client", "connection", "query"))
if _, err := querycli.Start(); err != nil {
return errors.Wrap(err, "Error starting ABCI client (query connection)")
} }
app.queryConn = NewAppConnQuery(querycli) app.queryConn = NewAppConnQuery(querycli)
// mempool connection // mempool connection
memcli, err := app.clientCreator.NewABCIClient() memcli, err := app.clientCreator.NewABCIClient()
memcli.SetLogger(app.Logger.With("module", "abci-client", "connection", "mempool"))
if err != nil { if err != nil {
return err return errors.Wrap(err, "Error creating ABCI client (mempool connection)")
}
memcli.SetLogger(app.Logger.With("module", "abci-client", "connection", "mempool"))
if _, err := memcli.Start(); err != nil {
return errors.Wrap(err, "Error starting ABCI client (mempool connection)")
} }
app.mempoolConn = NewAppConnMempool(memcli) app.mempoolConn = NewAppConnMempool(memcli)
// consensus connection // consensus connection
concli, err := app.clientCreator.NewABCIClient() concli, err := app.clientCreator.NewABCIClient()
concli.SetLogger(app.Logger.With("module", "abci-client", "connection", "consensus"))
if err != nil { if err != nil {
return err return errors.Wrap(err, "Error creating ABCI client (consensus connection)")
}
concli.SetLogger(app.Logger.With("module", "abci-client", "connection", "consensus"))
if _, err := concli.Start(); err != nil {
return errors.Wrap(err, "Error starting ABCI client (consensus connection)")
} }
app.consensusConn = NewAppConnConsensus(concli) app.consensusConn = NewAppConnConsensus(concli)
@ -96,5 +107,6 @@ func (app *multiAppConn) OnStart() error {
if app.handshaker != nil { if app.handshaker != nil {
return app.handshaker.Handshake(app) return app.handshaker.Handshake(app)
} }
return nil return nil
} }