trdelnik_sandbox_client/
tester.rs1use crate::{commander::Error, Commander, LocalnetHandle};
2use fehler::throws;
3use log::debug;
4use std::{borrow::Cow, mem};
5
6#[derive(Default)]
10pub struct Tester {
11 root: Cow<'static, str>,
12}
13
14impl Tester {
15 pub fn new() -> Self {
16 Self {
17 root: "../../".into(),
18 }
19 }
20
21 pub fn with_root(root: impl Into<Cow<'static, str>>) -> Self {
22 Self { root: root.into() }
23 }
24
25 #[throws]
26 pub async fn before(&mut self) -> LocalnetHandle {
27 debug!("_____________________");
28 debug!("____ BEFORE TEST ____");
29 let commander = Commander::with_root(mem::take(&mut self.root));
30 commander.start_localnet().await?
31 }
32
33 #[throws]
34 pub async fn after(&self, localnet_handle: LocalnetHandle) {
35 debug!("____ AFTER TEST ____");
36 localnet_handle.stop_and_remove_ledger().await?;
37 debug!("_____________________");
38 }
39}