Skip to content

Commit

Permalink
mock-consensus: 💇 use evidence::List::default
Browse files Browse the repository at this point in the history
`tendermint::evidence::List` implements `std::default::Default`. so,
let's use that instead of mandating that an empty evidence list be
provided each time that we build a new block.

#3840 (comment)

Reference: #3588
Reference: #3792
Reference: #3840
Co-Authored-By: Henry de Valence <[email protected]>
  • Loading branch information
cratelyn and hdevalence committed Feb 20, 2024
1 parent 1fae79d commit 4f7102d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 0 additions & 2 deletions crates/core/app/tests/mock_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use {
penumbra_app::server::consensus::Consensus,
penumbra_genesis::AppState,
penumbra_sct::component::clock::EpochRead,
tendermint::evidence::List,
tracing::{error_span, Instrument},
};

Expand Down Expand Up @@ -75,7 +74,6 @@ async fn mock_consensus_can_send_a_sequence_of_empty_blocks() -> anyhow::Result<
engine
.block()
.with_data(vec![])
.with_evidence(List::new(Vec::new()))
.execute()
.instrument(error_span!("executing block", %expected))
.await?;
Expand Down
9 changes: 3 additions & 6 deletions crates/test/mock-consensus/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Builder<'e, C> {
data: Option<Vec<Vec<u8>>>,

/// Evidence of malfeasance.
evidence: Option<evidence::List>,
evidence: evidence::List,
}

impl<C> TestNode<C> {
Expand All @@ -55,10 +55,7 @@ impl<'e, C> Builder<'e, C> {

/// Sets the evidence [`List`][evidence::List] for this block.
pub fn with_evidence(self, evidence: evidence::List) -> Self {
Self {
evidence: Some(evidence),
..self
}
Self { evidence, ..self }
}

// TODO(kate): add more `with_` setters for fields in the header.
Expand Down Expand Up @@ -116,7 +113,7 @@ where
tracing::trace!("building block");
let Self {
data: Some(data),
evidence: Some(evidence),
evidence,
test_node,
} = self
else {
Expand Down

0 comments on commit 4f7102d

Please sign in to comment.