From 1e89e9fe114f0edb9f32ce8cc9a8b8ae3513ed77 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Tue, 14 Jan 2025 10:40:19 +0000 Subject: [PATCH] feat(txpool): limit non-executables --- txpool/tx_pool_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/txpool/tx_pool_test.go b/txpool/tx_pool_test.go index 73fe7db0a..8d931d017 100644 --- a/txpool/tx_pool_test.go +++ b/txpool/tx_pool_test.go @@ -9,6 +9,7 @@ import ( "crypto/rand" "encoding/hex" "fmt" + "github.com/vechain/thor/v2/test/datagen" "math/big" "net/http" "net/http/httptest" @@ -661,3 +662,20 @@ func TestAddOverPendingCost(t *testing.T) { err = pool.Add(newDelegatedTx(pool.repo.ChainTag(), nil, 21000, tx.BlockRef{}, 100, nil, devAccounts[8], devAccounts[2])) assert.EqualError(t, err, "tx rejected: insufficient energy for overall pending cost") } + +func TestNonExecutables(t *testing.T) { + pool := newPool(100, 1000) + + nonExistentID := datagen.RandomHash() + nonExecutables := make([]*tx.Transaction, 0) + for i := 0; i < 100; i++ { + trx := newTx(pool.repo.ChainTag(), nil, 21000, tx.BlockRef{}, 100, &nonExistentID, tx.Features(0), genesis.DevAccounts()[1]) + nonExecutables = append(nonExecutables, trx) + } + for _, trx := range nonExecutables { + assert.NoError(t, pool.Add(trx)) + } + + executable := newTx(pool.repo.ChainTag(), nil, 21000, tx.BlockRef{}, 100, nil, tx.Features(0), genesis.DevAccounts()[1]) + assert.NoError(t, pool.Add(executable)) +}