-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 📝 implement cometstub crate (work-in-progress)
this commit introduces a new library, in `crates/test/`. this library contains a mock implementation of cometbft, for use in cargo integration tests. * this does NOT add the `penumbra-cometstub` crate to the list of crates included in the rust documentation in `deployments/scripts/rust-docs`. the `penumbra-tct-property-test` crate was also not included in that list at the time of writing. /!\ ------------------------------------------------------- /!\ /!\ NOTE: this is a rolling work-in-progress. /!\ /!\ this branch will be force-pushed frequently until it is /!\ /!\ ready for review. proceed accordingly! /!\ /!\ ------------------------------------------------------- /!\
- Loading branch information
Showing
4 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[package] | ||
name = "penumbra-cometstub" | ||
version = "0.64.1" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[features] | ||
default = ["component", "std"] | ||
component = [ | ||
# "cnidarium", | ||
# "cnidarium-component", | ||
# "penumbra-proto/cnidarium", | ||
# "penumbra-chain/component", | ||
] | ||
std = ["ibc-types/std"] | ||
|
||
[dependencies] | ||
# Workspace dependencies | ||
|
||
# Penumbra dependencies | ||
ibc-proto = { version = "0.40.0", default-features = false } | ||
ibc-types = { version = "0.11.0", default-features = false } | ||
|
||
# Crates.io deps | ||
anyhow = "1" | ||
tendermint = "0.34.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use tendermint::{ | ||
abci::types::CommitInfo, | ||
block::{Header, Round, Height}, | ||
Hash, Time, | ||
}; | ||
use { | ||
ibc_proto::{ | ||
google::protobuf::Any, ibc::core::client::v1::MsgCreateClient as RawMsgCreateClient, | ||
}, | ||
ibc_types::{core::client::msgs::MsgCreateClient, DomainType}, | ||
tendermint::abci::request::BeginBlock, | ||
}; | ||
|
||
pub fn begin_block() -> BeginBlock { | ||
BeginBlock { | ||
hash: Hash::None, | ||
header: header(), | ||
last_commit_info: CommitInfo { | ||
round: Round::default(), | ||
votes: vec![], | ||
}, | ||
byzantine_validators: vec![], | ||
} | ||
} | ||
|
||
fn header() -> Header { | ||
use tendermint::block::header::Version; | ||
Header { | ||
version: Version { block: 0, app: 0 }, //: Version, | ||
chain_id: todo!(), //: chain::Id, | ||
height: Height::default(), //: block::Height, | ||
time: Time::unix_epoch(), //: Time, | ||
last_block_id: None, //: Option<block::Id>, | ||
last_commit_hash: None, //: Option<Hash>, | ||
data_hash: None, //: Option<Hash>, | ||
validators_hash: todo!(), //: Hash, | ||
next_validators_hash: todo!(), //: Hash, | ||
consensus_hash: todo!(), //: Hash, | ||
app_hash: todo!(), //: AppHash, | ||
last_results_hash: None, //: Option<Hash>, | ||
evidence_hash: None, //: Option<Hash>, | ||
proposer_address: todo!(), //: account::Id, | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use { | ||
super::*, | ||
ibc_types::{core::client::msgs::MsgCreateClient, DomainType}, | ||
}; | ||
|
||
#[test] | ||
fn begin_block_works() { | ||
let msg = begin_block(); | ||
unimplemented!("generate a begin block message") | ||
} | ||
} | ||
|
||
// TODO(katie): this sketch is loosely based upon test_create_and_update_light_client. i am not | ||
// convinced this is the right direction quite yet. i see very little interaction with headers | ||
// themselves, it feels vaguely like we should be generating abci messages instead? | ||
// | ||
// Any is another puzzle. how to make those? | ||
// | ||
// tendermint_proxy contains the logic to marshal a tendermint::Block into its | ||
// protobuf representation. consider moving that, see the todo comment there. |