Skip to content

Commit b0a5214

Browse files
committed
Match original log messages
1 parent c586392 commit b0a5214

1 file changed

Lines changed: 50 additions & 4 deletions

File tree

crates/charon-core/src/qbft/internal_test.rs

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ fn test_qbft(test: Test) {
3636
const MAX_ROUND: usize = 50;
3737
const FIFO_LIMIT: usize = 100;
3838

39+
let start_time = time::Instant::now();
40+
3941
let cts = CancellationTokenSource::new();
4042
let mut receives = HashMap::<
4143
i64,
@@ -85,10 +87,35 @@ fn test_qbft(test: Test) {
8587
),
8688
nodes: N as i64,
8789
fifo_limit: FIFO_LIMIT as i64,
88-
/* Ignored logging */
89-
log_round_change: Box::new(|_, _, _, _, _, _| {}),
90-
log_unjust: Box::new(|_, _, _| {}),
91-
log_upon_rule: Box::new(|_, _, _, _, _| {}),
90+
log_round_change: Box::new(
91+
move |_, process: i64, round: i64, new_round: i64, upon_rule: UponRule, _| {
92+
println!(
93+
"{:?} - {}@{} change to {} ~= {}",
94+
start_time.elapsed(),
95+
process,
96+
round,
97+
new_round,
98+
upon_rule,
99+
);
100+
},
101+
),
102+
log_unjust: Box::new(|_, _, msg: Msg<i64, i64, i64>| {
103+
println!("Unjust: {:?}", msg);
104+
}),
105+
log_upon_rule: Box::new(
106+
move |_, process: i64, round: i64, msg: &Msg<i64, i64, i64>, upon_rule: UponRule| {
107+
println!(
108+
"{:?} {} => {}@{} -> {}@{} ~= {}",
109+
start_time.elapsed(),
110+
msg.source(),
111+
msg.type_(),
112+
msg.round(),
113+
process,
114+
round,
115+
upon_rule,
116+
);
117+
},
118+
),
92119
});
93120

94121
thread::scope(|s| {
@@ -113,9 +140,23 @@ fn test_qbft(test: Test) {
113140
}
114141

115142
if type_ == MSG_COMMIT && round <= test.commits_after.into() {
143+
println!(
144+
"{:?} {} dropping commit for round {}",
145+
start_time.elapsed(),
146+
source,
147+
round
148+
);
116149
return Ok(());
117150
}
118151

152+
println!(
153+
"{:?} {} => {}@{}",
154+
start_time.elapsed(),
155+
source,
156+
type_,
157+
round
158+
);
159+
119160
let msg = new_msg(
120161
type_,
121162
*instance,
@@ -204,6 +245,7 @@ fn test_qbft(test: Test) {
204245

205246
if let Some(p) = test.drop_prob.get(&msg.source()) {
206247
if rand::random::<f64>() < *p {
248+
println!("{:?} {} => {}@{} => {} (dropped)", start_time.elapsed(), msg.source(), msg.type_(), msg.round(), target);
207249
continue; // Drop
208250
}
209251
}
@@ -242,6 +284,10 @@ fn test_qbft(test: Test) {
242284
continue;
243285
}
244286

287+
let round = q_commit[0].round();
288+
println!("Got all results in round {} after {:?}: {:?}", round, start_time.elapsed(), results);
289+
290+
// Trigger shutdown
245291
decided = true;
246292

247293
cts.cancel();

0 commit comments

Comments
 (0)