Skip to content

Commit dc8afd0

Browse files
committed
store: Clear the chain_head_ptr_cache in tests
We need to start each test with a clean cache to avoid spurious failures
1 parent b8d7458 commit dc8afd0

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

store/postgres/src/chain_store.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,6 +2127,12 @@ impl ChainHeadPtrCache {
21272127
let ttl = self.current_ttl();
21282128
*self.entry.write() = Some((new_value, now + ttl));
21292129
}
2130+
2131+
/// Clear the cached value. Used in tests when chain is reset.
2132+
#[cfg(debug_assertions)]
2133+
fn clear(&self) {
2134+
*self.entry.write() = None;
2135+
}
21302136
}
21312137

21322138
pub struct ChainStore {
@@ -2360,6 +2366,7 @@ impl ChainStore {
23602366

23612367
self.storage.remove_chain(&mut conn, &self.chain).await;
23622368
self.recent_blocks_cache.clear();
2369+
self.chain_head_ptr_cache.clear();
23632370

23642371
for block in chain {
23652372
self.upsert_block(block).await.expect("can upsert block");

0 commit comments

Comments
 (0)