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 Scenario {
17 pub fn with_comment(mut self, comment: &str) -> Self {
18 self.comment = Some(comment.to_string());
19 self
20 }
21}
22
23impl InterpretableFrom<ScenarioRaw> for Scenario {
24 fn interpret_from(from: ScenarioRaw, context: &InterpreterContext) -> Self {
25 Scenario {
26 name: from.name,
27 comment: from.comment,
28 check_gas: from.check_gas,
29 steps: from
30 .steps
31 .into_iter()
32 .map(|s| Step::interpret_from(s, context))
33 .collect(),
34 }
35 }
36}
37
38impl IntoRaw<ScenarioRaw> for Scenario {
39 fn into_raw(self) -> ScenarioRaw {
40 ScenarioRaw {
41 name: self.name,
42 comment: self.comment,
43 check_gas: self.check_gas,
44 gas_schedule: None,
45 steps: self.steps.into_iter().map(Step::into_raw).collect(),
46 }
47 }
48}