eth/catalyst: use setcanonical instead of sethead in simulated fork (#30465)
Fixes https://github.com/ethereum/go-ethereum/issues/30448
This commit is contained in:
parent
cfe25c7a3b
commit
e67d5f8c44
@ -306,7 +306,8 @@ func (c *SimulatedBeacon) Fork(parentHash common.Hash) error {
|
|||||||
if parent == nil {
|
if parent == nil {
|
||||||
return errors.New("parent not found")
|
return errors.New("parent not found")
|
||||||
}
|
}
|
||||||
return c.eth.BlockChain().SetHead(parent.NumberU64())
|
_, err := c.eth.BlockChain().SetCanonical(parent)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdjustTime creates a new block with an adjusted timestamp.
|
// AdjustTime creates a new block with an adjusted timestamp.
|
||||||
|
@ -194,8 +194,8 @@ func TestFork(t *testing.T) {
|
|||||||
// 2. Send a transaction.
|
// 2. Send a transaction.
|
||||||
// 3. Check that the TX is included in block 1.
|
// 3. Check that the TX is included in block 1.
|
||||||
// 4. Fork by using the parent block as ancestor.
|
// 4. Fork by using the parent block as ancestor.
|
||||||
// 5. Mine a block, Re-send the transaction and mine another one.
|
// 5. Mine a block. We expect the out-forked tx to have trickled to the pool, and into the new block.
|
||||||
// 6. Check that the TX is now included in block 2.
|
// 6. Check that the TX is now included in (the new) block 1.
|
||||||
func TestForkResendTx(t *testing.T) {
|
func TestForkResendTx(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
|
||||||
@ -231,12 +231,8 @@ func TestForkResendTx(t *testing.T) {
|
|||||||
|
|
||||||
// 5.
|
// 5.
|
||||||
sim.Commit()
|
sim.Commit()
|
||||||
if err := client.SendTransaction(ctx, tx); err != nil {
|
|
||||||
t.Fatalf("sending transaction: %v", err)
|
|
||||||
}
|
|
||||||
sim.Commit()
|
|
||||||
receipt, _ = client.TransactionReceipt(ctx, tx.Hash())
|
receipt, _ = client.TransactionReceipt(ctx, tx.Hash())
|
||||||
if h := receipt.BlockNumber.Uint64(); h != 2 {
|
if h := receipt.BlockNumber.Uint64(); h != 1 {
|
||||||
t.Errorf("TX included in wrong block: %d", h)
|
t.Errorf("TX included in wrong block: %d", h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user