core/state: fix the flaky TestSizeTracker (#32993)

This commit is contained in:
Delweng 2025-10-22 22:35:26 +08:00 committed by GitHub
parent 6608a2aafd
commit 3b8075234e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -94,6 +94,14 @@ func TestSizeTracker(t *testing.T) {
} }
baselineRoot := currentRoot baselineRoot := currentRoot
// Close and reopen the trie database so all async flushes triggered by the
// baseline commits are written before we measure the baseline snapshot.
if err := tdb.Close(); err != nil {
t.Fatalf("Failed to close triedb before baseline measurement: %v", err)
}
tdb = triedb.NewDatabase(db, &triedb.Config{PathDB: pathdb.Defaults})
sdb = NewDatabase(tdb, nil)
// Wait for snapshot completion // Wait for snapshot completion
for !tdb.SnapshotCompleted() { for !tdb.SnapshotCompleted() {
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
@ -215,13 +223,12 @@ func TestSizeTracker(t *testing.T) {
if actualStats.ContractCodeBytes != expectedStats.ContractCodeBytes { if actualStats.ContractCodeBytes != expectedStats.ContractCodeBytes {
t.Errorf("Contract code bytes mismatch: expected %d, got %d", expectedStats.ContractCodeBytes, actualStats.ContractCodeBytes) t.Errorf("Contract code bytes mismatch: expected %d, got %d", expectedStats.ContractCodeBytes, actualStats.ContractCodeBytes)
} }
// TODO: failed on github actions, need to investigate if actualStats.AccountTrienodes != expectedStats.AccountTrienodes {
// if actualStats.AccountTrienodes != expectedStats.AccountTrienodes { t.Errorf("Account trie nodes mismatch: expected %d, got %d", expectedStats.AccountTrienodes, actualStats.AccountTrienodes)
// t.Errorf("Account trie nodes mismatch: expected %d, got %d", expectedStats.AccountTrienodes, actualStats.AccountTrienodes) }
// } if actualStats.AccountTrienodeBytes != expectedStats.AccountTrienodeBytes {
// if actualStats.AccountTrienodeBytes != expectedStats.AccountTrienodeBytes { t.Errorf("Account trie node bytes mismatch: expected %d, got %d", expectedStats.AccountTrienodeBytes, actualStats.AccountTrienodeBytes)
// t.Errorf("Account trie node bytes mismatch: expected %d, got %d", expectedStats.AccountTrienodeBytes, actualStats.AccountTrienodeBytes) }
// }
if actualStats.StorageTrienodes != expectedStats.StorageTrienodes { if actualStats.StorageTrienodes != expectedStats.StorageTrienodes {
t.Errorf("Storage trie nodes mismatch: expected %d, got %d", expectedStats.StorageTrienodes, actualStats.StorageTrienodes) t.Errorf("Storage trie nodes mismatch: expected %d, got %d", expectedStats.StorageTrienodes, actualStats.StorageTrienodes)
} }