core/txpool/blobpool: add custom check in test

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2025-10-27 13:09:22 +01:00
parent 3ede2631a0
commit ccc7366336
No known key found for this signature in database
GPG key ID: 0FE274EE8C95166E

View file

@ -1359,6 +1359,7 @@ func TestAdd(t *testing.T) {
from string from string
tx *types.BlobTx tx *types.BlobTx
err error err error
check func(*BlobPool, *types.Transaction) bool
} }
tests := []struct { tests := []struct {
@ -1407,6 +1408,9 @@ func TestAdd(t *testing.T) {
from: "eve", from: "eve",
tx: makeUnsignedTx(11, 1, 1, 1), tx: makeUnsignedTx(11, 1, 1, 1),
err: nil, err: nil,
check: func(pool *BlobPool, tx *types.Transaction) bool {
return pool.Status(tx.Hash()) == txpool.TxStatusQueued
},
}, },
}, },
}, },
@ -1768,7 +1772,7 @@ func TestAdd(t *testing.T) {
t.Errorf("test %d, tx %d: adding transaction error mismatch: have %v, want %v", i, j, errs[0], add.err) t.Errorf("test %d, tx %d: adding transaction error mismatch: have %v, want %v", i, j, errs[0], add.err)
} }
if add.err == nil { if add.err == nil {
// first check if tx is in the queue // first check if tx is in the pool (reorder queue or pending)
if !pool.Has(signed.Hash()) { if !pool.Has(signed.Hash()) {
t.Errorf("test %d, tx %d: added transaction not found in pool", i, j) t.Errorf("test %d, tx %d: added transaction not found in pool", i, j)
} }
@ -1784,6 +1788,12 @@ func TestAdd(t *testing.T) {
} }
} }
} }
if add.check != nil {
if !add.check(pool, signed) {
t.Errorf("test %d, tx %d: custom check failed", i, j)
}
}
// Verify the pool internals after each addition
verifyPoolInternals(t, pool) verifyPoolInternals(t, pool)
} }
verifyPoolInternals(t, pool) verifyPoolInternals(t, pool)