Fix flaky trie-db cache test
@@ -593,6 +593,10 @@ mod tests {
.map(|d| d.0)
.all(|l| TEST_DATA.iter().any(|d| l.storage_key().unwrap() == d.0)));
+ // Run this in a loop. The first time we check that with the filled value cache,
+ // the expected values are at the top of the LRU.
+ // The second run is using an empty value cache to ensure that we access the nodes.
+ for _ in 0..2 {
{
let local_cache = shared_cache.local_cache();
@@ -604,7 +608,8 @@ mod tests {
}
}
- // Ensure that the accessed items are most recently used items of the shared value cache.
+ // Ensure that the accessed items are most recently used items of the shared value
+ // cache.
assert!(shared_cache
.read_lock_inner()
.value_cache()
@@ -614,6 +619,10 @@ mod tests {
.map(|d| d.0)
.all(|l| { TEST_DATA.iter().take(2).any(|d| l.storage_key().unwrap() == d.0) }));
+ // Delete the value cache, so that we access the nodes.
+ shared_cache.reset_value_cache();
+ }
+
let most_recently_used_nodes = shared_cache
.read_lock_inner()
.node_cache()
@@ -622,9 +631,6 @@ mod tests {
.map(|d| *d.0)
.collect::<Vec<_>>();
- // Delete the value cache, so that we access the nodes.
- shared_cache.reset_value_cache();
-
{
let local_cache = shared_cache.local_cache();
