zebra_scan/service/scan_task/
tests.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! Tests for the scan task.

use std::sync::Arc;

use super::{ScanTask, ScanTaskCommand, SCAN_TASK_BUFFER_SIZE};

#[cfg(test)]
mod vectors;

impl ScanTask {
    /// Spawns a new [`ScanTask`] for tests.
    pub fn mock() -> (Self, tokio::sync::mpsc::Receiver<ScanTaskCommand>) {
        let (cmd_sender, cmd_receiver) = tokio::sync::mpsc::channel(SCAN_TASK_BUFFER_SIZE);

        (
            Self {
                handle: Arc::new(tokio::spawn(std::future::pending())),
                cmd_sender,
            },
            cmd_receiver,
        )
    }
}