This commit is contained in:
asxalex 2024-02-21 16:46:20 +08:00
parent d915e75e12
commit a3b808cc29
2 changed files with 7 additions and 5 deletions

View File

@ -31,6 +31,7 @@ mod test {
use crate::utils::gen_uuid;
use self::peer::SdlanSock;
use crate::config::AF_INET;
use crate::packet::Common;
use crate::utils::Result;
@ -47,7 +48,7 @@ mod test {
let pkt1 = RegisterSuper {
pass: "encrypt!",
sock: Some(SdlanSock {
family: 0,
family: AF_INET,
port: 1,
// has_v6: true,
// v6_port: 2345,

View File

@ -222,6 +222,7 @@ impl PeerMap {
#[cfg(test)]
mod test {
use crate::config::AF_INET;
use crate::utils::gen_uuid;
use super::*;
@ -233,14 +234,14 @@ mod test {
let mut p = Peer::new();
{
let mut sl = p.sock.lock().unwrap();
sl.family = 0;
sl.family = AF_INET;
sl.v4 = [1; 4];
sl.port = 20;
}
pm.insert_peer(&id, Arc::new(p));
if let Some(p2) = pm.find_peer_by_id(&id) {
let pl = p2.sock.lock().unwrap();
assert_eq!(pl.family, 0);
assert_eq!(pl.family, crate::config::AF_INET);
assert_eq!(pl.port, 20);
assert_eq!(pl.v4, [1; 4]);
} else {
@ -248,7 +249,7 @@ mod test {
}
if let Some(p3) = pm.find_peer_by_sock(&SdlanSock {
family: 0,
family: AF_INET,
port: 20,
// has_v6: true,
// v6_port: 30,
@ -256,7 +257,7 @@ mod test {
v6: [1; 16],
}) {
let pl = p3.sock.lock().unwrap();
assert_eq!(pl.family, 0);
assert_eq!(pl.family, AF_INET);
assert_eq!(pl.port, 20);
assert_eq!(pl.v4, [1; 4]);
} else {