eth/fetcher: use helper in all instances

This commit is contained in:
lightclient 2026-01-15 10:42:26 -07:00
parent 21171e07f3
commit a8776686d4
No known key found for this signature in database
GPG key ID: 657913021EF45A6A

View file

@ -1729,20 +1729,15 @@ func TestTransactionFetcherDropAlternates(t *testing.T) {
func TestTransactionFetcherWrongMetadata(t *testing.T) { func TestTransactionFetcherWrongMetadata(t *testing.T) {
testTransactionFetcherParallel(t, txFetcherTest{ testTransactionFetcherParallel(t, txFetcherTest{
init: func() *TxFetcher { init: func() *TxFetcher {
return NewTxFetcher( f := newTestTxFetcher()
func(_ common.Hash, kind byte) error { f.validateMeta = func(name common.Hash, kind byte) error {
switch kind { switch kind {
case types.LegacyTxType, types.AccessListTxType, types.DynamicFeeTxType, types.BlobTxType, types.SetCodeTxType: case types.LegacyTxType, types.AccessListTxType, types.DynamicFeeTxType, types.BlobTxType, types.SetCodeTxType:
return nil return nil
} }
return types.ErrTxTypeNotSupported return types.ErrTxTypeNotSupported
}, }
func(txs []*types.Transaction) []error { return f
return make([]error, len(txs))
},
func(string, []common.Hash) error { return nil },
nil,
)
}, },
steps: []interface{}{ steps: []interface{}{
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{0xff, types.LegacyTxType}, sizes: []uint32{111, 222}}, doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{0xff, types.LegacyTxType}, sizes: []uint32{111, 222}},
@ -1790,20 +1785,16 @@ func TestTransactionProtocolViolation(t *testing.T) {
) )
testTransactionFetcherParallel(t, txFetcherTest{ testTransactionFetcherParallel(t, txFetcherTest{
init: func() *TxFetcher { init: func() *TxFetcher {
return NewTxFetcher( f := newTestTxFetcher()
func(common.Hash, byte) error { return nil }, f.addTxs = func(txs []*types.Transaction) []error {
func(txs []*types.Transaction) []error { var errs []error
var errs []error for range txs {
for range txs { errs = append(errs, txpool.ErrKZGVerificationError)
errs = append(errs, txpool.ErrKZGVerificationError) }
} return errs
return errs }
}, f.dropPeer = func(string) { drop <- struct{}{} }
func(a string, b []common.Hash) error { return f
return nil
},
func(peer string) { drop <- struct{}{} },
)
}, },
steps: []interface{}{ steps: []interface{}{
// Initial announcement to get something into the waitlist // Initial announcement to get something into the waitlist