-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42f2a55
commit 3b4f88e
Showing
8 changed files
with
361 additions
and
41 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
polkadot/node/subsystem-bench/src/lib/mock/prospective_parachains.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// This file is part of Polkadot. | ||
|
||
// Polkadot is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Polkadot is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! A generic runtime api subsystem mockup suitable to be used in benchmarks. | ||
use futures::FutureExt; | ||
use polkadot_node_subsystem::{ | ||
messages::ProspectiveParachainsMessage, overseer, SpawnedSubsystem, SubsystemError, | ||
}; | ||
use polkadot_node_subsystem_types::OverseerSignal; | ||
|
||
const LOG_TARGET: &str = "subsystem-bench::prospective-parachains-mock"; | ||
|
||
pub struct MockProspectiveParachains {} | ||
|
||
impl MockProspectiveParachains { | ||
pub fn new() -> Self { | ||
Self {} | ||
} | ||
} | ||
|
||
#[overseer::subsystem(ProspectiveParachains, error=SubsystemError, prefix=self::overseer)] | ||
impl<Context> MockProspectiveParachains { | ||
fn start(self, ctx: Context) -> SpawnedSubsystem { | ||
let future = self.run(ctx).map(|_| Ok(())).boxed(); | ||
|
||
SpawnedSubsystem { name: "test-environment", future } | ||
} | ||
} | ||
|
||
#[overseer::contextbounds(ProspectiveParachains, prefix = self::overseer)] | ||
impl MockProspectiveParachains { | ||
async fn run<Context>(self, mut ctx: Context) { | ||
loop { | ||
let msg = ctx.recv().await.expect("Overseer never fails us"); | ||
match msg { | ||
orchestra::FromOrchestra::Signal(signal) => | ||
if signal == OverseerSignal::Conclude { | ||
return | ||
}, | ||
orchestra::FromOrchestra::Communication { msg } => { | ||
gum::debug!(target: LOG_TARGET, msg=?msg, "recv message"); | ||
|
||
match msg { | ||
ProspectiveParachainsMessage::GetMinimumRelayParents(_relay_parent, tx) => { | ||
tx.send(vec![]).unwrap(); | ||
}, | ||
ProspectiveParachainsMessage::GetHypotheticalFrontier(_req, tx) => { | ||
tx.send(vec![]).unwrap(); | ||
}, | ||
_ => { | ||
unimplemented!("Unexpected chain-api message") | ||
}, | ||
} | ||
}, | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.