Skip to content

Commit 71c649b

Browse files
committed
add test root domain in to_bytes in nsec
1 parent 1167f44 commit 71c649b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/message/rdata/nsec_rdata.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,5 +500,27 @@ mod nsec_rdata_test{
500500

501501
assert_eq!(nsec_rdata.get_type_bit_maps(), expected_type_bit_maps);
502502
}
503+
504+
#[test]
505+
fn to_bytes_root_domain() {
506+
let mut nsec_rdata = NsecRdata::new(DomainName::new(), vec![]);
507+
508+
let mut domain_name = DomainName::new();
509+
domain_name.set_name(String::from("."));
510+
nsec_rdata.set_next_domain_name(domain_name);
511+
512+
nsec_rdata.set_type_bit_maps(vec![Rtype::A, Rtype::MX, Rtype::RRSIG, Rtype::NSEC, Rtype::UNKNOWN(1234)]);
513+
514+
let next_domain_name_bytes = vec![0, 0, 0];
515+
516+
let bit_map_bytes_to_test = vec![0, 6, 64, 1, 0, 0, 0, 3,
517+
4, 27, 0, 0, 0, 0, 0, 0, 0,
518+
0, 0, 0, 0, 0, 0, 0, 0, 0,
519+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32];
520+
521+
let bytes_to_test = [next_domain_name_bytes, bit_map_bytes_to_test].concat();
522+
523+
assert_eq!(nsec_rdata.to_bytes(), bytes_to_test);
524+
}
503525

504526
}

0 commit comments

Comments
 (0)