From ac5c595015377a71f995b7cf00bc414f59309124 Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Tue, 7 May 2024 23:39:57 +0700 Subject: [PATCH] test(mempool/cat): fix flaky TestTxPool_BroadcastQueue (#1321) ## Description Closes #1261 (cherry picked from commit 485332b0317f30a5ace5630de5227697d7ced7da) --- mempool/cat/pool_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mempool/cat/pool_test.go b/mempool/cat/pool_test.go index ec954ae9c5..c32887e877 100644 --- a/mempool/cat/pool_test.go +++ b/mempool/cat/pool_test.go @@ -745,6 +745,12 @@ func TestTxPool_BroadcastQueue(t *testing.T) { wg := sync.WaitGroup{} wg.Add(1) + + for i := 0; i < txs; i++ { + tx := newDefaultTx(fmt.Sprintf("%d", i)) + require.NoError(t, txmp.CheckTx(tx, nil, mempool.TxInfo{SenderID: 0})) + } + go func() { defer wg.Done() for i := 0; i < txs; i++ { @@ -754,14 +760,8 @@ func TestTxPool_BroadcastQueue(t *testing.T) { case wtx := <-txmp.next(): require.Equal(t, wtx.tx, newDefaultTx(fmt.Sprintf("%d", i))) } - time.Sleep(10 * time.Millisecond) } }() - for i := 0; i < txs; i++ { - tx := newDefaultTx(fmt.Sprintf("%d", i)) - require.NoError(t, txmp.CheckTx(tx, nil, mempool.TxInfo{SenderID: 0})) - } - wg.Wait() }