Skip to content

Commit 30639ca

Browse files
committed
refactor: make property get a reference to history
Signed-off-by: Stevan A <stevana@users.noreply.github.com>
1 parent c4b7226 commit 30639ca

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

simulation/amaru-sim/src/simulator/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ pub fn run(rt: tokio::runtime::Runtime, args: Args) {
392392

393393
fn chain_property(
394394
chain_data_path: &PathBuf,
395-
) -> impl Fn(History<ChainSyncMessage>) -> Result<(), String> + use<'_> {
395+
) -> impl Fn(&History<ChainSyncMessage>) -> Result<(), String> + use<'_> {
396396
move |history| {
397397
match history.0.last() {
398398
None => Err("impossible, no last entry in history".to_string()),

simulation/amaru-sim/src/simulator/simulate.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl<Msg> Drop for World<Msg> {
254254
fn run_test<Msg: Debug + PartialEq + Clone, F: Fn() -> NodeHandle<Msg>>(
255255
number_of_nodes: u8,
256256
spawn: F,
257-
property: impl Fn(History<Msg>) -> Result<(), String>,
257+
property: impl Fn(&History<Msg>) -> Result<(), String>,
258258
) -> impl Fn(&[Reverse<Entry<Msg>>]) -> (History<Msg>, Result<(), String>) {
259259
move |entries| {
260260
let node_handles: Vec<_> = (1..=number_of_nodes)
@@ -266,7 +266,7 @@ fn run_test<Msg: Debug + PartialEq + Clone, F: Fn() -> NodeHandle<Msg>>(
266266
match world.run_world() {
267267
Ok(history) => {
268268
let history = History(history.to_vec());
269-
let result = property(history.clone());
269+
let result = property(&history);
270270
(history, result)
271271
}
272272
Err((reason, history)) => (History(history.to_vec()), Err(reason)),
@@ -278,7 +278,7 @@ pub fn simulate<Msg, F>(
278278
config: SimulateConfig,
279279
spawn: F,
280280
generator: impl Fn(&mut StdRng) -> Vec<Reverse<Entry<Msg>>>,
281-
property: impl Fn(History<Msg>) -> Result<(), String>,
281+
property: impl Fn(&History<Msg>) -> Result<(), String>,
282282
trace_buffer: Arc<parking_lot::Mutex<TraceBuffer>>,
283283
persist_on_success: bool,
284284
) where
@@ -525,7 +525,7 @@ mod tests {
525525
};
526526

527527
// TODO: Take response time into account.
528-
const ECHO_PROPERTY: fn(History<EchoMessage>) -> Result<(), String> = |history: History<
528+
const ECHO_PROPERTY: fn(&History<EchoMessage>) -> Result<(), String> = |history: &History<
529529
EchoMessage,
530530
>| {
531531
for (index, msg) in history

0 commit comments

Comments
 (0)