proto tests: simplify many repeated chancell unwraps
We use this pattern quite a few times on our tests in tor-proto:
let (id, chmsg) = rx.next().await.unwrap().into_circid_and_msg();
assert_eq!(id, CircId::new(128));
let rmsg = match chmsg {
AnyChanMsg::Relay(r) => {
AnyRelayMsgOuter::decode_singleton(RelayCellFormat::V0, r.into_relay_body())
.unwrap()
}
_ => panic!(),
};
let (streamid_2, rmsg) = rmsg.into_streamid_and_msg();
assert_eq!(streamid_2, streamid);
It would be nice to replace the whole thing—or at least the match— with a function that other tests could use.
(The rx.next().await.unwrap()
part would need to remain on the outside of the function.)
Edited by Nick Mathewson