[client] Reactions and replies: a message is named by its author and seq, a reply carries its reference, a reaction sets or removes, a newer kind is Unsupported
This commit is contained in:
@@ -145,6 +145,7 @@ proptest! {
|
||||
let _ = InviteId::parse(&text);
|
||||
let _ = Sha256Hash::parse(&text);
|
||||
let _ = Token::parse(&text);
|
||||
let _ = Author::parse(&text);
|
||||
let _ = Token::from_bearer(&text);
|
||||
let _ = WireBytes::parse(&text, MAX_BLOB_BYTES);
|
||||
}
|
||||
@@ -172,7 +173,10 @@ proptest! {
|
||||
#[test]
|
||||
fn whatever_parses_has_one_spelling(text in "[A-Za-z0-9_-]{22}") {
|
||||
if let Ok(id) = MailboxId::parse(&text) {
|
||||
prop_assert_eq!(id.to_wire(), text);
|
||||
prop_assert_eq!(&id.to_wire(), &text);
|
||||
}
|
||||
if let Ok(author) = Author::parse(&text) {
|
||||
prop_assert_eq!(&author.to_wire(), &text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,3 +268,24 @@ proptest! {
|
||||
let _ = PushEndpoint::parse(&format!("https://{text}"));
|
||||
}
|
||||
}
|
||||
|
||||
// Reactions and replies (`.agents/features/reactions-replies.md` §2.1): a message's author.
|
||||
#[test]
|
||||
fn an_author_is_16_bytes_in_22_canonical_characters_and_prints_as_its_wire() {
|
||||
let author = Author::from_bytes([0x5A; 16]);
|
||||
let wire = author.to_wire();
|
||||
assert_eq!(wire.len(), 22);
|
||||
assert_eq!(Author::parse(&wire), Ok(author));
|
||||
assert_eq!(
|
||||
serde_json::to_string(&author).expect("json"),
|
||||
format!("\"{wire}\"")
|
||||
);
|
||||
assert!(Author::parse(&wire[..21]).is_err());
|
||||
assert!(Author::parse(&Token::from_bytes([1; 32]).to_wire()).is_err());
|
||||
let zero = Author::from_bytes([0; 16]).to_wire();
|
||||
assert_eq!(
|
||||
Author::parse(&format!("{}B", &zero[..21])),
|
||||
Err(ParseError::Encoding)
|
||||
);
|
||||
assert_eq!(format!("{author:?}"), format!("Author({wire})"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user