ibc_testkit/fixtures/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
pub mod applications;
pub mod clients;
pub mod core;
use alloc::fmt::Debug;

use ibc::core::handler::types::error::HandlerError;
use ibc::core::primitives::prelude::*;

use crate::testapp::ibc::core::types::DefaultIbcStore;
pub enum Expect {
    Success,
    Failure(Option<HandlerError>),
}

#[derive(Debug)]
pub struct Fixture<M: Debug> {
    pub ctx: DefaultIbcStore,
    pub msg: M,
}

impl<M: Debug> Fixture<M> {
    pub fn generate_error_msg(
        &self,
        expect: &Expect,
        process: &str,
        res: &Result<(), HandlerError>,
    ) -> String {
        let base_error = match expect {
            Expect::Success => "step failed!",
            Expect::Failure(_) => "step passed but was supposed to fail!",
        };
        format!(
            "{process} {base_error} /n {res:?} /n {:?} /n {:?}",
            &self.msg, &self.ctx
        )
    }
}