core/state: reopen triedb to ensure buffer flushed

This commit is contained in:
jsvisa 2025-10-22 15:10:31 +08:00
parent 47fc9684a8
commit a50f220ab3

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)