mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-21 00:46:32 +00:00
Clean up event switch add helper function
This commit is contained in:
@ -179,59 +179,3 @@ func TestAppCalls(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestSubscriptions only works for HTTPClient
|
||||
//
|
||||
// TODO: generalize this functionality -> Local and Client
|
||||
// func TestSubscriptions(t *testing.T) {
|
||||
// require := require.New(t)
|
||||
// c := getHTTPClient()
|
||||
// err := c.StartWebsocket()
|
||||
// require.Nil(err)
|
||||
// defer c.StopWebsocket()
|
||||
|
||||
// // subscribe to a transaction event
|
||||
// _, _, tx := merktest.MakeTxKV()
|
||||
// eventType := types.EventStringTx(types.Tx(tx))
|
||||
// c.Subscribe(eventType)
|
||||
|
||||
// // set up a listener
|
||||
// r, e := c.GetEventChannels()
|
||||
// go func() {
|
||||
// // send a tx and wait for it to propogate
|
||||
// _, err = c.BroadcastTxCommit(tx)
|
||||
// require.Nil(err, string(tx))
|
||||
// }()
|
||||
|
||||
// checkData := func(data []byte, kind byte) {
|
||||
// x := []interface{}{}
|
||||
// err := json.Unmarshal(data, &x)
|
||||
// require.Nil(err)
|
||||
// // gotta love wire's json format
|
||||
// require.EqualValues(kind, x[0])
|
||||
// }
|
||||
|
||||
// res := <-r
|
||||
// checkData(res, ctypes.ResultTypeSubscribe)
|
||||
|
||||
// // read one event, must be success
|
||||
// select {
|
||||
// case res := <-r:
|
||||
// checkData(res, ctypes.ResultTypeEvent)
|
||||
// // this is good.. let's get the data... ugh...
|
||||
// // result := new(ctypes.TMResult)
|
||||
// // wire.ReadJSON(result, res, &err)
|
||||
// // require.Nil(err, "%+v", err)
|
||||
// // event, ok := (*result).(*ctypes.ResultEvent)
|
||||
// // require.True(ok)
|
||||
// // assert.Equal("foo", event.Name)
|
||||
// // data, ok := event.Data.(types.EventDataTx)
|
||||
// // require.True(ok)
|
||||
// // assert.EqualValues(0, data.Code)
|
||||
// // assert.EqualValues(tx, data.Tx)
|
||||
// case err := <-e:
|
||||
// // this is a failure
|
||||
// require.Nil(err)
|
||||
// }
|
||||
|
||||
// }
|
||||
|
Reference in New Issue
Block a user