use std::time::Duration;
use phoxal_runtime_contract::identity::{ParticipantId, ParticipantIdError};
pub use crate::participant::clock::ClockSource;
pub use crate::participant::clock::test::TestClock;
pub use crate::participant::runner::{run_test_harness, run_test_harness_with_clock};
pub use phoxal_runtime_contract::identity::TimelineId;
#[doc(hidden)]
#[derive(Clone, Debug)]
pub struct TestHarness {
pub(crate) participant_id: ParticipantId,
pub(crate) timeline: TimelineId,
pub(crate) shutdown_grace: Duration,
pub(crate) query_reply_delay: Option<Duration>,
}
impl TestHarness {
pub fn new(participant_id: impl Into<String>) -> std::result::Result<Self, ParticipantIdError> {
Ok(Self {
participant_id: ParticipantId::new(participant_id)?,
timeline: TimelineId::mint(),
shutdown_grace: crate::participant::launch::SHUTDOWN_GRACE,
query_reply_delay: None,
})
}
#[must_use]
pub fn with_timeline(mut self, timeline: TimelineId) -> Self {
self.timeline = timeline;
self
}
#[doc(hidden)]
#[must_use]
pub fn with_query_reply_delay(mut self, delay: Duration) -> Self {
self.query_reply_delay = Some(delay);
self
}
}