fix(lib): free a silent parent's slot and pace the moves we report
A candidate that accepted the dial and then said nothing kept its slot for the session, and ten of those blocked every later batch; a link now closes after a minute of silence. A parent that flaps its level made us tell the server four messages per flap; moves are now told at most once a second, the latest one winning. A parent that reports level zero is its own root from then on, whatever it said before. The wait for a searcher's control connection runs from the last message queued for it, not the first. A successful login is pinned to reset the leaf.
This commit is contained in:
@@ -36,15 +36,22 @@ fn the_server_socket_keeps_itself_alive() {
|
||||
}
|
||||
|
||||
fn parked_actor(port: u16) -> ServerActor {
|
||||
let (tx, _rx) = std::sync::mpsc::channel();
|
||||
ServerActor::new(
|
||||
parked_actor_with_client(port).0
|
||||
}
|
||||
|
||||
fn parked_actor_with_client(
|
||||
port: u16,
|
||||
) -> (ServerActor, std::sync::mpsc::Receiver<ClientOperation>) {
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
let actor = ServerActor::new(
|
||||
PeerAddress::new("127.0.0.1".to_string(), port),
|
||||
tx,
|
||||
0,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
)
|
||||
);
|
||||
(actor, rx)
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -191,6 +198,22 @@ fn a_successful_login_marks_the_session_live_again() {
|
||||
assert_eq!(actor.session.loss(), None);
|
||||
}
|
||||
|
||||
// A new session starts without a parent: the leaf drops whatever tree it
|
||||
// hung from and announces its parentless stance from there.
|
||||
#[test]
|
||||
fn a_successful_login_resets_the_distributed_leaf() {
|
||||
let (mut actor, client) = parked_actor_with_client(1);
|
||||
|
||||
actor.handle_login_status(true);
|
||||
|
||||
assert!(matches!(
|
||||
client.try_recv(),
|
||||
Ok(ClientOperation::ResetDistributed)
|
||||
));
|
||||
actor.handle_login_status(false);
|
||||
assert!(client.try_recv().is_err(), "a failed login resets nothing");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn post_login_messages_carry_counts_and_conditional_wait_port() {
|
||||
let messages = post_login_messages(true, 4321, 3, 7);
|
||||
|
||||
Reference in New Issue
Block a user