fix e2e noise from a goroutine exits after test cleanup (#15703)

Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
This commit is contained in:
kasey
2025-09-17 07:14:14 -05:00
committed by GitHub
parent 88af3f90a5
commit a1be3d68cd
4 changed files with 19 additions and 11 deletions

View File

@@ -0,0 +1,2 @@
### Ignored
- Fix a panic in e2e that is caused by poor context management leading to error assertions being called after test cleanup.

View File

@@ -170,7 +170,7 @@ func (d *Depositor) SendAndMine(ctx context.Context, offset, nvals int, batch ty
// This is the "AndMine" part of the function. WaitForBlocks will spam transactions to/from the given key
// to advance the EL chain and until the chain has advanced the requested amount.
if err = WaitForBlocks(d.Client, d.Key, params.BeaconConfig().Eth1FollowDistance); err != nil {
if err = WaitForBlocks(ctx, d.Client, d.Key, params.BeaconConfig().Eth1FollowDistance); err != nil {
return fmt.Errorf("failed to mine blocks %w", err)
}
return nil
@@ -210,7 +210,7 @@ func (d *Depositor) SendAndMineByBatch(ctx context.Context, offset, nvals, batch
}
// This is the "AndMine" part of the function. WaitForBlocks will spam transactions to/from the given key
// to advance the EL chain and until the chain has advanced the requested amount.
if err = WaitForBlocks(d.Client, d.Key, 1); err != nil {
if err = WaitForBlocks(ctx, d.Client, d.Key, 1); err != nil {
return fmt.Errorf("failed to mine blocks %w", err)
}
}
@@ -226,7 +226,7 @@ func (d *Depositor) SendAndMineByBatch(ctx context.Context, offset, nvals, batch
}
// This is the "AndMine" part of the function. WaitForBlocks will spam transactions to/from the given key
// to advance the EL chain and until the chain has advanced the requested amount.
if err = WaitForBlocks(d.Client, d.Key, 1); err != nil {
if err = WaitForBlocks(ctx, d.Client, d.Key, 1); err != nil {
return fmt.Errorf("failed to mine blocks %w", err)
}
return nil

View File

@@ -30,23 +30,26 @@ var _ e2etypes.ComponentRunner = (*Node)(nil)
var _ e2etypes.EngineProxy = (*Proxy)(nil)
// WaitForBlocks waits for a certain amount of blocks to be mined by the ETH1 chain before returning.
func WaitForBlocks(web3 *ethclient.Client, key *keystore.Key, blocksToWait uint64) error {
nonce, err := web3.PendingNonceAt(context.Background(), key.Address)
func WaitForBlocks(ctx context.Context, web3 *ethclient.Client, key *keystore.Key, blocksToWait uint64) error {
nonce, err := web3.PendingNonceAt(ctx, key.Address)
if err != nil {
return err
}
chainID, err := web3.NetworkID(context.Background())
chainID, err := web3.NetworkID(ctx)
if err != nil {
return err
}
block, err := web3.BlockByNumber(context.Background(), nil)
block, err := web3.BlockByNumber(ctx, nil)
if err != nil {
return err
}
finishBlock := block.NumberU64() + blocksToWait
for block.NumberU64() <= finishBlock {
gasPrice, err := web3.SuggestGasPrice(context.Background())
if ctx.Err() != nil {
return ctx.Err()
}
gasPrice, err := web3.SuggestGasPrice(ctx)
if err != nil {
return err
}
@@ -55,12 +58,12 @@ func WaitForBlocks(web3 *ethclient.Client, key *keystore.Key, blocksToWait uint6
if err != nil {
return err
}
if err = web3.SendTransaction(context.Background(), signed); err != nil {
if err = web3.SendTransaction(ctx, signed); err != nil {
return err
}
nonce++
time.Sleep(timeGapPerMiningTX)
block, err = web3.BlockByNumber(context.Background(), nil)
block, err = web3.BlockByNumber(ctx, nil)
if err != nil {
return err
}

View File

@@ -232,7 +232,10 @@ func (r *testRunner) testDepositsAndTx(ctx context.Context, g *errgroup.Group,
// for further deposit testing.
err := r.depositor.SendAndMine(ctx, minGenesisActiveCount, int(e2e.DepositCount), e2etypes.PostGenesisDepositBatch, false)
if err != nil {
r.t.Error(err)
// prevent noisy panic if this goroutine exits after test cleanup
if r.t.Context().Err() == nil {
r.t.Error(errors.Wrap(err, "depositor.SendAndMine failed"))
}
}
}
r.testTxGeneration(ctx, g, keystorePath, []e2etypes.ComponentRunner{})