Run cargo fmt on the whole code base (#9394)

* Run cargo fmt on the whole code base

* Second run

* Add CI check

* Fix compilation

* More unnecessary braces

* Handle weights

* Use --all

* Use correct attributes...

* Fix UI tests

* AHHHHHHHHH

* 🤦

* Docs

* Fix compilation

* 🤷

* Please stop

* 🤦 x 2

* More

* make rustfmt.toml consistent with polkadot

Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Bastian Köcher
2021-07-21 16:32:32 +02:00
committed by GitHub
parent d451c38c1c
commit 7b56ab15b4
1010 changed files with 53339 additions and 51208 deletions
+25 -31
View File
@@ -17,11 +17,14 @@
//! Support code for the runtime. A set of test accounts.
use std::{collections::HashMap, ops::Deref};
use lazy_static::lazy_static;
use sp_core::{ed25519::{Pair, Public, Signature}, Pair as PairT, Public as PublicT, H256};
pub use sp_core::ed25519;
use sp_core::{
ed25519::{Pair, Public, Signature},
Pair as PairT, Public as PublicT, H256,
};
use sp_runtime::AccountId32;
use std::{collections::HashMap, ops::Deref};
/// Set of test accounts.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, strum::Display, strum::EnumIter)]
@@ -79,7 +82,7 @@ impl Keyring {
}
/// Returns an iterator over all test accounts.
pub fn iter() -> impl Iterator<Item=Keyring> {
pub fn iter() -> impl Iterator<Item = Keyring> {
<Self as strum::IntoEnumIterator>::iter()
}
@@ -114,13 +117,10 @@ impl From<Keyring> for sp_runtime::MultiSigner {
}
lazy_static! {
static ref PRIVATE_KEYS: HashMap<Keyring, Pair> = {
Keyring::iter().map(|i| (i, i.pair())).collect()
};
static ref PUBLIC_KEYS: HashMap<Keyring, Public> = {
PRIVATE_KEYS.iter().map(|(&name, pair)| (name, pair.public())).collect()
};
static ref PRIVATE_KEYS: HashMap<Keyring, Pair> =
Keyring::iter().map(|i| (i, i.pair())).collect();
static ref PUBLIC_KEYS: HashMap<Keyring, Public> =
PRIVATE_KEYS.iter().map(|(&name, pair)| (name, pair.public())).collect();
}
impl From<Keyring> for Public {
@@ -185,26 +185,20 @@ mod tests {
#[test]
fn should_work() {
assert!(
Pair::verify(
&Keyring::Alice.sign(b"I am Alice!"),
b"I am Alice!",
&Keyring::Alice.public(),
)
);
assert!(
!Pair::verify(
&Keyring::Alice.sign(b"I am Alice!"),
b"I am Bob!",
&Keyring::Alice.public(),
)
);
assert!(
!Pair::verify(
&Keyring::Alice.sign(b"I am Alice!"),
b"I am Alice!",
&Keyring::Bob.public(),
)
);
assert!(Pair::verify(
&Keyring::Alice.sign(b"I am Alice!"),
b"I am Alice!",
&Keyring::Alice.public(),
));
assert!(!Pair::verify(
&Keyring::Alice.sign(b"I am Alice!"),
b"I am Bob!",
&Keyring::Alice.public(),
));
assert!(!Pair::verify(
&Keyring::Alice.sign(b"I am Alice!"),
b"I am Alice!",
&Keyring::Bob.public(),
));
}
}
+26 -33
View File
@@ -17,12 +17,14 @@
//! Support code for the runtime. A set of test accounts.
use std::collections::HashMap;
use std::ops::Deref;
use lazy_static::lazy_static;
use sp_core::{sr25519::{Pair, Public, Signature}, Pair as PairT, Public as PublicT, H256};
pub use sp_core::sr25519;
use sp_core::{
sr25519::{Pair, Public, Signature},
Pair as PairT, Public as PublicT, H256,
};
use sp_runtime::AccountId32;
use std::{collections::HashMap, ops::Deref};
/// Set of test accounts.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, strum::Display, strum::EnumIter)]
@@ -80,7 +82,7 @@ impl Keyring {
}
/// Returns an iterator over all test accounts.
pub fn iter() -> impl Iterator<Item=Keyring> {
pub fn iter() -> impl Iterator<Item = Keyring> {
<Self as strum::IntoEnumIterator>::iter()
}
@@ -135,19 +137,16 @@ impl std::str::FromStr for Keyring {
"ferdie" => Ok(Keyring::Ferdie),
"one" => Ok(Keyring::One),
"two" => Ok(Keyring::Two),
_ => Err(ParseKeyringError)
_ => Err(ParseKeyringError),
}
}
}
lazy_static! {
static ref PRIVATE_KEYS: HashMap<Keyring, Pair> = {
Keyring::iter().map(|i| (i, i.pair())).collect()
};
static ref PUBLIC_KEYS: HashMap<Keyring, Public> = {
PRIVATE_KEYS.iter().map(|(&name, pair)| (name, pair.public())).collect()
};
static ref PRIVATE_KEYS: HashMap<Keyring, Pair> =
Keyring::iter().map(|i| (i, i.pair())).collect();
static ref PUBLIC_KEYS: HashMap<Keyring, Public> =
PRIVATE_KEYS.iter().map(|(&name, pair)| (name, pair.public())).collect();
}
impl From<Keyring> for AccountId32 {
@@ -212,26 +211,20 @@ mod tests {
#[test]
fn should_work() {
assert!(
Pair::verify(
&Keyring::Alice.sign(b"I am Alice!"),
b"I am Alice!",
&Keyring::Alice.public(),
)
);
assert!(
!Pair::verify(
&Keyring::Alice.sign(b"I am Alice!"),
b"I am Bob!",
&Keyring::Alice.public(),
)
);
assert!(
!Pair::verify(
&Keyring::Alice.sign(b"I am Alice!"),
b"I am Alice!",
&Keyring::Bob.public(),
)
);
assert!(Pair::verify(
&Keyring::Alice.sign(b"I am Alice!"),
b"I am Alice!",
&Keyring::Alice.public(),
));
assert!(!Pair::verify(
&Keyring::Alice.sign(b"I am Alice!"),
b"I am Bob!",
&Keyring::Alice.public(),
));
assert!(!Pair::verify(
&Keyring::Alice.sign(b"I am Alice!"),
b"I am Alice!",
&Keyring::Bob.public(),
));
}
}