ethclient: fix flaky test (#28864)

Fix flaky test due to incomplete transaction indexing
pull/28868/head
rjl493456442 8 months ago committed by GitHub
parent a8a87586c1
commit 765f2904d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      ethclient/ethclient.go
  2. 7
      ethclient/ethclient_test.go

@ -689,6 +689,8 @@ type rpcProgress struct {
HealedBytecodeBytes hexutil.Uint64 HealedBytecodeBytes hexutil.Uint64
HealingTrienodes hexutil.Uint64 HealingTrienodes hexutil.Uint64
HealingBytecode hexutil.Uint64 HealingBytecode hexutil.Uint64
TxIndexFinishedBlocks hexutil.Uint64
TxIndexRemainingBlocks hexutil.Uint64
} }
func (p *rpcProgress) toSyncProgress() *ethereum.SyncProgress { func (p *rpcProgress) toSyncProgress() *ethereum.SyncProgress {
@ -713,5 +715,7 @@ func (p *rpcProgress) toSyncProgress() *ethereum.SyncProgress {
HealedBytecodeBytes: uint64(p.HealedBytecodeBytes), HealedBytecodeBytes: uint64(p.HealedBytecodeBytes),
HealingTrienodes: uint64(p.HealingTrienodes), HealingTrienodes: uint64(p.HealingTrienodes),
HealingBytecode: uint64(p.HealingBytecode), HealingBytecode: uint64(p.HealingBytecode),
TxIndexFinishedBlocks: uint64(p.TxIndexFinishedBlocks),
TxIndexRemainingBlocks: uint64(p.TxIndexRemainingBlocks),
} }
} }

@ -231,6 +231,13 @@ func newTestBackend(t *testing.T) (*node.Node, []*types.Block) {
if _, err := ethservice.BlockChain().InsertChain(blocks[1:]); err != nil { if _, err := ethservice.BlockChain().InsertChain(blocks[1:]); err != nil {
t.Fatalf("can't import test blocks: %v", err) t.Fatalf("can't import test blocks: %v", err)
} }
// Ensure the tx indexing is fully generated
for ; ; time.Sleep(time.Millisecond * 100) {
progress, err := ethservice.BlockChain().TxIndexProgress()
if err == nil && progress.Done() {
break
}
}
return n, blocks return n, blocks
} }

Loading…
Cancel
Save