fix flakiness in test

This commit is contained in:
Callum Waters
2022-11-22 15:52:57 +01:00
parent 15065f898c
commit 39ff07e648
2 changed files with 4 additions and 8 deletions

View File

@@ -53,7 +53,7 @@ func TestHangingAsyncCalls(t *testing.T) {
// Call CheckTx
reqres, err := c.CheckTxAsync(context.Background(), &types.RequestCheckTx{})
require.NoError(t, err)
// wait 20 ms for all events to travel socket, but
// wait 50 ms for all events to travel socket, but
// no response yet from server
time.Sleep(50 * time.Millisecond)
// kill the server, so the connections break
@@ -62,7 +62,6 @@ func TestHangingAsyncCalls(t *testing.T) {
// wait for the response from CheckTx
reqres.Wait()
fmt.Print(reqres)
resp <- c.Error()
}()
@@ -157,9 +156,9 @@ type slowApp struct {
types.BaseApplication
}
func (slowApp) CheckTxAsync(_ context.Context, req types.RequestCheckTx) types.ResponseCheckTx {
time.Sleep(200 * time.Millisecond)
return types.ResponseCheckTx{}
func (slowApp) CheckTx(_ context.Context, req *types.RequestCheckTx) (*types.ResponseCheckTx, error) {
time.Sleep(time.Second)
return &types.ResponseCheckTx{}, nil
}
// TestCallbackInvokedWhenSetLaet ensures that the callback is invoked when

View File

@@ -249,7 +249,6 @@ func TestMempoolUpdateDoesNotPanicWhenApplicationMissedTx(t *testing.T) {
mockClient.On("SetLogger", mock.Anything)
mockClient.On("Error").Return(nil).Times(4)
mockClient.On("Flush", mock.Anything).Return(nil)
mockClient.On("SetResponseCallback", mock.MatchedBy(func(cb abciclient.Callback) bool { callback = cb; return true }))
app := kvstore.NewInMemoryApplication()
@@ -290,8 +289,6 @@ func TestMempoolUpdateDoesNotPanicWhenApplicationMissedTx(t *testing.T) {
req = &abci.RequestCheckTx{Tx: txs[3]}
callback(abci.ToRequestCheckTx(req), abci.ToResponseCheckTx(resp))
mockClient.AssertExpectations(t)
mockClient.AssertExpectations(t)
}
func TestMempool_KeepInvalidTxsInCache(t *testing.T) {