From 5a45970266d99cc163639ad5016740958aa6f9b8 Mon Sep 17 00:00:00 2001 From: Devin Ragotzy Date: Tue, 11 Aug 2020 23:53:33 -0400 Subject: [PATCH] Update how PDU works this needs to be fixed TODO I have just added a hack to make the Pdu deserialize correctly in the tests this has to be fixed!! --- benches/state_res_bench.rs | 17 +++++++++++++++++ src/state_event.rs | 2 +- tests/res_with_auth_ids.rs | 17 +++++++++++++++++ tests/state_res.rs | 17 +++++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/benches/state_res_bench.rs b/benches/state_res_bench.rs index fb25ef0a..67e48450 100644 --- a/benches/state_res_bench.rs +++ b/benches/state_res_bench.rs @@ -14,6 +14,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use maplit::btreemap; use ruma::{ events::{ + pdu::EventHash, room::{ join_rules::JoinRule, member::{MemberEventContent, MembershipState}, @@ -388,11 +389,27 @@ where .iter() .map(AsRef::as_ref) .map(event_id) + .map(|id| { + ( + id, + EventHash { + sha256: "hello".into(), + }, + ) + }) .collect::>(); let prev_events = prev_events .iter() .map(AsRef::as_ref) .map(event_id) + .map(|id| { + ( + id, + EventHash { + sha256: "hello".into(), + }, + ) + }) .collect::>(); let json = if let Some(state_key) = state_key { diff --git a/src/state_event.rs b/src/state_event.rs index 751098f8..abcd2fbd 100644 --- a/src/state_event.rs +++ b/src/state_event.rs @@ -266,7 +266,7 @@ impl<'de> de::Deserialize<'de> for StateEvent { Some(unsigned) if unsigned.redacted_because.is_some() => { panic!("TODO deal with redacted events") } - _ => StateEvent::Full(from_raw_json_value(&json)?), + _ => StateEvent::Full(Pdu::RoomV1Pdu(from_raw_json_value(&json)?)), }) } else { Ok(match unsigned { diff --git a/tests/res_with_auth_ids.rs b/tests/res_with_auth_ids.rs index 6d374a5b..71bdfdd6 100644 --- a/tests/res_with_auth_ids.rs +++ b/tests/res_with_auth_ids.rs @@ -10,6 +10,7 @@ use std::{ use ruma::{ events::{ + pdu::EventHash, room::{ join_rules::JoinRule, member::{MemberEventContent, MembershipState}, @@ -360,11 +361,27 @@ where .iter() .map(AsRef::as_ref) .map(event_id) + .map(|id| { + ( + id, + EventHash { + sha256: "hello".into(), + }, + ) + }) .collect::>(); let prev_events = prev_events .iter() .map(AsRef::as_ref) .map(event_id) + .map(|id| { + ( + id, + EventHash { + sha256: "hello".into(), + }, + ) + }) .collect::>(); let json = if let Some(state_key) = state_key { diff --git a/tests/state_res.rs b/tests/state_res.rs index d62bc132..80bf3500 100644 --- a/tests/state_res.rs +++ b/tests/state_res.rs @@ -10,6 +10,7 @@ use std::{ use maplit::btreemap; use ruma::{ events::{ + pdu::EventHash, room::{ join_rules::JoinRule, member::{MemberEventContent, MembershipState}, @@ -103,11 +104,27 @@ where .iter() .map(AsRef::as_ref) .map(event_id) + .map(|id| { + ( + id, + EventHash { + sha256: "hello".into(), + }, + ) + }) .collect::>(); let prev_events = prev_events .iter() .map(AsRef::as_ref) .map(event_id) + .map(|id| { + ( + id, + EventHash { + sha256: "hello".into(), + }, + ) + }) .collect::>(); let json = if let Some(state_key) = state_key {