Skip to content

Commit 765f290

Browse files
authored
ethclient: fix flaky test (#28864)
Fix flaky test due to incomplete transaction indexing
1 parent a8a8758 commit 765f290

File tree

2 files changed

+40
-29
lines changed

2 files changed

+40
-29
lines changed

ethclient/ethclient.go

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -677,41 +677,45 @@ type rpcProgress struct {
677677
PulledStates hexutil.Uint64
678678
KnownStates hexutil.Uint64
679679

680-
SyncedAccounts hexutil.Uint64
681-
SyncedAccountBytes hexutil.Uint64
682-
SyncedBytecodes hexutil.Uint64
683-
SyncedBytecodeBytes hexutil.Uint64
684-
SyncedStorage hexutil.Uint64
685-
SyncedStorageBytes hexutil.Uint64
686-
HealedTrienodes hexutil.Uint64
687-
HealedTrienodeBytes hexutil.Uint64
688-
HealedBytecodes hexutil.Uint64
689-
HealedBytecodeBytes hexutil.Uint64
690-
HealingTrienodes hexutil.Uint64
691-
HealingBytecode hexutil.Uint64
680+
SyncedAccounts hexutil.Uint64
681+
SyncedAccountBytes hexutil.Uint64
682+
SyncedBytecodes hexutil.Uint64
683+
SyncedBytecodeBytes hexutil.Uint64
684+
SyncedStorage hexutil.Uint64
685+
SyncedStorageBytes hexutil.Uint64
686+
HealedTrienodes hexutil.Uint64
687+
HealedTrienodeBytes hexutil.Uint64
688+
HealedBytecodes hexutil.Uint64
689+
HealedBytecodeBytes hexutil.Uint64
690+
HealingTrienodes hexutil.Uint64
691+
HealingBytecode hexutil.Uint64
692+
TxIndexFinishedBlocks hexutil.Uint64
693+
TxIndexRemainingBlocks hexutil.Uint64
692694
}
693695

694696
func (p *rpcProgress) toSyncProgress() *ethereum.SyncProgress {
695697
if p == nil {
696698
return nil
697699
}
698700
return &ethereum.SyncProgress{
699-
StartingBlock: uint64(p.StartingBlock),
700-
CurrentBlock: uint64(p.CurrentBlock),
701-
HighestBlock: uint64(p.HighestBlock),
702-
PulledStates: uint64(p.PulledStates),
703-
KnownStates: uint64(p.KnownStates),
704-
SyncedAccounts: uint64(p.SyncedAccounts),
705-
SyncedAccountBytes: uint64(p.SyncedAccountBytes),
706-
SyncedBytecodes: uint64(p.SyncedBytecodes),
707-
SyncedBytecodeBytes: uint64(p.SyncedBytecodeBytes),
708-
SyncedStorage: uint64(p.SyncedStorage),
709-
SyncedStorageBytes: uint64(p.SyncedStorageBytes),
710-
HealedTrienodes: uint64(p.HealedTrienodes),
711-
HealedTrienodeBytes: uint64(p.HealedTrienodeBytes),
712-
HealedBytecodes: uint64(p.HealedBytecodes),
713-
HealedBytecodeBytes: uint64(p.HealedBytecodeBytes),
714-
HealingTrienodes: uint64(p.HealingTrienodes),
715-
HealingBytecode: uint64(p.HealingBytecode),
701+
StartingBlock: uint64(p.StartingBlock),
702+
CurrentBlock: uint64(p.CurrentBlock),
703+
HighestBlock: uint64(p.HighestBlock),
704+
PulledStates: uint64(p.PulledStates),
705+
KnownStates: uint64(p.KnownStates),
706+
SyncedAccounts: uint64(p.SyncedAccounts),
707+
SyncedAccountBytes: uint64(p.SyncedAccountBytes),
708+
SyncedBytecodes: uint64(p.SyncedBytecodes),
709+
SyncedBytecodeBytes: uint64(p.SyncedBytecodeBytes),
710+
SyncedStorage: uint64(p.SyncedStorage),
711+
SyncedStorageBytes: uint64(p.SyncedStorageBytes),
712+
HealedTrienodes: uint64(p.HealedTrienodes),
713+
HealedTrienodeBytes: uint64(p.HealedTrienodeBytes),
714+
HealedBytecodes: uint64(p.HealedBytecodes),
715+
HealedBytecodeBytes: uint64(p.HealedBytecodeBytes),
716+
HealingTrienodes: uint64(p.HealingTrienodes),
717+
HealingBytecode: uint64(p.HealingBytecode),
718+
TxIndexFinishedBlocks: uint64(p.TxIndexFinishedBlocks),
719+
TxIndexRemainingBlocks: uint64(p.TxIndexRemainingBlocks),
716720
}
717721
}

ethclient/ethclient_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ func newTestBackend(t *testing.T) (*node.Node, []*types.Block) {
231231
if _, err := ethservice.BlockChain().InsertChain(blocks[1:]); err != nil {
232232
t.Fatalf("can't import test blocks: %v", err)
233233
}
234+
// Ensure the tx indexing is fully generated
235+
for ; ; time.Sleep(time.Millisecond * 100) {
236+
progress, err := ethservice.BlockChain().TxIndexProgress()
237+
if err == nil && progress.Done() {
238+
break
239+
}
240+
}
234241
return n, blocks
235242
}
236243

0 commit comments

Comments
 (0)