Skip to content

Commit

Permalink
Fix update tests
Browse files Browse the repository at this point in the history
Which were forgotten to be changed in the previous 2 commits

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
  • Loading branch information
LeeSmet committed Jan 17, 2024
1 parent 4b0df42 commit 2e58fa2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/babel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ mod tests {
400,
16.into(),
25.into(),
Subnet::new(Ipv6Addr::new(0x200, 1, 2, 3, 4, 5, 6, 7).into(), 64)
Subnet::new(Ipv6Addr::new(0x200, 1, 2, 3, 0, 0, 0, 0).into(), 64)
.expect("64 is a valid IPv6 prefix size; qed"),
[
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
Expand All @@ -254,11 +254,13 @@ mod tests {
.send(update.clone().into())
.await
.expect("Send on a non-networked buffer can never fail; qed");
println!("Sent update packet");
let recv_update = receiver
.next()
.await
.expect("Buffer isn't closed so this is always `Some`; qed")
.expect("Can decode the previously encoded value");
println!("Received update packet");
assert_eq!(super::Tlv::from(update), recv_update);
}

Expand Down
25 changes: 12 additions & 13 deletions src/babel/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ mod tests {

ihu.write_bytes(&mut buf);

assert_eq!(buf.len(), 66);
assert_eq!(buf.len(), 58);
assert_eq!(
buf[..66],
buf[..58],
[
2, 192, 64, 0, 1, 144, 0, 17, 0, 25, 2, 0, 0, 25, 0, 26, 0, 27, 0, 28, 0, 0, 0, 0,
0, 29, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
2, 192, 64, 0, 1, 144, 0, 17, 0, 25, 2, 0, 0, 25, 0, 26, 0, 27, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1
]
);

Expand All @@ -217,20 +217,19 @@ mod tests {
interval: 600,
seqno: 170.into(),
metric: 256.into(),
subnet: Subnet::new(Ipv4Addr::new(10, 101, 4, 1).into(), 32)
.expect("32 is a valid IPv4 prefix size; qed"),
subnet: Subnet::new(Ipv4Addr::new(10, 101, 4, 1).into(), 23)
.expect("23 is a valid IPv4 prefix size; qed"),
router_id: RouterId::from([2u8; RouterId::BYTE_SIZE]),
};

ihu.write_bytes(&mut buf);

assert_eq!(buf.len(), 54);
assert_eq!(buf.len(), 53);
assert_eq!(
buf[..54],
buf[..53],
[
1, 0, 32, 0, 2, 88, 0, 170, 1, 0, 10, 101, 4, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2
1, 0, 23, 0, 2, 88, 0, 170, 1, 0, 10, 101, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
]
);
}
Expand Down Expand Up @@ -345,7 +344,7 @@ mod tests {
10.into(),
25.into(),
Subnet::new(
Ipv6Addr::new(0x21f, 0x4025, 0xabcd, 0xdead, 0xbeef, 0xbabe, 0xdeaf, 1).into(),
Ipv6Addr::new(0x21f, 0x4025, 0xabcd, 0xdead, 0, 0, 0, 0).into(),
64,
)
.expect("64 is a valid IPv6 prefix size; qed"),
Expand Down

0 comments on commit 2e58fa2

Please sign in to comment.