From 9693795c4cc45617dc336562957dc06960ff69a1 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 23 Feb 2017 13:43:28 +0100 Subject: [PATCH] Move common code to merkleeyes/testutil --- glide.lock | 2 +- rpc/client/http/app_test.go | 45 ------------------------------------- rpc/client/http/rpc_test.go | 6 ++--- 3 files changed, 4 insertions(+), 49 deletions(-) delete mode 100644 rpc/client/http/app_test.go diff --git a/glide.lock b/glide.lock index 3d72ddc04..28082d2c5 100644 --- a/glide.lock +++ b/glide.lock @@ -141,7 +141,7 @@ imports: - transport testImports: - name: github.com/tendermint/merkleeyes - version: 87b0a111a716f1495f30ce58bd469e36ac220e09 + version: acd8e9c42e1d819c51e9e1cd3870ea4d94b167f5 subpackages: - app - name: github.com/stretchr/testify diff --git a/rpc/client/http/app_test.go b/rpc/client/http/app_test.go deleted file mode 100644 index f90341440..000000000 --- a/rpc/client/http/app_test.go +++ /dev/null @@ -1,45 +0,0 @@ -package http_test - -import ( - "math/rand" - - meapp "github.com/tendermint/merkleeyes/app" - - wire "github.com/tendermint/go-wire" -) - -// MakeTxKV returns a text transaction, allong with expected key, value pair -func MakeTxKV() ([]byte, []byte, []byte) { - k := RandAsciiBytes(8) - v := RandAsciiBytes(8) - return k, v, makeSet(k, v) -} - -// blatently copied from merkleeyes/app/app_test.go -// constructs a "set" transaction -func makeSet(key, value []byte) []byte { - tx := make([]byte, 1+wire.ByteSliceSize(key)+wire.ByteSliceSize(value)) - buf := tx - buf[0] = meapp.WriteSet // Set TypeByte - buf = buf[1:] - n, err := wire.PutByteSlice(buf, key) - if err != nil { - panic(err) - } - buf = buf[n:] - n, err = wire.PutByteSlice(buf, value) - if err != nil { - panic(err) - } - return tx -} - -const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - -func RandAsciiBytes(n int) []byte { - b := make([]byte, n) - for i := range b { - b[i] = letterBytes[rand.Intn(len(letterBytes))] - } - return b -} diff --git a/rpc/client/http/rpc_test.go b/rpc/client/http/rpc_test.go index 4f48c7a27..965853777 100644 --- a/rpc/client/http/rpc_test.go +++ b/rpc/client/http/rpc_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" merkle "github.com/tendermint/go-merkle" + merktest "github.com/tendermint/merkleeyes/testutil" "github.com/tendermint/tendermint/rpc/client/http" ctypes "github.com/tendermint/tendermint/rpc/core/types" rpctest "github.com/tendermint/tendermint/rpc/test" @@ -95,7 +96,7 @@ func TestAppCalls(t *testing.T) { assert.NotNil(err) // no block yet // write something - k, v, tx := MakeTxKV() + k, v, tx := merktest.MakeTxKV() _, err = c.BroadcastTxCommit(tx) require.Nil(err, "%+v", err) // wait before querying @@ -164,8 +165,7 @@ func TestSubscriptions(t *testing.T) { defer c.StopWebsocket() // subscribe to a transaction event - _, _, tx := MakeTxKV() - // this causes a panic in tendermint core!!! + _, _, tx := merktest.MakeTxKV() eventType := types.EventStringTx(types.Tx(tx)) c.Subscribe(eventType)