Skip to content

Commit

Permalink
test start stop of service
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita committed Jun 14, 2022
1 parent b071db5 commit 5685038
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions fuel-txpool/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,28 @@ pub mod tests {
use super::*;
use fuel_core_interfaces::db::helpers::*;

#[tokio::test]
async fn test_start_stop() {
let config = Config::default();
let db = Box::new(DummyDb::filled());
let (bs, _br) = broadcast::channel(10);

let service = Service::new(db, config).unwrap();
assert!(service.start(bs.subscribe()).await, "start service");

//double start will return false
assert!(
!service.start(bs.subscribe()).await,
"double start should fail"
);

let stop_handle = service.stop().await;
assert!(stop_handle.is_some());
let _ = stop_handle.unwrap().await;

assert!(service.start(bs.subscribe()).await, "Should start again");
}

#[tokio::test]
async fn test_filter_by_negative() {
let config = Config::default();
Expand Down

0 comments on commit 5685038

Please sign in to comment.