mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-26 08:57:26 +02:00
some basic careof tests
Signed-off-by: Erik Hollensbe <git@hollensbe.org>
This commit is contained in:
parent
f45d6e1eec
commit
ec9fa2a259
1 changed files with 30 additions and 0 deletions
|
@ -106,3 +106,33 @@ impl CareOf {
|
||||||
self.fingerprints.binary_search(&id.fingerprint).is_ok()
|
self.fingerprints.binary_search(&id.fingerprint).is_ok()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use std::sync::mpsc;
|
||||||
|
|
||||||
|
use super::CareOf;
|
||||||
|
use super::Identity;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn add() {
|
||||||
|
let (s, r) = mpsc::channel();
|
||||||
|
|
||||||
|
for _ in 0..10 {
|
||||||
|
let s2 = s.clone();
|
||||||
|
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
let id = Identity::generate();
|
||||||
|
let mut c = CareOf::new(rand::random());
|
||||||
|
|
||||||
|
s2.send(!c.contains(&id)).unwrap();
|
||||||
|
c.add_care_of(&id);
|
||||||
|
s2.send(c.contains(&id)).unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for _ in 0..20 {
|
||||||
|
assert!(r.recv().unwrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue