Browse Source

update for a new ABCI API

pull/503/head
Anton Kaliaev 7 years ago
parent
commit
91dc87e7c4
No known key found for this signature in database GPG Key ID: 7B6881D965918214
6 changed files with 71 additions and 33 deletions
  1. +1
    -0
      consensus/replay.go
  2. +5
    -12
      glide.lock
  3. +8
    -0
      mempool/mempool_test.go
  4. +36
    -12
      proxy/app_conn_test.go
  5. +3
    -3
      proxy/client.go
  6. +18
    -6
      proxy/multi_app_conn.go

+ 1
- 0
consensus/replay.go View File

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


+ 5
- 12
glide.lock View File

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


+ 8
- 0
mempool/mempool_test.go View File

@ -18,7 +18,15 @@ func TestSerialReap(t *testing.T) {
app.SetOption("serial", "on")
cc := proxy.NewLocalClientCreator(app)
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.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.SetLogger(log.TestingLogger())


+ 36
- 12
proxy/app_conn_test.go View File

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


+ 3
- 3
proxy/client.go View File

@ -1,9 +1,10 @@
package proxy
import (
"fmt"
"sync"
"github.com/pkg/errors"
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/types"
@ -51,10 +52,9 @@ func NewRemoteClientCreator(addr, transport string, mustConnect bool) ClientCrea
}
func (r *remoteClientCreator) NewABCIClient() (abcicli.Client, error) {
// Run forever in a loop
remoteApp, err := abcicli.NewClient(r.addr, r.transport, r.mustConnect)
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
}


+ 18
- 6
proxy/multi_app_conn.go View File

@ -1,6 +1,8 @@
package proxy
import (
"github.com/pkg/errors"
cmn "github.com/tendermint/tmlibs/common"
)
@ -70,25 +72,34 @@ func (app *multiAppConn) Query() AppConnQuery {
func (app *multiAppConn) OnStart() error {
// query connection
querycli, err := app.clientCreator.NewABCIClient()
querycli.SetLogger(app.Logger.With("module", "abci-client", "connection", "query"))
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)
// mempool connection
memcli, err := app.clientCreator.NewABCIClient()
memcli.SetLogger(app.Logger.With("module", "abci-client", "connection", "mempool"))
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)
// consensus connection
concli, err := app.clientCreator.NewABCIClient()
concli.SetLogger(app.Logger.With("module", "abci-client", "connection", "consensus"))
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)
@ -96,5 +107,6 @@ func (app *multiAppConn) OnStart() error {
if app.handshaker != nil {
return app.handshaker.Handshake(app)
}
return nil
}

Loading…
Cancel
Save