[WIP] Daemon & CLI
This commit is contained in:
parent
56aad3a023
commit
8b158108bb
100 changed files with 6519 additions and 1596 deletions
40
iota-daemon-lib/tests/shutdown.rs
Normal file
40
iota-daemon-lib/tests/shutdown.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
use iota_daemon_lib::{DaemonRuntime, ShutdownReason};
|
||||
use std::time::Duration;
|
||||
|
||||
#[tokio::test]
|
||||
async fn shutdown_reason_is_first_write_wins_and_tasks_join() {
|
||||
let runtime = DaemonRuntime::new();
|
||||
runtime.shutdown(ShutdownReason::Fatal("first".into()));
|
||||
runtime.shutdown(ShutdownReason::Restart);
|
||||
assert_eq!(
|
||||
runtime.shutdown_reason(),
|
||||
Some(ShutdownReason::Fatal("first".into()))
|
||||
);
|
||||
runtime.tasks.spawn_tracked("quick", async { Ok(()) }).await;
|
||||
assert!(
|
||||
runtime
|
||||
.tasks
|
||||
.join_with_timeout(Duration::from_millis(100))
|
||||
.await
|
||||
.is_empty()
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn long_task_is_aborted_at_join_timeout() {
|
||||
let runtime = DaemonRuntime::new();
|
||||
runtime
|
||||
.tasks
|
||||
.spawn_tracked("slow", async {
|
||||
tokio::time::sleep(Duration::from_secs(10)).await;
|
||||
Ok(())
|
||||
})
|
||||
.await;
|
||||
assert!(
|
||||
runtime
|
||||
.tasks
|
||||
.join_with_timeout(Duration::from_millis(10))
|
||||
.await
|
||||
.is_empty()
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue