Skip to content

Commit

Permalink
Add history state to driver trace
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Dec 5, 2023
1 parent c95469b commit 2ff534a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
34 changes: 34 additions & 0 deletions Code/itf/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ use crate::{Address, Height, Proposal, Round, Timeout, Value, Vote, Weight};
pub struct State {
#[serde(rename = "line28Test::N4F1::system")]
pub system: HashMap<Address, NodeState>,

#[serde(rename = "line28Test::N4F1::_hist")]
pub history: HistoryEntry,
}

#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
pub struct HistoryEntry {
pub validator: Address,
pub input: DriverInput,
pub output: ConsensusOutput,
}

#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
Expand Down Expand Up @@ -52,3 +62,27 @@ pub struct DriverState {
#[serde(rename = "nextValueToPropose")]
pub next_value_to_propose: Value,
}

#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DriverInput {
pub name: String,
pub proposal: Proposal,
pub vote: Vote,
pub timeout: Timeout,
pub cs_input: ConsensusInput,
pub next_value_to_propose: Value,
}

#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConsensusOutput {
pub name: String,
pub proposal: Proposal,
#[serde(rename = "voteMessage")]
pub vote: Vote,
pub timeout: Timeout,
pub decided: Value,
#[serde(with = "As::<Integer>")]
pub skip_round: Round,
}
6 changes: 5 additions & 1 deletion Code/itf/tests/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ fn line28() {
.matcher("\\bline28Test")
.build();

std::mem::forget(temp_dir);

for json_fixture in trace_generator.generate() {
println!("Parsing {json_fixture:?}");

let json = std::fs::read_to_string(&json_fixture).unwrap();
let trace = itf::trace_from_str::<State>(&json).unwrap();

dbg!(trace);
println!("Trace has {} states", trace.states.len());

dbg!(&trace.states[0..2]);
}
}

0 comments on commit 2ff534a

Please sign in to comment.