mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-07 17:47:23 +00:00
Rename polkadot-consensus -> polkadot-validation (#151)
* Initial rename of consensus -> validation * Rename crate imports * network: rename consensus to validation * network: rename consensus in comments and logs * Grumbles * Rename tests consensus -> validation
This commit is contained in:
committed by
Robert Habermeier
parent
62cf571336
commit
7a619ea222
@@ -14,13 +14,13 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Tests for polkadot and consensus network.
|
||||
//! Tests for polkadot and validation network.
|
||||
|
||||
use super::{PolkadotProtocol, Status, Message, FullStatus};
|
||||
use consensus::{CurrentConsensus, Knowledge};
|
||||
use validation::{ValidationSession, Knowledge};
|
||||
|
||||
use parking_lot::Mutex;
|
||||
use polkadot_consensus::GenericStatement;
|
||||
use polkadot_validation::GenericStatement;
|
||||
use polkadot_primitives::{Block, SessionKey};
|
||||
use polkadot_primitives::parachain::{CandidateReceipt, HeadData, BlockData};
|
||||
use substrate_primitives::H512;
|
||||
@@ -34,7 +34,7 @@ use substrate_network::{
|
||||
use std::sync::Arc;
|
||||
use futures::Future;
|
||||
|
||||
mod consensus;
|
||||
mod validation;
|
||||
|
||||
#[derive(Default)]
|
||||
struct TestContext {
|
||||
@@ -87,9 +87,9 @@ fn make_status(status: &Status, roles: Roles) -> FullStatus {
|
||||
}
|
||||
}
|
||||
|
||||
fn make_consensus(local_key: SessionKey) -> (CurrentConsensus, Arc<Mutex<Knowledge>>) {
|
||||
fn make_validation_session(local_key: SessionKey) -> (ValidationSession, Arc<Mutex<Knowledge>>) {
|
||||
let knowledge = Arc::new(Mutex::new(Knowledge::new()));
|
||||
let c = CurrentConsensus::new(knowledge.clone(), local_key);
|
||||
let c = ValidationSession::new(knowledge.clone(), local_key);
|
||||
|
||||
(c, knowledge)
|
||||
}
|
||||
@@ -119,8 +119,8 @@ fn sends_session_key() {
|
||||
|
||||
{
|
||||
let mut ctx = TestContext::default();
|
||||
let (consensus, _knowledge) = make_consensus(local_key);
|
||||
protocol.new_consensus(&mut ctx, parent_hash, consensus);
|
||||
let (session, _knowledge) = make_validation_session(local_key);
|
||||
protocol.new_validation_session(&mut ctx, parent_hash, session);
|
||||
assert!(ctx.has_message(peer_a, Message::SessionKey(local_key)));
|
||||
}
|
||||
|
||||
@@ -159,8 +159,8 @@ fn fetches_from_those_with_knowledge() {
|
||||
|
||||
let status = Status { collating_for: None };
|
||||
|
||||
let (consensus, knowledge) = make_consensus(local_key);
|
||||
protocol.new_consensus(&mut TestContext::default(), parent_hash, consensus);
|
||||
let (session, knowledge) = make_validation_session(local_key);
|
||||
protocol.new_validation_session(&mut TestContext::default(), parent_hash, session);
|
||||
|
||||
knowledge.lock().note_statement(a_key, &GenericStatement::Valid(candidate_hash));
|
||||
let recv = protocol.fetch_block_data(&mut TestContext::default(), &candidate_receipt, parent_hash);
|
||||
@@ -289,13 +289,13 @@ fn many_session_keys() {
|
||||
let local_key_a = [3; 32].into();
|
||||
let local_key_b = [4; 32].into();
|
||||
|
||||
let (consensus_a, _knowledge_a) = make_consensus(local_key_a);
|
||||
let (consensus_b, _knowledge_b) = make_consensus(local_key_b);
|
||||
let (session_a, _knowledge_a) = make_validation_session(local_key_a);
|
||||
let (session_b, _knowledge_b) = make_validation_session(local_key_b);
|
||||
|
||||
protocol.new_consensus(&mut TestContext::default(), parent_a, consensus_a);
|
||||
protocol.new_consensus(&mut TestContext::default(), parent_b, consensus_b);
|
||||
protocol.new_validation_session(&mut TestContext::default(), parent_a, session_a);
|
||||
protocol.new_validation_session(&mut TestContext::default(), parent_b, session_b);
|
||||
|
||||
assert_eq!(protocol.live_consensus.recent_keys(), &[local_key_a, local_key_b]);
|
||||
assert_eq!(protocol.live_validation_sessions.recent_keys(), &[local_key_a, local_key_b]);
|
||||
|
||||
let peer_a = 1;
|
||||
|
||||
@@ -312,7 +312,7 @@ fn many_session_keys() {
|
||||
|
||||
let peer_b = 2;
|
||||
|
||||
protocol.remove_consensus(&parent_a);
|
||||
protocol.remove_validation_session(&parent_a);
|
||||
|
||||
{
|
||||
let mut ctx = TestContext::default();
|
||||
|
||||
@@ -14,15 +14,15 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Tests and helpers for consensus networking.
|
||||
//! Tests and helpers for validation networking.
|
||||
|
||||
use consensus::NetworkService;
|
||||
use validation::NetworkService;
|
||||
use substrate_network::{consensus_gossip::ConsensusMessage, Context as NetContext};
|
||||
use substrate_primitives::{Ed25519AuthorityId, NativeOrEncoded};
|
||||
use substrate_keyring::Keyring;
|
||||
use {PolkadotProtocol};
|
||||
|
||||
use polkadot_consensus::{SharedTable, MessagesFrom, Network, TableRouter};
|
||||
use polkadot_validation::{SharedTable, MessagesFrom, Network, TableRouter};
|
||||
use polkadot_primitives::{AccountId, Block, Hash, Header, BlockId};
|
||||
use polkadot_primitives::parachain::{Id as ParaId, Chain, DutyRoster, ParachainHost, OutgoingMessage};
|
||||
use parking_lot::Mutex;
|
||||
@@ -298,7 +298,7 @@ impl ParachainHost<Block> for RuntimeApi {
|
||||
}
|
||||
}
|
||||
|
||||
type TestConsensusNetwork = ::consensus::ConsensusNetwork<
|
||||
type TestValidationNetwork = ::validation::ValidationNetwork<
|
||||
TestApi,
|
||||
NeverExit,
|
||||
TestNetwork,
|
||||
@@ -308,7 +308,7 @@ type TestConsensusNetwork = ::consensus::ConsensusNetwork<
|
||||
struct Built {
|
||||
gossip: GossipRouter,
|
||||
api_handle: Arc<Mutex<ApiData>>,
|
||||
networks: Vec<TestConsensusNetwork>,
|
||||
networks: Vec<TestValidationNetwork>,
|
||||
}
|
||||
|
||||
fn build_network(n: usize, executor: TaskExecutor) -> Built {
|
||||
@@ -322,7 +322,7 @@ fn build_network(n: usize, executor: TaskExecutor) -> Built {
|
||||
gossip: gossip_handle.clone(),
|
||||
});
|
||||
|
||||
TestConsensusNetwork::new(
|
||||
TestValidationNetwork::new(
|
||||
net,
|
||||
NeverExit,
|
||||
runtime_api.clone(),
|
||||
@@ -356,7 +356,7 @@ impl IngressBuilder {
|
||||
let mut map = HashMap::new();
|
||||
for ((source, target), messages) in self.egress {
|
||||
map.entry(target).or_insert_with(Vec::new)
|
||||
.push((source, polkadot_consensus::message_queue_root(&messages)));
|
||||
.push((source, polkadot_validation::message_queue_root(&messages)));
|
||||
}
|
||||
|
||||
for roots in map.values_mut() {
|
||||
@@ -372,7 +372,7 @@ fn make_table(data: &ApiData, local_key: &Keyring, parent_hash: Hash) -> Arc<Sha
|
||||
|
||||
let store = Store::new_in_memory();
|
||||
let authorities: Vec<_> = data.validators.iter().map(|v| v.to_fixed_bytes().into()).collect();
|
||||
let (group_info, _) = ::polkadot_consensus::make_group_info(
|
||||
let (group_info, _) = ::polkadot_validation::make_group_info(
|
||||
DutyRoster { validator_duty: data.duties.clone() },
|
||||
&authorities,
|
||||
local_key.to_raw_public().into()
|
||||
Reference in New Issue
Block a user