2016-01-10 16:33:52 -05:00
|
|
|
package rpctest
|
|
|
|
|
|
|
|
import (
|
2016-07-05 14:41:50 -04:00
|
|
|
"bytes"
|
2016-08-22 16:00:48 -04:00
|
|
|
crand "crypto/rand"
|
2016-01-10 16:33:52 -05:00
|
|
|
"fmt"
|
2016-08-22 16:00:48 -04:00
|
|
|
"math/rand"
|
2016-01-10 16:33:52 -05:00
|
|
|
"testing"
|
2016-08-22 16:00:48 -04:00
|
|
|
"time"
|
2016-01-10 16:33:52 -05:00
|
|
|
|
2017-02-21 19:57:10 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
2017-04-09 23:07:15 -04:00
|
|
|
|
2017-01-28 08:27:13 -08:00
|
|
|
abci "github.com/tendermint/abci/types"
|
2017-04-28 17:57:06 -04:00
|
|
|
"github.com/tendermint/go-wire/data"
|
2017-04-29 00:07:50 -04:00
|
|
|
. "github.com/tendermint/tmlibs/common"
|
|
|
|
|
2017-04-26 19:57:33 -04:00
|
|
|
"github.com/tendermint/tendermint/rpc/core"
|
|
|
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
2017-04-27 19:51:18 -04:00
|
|
|
rpc "github.com/tendermint/tendermint/rpc/lib/client"
|
2017-04-18 19:56:41 -04:00
|
|
|
"github.com/tendermint/tendermint/state/txindex/null"
|
2016-01-10 16:33:52 -05:00
|
|
|
"github.com/tendermint/tendermint/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
// Test the HTTP client
|
2016-08-22 16:00:48 -04:00
|
|
|
// These tests assume the dummy app
|
2016-03-03 06:18:11 +00:00
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
// status
|
2016-01-10 16:33:52 -05:00
|
|
|
|
|
|
|
func TestURIStatus(t *testing.T) {
|
2017-04-11 15:44:36 -04:00
|
|
|
testStatus(t, GetURIClient())
|
2016-01-10 16:33:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestJSONStatus(t *testing.T) {
|
2017-04-11 15:44:36 -04:00
|
|
|
testStatus(t, GetJSONClient())
|
2016-01-10 16:33:52 -05:00
|
|
|
}
|
|
|
|
|
2017-04-11 15:44:36 -04:00
|
|
|
func testStatus(t *testing.T, client rpc.HTTPClient) {
|
2017-05-01 23:15:12 -04:00
|
|
|
moniker := GetConfig().Moniker
|
2017-04-28 22:26:17 -04:00
|
|
|
result := new(ctypes.ResultStatus)
|
|
|
|
_, err := client.Call("status", map[string]interface{}{}, result)
|
2017-04-11 15:44:36 -04:00
|
|
|
require.Nil(t, err)
|
2017-05-04 23:03:42 -04:00
|
|
|
assert.Equal(t, moniker, result.NodeInfo.Moniker)
|
2016-01-10 16:33:52 -05:00
|
|
|
}
|
|
|
|
|
2016-07-05 14:41:50 -04:00
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
// broadcast tx sync
|
|
|
|
|
2016-08-22 16:00:48 -04:00
|
|
|
// random bytes (excluding byte('='))
|
2017-02-21 19:57:10 +01:00
|
|
|
func randBytes(t *testing.T) []byte {
|
2016-08-22 16:00:48 -04:00
|
|
|
n := rand.Intn(10) + 2
|
|
|
|
buf := make([]byte, n)
|
|
|
|
_, err := crand.Read(buf)
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Nil(t, err)
|
2016-08-22 16:00:48 -04:00
|
|
|
return bytes.Replace(buf, []byte("="), []byte{100}, -1)
|
2016-07-11 20:40:24 -04:00
|
|
|
}
|
2016-07-05 14:41:50 -04:00
|
|
|
|
|
|
|
func TestURIBroadcastTxSync(t *testing.T) {
|
2017-04-11 15:44:36 -04:00
|
|
|
testBroadcastTxSync(t, GetURIClient())
|
2016-07-05 14:41:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestJSONBroadcastTxSync(t *testing.T) {
|
2017-04-11 15:44:36 -04:00
|
|
|
testBroadcastTxSync(t, GetJSONClient())
|
|
|
|
}
|
|
|
|
|
|
|
|
func testBroadcastTxSync(t *testing.T, client rpc.HTTPClient) {
|
2017-04-12 21:23:58 -04:00
|
|
|
mem := node.MempoolReactor().Mempool
|
|
|
|
initMemSize := mem.Size()
|
2017-04-28 22:26:17 -04:00
|
|
|
result := new(ctypes.ResultBroadcastTx)
|
2017-02-21 19:57:10 +01:00
|
|
|
tx := randBytes(t)
|
2017-04-28 22:26:17 -04:00
|
|
|
_, err := client.Call("broadcast_tx_sync", map[string]interface{}{"tx": tx}, result)
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Nil(t, err)
|
2016-07-05 14:41:50 -04:00
|
|
|
|
2017-04-28 22:26:17 -04:00
|
|
|
require.Equal(t, abci.CodeType_OK, result.Code)
|
2017-04-12 21:23:58 -04:00
|
|
|
require.Equal(t, initMemSize+1, mem.Size())
|
2016-07-05 14:41:50 -04:00
|
|
|
txs := mem.Reap(1)
|
2017-02-21 19:57:10 +01:00
|
|
|
require.EqualValues(t, tx, txs[0])
|
2016-07-05 14:41:50 -04:00
|
|
|
mem.Flush()
|
|
|
|
}
|
|
|
|
|
2016-08-22 16:00:48 -04:00
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
// query
|
|
|
|
|
2017-03-22 20:13:18 +01:00
|
|
|
func testTxKV(t *testing.T) ([]byte, []byte, types.Tx) {
|
2017-02-21 19:57:10 +01:00
|
|
|
k := randBytes(t)
|
|
|
|
v := randBytes(t)
|
2017-03-22 20:13:18 +01:00
|
|
|
return k, v, types.Tx(Fmt("%s=%s", k, v))
|
2016-08-22 16:00:48 -04:00
|
|
|
}
|
|
|
|
|
2017-04-11 15:44:36 -04:00
|
|
|
func sendTx(t *testing.T, client rpc.HTTPClient) ([]byte, []byte) {
|
2017-04-28 22:26:17 -04:00
|
|
|
result := new(ctypes.ResultBroadcastTxCommit)
|
2017-02-21 19:57:10 +01:00
|
|
|
k, v, tx := testTxKV(t)
|
2017-04-28 22:26:17 -04:00
|
|
|
_, err := client.Call("broadcast_tx_commit", map[string]interface{}{"tx": tx}, result)
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Nil(t, err)
|
2017-04-28 22:26:17 -04:00
|
|
|
require.NotNil(t, 0, result.DeliverTx, "%#v", result)
|
|
|
|
require.EqualValues(t, 0, result.CheckTx.Code, "%#v", result)
|
|
|
|
require.EqualValues(t, 0, result.DeliverTx.Code, "%#v", result)
|
2016-08-22 16:00:48 -04:00
|
|
|
return k, v
|
|
|
|
}
|
|
|
|
|
2017-01-12 15:53:32 -05:00
|
|
|
func TestURIABCIQuery(t *testing.T) {
|
2017-04-11 15:44:36 -04:00
|
|
|
testABCIQuery(t, GetURIClient())
|
2016-08-22 16:00:48 -04:00
|
|
|
}
|
|
|
|
|
2017-01-12 15:53:32 -05:00
|
|
|
func TestJSONABCIQuery(t *testing.T) {
|
2017-04-25 16:49:01 +02:00
|
|
|
testABCIQuery(t, GetJSONClient())
|
2017-04-11 15:44:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func testABCIQuery(t *testing.T, client rpc.HTTPClient) {
|
|
|
|
k, _ := sendTx(t, client)
|
2017-04-21 17:28:13 -04:00
|
|
|
time.Sleep(time.Millisecond * 500)
|
2017-04-28 22:26:17 -04:00
|
|
|
result := new(ctypes.ResultABCIQuery)
|
2017-04-11 15:44:36 -04:00
|
|
|
_, err := client.Call("abci_query",
|
2017-04-28 22:26:17 -04:00
|
|
|
map[string]interface{}{"path": "", "data": data.Bytes(k), "prove": false}, result)
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Nil(t, err)
|
2017-04-21 17:28:13 -04:00
|
|
|
|
2017-04-28 22:26:17 -04:00
|
|
|
require.EqualValues(t, 0, result.Code)
|
2016-11-22 21:28:57 -05:00
|
|
|
|
2016-08-22 16:00:48 -04:00
|
|
|
// XXX: specific to value returned by the dummy
|
2017-04-28 22:26:17 -04:00
|
|
|
require.NotEqual(t, 0, len(result.Value))
|
2016-08-22 16:00:48 -04:00
|
|
|
}
|
|
|
|
|
2016-07-05 14:41:50 -04:00
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
// broadcast tx commit
|
|
|
|
|
|
|
|
func TestURIBroadcastTxCommit(t *testing.T) {
|
2017-04-11 15:44:36 -04:00
|
|
|
testBroadcastTxCommit(t, GetURIClient())
|
2016-07-05 14:41:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestJSONBroadcastTxCommit(t *testing.T) {
|
2017-04-11 15:44:36 -04:00
|
|
|
testBroadcastTxCommit(t, GetJSONClient())
|
2017-04-11 12:57:06 +02:00
|
|
|
}
|
2017-04-10 21:16:41 +02:00
|
|
|
|
2017-04-11 15:44:36 -04:00
|
|
|
func testBroadcastTxCommit(t *testing.T, client rpc.HTTPClient) {
|
2017-04-11 12:57:06 +02:00
|
|
|
require := require.New(t)
|
2017-04-11 15:44:36 -04:00
|
|
|
|
2017-04-28 22:26:17 -04:00
|
|
|
result := new(ctypes.ResultBroadcastTxCommit)
|
2017-04-11 15:44:36 -04:00
|
|
|
tx := randBytes(t)
|
2017-04-28 22:26:17 -04:00
|
|
|
_, err := client.Call("broadcast_tx_commit", map[string]interface{}{"tx": tx}, result)
|
2017-04-11 15:44:36 -04:00
|
|
|
require.Nil(err)
|
|
|
|
|
2017-04-28 22:26:17 -04:00
|
|
|
checkTx := result.CheckTx
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Equal(abci.CodeType_OK, checkTx.Code)
|
2017-04-28 22:26:17 -04:00
|
|
|
deliverTx := result.DeliverTx
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Equal(abci.CodeType_OK, deliverTx.Code)
|
2016-07-05 14:41:50 -04:00
|
|
|
mem := node.MempoolReactor().Mempool
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Equal(0, mem.Size())
|
2016-07-11 20:40:24 -04:00
|
|
|
// TODO: find tx in block
|
2016-07-05 14:41:50 -04:00
|
|
|
}
|
2016-01-10 16:33:52 -05:00
|
|
|
|
2017-04-13 14:18:35 -04:00
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
// query tx
|
|
|
|
|
|
|
|
func TestURITx(t *testing.T) {
|
2017-04-13 22:26:07 +02:00
|
|
|
testTx(t, GetURIClient(), true)
|
2017-04-13 16:38:44 -04:00
|
|
|
|
2017-04-18 19:56:41 -04:00
|
|
|
core.SetTxIndexer(&null.TxIndex{})
|
2017-05-04 23:03:42 -04:00
|
|
|
defer core.SetTxIndexer(node.ConsensusState().GetState().TxIndexer)
|
|
|
|
|
|
|
|
testTx(t, GetURIClient(), false)
|
2017-04-13 14:18:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestJSONTx(t *testing.T) {
|
2017-04-13 22:26:07 +02:00
|
|
|
testTx(t, GetJSONClient(), true)
|
2017-04-13 14:18:35 -04:00
|
|
|
|
2017-04-18 19:56:41 -04:00
|
|
|
core.SetTxIndexer(&null.TxIndex{})
|
2017-04-13 22:26:07 +02:00
|
|
|
testTx(t, GetJSONClient(), false)
|
2017-04-13 16:38:44 -04:00
|
|
|
core.SetTxIndexer(node.ConsensusState().GetState().TxIndexer)
|
2017-04-13 22:26:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func testTx(t *testing.T, client rpc.HTTPClient, withIndexer bool) {
|
2017-04-13 20:43:16 +02:00
|
|
|
assert, require := assert.New(t), require.New(t)
|
2017-04-13 14:18:35 -04:00
|
|
|
|
|
|
|
// first we broadcast a tx
|
2017-04-28 22:26:17 -04:00
|
|
|
result := new(ctypes.ResultBroadcastTxCommit)
|
2017-04-13 16:04:20 -04:00
|
|
|
txBytes := randBytes(t)
|
|
|
|
tx := types.Tx(txBytes)
|
2017-04-28 22:26:17 -04:00
|
|
|
_, err := client.Call("broadcast_tx_commit", map[string]interface{}{"tx": txBytes}, result)
|
2017-04-13 14:18:35 -04:00
|
|
|
require.Nil(err)
|
|
|
|
|
2017-04-28 22:26:17 -04:00
|
|
|
checkTx := result.CheckTx
|
2017-04-13 14:18:35 -04:00
|
|
|
require.Equal(abci.CodeType_OK, checkTx.Code)
|
2017-04-28 22:26:17 -04:00
|
|
|
deliverTx := result.DeliverTx
|
2017-04-13 14:18:35 -04:00
|
|
|
require.Equal(abci.CodeType_OK, deliverTx.Code)
|
|
|
|
mem := node.MempoolReactor().Mempool
|
|
|
|
require.Equal(0, mem.Size())
|
|
|
|
|
2017-04-18 19:56:41 -04:00
|
|
|
txHash := tx.Hash()
|
|
|
|
txHash2 := types.Tx("a different tx").Hash()
|
|
|
|
|
2017-04-13 20:43:16 +02:00
|
|
|
cases := []struct {
|
2017-04-18 19:56:41 -04:00
|
|
|
valid bool
|
|
|
|
hash []byte
|
|
|
|
prove bool
|
2017-04-13 20:43:16 +02:00
|
|
|
}{
|
2017-04-18 19:56:41 -04:00
|
|
|
// only valid if correct hash provided
|
|
|
|
{true, txHash, false},
|
|
|
|
{true, txHash, true},
|
|
|
|
{false, txHash2, false},
|
|
|
|
{false, txHash2, true},
|
|
|
|
{false, nil, false},
|
|
|
|
{false, nil, true},
|
2017-04-13 20:43:16 +02:00
|
|
|
}
|
|
|
|
|
2017-04-13 21:20:21 +02:00
|
|
|
for i, tc := range cases {
|
|
|
|
idx := fmt.Sprintf("%d", i)
|
|
|
|
|
2017-04-13 20:43:16 +02:00
|
|
|
// now we query for the tx.
|
|
|
|
// since there's only one tx, we know index=0.
|
2017-04-28 22:26:17 -04:00
|
|
|
result2 := new(ctypes.ResultTx)
|
2017-04-13 20:43:16 +02:00
|
|
|
query := map[string]interface{}{
|
2017-04-18 19:56:41 -04:00
|
|
|
"hash": tc.hash,
|
|
|
|
"prove": tc.prove,
|
2017-04-13 20:43:16 +02:00
|
|
|
}
|
2017-04-28 22:26:17 -04:00
|
|
|
_, err = client.Call("tx", query, result2)
|
2017-04-18 19:56:41 -04:00
|
|
|
valid := (withIndexer && tc.valid)
|
2017-04-13 22:26:07 +02:00
|
|
|
if !valid {
|
2017-04-13 21:20:21 +02:00
|
|
|
require.NotNil(err, idx)
|
2017-04-13 20:43:16 +02:00
|
|
|
} else {
|
2017-04-13 21:20:21 +02:00
|
|
|
require.Nil(err, idx)
|
2017-04-28 22:26:17 -04:00
|
|
|
assert.Equal(tx, result2.Tx, idx)
|
|
|
|
assert.Equal(result.Height, result2.Height, idx)
|
|
|
|
assert.Equal(0, result2.Index, idx)
|
|
|
|
assert.Equal(abci.CodeType_OK, result2.TxResult.Code, idx)
|
2017-04-13 20:43:16 +02:00
|
|
|
// time to verify the proof
|
2017-04-28 22:26:17 -04:00
|
|
|
proof := result2.Proof
|
2017-04-13 21:20:21 +02:00
|
|
|
if tc.prove && assert.Equal(tx, proof.Data, idx) {
|
|
|
|
assert.True(proof.Proof.Verify(proof.Index, proof.Total, tx.Hash(), proof.RootHash), idx)
|
2017-04-13 20:43:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-13 14:18:35 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-01-10 16:33:52 -05:00
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
// Test the websocket service
|
|
|
|
|
|
|
|
// make a simple connection to the server
|
|
|
|
func TestWSConnect(t *testing.T) {
|
2017-02-21 19:36:18 +01:00
|
|
|
wsc := GetWSClient()
|
2016-01-13 21:20:25 -05:00
|
|
|
wsc.Stop()
|
2016-01-10 16:33:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// receive a new block message
|
|
|
|
func TestWSNewBlock(t *testing.T) {
|
2017-02-21 19:36:18 +01:00
|
|
|
wsc := GetWSClient()
|
2016-01-10 16:33:52 -05:00
|
|
|
eid := types.EventStringNewBlock()
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Nil(t, wsc.Subscribe(eid))
|
|
|
|
|
2016-01-10 16:33:52 -05:00
|
|
|
defer func() {
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Nil(t, wsc.Unsubscribe(eid))
|
2016-01-13 21:20:25 -05:00
|
|
|
wsc.Stop()
|
2016-01-10 16:33:52 -05:00
|
|
|
}()
|
2016-01-13 21:20:25 -05:00
|
|
|
waitForEvent(t, wsc, eid, true, func() {}, func(eid string, b interface{}) error {
|
2017-02-21 19:36:18 +01:00
|
|
|
// fmt.Println("Check:", b)
|
2016-01-10 16:33:52 -05:00
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// receive a few new block messages in a row, with increasing height
|
|
|
|
func TestWSBlockchainGrowth(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skipping test in short mode.")
|
|
|
|
}
|
2017-02-21 19:36:18 +01:00
|
|
|
wsc := GetWSClient()
|
2016-01-10 16:33:52 -05:00
|
|
|
eid := types.EventStringNewBlock()
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Nil(t, wsc.Subscribe(eid))
|
|
|
|
|
2016-01-10 16:33:52 -05:00
|
|
|
defer func() {
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Nil(t, wsc.Unsubscribe(eid))
|
2016-01-13 21:20:25 -05:00
|
|
|
wsc.Stop()
|
2016-01-10 16:33:52 -05:00
|
|
|
}()
|
2016-01-13 21:20:25 -05:00
|
|
|
|
2016-01-10 16:33:52 -05:00
|
|
|
// listen for NewBlock, ensure height increases by 1
|
2016-01-13 21:20:25 -05:00
|
|
|
|
|
|
|
var initBlockN int
|
|
|
|
for i := 0; i < 3; i++ {
|
|
|
|
waitForEvent(t, wsc, eid, true, func() {}, func(eid string, eventData interface{}) error {
|
2017-04-28 17:57:06 -04:00
|
|
|
block := eventData.(types.TMEventData).Unwrap().(types.EventDataNewBlock).Block
|
2016-01-13 21:20:25 -05:00
|
|
|
if i == 0 {
|
|
|
|
initBlockN = block.Header.Height
|
|
|
|
} else {
|
|
|
|
if block.Header.Height != initBlockN+i {
|
|
|
|
return fmt.Errorf("Expected block %d, got block %d", initBlockN+i, block.Header.Height)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
2016-01-10 16:33:52 -05:00
|
|
|
}
|
|
|
|
|
2016-10-06 21:23:22 +02:00
|
|
|
func TestWSTxEvent(t *testing.T) {
|
2017-02-21 19:57:10 +01:00
|
|
|
require := require.New(t)
|
2017-02-21 19:36:18 +01:00
|
|
|
wsc := GetWSClient()
|
2017-02-21 19:57:10 +01:00
|
|
|
tx := randBytes(t)
|
2016-10-06 21:23:22 +02:00
|
|
|
|
|
|
|
// listen for the tx I am about to submit
|
|
|
|
eid := types.EventStringTx(types.Tx(tx))
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Nil(wsc.Subscribe(eid))
|
|
|
|
|
2016-10-06 21:23:22 +02:00
|
|
|
defer func() {
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Nil(wsc.Unsubscribe(eid))
|
2016-10-06 21:23:22 +02:00
|
|
|
wsc.Stop()
|
|
|
|
}()
|
|
|
|
|
|
|
|
// send an tx
|
2017-04-28 22:26:17 -04:00
|
|
|
result := new(ctypes.ResultBroadcastTx)
|
|
|
|
_, err := GetJSONClient().Call("broadcast_tx_sync", map[string]interface{}{"tx": tx}, result)
|
2017-02-21 19:57:10 +01:00
|
|
|
require.Nil(err)
|
2016-10-06 21:23:22 +02:00
|
|
|
|
|
|
|
waitForEvent(t, wsc, eid, true, func() {}, func(eid string, b interface{}) error {
|
2017-04-28 17:57:06 -04:00
|
|
|
evt, ok := b.(types.TMEventData).Unwrap().(types.EventDataTx)
|
2017-02-21 19:57:10 +01:00
|
|
|
require.True(ok, "Got wrong event type: %#v", b)
|
|
|
|
require.Equal(tx, []byte(evt.Tx), "Returned different tx")
|
|
|
|
require.Equal(abci.CodeType_OK, evt.Code)
|
2016-10-06 21:23:22 +02:00
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-01-10 16:33:52 -05:00
|
|
|
/* TODO: this with dummy app..
|
|
|
|
func TestWSDoubleFire(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skipping test in short mode.")
|
|
|
|
}
|
|
|
|
con := newWSCon(t)
|
|
|
|
eid := types.EventStringAccInput(user[0].Address)
|
|
|
|
subscribe(t, con, eid)
|
|
|
|
defer func() {
|
|
|
|
unsubscribe(t, con, eid)
|
|
|
|
con.Close()
|
|
|
|
}()
|
|
|
|
amt := int64(100)
|
|
|
|
toAddr := user[1].Address
|
|
|
|
// broadcast the transaction, wait to hear about it
|
|
|
|
waitForEvent(t, con, eid, true, func() {
|
|
|
|
tx := makeDefaultSendTxSigned(t, wsTyp, toAddr, amt)
|
|
|
|
broadcastTx(t, wsTyp, tx)
|
|
|
|
}, func(eid string, b []byte) error {
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
// but make sure we don't hear about it twice
|
|
|
|
waitForEvent(t, con, eid, false, func() {
|
|
|
|
}, func(eid string, b []byte) error {
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}*/
|