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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
extern crate core;
cfg_if::cfg_if! {
    if #[cfg(test)] {
        #[allow(clippy::all)]
        pub mod common;
        #[allow(clippy::all)]
        pub mod component;
        #[allow(clippy::all)]
        pub mod non_functional;
        #[allow(clippy::all)]
        pub mod integration;
        #[allow(clippy::all)]
        pub mod e2e;
    }
}

use jormungandr_automation::{jormungandr::JormungandrRest, testing::time};
use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {
    #[error("vitup error")]
    VitupError(#[from] vitup::error::Error),
    #[error("verification error")]
    VerificationError(#[from] jormungandr_automation::testing::VerificationError),
    #[error("sender error")]
    FragmentSenderError(#[from] thor::FragmentSenderError),
    #[error("iapyx error")]
    IapyxError(#[from] iapyx::ControllerError),
}

#[allow(dead_code)]
#[derive(Copy, Clone)]
pub enum Vote {
    Yes = 0,
    No = 1,
}

#[allow(dead_code)]
pub struct VoteTiming {
    pub vote_start: u32,
    pub tally_start: u32,
    pub tally_end: u32,
}

impl VoteTiming {
    pub fn new(vote_start: u32, tally_start: u32, tally_end: u32) -> Self {
        Self {
            vote_start,
            tally_start,
            tally_end,
        }
    }

    pub fn wait_for_tally_start(self, rest: JormungandrRest) {
        time::wait_for_epoch(self.tally_start, rest);
    }

    pub fn wait_for_tally_end(self, rest: JormungandrRest) {
        time::wait_for_epoch(self.tally_end, rest);
    }
}