codex / codex-rs /exec-server /src /client /accepted_tests.rs
SaylorTwift's picture
SaylorTwift HF Staff
Add files using upload-large-folder tool
ea39c0e verified
Raw
History Blame Contribute Delete
1.09 kB
use tokio::sync::oneshot;
use super::AcceptedConnectionSource;
use crate::ExecServerClientConnectOptions;
#[tokio::test]
async fn replacement_claim_is_released_when_handoff_is_cancelled() {
let source = AcceptedConnectionSource::new(ExecServerClientConnectOptions::default());
let (claimed_tx, claimed_rx) = oneshot::channel();
let (_release_tx, release_rx) = oneshot::channel::<()>();
let handoff = tokio::spawn({
let source = source.clone();
async move {
let _submission = source
.begin_replacement()
.expect("the first replacement should claim the handoff");
claimed_tx
.send(())
.expect("the test should wait for the claim");
let _ = release_rx.await;
}
});
claimed_rx.await.expect("the handoff should be claimed");
assert!(source.begin_replacement().is_err());
handoff.abort();
let _ = handoff.await;
source
.begin_replacement()
.expect("a new replacement should be accepted after cancellation");
}