mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 15:04:22 +00:00
TMEventDataInner
This commit is contained in:
@@ -25,7 +25,7 @@ func TestHeaderEvents(t *testing.T) {
|
||||
evtTyp := types.EventStringNewBlockHeader()
|
||||
evt, err := client.WaitForOneEvent(c, evtTyp, 1*time.Second)
|
||||
require.Nil(err, "%d: %+v", i, err)
|
||||
_, ok := evt.(types.EventDataNewBlockHeader)
|
||||
_, ok := evt.Unwrap().(types.EventDataNewBlockHeader)
|
||||
require.True(ok, "%d: %#v", i, evt)
|
||||
// TODO: more checks...
|
||||
}
|
||||
@@ -56,7 +56,7 @@ func TestTxEvents(t *testing.T) {
|
||||
evt, err := client.WaitForOneEvent(c, evtTyp, 1*time.Second)
|
||||
require.Nil(err, "%d: %+v", i, err)
|
||||
// and make sure it has the proper info
|
||||
txe, ok := evt.(types.EventDataTx)
|
||||
txe, ok := evt.Unwrap().(types.EventDataTx)
|
||||
require.True(ok, "%d: %#v", i, evt)
|
||||
// make sure this is the proper tx
|
||||
require.EqualValues(tx, txe.Tx)
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
events "github.com/tendermint/tmlibs/events"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
// Waiter is informed of current height, decided whether to quit early
|
||||
@@ -77,12 +77,12 @@ func WaitForOneEvent(evsw types.EventSwitch,
|
||||
|
||||
select {
|
||||
case <-quit:
|
||||
return nil, errors.New("timed out waiting for event")
|
||||
return types.TMEventData{}, errors.New("timed out waiting for event")
|
||||
case evt := <-evts:
|
||||
tmevt, ok := evt.(types.TMEventData)
|
||||
if ok {
|
||||
return tmevt, nil
|
||||
}
|
||||
return nil, errors.Errorf("Got unexpected event type: %#v", evt)
|
||||
return types.TMEventData{}, errors.Errorf("Got unexpected event type: %#v", evt)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
// subscribe to tx being committed in block
|
||||
deliverTxResCh := make(chan types.EventDataTx, 1)
|
||||
types.AddListenerForEvent(eventSwitch, "rpc", types.EventStringTx(tx), func(data types.TMEventData) {
|
||||
deliverTxResCh <- data.(types.EventDataTx)
|
||||
deliverTxResCh <- data.Unwrap().(types.EventDataTx)
|
||||
})
|
||||
|
||||
// broadcast the tx and register checktx callback
|
||||
|
||||
+4
-6
@@ -208,12 +208,10 @@ func testWithHTTPClient(t *testing.T, cl client.HTTPClient) {
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, got3, val3)
|
||||
|
||||
/*
|
||||
val4 := rand.Intn(10000)
|
||||
got4, err := echoIntViaHTTP(cl, val4)
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, got4, val4)
|
||||
*/
|
||||
val4 := rand.Intn(10000)
|
||||
got4, err := echoIntViaHTTP(cl, val4)
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, got4, val4)
|
||||
}
|
||||
|
||||
func echoViaWS(cl *client.WSClient, val string) (string, error) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/tendermint/rpc/core"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
rpc "github.com/tendermint/tendermint/rpc/lib/client"
|
||||
@@ -116,7 +117,7 @@ func testABCIQuery(t *testing.T, client rpc.HTTPClient) {
|
||||
time.Sleep(time.Millisecond * 500)
|
||||
tmResult := new(ctypes.TMResult)
|
||||
_, err := client.Call("abci_query",
|
||||
map[string]interface{}{"path": "", "data": k, "prove": false}, tmResult)
|
||||
map[string]interface{}{"path": "", "data": data.Bytes(k), "prove": false}, tmResult)
|
||||
require.Nil(t, err)
|
||||
|
||||
resQuery := tmResult.Unwrap().(*ctypes.ResultABCIQuery)
|
||||
@@ -286,7 +287,7 @@ func TestWSBlockchainGrowth(t *testing.T) {
|
||||
var initBlockN int
|
||||
for i := 0; i < 3; i++ {
|
||||
waitForEvent(t, wsc, eid, true, func() {}, func(eid string, eventData interface{}) error {
|
||||
block := eventData.(types.EventDataNewBlock).Block
|
||||
block := eventData.(types.TMEventData).Unwrap().(types.EventDataNewBlock).Block
|
||||
if i == 0 {
|
||||
initBlockN = block.Header.Height
|
||||
} else {
|
||||
@@ -320,7 +321,7 @@ func TestWSTxEvent(t *testing.T) {
|
||||
require.Nil(err)
|
||||
|
||||
waitForEvent(t, wsc, eid, true, func() {}, func(eid string, b interface{}) error {
|
||||
evt, ok := b.(types.EventDataTx)
|
||||
evt, ok := b.(types.TMEventData).Unwrap().(types.EventDataTx)
|
||||
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)
|
||||
|
||||
@@ -131,9 +131,11 @@ func waitForEvent(t *testing.T, wsc *client.WSClient, eventid string, dieOnTimeo
|
||||
for {
|
||||
select {
|
||||
case r := <-wsc.ResultsCh:
|
||||
fmt.Println("GOT IT", string(r))
|
||||
result := new(ctypes.TMResult)
|
||||
err = json.Unmarshal(r, result)
|
||||
if err != nil {
|
||||
fmt.Println("POOP", err)
|
||||
errCh <- err
|
||||
break LOOP
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user