Skip to content

Commit

Permalink
add test min values to bytes ds
Browse files Browse the repository at this point in the history
  • Loading branch information
konegoro committed Jan 17, 2024
1 parent 39a24f9 commit 98478a5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/message/rdata/ds_rdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use crate::message::resource_record::{FromBytes, ToBytes};

pub struct DsRdata {
pub key_tag: u16,
pub algorithm: u8,
pub digest_type: u8,
pub digest: Vec<u8>,
pub key_tag: u16, //the key tag of the DNSKEY RR referred
pub algorithm: u8, //the algorithm number of the DNSKEY RR referred to by the DS record.
pub digest_type: u8, //the algorithm to construct the digest
pub digest: Vec<u8>, //digest = digest_algorithm( DNSKEY owner name | DNSKEY RDATA);
}

impl ToBytes for DsRdata{
Expand Down Expand Up @@ -220,4 +220,11 @@ mod ds_rdata_test{
assert_eq!(ds_rdata.get_digest_type(), 0);
assert_eq!(ds_rdata.get_digest(), vec![1, 2, 3]);
}

#[test]
fn to_bytes_min_values(){
let ds_rdata = DsRdata::new(0, 0, 0, Vec::new());
let ds_rdata_bytes = ds_rdata.to_bytes();
assert_eq!(ds_rdata_bytes, vec![0, 0, 0, 0]);
}
}

0 comments on commit 98478a5

Please sign in to comment.