Skip to content

Commit

Permalink
add test case: header marshal
Browse files Browse the repository at this point in the history
  • Loading branch information
Arikato111 committed May 11, 2024
1 parent 320d8e6 commit 6140181
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions tests/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
mod tests {
use tenjin::{
openflow::{
controller_frame::ControllerFrame, ofp_manager::OfpMsgEvent, ofp_v1_0::Openflow10,
controller_frame::ControllerFrame,
ofp_manager::{OfpMsg, OfpMsgEvent},
ofp_v1_0::Openflow10,
},
Controller,
};
Expand All @@ -13,12 +15,23 @@ mod tests {

let controller = Controller::new(Openflow10::new());
let ofp = controller.get_ofp();

let header = ofp.header_parse(&ofp_header_bytes);

assert_eq!(header.version(), 1);
assert_eq!(header.message(), 0);
assert_eq!(header.length(), 8);
assert_eq!(header.xid(), 1);
}
#[test]
fn test_header_v1_0_marshal() {
let ofp_header_bytes: Vec<u8> = vec![1, 0, 0, 8, 0, 0, 0, 0];

let controller = Controller::new(Openflow10::new());
let ofp = controller.get_ofp();
let ofp_header = ofp.header(ofp.msg_usize(OfpMsg::Hello) as u8, 0, 0);
let mut bytes: Vec<u8> = Vec::new();
ofp_header.marshal(&mut bytes);

assert_eq!(ofp_header_bytes, bytes);
}
}

0 comments on commit 6140181

Please sign in to comment.