Skip to content

Commit

Permalink
Avoid skipping some messages in graph tests
Browse files Browse the repository at this point in the history
  • Loading branch information
contrun committed Dec 10, 2024
1 parent 14f2869 commit ff65a51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/fiber/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,16 @@ where
}
}

// Completely reload from store. Because messages with larger timestamp
// can be added to the store earlier than messages with smaller timestamp,
// It is possible in regular load_from_store may skip some messages.
// We use this method to reset the cursor and load all messages from start.
#[cfg(test)]
pub(crate) fn reload_from_store(&mut self) {
self.reset();
self.load_from_store();
}

fn load_channel_updates_from_store(&self, channel_info: &mut ChannelInfo) {
let channel_update_of_node1 = self
.store
Expand Down Expand Up @@ -589,6 +599,7 @@ where

#[cfg(test)]
pub fn reset(&mut self) {
self.latest_cursor = Cursor::default();
self.channels.clear();
self.nodes.clear();
self.history.reset();
Expand Down
2 changes: 1 addition & 1 deletion src/fiber/tests/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl MockNetworkGraph {
channel_outpoint: channel_outpoint.clone(),
});
}
self.graph.load_from_store();
self.graph.reload_from_store();
}

pub fn add_edge(
Expand Down

0 comments on commit ff65a51

Please sign in to comment.