Skip to content

Commit

Permalink
feat(txpool): limit non-executables
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenvechain committed Jan 14, 2025
1 parent 7ddf539 commit 1e89e9f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions txpool/tx_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"crypto/rand"
"encoding/hex"
"fmt"
"github.com/vechain/thor/v2/test/datagen"
"math/big"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -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))
}

0 comments on commit 1e89e9f

Please sign in to comment.