core, trie: speed up some tests with quadratic processing flaw (#21987)
This commit fixes a flaw in two testcases, and brings down the exec-time from ~40s to ~8s for trie/TestIncompleteSync. The checkConsistency was performed over and over again on the complete set of nodes, not just the recently added, turning it into a quadratic runtime.
This commit is contained in:
committed by
GitHub
parent
9f6bb492bb
commit
b44f24e3e6
@ -377,7 +377,6 @@ func TestIncompleteSync(t *testing.T) {
|
||||
|
||||
nodes, _, codes := sched.Missing(1)
|
||||
queue := append(append([]common.Hash{}, nodes...), codes...)
|
||||
|
||||
for len(queue) > 0 {
|
||||
// Fetch a batch of trie nodes
|
||||
results := make([]SyncResult, len(queue))
|
||||
@ -401,10 +400,8 @@ func TestIncompleteSync(t *testing.T) {
|
||||
batch.Write()
|
||||
for _, result := range results {
|
||||
added = append(added, result.Hash)
|
||||
}
|
||||
// Check that all known sub-tries in the synced trie are complete
|
||||
for _, root := range added {
|
||||
if err := checkTrieConsistency(triedb, root); err != nil {
|
||||
// Check that all known sub-tries in the synced trie are complete
|
||||
if err := checkTrieConsistency(triedb, result.Hash); err != nil {
|
||||
t.Fatalf("trie inconsistent: %v", err)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user