Skip to content

Commit

Permalink
Fix expired txs flaky test (#955)
Browse files Browse the repository at this point in the history
* Fix expired txs flaky test
  • Loading branch information
vanja-vechain authored Jan 23, 2025
1 parent df5e113 commit 4d3c7bf
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions txpool/tx_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"net/http"
"net/http/httptest"
"os"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -496,18 +495,9 @@ func TestNonExecutables(t *testing.T) {
assert.NoError(t, pool.AddLocal(newTx(pool.repo.ChainTag(), nil, 21000, tx.BlockRef{}, 100, nil, tx.Features(0), devAccounts[i%len(devAccounts)])))
}

var wg sync.WaitGroup
wg.Add(1)

go func() {
defer wg.Done()
pool.housekeeping()
}()

time.Sleep(2 * time.Second)
pool.cancel()
executables, _, _ := pool.wash(pool.repo.BestBlockSummary())
pool.executables.Store(executables)

wg.Wait()
// add 1 non-executable
assert.NoError(t, pool.AddLocal(newTx(pool.repo.ChainTag(), nil, 21000, tx.BlockRef{}, 100, &thor.Bytes32{1}, tx.Features(0), devAccounts[2])))
}
Expand All @@ -520,18 +510,9 @@ func TestExpiredTxs(t *testing.T) {
assert.NoError(t, pool.Add(newTx(pool.repo.ChainTag(), nil, 21000, tx.BlockRef{}, 100, nil, tx.Features(0), devAccounts[i%len(devAccounts)])))
}

var wg sync.WaitGroup
wg.Add(1)

go func() {
defer wg.Done()
pool.housekeeping()
}()

time.Sleep(1 * time.Second)
pool.cancel()
executables, _, _ := pool.wash(pool.repo.BestBlockSummary())
pool.executables.Store(executables)

wg.Wait()
// add 1 non-executable
assert.NoError(t, pool.Add(newTx(pool.repo.ChainTag(), nil, 21000, tx.BlockRef{}, 100, &thor.Bytes32{1}, tx.Features(0), devAccounts[2])))

Expand Down

0 comments on commit 4d3c7bf

Please sign in to comment.