state-res: Simplify tests a bit

This commit is contained in:
Jonas Platte 2021-09-13 15:40:54 +02:00
parent 717fd1198d
commit 3830dcddc2
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
3 changed files with 14 additions and 20 deletions

View File

@ -68,9 +68,7 @@ fn resolution_shallow_auth_chain(c: &mut Criterion) {
state_sets
.iter()
.map(|map| {
store
.auth_event_ids(&room_id(), &map.values().cloned().collect::<Vec<_>>())
.unwrap()
store.auth_event_ids(&room_id(), map.values().cloned().collect()).unwrap()
})
.collect(),
|id| ev_map.get(id).map(Arc::clone),
@ -134,9 +132,7 @@ fn resolve_deeper_event_set(c: &mut Criterion) {
state_sets
.iter()
.map(|map| {
store
.auth_event_ids(&room_id(), &map.values().cloned().collect::<Vec<_>>())
.unwrap()
store.auth_event_ids(&room_id(), map.values().cloned().collect()).unwrap()
})
.collect(),
|id| inner.get(id).map(Arc::clone),
@ -183,9 +179,13 @@ impl<E: Event> TestStore<E> {
}
/// Returns a Vec of the related auth events to the given `event`.
fn auth_event_ids(&self, room_id: &RoomId, event_ids: &[EventId]) -> Result<HashSet<EventId>> {
fn auth_event_ids(
&self,
room_id: &RoomId,
event_ids: Vec<EventId>,
) -> Result<HashSet<EventId>> {
let mut result = HashSet::new();
let mut stack = event_ids.to_vec();
let mut stack = event_ids;
// DFS for auth event chain
while !stack.is_empty() {
@ -214,7 +214,7 @@ impl<E: Event> TestStore<E> {
for ids in event_ids {
// TODO state store `auth_event_ids` returns self in the event ids list
// when an event returns `auth_event_ids` self is not contained
let chain = self.auth_event_ids(room_id, &ids)?.into_iter().collect::<HashSet<_>>();
let chain = self.auth_event_ids(room_id, ids)?.into_iter().collect::<HashSet<_>>();
auth_chain_sets.push(chain);
}

View File

@ -982,9 +982,7 @@ mod tests {
state_sets
.iter()
.map(|map| {
store
.auth_event_ids(&room_id(), &map.values().cloned().collect::<Vec<_>>())
.unwrap()
store.auth_event_ids(&room_id(), map.values().cloned().collect()).unwrap()
})
.collect(),
|id| ev_map.get(id).map(Arc::clone),
@ -1088,9 +1086,7 @@ mod tests {
state_sets
.iter()
.map(|map| {
store
.auth_event_ids(&room_id(), &map.values().cloned().collect::<Vec<_>>())
.unwrap()
store.auth_event_ids(&room_id(), map.values().cloned().collect()).unwrap()
})
.collect(),
|id| ev_map.get(id).map(Arc::clone),

View File

@ -112,9 +112,7 @@ pub fn do_check(
state_sets
.iter()
.map(|map| {
store
.auth_event_ids(&room_id(), &map.values().cloned().collect::<Vec<_>>())
.unwrap()
store.auth_event_ids(&room_id(), map.values().cloned().collect()).unwrap()
})
.collect(),
|id| event_map.get(id).map(Arc::clone),
@ -217,10 +215,10 @@ impl<E: Event> TestStore<E> {
pub fn auth_event_ids(
&self,
room_id: &RoomId,
event_ids: &[EventId],
event_ids: Vec<EventId>,
) -> Result<HashSet<EventId>> {
let mut result = HashSet::new();
let mut stack = event_ids.to_vec();
let mut stack = event_ids;
// DFS for auth event chain
while let Some(ev_id) = stack.pop() {