mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
core/txpool/blobpool: extend unit test and improve the interruption
This commit is contained in:
parent
4ab84115ed
commit
e2744c0992
2 changed files with 23 additions and 9 deletions
|
|
@ -1810,9 +1810,14 @@ func TestAdd(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests adding transactions with legacy sidecars are correctly rejected
|
// Tests that transactions with legacy sidecars are accepted within the
|
||||||
// after the conversion window has passed.
|
// conversion window but rejected after it has passed.
|
||||||
func TestAddLegacyBlobTx(t *testing.T) {
|
func TestAddLegacyBlobTx(t *testing.T) {
|
||||||
|
testAddLegacyBlobTx(t, true) // conversion window has not yet passed
|
||||||
|
testAddLegacyBlobTx(t, false) // conversion window passed
|
||||||
|
}
|
||||||
|
|
||||||
|
func testAddLegacyBlobTx(t *testing.T, accept bool) {
|
||||||
var (
|
var (
|
||||||
key1, _ = crypto.GenerateKey()
|
key1, _ = crypto.GenerateKey()
|
||||||
key2, _ = crypto.GenerateKey()
|
key2, _ = crypto.GenerateKey()
|
||||||
|
|
@ -1832,7 +1837,13 @@ func TestAddLegacyBlobTx(t *testing.T) {
|
||||||
blobfee: uint256.NewInt(105),
|
blobfee: uint256.NewInt(105),
|
||||||
statedb: statedb,
|
statedb: statedb,
|
||||||
}
|
}
|
||||||
time := *params.MergedTestChainConfig.OsakaTime + uint64(conversionTimeWindow.Seconds()) + 1
|
var timeDiff uint64
|
||||||
|
if accept {
|
||||||
|
timeDiff = uint64(conversionTimeWindow.Seconds()) - 1
|
||||||
|
} else {
|
||||||
|
timeDiff = uint64(conversionTimeWindow.Seconds()) + 1
|
||||||
|
}
|
||||||
|
time := *params.MergedTestChainConfig.OsakaTime + timeDiff
|
||||||
chain.setHeadTime(time)
|
chain.setHeadTime(time)
|
||||||
|
|
||||||
pool := New(Config{Datadir: t.TempDir()}, chain, nil)
|
pool := New(Config{Datadir: t.TempDir()}, chain, nil)
|
||||||
|
|
@ -1844,12 +1855,15 @@ func TestAddLegacyBlobTx(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
tx1 = makeMultiBlobTx(0, 1, 1000, 100, 6, 0, key1, types.BlobSidecarVersion0)
|
tx1 = makeMultiBlobTx(0, 1, 1000, 100, 6, 0, key1, types.BlobSidecarVersion0)
|
||||||
tx2 = makeMultiBlobTx(0, 1, 800, 70, 6, 6, key2, types.BlobSidecarVersion0)
|
tx2 = makeMultiBlobTx(0, 1, 800, 70, 6, 6, key2, types.BlobSidecarVersion0)
|
||||||
tx3 = makeMultiBlobTx(1, 1, 800, 70, 6, 12, key2, types.BlobSidecarVersion1)
|
txs = []*types.Transaction{tx1, tx2}
|
||||||
)
|
)
|
||||||
errs := pool.Add([]*types.Transaction{tx1, tx2, tx3}, true)
|
errs := pool.Add(txs, true)
|
||||||
for _, err := range errs {
|
for _, err := range errs {
|
||||||
if err == nil {
|
if accept && err != nil {
|
||||||
t.Fatalf("expected tx add to fail")
|
t.Fatalf("expected tx add to succeed, %v", err)
|
||||||
|
}
|
||||||
|
if !accept && err == nil {
|
||||||
|
t.Fatal("expected tx add to fail")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
verifyPoolInternals(t, pool)
|
verifyPoolInternals(t, pool)
|
||||||
|
|
|
||||||
|
|
@ -90,8 +90,8 @@ func (q *conversionQueue) run(tasks []*cTask, done chan struct{}, interrupt *ato
|
||||||
|
|
||||||
for _, t := range tasks {
|
for _, t := range tasks {
|
||||||
if interrupt != nil && interrupt.Load() != 0 {
|
if interrupt != nil && interrupt.Load() != 0 {
|
||||||
log.Info("Legacy blob tx conversion is interrupted")
|
t.done <- errors.New("conversion is interrupted")
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
sidecar := t.tx.BlobTxSidecar()
|
sidecar := t.tx.BlobTxSidecar()
|
||||||
if sidecar == nil {
|
if sidecar == nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue