Add gen-eventid feature to generate EventId every deserialize
So we do not rely on any found EventId, this makes all the tests break.
This commit is contained in:
parent
ac4ab7ac06
commit
5e7f60e5d9
@ -41,6 +41,7 @@ features = ["client-api", "federation-api", "appservice-api", "unstable-pre-spec
|
||||
|
||||
[features]
|
||||
default = ["unstable-pre-spec"]
|
||||
gen-eventid = []
|
||||
unstable-pre-spec = ["ruma/unstable-pre-spec"]
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -92,18 +92,18 @@ impl<'de> de::Deserialize<'de> for StateEvent {
|
||||
}
|
||||
}
|
||||
|
||||
// #[cfg(not(test))]
|
||||
// fn event_id<E: de::Error>(json: &RawJsonValue) -> Result<EventId, E> {
|
||||
// use std::convert::TryFrom;
|
||||
// EventId::try_from(format!(
|
||||
// "${}",
|
||||
// reference_hash(&from_raw_json_value(&json)?, &RoomVersionId::Version6)
|
||||
// .map_err(de::Error::custom)?,
|
||||
// ))
|
||||
// .map_err(de::Error::custom)
|
||||
// }
|
||||
#[cfg(feature = "gen-eventid")]
|
||||
fn event_id<E: de::Error>(json: &RawJsonValue) -> Result<EventId, E> {
|
||||
use std::convert::TryFrom;
|
||||
EventId::try_from(format!(
|
||||
"${}",
|
||||
reference_hash(&from_raw_json_value(&json)?, &RoomVersionId::Version6)
|
||||
.map_err(de::Error::custom)?,
|
||||
))
|
||||
.map_err(de::Error::custom)
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
#[cfg(not(feature = "gen-eventid"))]
|
||||
fn event_id<E: de::Error>(json: &RawJsonValue) -> Result<EventId, E> {
|
||||
use std::convert::TryFrom;
|
||||
Ok(match from_raw_json_value::<EventIdHelper, E>(&json) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user