Commit d4a3a490 authored by Bernhard Schuster's avatar Bernhard Schuster
Browse files

chore: cargo fmt

parent e410fbb1
Pipeline #154755 failed with stages
in 20 minutes and 47 seconds
......@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use crate::cli::{Cli, Subcommand, RunCmd};
use crate::cli::{Cli, RunCmd, Subcommand};
use futures::future::TryFutureExt;
use log::info;
use sc_cli::{Role, RuntimeVersion, SubstrateCli};
......@@ -211,10 +211,7 @@ fn ensure_dev(spec: &Box<dyn service::ChainSpec>) -> std::result::Result<(), Str
/// for integration tests as needed.
#[cfg(feature = "malus")]
pub fn run_node(run: RunCmd, overseer_gen: impl service::OverseerGen) -> Result<()> {
run_node_inner(Cli {
subcommand: None,
run,
}, overseer_gen)
run_node_inner(Cli { subcommand: None, run }, overseer_gen)
}
fn run_node_inner(cli: Cli, overseer_gen: impl service::OverseerGen) -> Result<()> {
......
......@@ -147,7 +147,9 @@ where
match self.inner.try_recv().await? {
None => return Ok(None),
Some(msg) =>
if let Some(msg) = self.message_filter.intercept_incoming(self.inner.sender(), msg) {
if let Some(msg) =
self.message_filter.intercept_incoming(self.inner.sender(), msg)
{
return Ok(Some(msg))
},
}
......
......@@ -20,8 +20,8 @@ use color_eyre::eyre;
use polkadot_cli::RunCmd;
use structopt::StructOpt;
pub(crate) mod shared;
pub(crate) mod interceptor;
pub(crate) mod shared;
mod variants;
......@@ -31,59 +31,60 @@ use variants::*;
#[derive(Debug, StructOpt, PartialEq, Eq)]
#[structopt(rename_all = "kebab-case")]
enum NemesisVariant {
BackGarbageCandidate,
SuggestGarabageCandidate,
DisputeAncestor,
BackGarbageCandidate,
SuggestGarabageCandidate,
DisputeAncestor,
}
#[derive(Debug, StructOpt)]
#[allow(missing_docs)]
struct MalusCli {
#[structopt(subcommand)]
pub variant: NemesisVariant,
#[structopt(subcommand)]
pub variant: NemesisVariant,
#[structopt(flatten)]
pub run: RunCmd,
}
impl MalusCli {
/// Launch a malus node.
fn launch(self) -> eyre::Result<()> {
let Self {
variant,
run,
} = self;
match variant {
NemesisVariant::BackGarbageCandidate => polkadot_cli::run_node(run, BackGarbageCandidate)?,
NemesisVariant::SuggestGarabageCandidate => polkadot_cli::run_node(run, SuggestGarbageCandidate)?,
NemesisVariant::DisputeAncestor => polkadot_cli::run_node(run, DisputeAncestor)?,
}
Ok(())
}
/// Launch a malus node.
fn launch(self) -> eyre::Result<()> {
let Self { variant, run } = self;
match variant {
NemesisVariant::BackGarbageCandidate =>
polkadot_cli::run_node(run, BackGarbageCandidate)?,
NemesisVariant::SuggestGarabageCandidate =>
polkadot_cli::run_node(run, SuggestGarbageCandidate)?,
NemesisVariant::DisputeAncestor => polkadot_cli::run_node(run, DisputeAncestor)?,
}
Ok(())
}
}
fn main() -> eyre::Result<()> {
color_eyre::install()?;
let cli = MalusCli::from_args();
cli.launch()?;
cli.launch()?;
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn subcommand_works() {
let cli = MalusCli::from_iter_safe(IntoIterator::into_iter(
["malus", "dispute-ancestor", "--alice"]
)).unwrap();
assert_matches::assert_matches!(cli, MalusCli {
variant,
..
} => {
assert_eq!(variant, NemesisVariant::DisputeAncestor);
});
}
use super::*;
#[test]
fn subcommand_works() {
let cli = MalusCli::from_iter_safe(IntoIterator::into_iter([
"malus",
"dispute-ancestor",
"--alice",
]))
.unwrap();
assert_matches::assert_matches!(cli, MalusCli {
variant,
..
} => {
assert_eq!(variant, NemesisVariant::DisputeAncestor);
});
}
}
......@@ -37,8 +37,7 @@ use polkadot_node_subsystem_util as util;
use util::metrics::Metrics as _;
// Filter wrapping related types.
use crate::interceptor::*;
use crate::shared::*;
use crate::{interceptor::*, shared::*};
use polkadot_node_primitives::{PoV, ValidationResult};
use polkadot_primitives::v1::{
......@@ -47,8 +46,10 @@ use polkadot_primitives::v1::{
};
use futures::channel::oneshot;
use std::sync::{Arc, Mutex};
use std::collections::HashMap;
use std::{
collections::HashMap,
sync::{Arc, Mutex},
};
#[derive(Clone, Debug)]
struct BribedPassageInner<Spawner> {
......
......@@ -30,8 +30,7 @@ use polkadot_cli::{
};
// Filter wrapping related types.
use crate::interceptor::*;
use crate::shared::*;
use crate::{interceptor::*, shared::*};
use polkadot_node_subsystem::overseer::SubsystemSender;
// Import extra types relevant to the particular
......@@ -43,9 +42,8 @@ use polkadot_primitives::v1::CandidateReceipt;
use sp_keystore::SyncCryptoStorePtr;
use util::{metered, metrics::Metrics as _};
use std::sync::Arc;
use std::time::Duration;
use futures_timer::Delay;
use std::{sync::Arc, time::Duration};
/// Become Loki and throw in a dispute once in a while, for an unfinalized block.
#[derive(Clone, Debug)]
......
......@@ -17,9 +17,10 @@
//! Collection of behavior variants.
mod back_garbage_candidate;
mod suggest_garbage_candidate;
mod dispute_ancestor;
mod suggest_garbage_candidate;
pub(crate) use self::back_garbage_candidate::BackGarbageCandidate;
pub(crate) use self::suggest_garbage_candidate::SuggestGarbageCandidate;
pub(crate) use self::dispute_ancestor::DisputeAncestor;
pub(crate) use self::{
back_garbage_candidate::BackGarbageCandidate, dispute_ancestor::DisputeAncestor,
suggest_garbage_candidate::SuggestGarbageCandidate,
};
......@@ -34,8 +34,10 @@ use polkadot_cli::{
// subsystem.
use polkadot_node_core_backing::{CandidateBackingSubsystem, Metrics};
use polkadot_node_primitives::Statement;
use polkadot_node_subsystem::messages::{CandidateBackingMessage, StatementDistributionMessage};
use polkadot_node_subsystem::overseer::{self, SubsystemSender};
use polkadot_node_subsystem::{
messages::{CandidateBackingMessage, StatementDistributionMessage},
overseer::{self, SubsystemSender},
};
use polkadot_node_subsystem_util as util;
// Filter wrapping related types.
use crate::interceptor::*;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment