Skip to content

Commit

Permalink
Implement missing syncinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
zbuc committed Aug 20, 2024
1 parent 9a12043 commit 67ebaf6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
1 change: 0 additions & 1 deletion crates/core/app/tests/common/temp_storage_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub trait TempStorageExt: Sized {

#[async_trait]
impl TempStorageExt for TempStorage {
// TODO: move this to an Ext trait for Storage instead of TempStorage
async fn new_with_penumbra_prefixes() -> anyhow::Result<TempStorage> {
TempStorage::new_with_prefixes(SUBSTORE_PREFIXES.to_vec()).await
}
Expand Down
10 changes: 0 additions & 10 deletions crates/test/mock-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ impl MockClient {
Ok(self)
}

pub async fn with_sync_to_inner_storage(
mut self,
storage: cnidarium::Storage,
) -> anyhow::Result<Self> {
let latest = storage.latest_snapshot();
self.sync_to_latest(latest).await?;

Ok(self)
}

pub async fn sync_to_latest<R: StateRead>(&mut self, state: R) -> anyhow::Result<()> {
let height = state.get_block_height().await?;
self.sync_to(height, state).await?;
Expand Down
21 changes: 15 additions & 6 deletions crates/test/mock-tendermint-proxy/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ impl TestNodeProxy {
Box::new(move |block| inner.on_block(block))
}

/// Returns the last committed block height.
fn last_block_height(&self) -> tendermint::block::Height {
/// Returns the latest committed block height.
fn latest_block_height(&self) -> tendermint::block::Height {
self.inner
.blocks()
.last_key_value()
Expand Down Expand Up @@ -164,12 +164,21 @@ impl TendermintProxyService for TestNodeProxy {
req: tonic::Request<GetStatusRequest>,
) -> Result<tonic::Response<GetStatusResponse>, Status> {
let GetStatusRequest { .. } = req.into_inner();
let latest_block_height = self.last_block_height().into();
let latest_block_height = self.latest_block_height().into();
let block_ts: tendermint_proto::google::protobuf::Timestamp = self.timestamp().into();
let sync_info = SyncInfo {
// TODO: these should get set
latest_block_hash: vec![],
latest_app_hash: vec![],
latest_block_hash: self
.inner
.blocks()
.last_key_value()
.map(|(_, b)| b.header.hash().into())
.unwrap_or_default(),
latest_app_hash: self
.inner
.blocks()
.last_key_value()
.map(|(_, b)| b.header.app_hash.clone().into())
.unwrap_or_default(),
latest_block_height,
latest_block_time: Some(pbjson_types::Timestamp {
seconds: block_ts.seconds,
Expand Down

0 comments on commit 67ebaf6

Please sign in to comment.