referrerpolicy=no-referrer-when-downgrade

polkadot_subsystem_bench/mock/
mod.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
16
17use polkadot_node_subsystem::HeadSupportsParachains;
18use polkadot_node_subsystem_types::Hash;
19use sp_consensus::SyncOracle;
20
21pub mod approval_voting_parallel;
22pub mod av_store;
23pub mod availability_recovery;
24pub mod candidate_backing;
25pub mod candidate_validation;
26pub mod chain_api;
27pub mod dummy;
28pub mod network_bridge;
29pub mod prospective_parachains;
30pub mod runtime_api;
31
32pub struct AlwaysSupportsParachains {}
33
34#[async_trait::async_trait]
35impl HeadSupportsParachains for AlwaysSupportsParachains {
36	async fn head_supports_parachains(&self, _head: &Hash) -> bool {
37		true
38	}
39}
40
41// An orchestra with dummy subsystems
42#[macro_export]
43macro_rules! dummy_builder {
44	($spawn_task_handle: ident, $metrics: ident) => {{
45		use $crate::mock::dummy::*;
46
47		// Initialize a mock overseer.
48		// All subsystem except approval_voting and approval_distribution are mock subsystems.
49		Overseer::builder()
50			.approval_voting(MockApprovalVoting {})
51			.approval_voting_parallel(MockApprovalVotingParallel {})
52			.approval_distribution(MockApprovalDistribution {})
53			.availability_recovery(MockAvailabilityRecovery {})
54			.candidate_validation(MockCandidateValidation {})
55			.chain_api(MockChainApi {})
56			.chain_selection(MockChainSelection {})
57			.dispute_coordinator(MockDisputeCoordinator {})
58			.runtime_api(MockRuntimeApi {})
59			.network_bridge_tx(MockNetworkBridgeTx {})
60			.availability_distribution(MockAvailabilityDistribution {})
61			.availability_store(MockAvailabilityStore {})
62			.pvf_checker(MockPvfChecker {})
63			.candidate_backing(MockCandidateBacking {})
64			.statement_distribution(MockStatementDistribution {})
65			.bitfield_signing(MockBitfieldSigning {})
66			.bitfield_distribution(MockBitfieldDistribution {})
67			.provisioner(MockProvisioner {})
68			.network_bridge_rx(MockNetworkBridgeRx {})
69			.collation_generation(MockCollationGeneration {})
70			.collator_protocol(MockCollatorProtocol {})
71			.gossip_support(MockGossipSupport {})
72			.dispute_distribution(MockDisputeDistribution {})
73			.prospective_parachains(MockProspectiveParachains {})
74			.activation_external_listeners(Default::default())
75			.active_leaves(Default::default())
76			.metrics($metrics)
77			.supports_parachains(AlwaysSupportsParachains {})
78			.spawner(SpawnGlue($spawn_task_handle))
79	}};
80}
81
82#[derive(Clone)]
83pub struct TestSyncOracle {}
84
85impl SyncOracle for TestSyncOracle {
86	fn is_major_syncing(&self) -> bool {
87		false
88	}
89
90	fn is_offline(&self) -> bool {
91		unimplemented!("not used by subsystem benchmarks")
92	}
93}