mirror of
https://github.com/ratspeak/rsLXMF
synced 2026-08-12 18:08:14 -04:00
propagation: guard transfer restarts
This commit is contained in:
parent
c52c0a254f
commit
3070484a5f
1 changed files with 28 additions and 0 deletions
|
|
@ -188,6 +188,20 @@ impl PropagationClient {
|
|||
Some(h) => h,
|
||||
None => return false,
|
||||
};
|
||||
if !matches!(
|
||||
self.status.state,
|
||||
PropagationClientState::Idle
|
||||
| PropagationClientState::Complete
|
||||
| PropagationClientState::Failed
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if matches!(
|
||||
self.status.state,
|
||||
PropagationClientState::Complete | PropagationClientState::Failed
|
||||
) {
|
||||
self.cleanup();
|
||||
}
|
||||
|
||||
let (link, request_data) = Link::new_initiator(node_hash, 1);
|
||||
let link_id = link.link_id;
|
||||
|
|
@ -1179,6 +1193,20 @@ mod tests {
|
|||
assert!(matches!(outbound.unwrap(), TransportMessage::Outbound(_)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_start_download_rejects_an_active_transfer() {
|
||||
let (tx, mut rx) = mpsc::channel(64);
|
||||
let mut client = PropagationClient::new(tx, None, None);
|
||||
client.set_propagation_node([0xBC; 16]);
|
||||
|
||||
assert!(client.start_download());
|
||||
while rx.try_recv().is_ok() {}
|
||||
|
||||
assert!(!client.start_download());
|
||||
assert!(rx.try_recv().is_err());
|
||||
assert_eq!(client.state(), PropagationClientState::LinkEstablishing);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_local_messages() {
|
||||
let (tx, _rx) = mpsc::channel(16);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue