Skip to content

Commit a611c62

Browse files
sanityclaude
andcommitted
Fix unit test for startup batching behavior
Added `end_startup_mode()` method for tests to manually transition out of startup batching mode. Updated `test_contract_caching_and_eviction` to call this method before testing immediate announcements. The test was failing because the new batching implementation returns `None` during the 30-second startup grace period, but the test runs instantaneously and expects immediate announcements. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 5b6d4be commit a611c62

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

crates/core/src/node/proximity_cache.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ impl ProximityCacheManager {
151151
}
152152
}
153153

154+
/// Manually end startup mode (for testing)
155+
/// This allows tests to transition out of startup batching mode immediately
156+
#[cfg(test)]
157+
pub fn end_startup_mode(&self) {
158+
self.startup_mode.store(false, Ordering::Relaxed);
159+
}
160+
154161
/// Flush batched announcements from startup period
155162
/// This should be called after the node's startup/initialization phase completes
156163
/// Returns a single announcement containing all contracts cached during startup
@@ -206,7 +213,9 @@ impl ProximityCacheManager {
206213
let op_manager = match op_manager.upgrade() {
207214
Some(manager) => manager,
208215
None => {
209-
debug!("PROXIMITY_PROPAGATION: OpManager dropped, skipping startup batch flush");
216+
debug!(
217+
"PROXIMITY_PROPAGATION: OpManager dropped, skipping startup batch flush"
218+
);
210219
return;
211220
}
212221
};
@@ -605,6 +614,9 @@ mod tests {
605614
let cache = ProximityCacheManager::new();
606615
let contract_key = create_test_contract_key();
607616

617+
// End startup mode to get immediate announcements in this test
618+
cache.end_startup_mode();
619+
608620
// Test caching a contract generates immediate announcement
609621
let announcement = cache.on_contract_cached(&contract_key).await;
610622
assert!(announcement.is_some());

0 commit comments

Comments
 (0)