Fix up checktx/delivertx in broadcastTx(A)sync
This commit is contained in:
parent
9693795c4c
commit
202146e4ce
|
@ -40,13 +40,21 @@ func (a ABCIApp) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit
|
|||
}
|
||||
|
||||
func (a ABCIApp) BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
d := a.App.DeliverTx(tx)
|
||||
return &ctypes.ResultBroadcastTx{d.Code, d.Data, d.Log}, nil
|
||||
c := a.App.CheckTx(tx)
|
||||
// and this gets writen in a background thread...
|
||||
if c.IsOK() {
|
||||
go func() { a.App.DeliverTx(tx) }()
|
||||
}
|
||||
return &ctypes.ResultBroadcastTx{c.Code, c.Data, c.Log}, nil
|
||||
}
|
||||
|
||||
func (a ABCIApp) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
d := a.App.DeliverTx(tx)
|
||||
return &ctypes.ResultBroadcastTx{d.Code, d.Data, d.Log}, nil
|
||||
c := a.App.CheckTx(tx)
|
||||
// and this gets writen in a background thread...
|
||||
if c.IsOK() {
|
||||
go func() { a.App.DeliverTx(tx) }()
|
||||
}
|
||||
return &ctypes.ResultBroadcastTx{c.Code, c.Data, c.Log}, nil
|
||||
}
|
||||
|
||||
// ABCIMock will send all abci related request to the named app,
|
||||
|
|
|
@ -156,9 +156,11 @@ func TestABCIApp(t *testing.T) {
|
|||
// add a key
|
||||
key, value := "foo", "bar"
|
||||
tx := fmt.Sprintf("%s=%s", key, value)
|
||||
res, err := m.BroadcastTxSync(types.Tx(tx))
|
||||
res, err := m.BroadcastTxCommit(types.Tx(tx))
|
||||
require.Nil(err)
|
||||
assert.True(res.Code.IsOK())
|
||||
assert.True(res.CheckTx.Code.IsOK())
|
||||
require.NotNil(res.DeliverTx)
|
||||
assert.True(res.DeliverTx.Code.IsOK())
|
||||
|
||||
// check the key
|
||||
qres, err := m.ABCIQuery("/key", []byte(key), false)
|
||||
|
|
Loading…
Reference in New Issue