Merge pull request #188 from udoprog/fix-outgoing-state
Fix updating outgoing client state
This commit is contained in:
commit
866b5a60a0
1 changed files with 8 additions and 28 deletions
|
@ -496,7 +496,7 @@ impl ClientState {
|
|||
fn new(sender: Sender, config: Config) -> ClientState {
|
||||
ClientState {
|
||||
sender,
|
||||
config: config,
|
||||
config,
|
||||
chanlists: RwLock::new(HashMap::new()),
|
||||
alt_nick_index: RwLock::new(0),
|
||||
default_ghost_sequence: vec![String::from("GHOST")],
|
||||
|
@ -1056,7 +1056,7 @@ impl Client {
|
|||
/// # }
|
||||
/// ```
|
||||
pub fn send<M: Into<Message>>(&self, msg: M) -> error::Result<()> {
|
||||
self.sender.send(msg)
|
||||
self.state.send(msg)
|
||||
}
|
||||
|
||||
/// Sends a CAP END, NICK and USER to identify.
|
||||
|
@ -1363,7 +1363,6 @@ mod test {
|
|||
#[cfg(not(feature = "nochanlists"))]
|
||||
async fn channel_tracking_names_part() -> Result<()> {
|
||||
use crate::proto::command::Command::PART;
|
||||
use futures::prelude::*;
|
||||
|
||||
let value = ":irc.test.net 353 test = #test :test ~owner &admin\r\n";
|
||||
let mut client = Client::from_config(Config {
|
||||
|
@ -1372,32 +1371,13 @@ mod test {
|
|||
})
|
||||
.await?;
|
||||
|
||||
let mut stream = client.stream()?;
|
||||
let (shutdown_tx, shutdown_rx) = futures::channel::oneshot::channel();
|
||||
client.stream()?.collect().await?;
|
||||
|
||||
// TODO: Add the necessary testing hooks to drive this more
|
||||
// deterministically, like "wait until one outgoing message has been
|
||||
// processed". We currently more-or-less rely on the test executor being
|
||||
// singlethreaded (tokio without rt-threaded feature), but even that is
|
||||
// a bit shaky.
|
||||
let task = tokio::spawn(async move {
|
||||
let mut shutdown_rx = shutdown_rx.fuse();
|
||||
|
||||
loop {
|
||||
futures::select! {
|
||||
_ = stream.next() => {
|
||||
}
|
||||
_ = shutdown_rx => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
assert!(client.send(PART(format!("#test"), None)).is_ok());
|
||||
assert!(client.list_channels().unwrap().is_empty());
|
||||
shutdown_tx.send(()).expect("send to work");
|
||||
task.await?;
|
||||
assert_eq!(client.list_channels(), Some(vec!["#test".to_owned()]));
|
||||
// we ignore the result, as soon as we queue an outgoing message we
|
||||
// update client state, regardless if the queue is available or not.
|
||||
let _ = client.send(PART(format!("#test"), None));
|
||||
assert_eq!(client.list_channels(), Some(vec![]));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue