Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinI committed Oct 23, 2024
1 parent 2b1c75c commit 2409eb2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
8 changes: 5 additions & 3 deletions crates/shared/src/testing/generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ where
let mut data = vec![0; txn_size];
rng.fill(data.as_mut_slice());
let transaction = TransactionPayload {
number: self.txn_nonce,
index: self.txn_nonce,
created: now,
data,
};
Expand All @@ -177,7 +177,7 @@ where
rng.fill(data.as_mut_slice());

let transaction = TransactionPayload {
number: self.txn_nonce,
index: self.txn_nonce,
created: now,
data,
};
Expand All @@ -202,6 +202,7 @@ where
type Event = Event<Types>;

async fn handle_event(&mut self, (event, id): (Self::Event, usize)) -> anyhow::Result<()> {
// We only need to handle events from one node
if id != 0 {
return Ok(());
}
Expand Down Expand Up @@ -246,7 +247,8 @@ where
builder::Error::Request(request_error) => {
panic!("Builder API not available: {request_error}")
}
// If the builder returns an error, we will re-try on the next view
// If the builder returns an error, we will re-submit this transaction
// on the next view, so we return it to the queue and break
error => {
tracing::warn!(?error, "Builder API error");
self.txn_queue.push_front(txn);
Expand Down
4 changes: 2 additions & 2 deletions crates/shared/src/testing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub mod validation;
pub struct TransactionPayload {
/// Monotonically increasing transaction number, to uniquely
/// identify the transaction and track transaction ordering
number: usize,
index: usize,
/// Time of transaction creation
created: DateTime<Local>,
/// Arbitrary data to pad transaction length with
Expand All @@ -35,7 +35,7 @@ impl TransactionPayload {
let mut data = Vec::with_capacity(data_bytes);
thread_rng().fill(data.as_mut_slice());
Self {
number,
index: number,
created: Local::now(),
data,
}
Expand Down
3 changes: 2 additions & 1 deletion crates/shared/src/testing/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ where
type Event = Event<Types>;

async fn handle_event(&mut self, (event, id): (Self::Event, usize)) -> anyhow::Result<()> {
// We only need to handle events from one node
if id != 0 {
return Ok(());
}
Expand Down Expand Up @@ -112,7 +113,7 @@ where
if let Err(e) = self
.txn_history
.iter()
.map(|txn| txn.payload.number as i64)
.map(|txn| txn.payload.index as i64)
.try_fold(-1, |prev, next| {
if prev + 1 == next {
Ok(next)
Expand Down

0 comments on commit 2409eb2

Please sign in to comment.