Browse Source

Move common code to merkleeyes/testutil

pull/418/head
Ethan Frey 8 years ago
parent
commit
9693795c4c
3 changed files with 4 additions and 49 deletions
  1. +1
    -1
      glide.lock
  2. +0
    -45
      rpc/client/http/app_test.go
  3. +3
    -3
      rpc/client/http/rpc_test.go

+ 1
- 1
glide.lock View File

@ -141,7 +141,7 @@ imports:
- transport
testImports:
- name: github.com/tendermint/merkleeyes
version: 87b0a111a716f1495f30ce58bd469e36ac220e09
version: acd8e9c42e1d819c51e9e1cd3870ea4d94b167f5
subpackages:
- app
- name: github.com/stretchr/testify


+ 0
- 45
rpc/client/http/app_test.go View File

@ -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
}

+ 3
- 3
rpc/client/http/rpc_test.go View File

@ -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)


Loading…
Cancel
Save