multiversx_sc_scenario/scenario/model/
scenario.rs1use crate::scenario_format::{
2 interpret_trait::{InterpretableFrom, InterpreterContext, IntoRaw},
3 serde_raw::ScenarioRaw,
4};
5
6use super::Step;
7
8#[derive(Debug, Default)]
9pub struct Scenario {
10 pub name: Option<String>,
11 pub comment: Option<String>,
12 pub check_gas: Option<bool>,
13 pub steps: Vec<Step>,
14}
15
16impl InterpretableFrom<ScenarioRaw> for Scenario {
17 fn interpret_from(from: ScenarioRaw, context: &InterpreterContext) -> Self {
18 Scenario {
19 name: from.name,
20 comment: from.comment,
21 check_gas: from.check_gas,
22 steps: from
23 .steps
24 .into_iter()
25 .map(|s| Step::interpret_from(s, context))
26 .collect(),
27 }
28 }
29}
30
31impl IntoRaw<ScenarioRaw> for Scenario {
32 fn into_raw(self) -> ScenarioRaw {
33 ScenarioRaw {
34 name: self.name,
35 comment: self.comment,
36 check_gas: self.check_gas,
37 gas_schedule: None,
38 steps: self.steps.into_iter().map(Step::into_raw).collect(),
39 }
40 }
41}