|
@ -6,6 +6,7 @@ import ( |
|
|
"strings" |
|
|
"strings" |
|
|
"testing" |
|
|
"testing" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require" |
|
|
abciclient "github.com/tendermint/tendermint/abci/client" |
|
|
abciclient "github.com/tendermint/tendermint/abci/client" |
|
|
"github.com/tendermint/tendermint/abci/example/kvstore" |
|
|
"github.com/tendermint/tendermint/abci/example/kvstore" |
|
|
"github.com/tendermint/tendermint/abci/server" |
|
|
"github.com/tendermint/tendermint/abci/server" |
|
@ -56,20 +57,14 @@ func TestEcho(t *testing.T) { |
|
|
|
|
|
|
|
|
// Start server
|
|
|
// Start server
|
|
|
s := server.NewSocketServer(logger.With("module", "abci-server"), sockPath, kvstore.NewApplication()) |
|
|
s := server.NewSocketServer(logger.With("module", "abci-server"), sockPath, kvstore.NewApplication()) |
|
|
if err := s.Start(ctx); err != nil { |
|
|
|
|
|
t.Fatalf("Error starting socket server: %v", err.Error()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
require.NoError(t, s.Start(ctx), "error starting socket server") |
|
|
t.Cleanup(func() { cancel(); s.Wait() }) |
|
|
t.Cleanup(func() { cancel(); s.Wait() }) |
|
|
|
|
|
|
|
|
// Start client
|
|
|
// Start client
|
|
|
cli, err := clientCreator(logger.With("module", "abci-client")) |
|
|
cli, err := clientCreator(logger.With("module", "abci-client")) |
|
|
if err != nil { |
|
|
|
|
|
t.Fatalf("Error creating ABCI client: %v", err.Error()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
require.NoError(t, err, "Error creating ABCI client:") |
|
|
|
|
|
|
|
|
if err := cli.Start(ctx); err != nil { |
|
|
|
|
|
t.Fatalf("Error starting ABCI client: %v", err.Error()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
require.NoError(t, cli.Start(ctx), "Error starting ABCI client") |
|
|
|
|
|
|
|
|
proxy := newAppConnTest(cli) |
|
|
proxy := newAppConnTest(cli) |
|
|
t.Log("Connected") |
|
|
t.Log("Connected") |
|
@ -102,20 +97,14 @@ func BenchmarkEcho(b *testing.B) { |
|
|
|
|
|
|
|
|
// Start server
|
|
|
// Start server
|
|
|
s := server.NewSocketServer(logger.With("module", "abci-server"), sockPath, kvstore.NewApplication()) |
|
|
s := server.NewSocketServer(logger.With("module", "abci-server"), sockPath, kvstore.NewApplication()) |
|
|
if err := s.Start(ctx); err != nil { |
|
|
|
|
|
b.Fatalf("Error starting socket server: %v", err.Error()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
require.NoError(b, s.Start(ctx), "Error starting socket server") |
|
|
b.Cleanup(func() { cancel(); s.Wait() }) |
|
|
b.Cleanup(func() { cancel(); s.Wait() }) |
|
|
|
|
|
|
|
|
// Start client
|
|
|
// Start client
|
|
|
cli, err := clientCreator(logger.With("module", "abci-client")) |
|
|
cli, err := clientCreator(logger.With("module", "abci-client")) |
|
|
if err != nil { |
|
|
|
|
|
b.Fatalf("Error creating ABCI client: %v", err.Error()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
require.NoError(b, err, "Error creating ABCI client") |
|
|
|
|
|
|
|
|
if err := cli.Start(ctx); err != nil { |
|
|
|
|
|
b.Fatalf("Error starting ABCI client: %v", err.Error()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
require.NoError(b, cli.Start(ctx), "Error starting ABCI client") |
|
|
|
|
|
|
|
|
proxy := newAppConnTest(cli) |
|
|
proxy := newAppConnTest(cli) |
|
|
b.Log("Connected") |
|
|
b.Log("Connected") |
|
@ -153,28 +142,21 @@ func TestInfo(t *testing.T) { |
|
|
|
|
|
|
|
|
// Start server
|
|
|
// Start server
|
|
|
s := server.NewSocketServer(logger.With("module", "abci-server"), sockPath, kvstore.NewApplication()) |
|
|
s := server.NewSocketServer(logger.With("module", "abci-server"), sockPath, kvstore.NewApplication()) |
|
|
if err := s.Start(ctx); err != nil { |
|
|
|
|
|
t.Fatalf("Error starting socket server: %v", err.Error()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
require.NoError(t, s.Start(ctx), "Error starting socket server") |
|
|
t.Cleanup(func() { cancel(); s.Wait() }) |
|
|
t.Cleanup(func() { cancel(); s.Wait() }) |
|
|
|
|
|
|
|
|
// Start client
|
|
|
// Start client
|
|
|
cli, err := clientCreator(logger.With("module", "abci-client")) |
|
|
cli, err := clientCreator(logger.With("module", "abci-client")) |
|
|
if err != nil { |
|
|
|
|
|
t.Fatalf("Error creating ABCI client: %v", err.Error()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
require.NoError(t, err, "Error creating ABCI client") |
|
|
|
|
|
|
|
|
if err := cli.Start(ctx); err != nil { |
|
|
|
|
|
t.Fatalf("Error starting ABCI client: %v", err.Error()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
require.NoError(t, cli.Start(ctx), "Error starting ABCI client") |
|
|
|
|
|
|
|
|
proxy := newAppConnTest(cli) |
|
|
proxy := newAppConnTest(cli) |
|
|
t.Log("Connected") |
|
|
t.Log("Connected") |
|
|
|
|
|
|
|
|
resInfo, err := proxy.InfoSync(context.Background(), RequestInfo) |
|
|
resInfo, err := proxy.InfoSync(context.Background(), RequestInfo) |
|
|
if err != nil { |
|
|
|
|
|
t.Errorf("unexpected error: %v", err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
if resInfo.Data != "{\"size\":0}" { |
|
|
if resInfo.Data != "{\"size\":0}" { |
|
|
t.Error("Expected ResponseInfo with one element '{\"size\":0}' but got something else") |
|
|
t.Error("Expected ResponseInfo with one element '{\"size\":0}' but got something else") |
|
|
} |
|
|
} |
|
|