Merge branch 'bug608' into 'main'

msg::{CreateFast/CreatedFast}: Rename accessor to (into_)body()

Closes #608

See merge request tpo/core/arti!948
This commit is contained in:
Nick Mathewson 2022-12-19 16:46:27 +00:00
commit 21670d3aaf
4 changed files with 8 additions and 6 deletions

View File

@ -302,7 +302,7 @@ fixed_len_handshake! {
}
impl CreateFast {
/// Return the content of this handshake
pub fn body(&self) -> &[u8] {
pub fn handshake(&self) -> &[u8] {
&self.handshake
}
}
@ -315,7 +315,7 @@ fixed_len_handshake! {
}
impl CreatedFast {
/// Consume this message and return the content of this handshake
pub fn into_body(self) -> Vec<u8> {
pub fn into_handshake(self) -> Vec<u8> {
self.handshake
}
}

View File

@ -186,7 +186,7 @@ fn test_create_fast() {
fbody(cmd, body, &msg::CreateFast::new(handshake.clone()).into());
let create_fast = msg::CreateFast::new(handshake.clone());
assert_eq!(create_fast.body(), &handshake[..]);
assert_eq!(create_fast.handshake(), &handshake[..]);
}
#[test]
@ -221,7 +221,7 @@ fn test_created_fast() {
fbody(cmd, body, &msg::CreatedFast::new(handshake.clone()).into());
let created_fast = msg::CreatedFast::new(handshake.clone());
assert_eq!(created_fast.into_body(), handshake);
assert_eq!(created_fast.into_handshake(), handshake);
}
#[test]

View File

@ -0,0 +1,2 @@
BREAKING: Deprecated CreateFast::body(), CreatedFast::into_body() methods
MODIFIED: Added CreateFast::handshake(), CreatedFast::into_handshake() methods

View File

@ -592,7 +592,7 @@ impl CreateHandshakeWrap for CreateFastWrap {
fn decode_chanmsg(&self, msg: CreateResponse) -> Result<Vec<u8>> {
use CreateResponse::*;
match msg {
CreatedFast(m) => Ok(m.into_body()),
CreatedFast(m) => Ok(m.into_handshake()),
Destroy(_) => Err(Error::CircRefused(
"Relay replied to CREATE_FAST with DESTROY.",
)),
@ -769,7 +769,7 @@ mod test {
ChanMsg::CreateFast(cf) => cf,
_ => panic!(),
};
let (_, rep) = CreateFastServer::server(&mut rng, &[()], cf.body()).unwrap();
let (_, rep) = CreateFastServer::server(&mut rng, &[()], cf.handshake()).unwrap();
CreateResponse::CreatedFast(CreatedFast::new(rep))
} else {
let c2 = match create_cell.msg() {