eth: fix test

This commit is contained in:
Gary Rong 2025-04-14 20:04:43 +08:00
parent eb25e657e7
commit 492003943f

View file

@ -20,9 +20,7 @@ import (
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"errors" "errors"
"fmt"
"math/big" "math/big"
"path/filepath"
"testing" "testing"
"time" "time"
@ -68,8 +66,7 @@ func initBackend(t *testing.T, withLocal bool) *EthAPIBackend {
txconfig := legacypool.DefaultConfig txconfig := legacypool.DefaultConfig
txconfig.Journal = "" // Don't litter the disk with test journals txconfig.Journal = "" // Don't litter the disk with test journals
dir := filepath.Join(t.TempDir(), fmt.Sprintf("withLocal%t", withLocal)) blobPool := blobpool.New(blobpool.Config{Datadir: t.TempDir()}, chain, nil)
blobPool := blobpool.New(blobpool.Config{Datadir: dir}, chain, nil)
legacyPool := legacypool.New(txconfig, chain) legacyPool := legacypool.New(txconfig, chain)
txpool, _ := txpool.New(txconfig.PriceLimit, chain, []txpool.SubPool{legacyPool, blobPool}) txpool, _ := txpool.New(txconfig.PriceLimit, chain, []txpool.SubPool{legacyPool, blobPool})
@ -129,8 +126,12 @@ func pricedSetCodeTxWithAuth(nonce uint64, gaslimit uint64, gasFee, tip *uint256
}) })
} }
func TestLocalTxSend(t *testing.T) { func TestSendTx(t *testing.T) {
for _, withLocal := range []bool{false, true} { testSendTx(t, false)
testSendTx(t, true)
}
func testSendTx(t *testing.T, withLocal bool) {
b := initBackend(t, withLocal) b := initBackend(t, withLocal)
txA := pricedSetCodeTx(0, 250000, uint256.NewInt(params.GWei), uint256.NewInt(params.GWei), key, []unsignedAuth{ txA := pricedSetCodeTx(0, 250000, uint256.NewInt(params.GWei), uint256.NewInt(params.GWei), key, []unsignedAuth{
@ -153,5 +154,4 @@ func TestLocalTxSend(t *testing.T) {
t.Fatalf("Unexpected error, want: %v, got: %v", txpool.ErrInflightTxLimitReached, err) t.Fatalf("Unexpected error, want: %v, got: %v", txpool.ErrInflightTxLimitReached, err)
} }
} }
}
} }