diff --git a/tendermint/src/block.rs b/tendermint/src/block.rs index 440da5cda..cd4bb8728 100644 --- a/tendermint/src/block.rs +++ b/tendermint/src/block.rs @@ -9,7 +9,7 @@ pub mod parts; mod size; pub use self::{ - commit::LastCommit, + commit::Commit, header::Header, height::*, id::{Id, ParseId}, @@ -35,5 +35,5 @@ pub struct Block { pub evidence: evidence::Data, /// Last commit - pub last_commit: LastCommit, + pub last_commit: Commit, } diff --git a/tendermint/src/block/commit.rs b/tendermint/src/block/commit.rs index 76c907736..ac0d21f9a 100644 --- a/tendermint/src/block/commit.rs +++ b/tendermint/src/block/commit.rs @@ -4,11 +4,12 @@ use crate::{block, Vote}; use serde::{Deserialize, Serialize}; use std::{ops::Deref, slice}; -/// Last commit to a particular blockchain: +2/3 precommit signatures. +/// Commit contains the justification (ie. a set of signatures) that a block was committed by a set of validators. /// +/// /// #[derive(Serialize, Deserialize, Clone, Debug)] -pub struct LastCommit { +pub struct Commit { /// Block ID of the last commit pub block_id: block::Id, diff --git a/tendermint/src/rpc/endpoint/commit.rs b/tendermint/src/rpc/endpoint/commit.rs index 3b05ead19..a4e0768d1 100644 --- a/tendermint/src/rpc/endpoint/commit.rs +++ b/tendermint/src/rpc/endpoint/commit.rs @@ -2,7 +2,6 @@ use crate::{block, rpc}; use serde::{Deserialize, Serialize}; -use std::ops::Deref; /// Get commit information about a specific block #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] @@ -44,12 +43,6 @@ impl rpc::Response for Response {} pub struct SignedHeader { /// Block header pub header: block::Header, -} - -impl Deref for SignedHeader { - type Target = block::Header; - - fn deref(&self) -> &block::Header { - &self.header - } + /// Commit containing signatures for the header + pub commit: block::Commit, } diff --git a/tests/config.rs b/tendermint/tests/config.rs similarity index 100% rename from tests/config.rs rename to tendermint/tests/config.rs diff --git a/tests/integration.rs b/tendermint/tests/integration.rs similarity index 100% rename from tests/integration.rs rename to tendermint/tests/integration.rs diff --git a/tests/rpc.rs b/tendermint/tests/rpc.rs similarity index 95% rename from tests/rpc.rs rename to tendermint/tests/rpc.rs index a62dcaac1..5a0992524 100644 --- a/tests/rpc.rs +++ b/tendermint/tests/rpc.rs @@ -163,6 +163,12 @@ mod endpoints { let response = endpoint::commit::Response::from_json(&read_json_fixture("commit")).unwrap(); let header = response.signed_header.header; assert_eq!(header.chain_id.as_ref(), EXAMPLE_CHAIN); + // For now we just want to make sure the commit including precommits and a block_id exist + // in SignedHeader; later we should verify some properties: e.g. block_id.hash matches the + // header etc: + let commit = response.signed_header.commit; + let _block_id = commit.block_id; + let _precommits = commit.precommits; } #[test] diff --git a/tests/secret_connection.rs b/tendermint/tests/secret_connection.rs similarity index 100% rename from tests/secret_connection.rs rename to tendermint/tests/secret_connection.rs diff --git a/tests/support/TestDeriveSecretsAndChallenge.golden b/tendermint/tests/support/TestDeriveSecretsAndChallenge.golden similarity index 100% rename from tests/support/TestDeriveSecretsAndChallenge.golden rename to tendermint/tests/support/TestDeriveSecretsAndChallenge.golden diff --git a/tests/support/config/config.toml b/tendermint/tests/support/config/config.toml similarity index 100% rename from tests/support/config/config.toml rename to tendermint/tests/support/config/config.toml diff --git a/tests/support/config/node_key.json b/tendermint/tests/support/config/node_key.json similarity index 100% rename from tests/support/config/node_key.json rename to tendermint/tests/support/config/node_key.json diff --git a/tests/support/config/priv_validator_key.json b/tendermint/tests/support/config/priv_validator_key.json similarity index 100% rename from tests/support/config/priv_validator_key.json rename to tendermint/tests/support/config/priv_validator_key.json diff --git a/tests/support/rpc/abci_info.json b/tendermint/tests/support/rpc/abci_info.json similarity index 100% rename from tests/support/rpc/abci_info.json rename to tendermint/tests/support/rpc/abci_info.json diff --git a/tests/support/rpc/abci_query.json b/tendermint/tests/support/rpc/abci_query.json similarity index 100% rename from tests/support/rpc/abci_query.json rename to tendermint/tests/support/rpc/abci_query.json diff --git a/tests/support/rpc/block.json b/tendermint/tests/support/rpc/block.json similarity index 100% rename from tests/support/rpc/block.json rename to tendermint/tests/support/rpc/block.json diff --git a/tests/support/rpc/block_results.json b/tendermint/tests/support/rpc/block_results.json similarity index 100% rename from tests/support/rpc/block_results.json rename to tendermint/tests/support/rpc/block_results.json diff --git a/tests/support/rpc/blockchain.json b/tendermint/tests/support/rpc/blockchain.json similarity index 100% rename from tests/support/rpc/blockchain.json rename to tendermint/tests/support/rpc/blockchain.json diff --git a/tests/support/rpc/broadcast_tx_async.json b/tendermint/tests/support/rpc/broadcast_tx_async.json similarity index 100% rename from tests/support/rpc/broadcast_tx_async.json rename to tendermint/tests/support/rpc/broadcast_tx_async.json diff --git a/tests/support/rpc/broadcast_tx_commit.json b/tendermint/tests/support/rpc/broadcast_tx_commit.json similarity index 100% rename from tests/support/rpc/broadcast_tx_commit.json rename to tendermint/tests/support/rpc/broadcast_tx_commit.json diff --git a/tests/support/rpc/broadcast_tx_sync.json b/tendermint/tests/support/rpc/broadcast_tx_sync.json similarity index 100% rename from tests/support/rpc/broadcast_tx_sync.json rename to tendermint/tests/support/rpc/broadcast_tx_sync.json diff --git a/tests/support/rpc/broadcast_tx_sync_int.json b/tendermint/tests/support/rpc/broadcast_tx_sync_int.json similarity index 100% rename from tests/support/rpc/broadcast_tx_sync_int.json rename to tendermint/tests/support/rpc/broadcast_tx_sync_int.json diff --git a/tests/support/rpc/commit.json b/tendermint/tests/support/rpc/commit.json similarity index 100% rename from tests/support/rpc/commit.json rename to tendermint/tests/support/rpc/commit.json diff --git a/tests/support/rpc/error.json b/tendermint/tests/support/rpc/error.json similarity index 100% rename from tests/support/rpc/error.json rename to tendermint/tests/support/rpc/error.json diff --git a/tests/support/rpc/genesis.json b/tendermint/tests/support/rpc/genesis.json similarity index 100% rename from tests/support/rpc/genesis.json rename to tendermint/tests/support/rpc/genesis.json diff --git a/tests/support/rpc/health.json b/tendermint/tests/support/rpc/health.json similarity index 100% rename from tests/support/rpc/health.json rename to tendermint/tests/support/rpc/health.json diff --git a/tests/support/rpc/net_info.json b/tendermint/tests/support/rpc/net_info.json similarity index 100% rename from tests/support/rpc/net_info.json rename to tendermint/tests/support/rpc/net_info.json diff --git a/tests/support/rpc/status.json b/tendermint/tests/support/rpc/status.json similarity index 100% rename from tests/support/rpc/status.json rename to tendermint/tests/support/rpc/status.json diff --git a/tests/support/rpc/validators.json b/tendermint/tests/support/rpc/validators.json similarity index 100% rename from tests/support/rpc/validators.json rename to tendermint/tests/support/rpc/validators.json