Browse Source

Add round-trip test for pierce firewall peer message.

wip
Titouan Rigoudy 7 years ago
parent
commit
c2db26119b
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      src/proto/peer/message.rs

+ 7
- 2
src/proto/peer/message.rs View File

@ -156,16 +156,21 @@ mod tests {
use super::*; use super::*;
fn roundtrip<T: Debug + Eq + ProtoDecode + ProtoEncode>(input: T) {
fn roundtrip(input: Message) {
let mut bytes = BytesMut::new(); let mut bytes = BytesMut::new();
input.encode(&mut ProtoEncoder::new(&mut bytes)).unwrap(); input.encode(&mut ProtoEncoder::new(&mut bytes)).unwrap();
let mut cursor = io::Cursor::new(bytes); let mut cursor = io::Cursor::new(bytes);
let output = T::decode(&mut ProtoDecoder::new(&mut cursor)).unwrap();
let output = Message::decode(&mut ProtoDecoder::new(&mut cursor)).unwrap();
assert_eq!(output, input); assert_eq!(output, input);
} }
#[test]
fn roundtrip_pierce_firewall() {
roundtrip(Message::PierceFirewall(1337))
}
#[test] #[test]
fn roundtrip_peer_init() { fn roundtrip_peer_init() {
roundtrip(Message::PeerInit(PeerInit { roundtrip(Message::PeerInit(PeerInit {


Loading…
Cancel
Save