You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The parsing of the commands is currently not being validated properly. Specifically, the following unit tests would fail when added to this crate at this point in time.
#[test]fnlength_0_should_fail(){// Here length is 0// should fail because it is lower than 2assert!(ArtCommand::from_buffer(&vec![65,114,116,45,78,101,116,0,0,80,0,14,0,0,1,0,0,0,]).is_err());}#[test]fnlength_1_should_fail(){// Here length is 1// should fail because it is uneven and lower than 2assert!(ArtCommand::from_buffer(&vec![65,114,116,45,78,101,116,0,0,80,0,14,0,0,1,0,0,1,255,]).is_err());}#[test]fnlength_3_should_fail(){// Here length is 3// should fail because it is unevenassert!(ArtCommand::from_buffer(&vec![65,114,116,45,78,101,116,0,0,80,0,14,0,0,1,0,0,3,255,255,255]).is_err());}#[test]fnlength_513_should_fail(){// Here length is 513// should fail because it is uneven and above 512// Here length is 513 (over 512 and uneven should fail)assert!(ArtCommand::from_buffer(&vec![
vec![65,114,116,45,78,101,116,0,0,80,0,14,0,0,1,0,2,1,],
vec![255;513],].concat()).is_err());}#[test]fnlength_514_should_fail(){// Here length is 514// should fail because it is above 512assert!(ArtCommand::from_buffer(&vec![
vec![65,114,116,45,78,101,116,0,0,80,0,14,0,0,1,0,2,2,],
vec![255;514],].concat()).is_err());}#[test]fndata_shorter_than_length_should_fail(){// Here length field claims 512 bytes of data, but only 510 bytes are deliveredassert!(ArtCommand::from_buffer(&vec![
vec![65,114,116,45,78,101,116,0,0,80,0,14,0,0,1,0,2,0,],
vec![255;510],].concat()).is_err());}#[test]fndata_longer_than_length(){// Parser must only parse as many bytes as length tells it to// After that it must ignore all data byteslet packet = &vec![
vec![65,114,116,45,78,101,116,0,0,80,0,14,0,0,1,0,0,2,],
vec![255;512],].concat();// jump through hoops to compare the results to what we expect...let command = ArtCommand::from_buffer(packet).unwrap();ifletArtCommand::Output(output) = command {assert_eq!(output.version,[0,14]);assert_eq!(output.sequence,0);assert_eq!(output.physical,0);assert_eq!(output.port_address,1.into());assert_eq!(output.length.parsed_length,Some(2));assert_eq!(output.data.inner, vec![255,255]);}}#[test]fnprotver_above_14_should_fail(){// Here protocol version is 15// Any version above 14 should fail because we may not be able to parse itassert!(ArtCommand::from_buffer(&vec![65,114,116,45,78,101,116,0,0,80,0,15,0,0,1,0,0,2,255,255,]).is_err());}
The text was updated successfully, but these errors were encountered:
The parsing of the commands is currently not being validated properly. Specifically, the following unit tests would fail when added to this crate at this point in time.
The text was updated successfully, but these errors were encountered: