mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-02 02:00:49 +08:00
fix: race conditions (y-crdt/y-octo#51)
This commit is contained in:
@@ -286,7 +286,16 @@ mod tests {
|
||||
|
||||
let mut reader = RawDecoder::new(&update);
|
||||
let tag_type = reader.read_u8()?;
|
||||
assert_eq!(Content::read(&mut reader, tag_type)?, *content);
|
||||
let decoded = Content::read(&mut reader, tag_type)?;
|
||||
match (&decoded, content) {
|
||||
(Content::Type(decoded_ty), Content::Type(original_ty)) => {
|
||||
let decoded_ty = decoded_ty.ty().expect("decoded ytype must exist");
|
||||
let original_ty = original_ty.ty().expect("original ytype must exist");
|
||||
assert_eq!(decoded_ty.kind(), original_ty.kind());
|
||||
assert_eq!(decoded_ty.name.as_deref(), original_ty.name.as_deref());
|
||||
}
|
||||
_ => assert_eq!(decoded, *content),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -55,12 +55,9 @@ impl PartialEq for YType {
|
||||
|
||||
impl PartialEq for YTypeRef {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
// only check pointer equality
|
||||
// currently no scenarios that involve cross document ytype comparisons
|
||||
self.inner.ptr_eq(&other.inner)
|
||||
|| match (self.ty(), other.ty()) {
|
||||
(Some(l), Some(r)) => *l == *r,
|
||||
(None, None) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user