Fully test contact request acceptance

* Be sure we send updates to multiple clients for the same user
* Be sure we send a full contacts update on initial connection

As part of this commit, I fixed an issue where we couldn't disconnect and reconnect in tests. The first disconnect would cause the I/O future to terminate asynchronously, which caused us to sign out even though the active connection didn't belong to that future. I added a guard to ensure that we only sign out if the I/O future is associated with the current connection.
This commit is contained in:
Nathan Sobo 2022-05-08 15:19:56 -06:00
parent 5d20338f69
commit 9b1b61355a
5 changed files with 149 additions and 68 deletions

View file

@ -173,7 +173,10 @@ impl Peer {
Err(anyhow!("timed out writing message"))?;
}
}
None => return Ok(()),
None => {
log::info!("outgoing channel closed");
return Ok(())
},
},
incoming = read_message => {
let incoming = incoming.context("received invalid RPC message")?;
@ -181,7 +184,10 @@ impl Peer {
if let proto::Message::Envelope(incoming) = incoming {
match incoming_tx.send(incoming).timeout(RECEIVE_TIMEOUT).await {
Some(Ok(_)) => {},
Some(Err(_)) => return Ok(()),
Some(Err(_)) => {
log::info!("incoming channel closed");
return Ok(())
},
None => Err(anyhow!("timed out processing incoming message"))?,
}
}