Revive silk-testnode

This commit is contained in:
Greg Fitzgerald 2018-03-23 21:49:28 -06:00
parent c385f8bb6e
commit 9a437f0d38
3 changed files with 8 additions and 8 deletions

View File

@ -134,7 +134,7 @@ impl AccountantSkel {
obj: Arc<Mutex<AccountantSkel>>,
addr: &str,
exit: Arc<AtomicBool>,
) -> Result<[Arc<JoinHandle<()>>; 3]> {
) -> Result<Vec<JoinHandle<()>>> {
let read = UdpSocket::bind(addr)?;
// make sure we are on the same interface
let mut local = read.local_addr()?;
@ -158,6 +158,6 @@ impl AccountantSkel {
}
}
});
Ok([Arc::new(t_receiver), Arc::new(t_sender), Arc::new(t_server)])
Ok(vec![t_receiver, t_sender, t_server])
}
}

View File

@ -149,11 +149,8 @@ mod tests {
acc.wait_on_signature(&sig, &last_id).unwrap();
assert_eq!(acc.get_balance(&bob_pubkey).unwrap().unwrap(), 500);
exit.store(true, Ordering::Relaxed);
for t in threads.iter() {
match Arc::try_unwrap((*t).clone()) {
Ok(j) => j.join().expect("join"),
_ => (),
}
for t in threads {
t.join().expect("join");
}
}
}

View File

@ -18,5 +18,8 @@ fn main() {
let exit = Arc::new(AtomicBool::new(false));
let skel = Arc::new(Mutex::new(AccountantSkel::new(acc)));
eprintln!("Listening on {}", addr);
let _threads = AccountantSkel::serve(skel, addr, exit.clone()).unwrap();
let threads = AccountantSkel::serve(skel, addr, exit.clone()).unwrap();
for t in threads {
t.join().expect("join");
}
}