referrerpolicy=no-referrer-when-downgrade

polkadot_subsystem_bench/availability/
av_store_helpers.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 crate::{environment::TestEnvironmentDependencies, mock::TestSyncOracle};
18use polkadot_node_core_av_store::{AvailabilityStoreSubsystem, Config};
19use polkadot_node_metrics::metrics::Metrics;
20use polkadot_node_subsystem_util::database::Database;
21use std::sync::Arc;
22
23mod columns {
24	pub const DATA: u32 = 0;
25	pub const META: u32 = 1;
26	pub const NUM_COLUMNS: u32 = 2;
27}
28
29const TEST_CONFIG: Config =
30	Config { col_data: columns::DATA, col_meta: columns::META, keep_finalized_for: 1 };
31
32pub fn new_av_store(dependencies: &TestEnvironmentDependencies) -> AvailabilityStoreSubsystem {
33	let metrics = Metrics::try_register(&dependencies.registry).unwrap();
34
35	AvailabilityStoreSubsystem::new(test_store(), TEST_CONFIG, Box::new(TestSyncOracle {}), metrics)
36}
37
38fn test_store() -> Arc<dyn Database> {
39	let db = kvdb_memorydb::create(columns::NUM_COLUMNS);
40	let db =
41		polkadot_node_subsystem_util::database::kvdb_impl::DbAdapter::new(db, &[columns::META]);
42	Arc::new(db)
43}