From 33bb319b4515249d98c12597e570885bc42a6159 Mon Sep 17 00:00:00 2001 From: Devin Ragotzy Date: Mon, 14 Dec 2020 13:27:47 -0500 Subject: [PATCH] Fix failing tests because clean overwrites resolved_state in resolve fn --- src/lib.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b7ad4585..c835996c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -196,19 +196,20 @@ impl StateResolution { .collect::>() ); - let mut resolved_state = StateResolution::iterative_auth_check( + let resolved_state = StateResolution::iterative_auth_check( room_id, room_version, &sorted_left_events, - &resolved_control, // the control events are added to the final resolved state + &resolved_control, // The control events are added to the final resolved state &mut event_map, store, )?; - // add unconflicted state to the resolved state - resolved_state.extend(unconflicted.clone()); - - Ok(resolved_state) + // Add unconflicted state to the resolved state + // We do it this way so any resolved_state would overwrite unconflicted + let mut clean = unconflicted.clone(); + clean.extend(resolved_state); + Ok(clean) } /// Resolve sets of state events as they come in. Internally `StateResolution` builds a graph @@ -384,14 +385,15 @@ impl StateResolution { room_id, room_version, &sorted_left_events, - &resolved_control, // the control events are added to the final resolved state + &resolved_control, // The control events are added to the final resolved state &mut event_map, store, )?; // add unconflicted state to the resolved state + // TODO: + // CLEAN OVERWRITES ANY DUPLICATE KEYS FROM RESOLVED STATE resolved_state.extend(clean); - Ok(resolved_state) }