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
+75 -47
View File
@@ -20,13 +20,13 @@
use super::*;
use crate as pallet_identity;
use codec::{Encode, Decode};
use sp_runtime::traits::BadOrigin;
use frame_support::{assert_ok, assert_noop, parameter_types, ord_parameter_types, BoundedVec};
use codec::{Decode, Encode};
use frame_support::{assert_noop, assert_ok, ord_parameter_types, parameter_types, BoundedVec};
use frame_system::{EnsureOneOf, EnsureRoot, EnsureSignedBy};
use sp_core::H256;
use frame_system::{EnsureSignedBy, EnsureOneOf, EnsureRoot};
use sp_runtime::{
testing::Header, traits::{BlakeTwo256, IdentityLookup},
testing::Header,
traits::{BadOrigin, BlakeTwo256, IdentityLookup},
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
@@ -100,16 +100,8 @@ ord_parameter_types! {
pub const One: u64 = 1;
pub const Two: u64 = 2;
}
type EnsureOneOrRoot = EnsureOneOf<
u64,
EnsureRoot<u64>,
EnsureSignedBy<One, u64>
>;
type EnsureTwoOrRoot = EnsureOneOf<
u64,
EnsureRoot<u64>,
EnsureSignedBy<Two, u64>
>;
type EnsureOneOrRoot = EnsureOneOf<u64, EnsureRoot<u64>, EnsureSignedBy<One, u64>>;
type EnsureTwoOrRoot = EnsureOneOf<u64, EnsureRoot<u64>, EnsureSignedBy<Two, u64>>;
impl pallet_identity::Config for Test {
type Event = Event;
type Currency = Balances;
@@ -128,15 +120,10 @@ impl pallet_identity::Config for Test {
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
pallet_balances::GenesisConfig::<Test> {
balances: vec![
(1, 10),
(2, 10),
(3, 10),
(10, 100),
(20, 100),
(30, 100),
],
}.assimilate_storage(&mut t).unwrap();
balances: vec![(1, 10), (2, 10), (3, 10), (10, 100), (20, 100), (30, 100)],
}
.assimilate_storage(&mut t)
.unwrap();
t.into()
}
@@ -144,7 +131,7 @@ fn ten() -> IdentityInfo<MaxAdditionalFields> {
IdentityInfo {
display: Data::Raw(b"ten".to_vec().try_into().unwrap()),
legal: Data::Raw(b"The Right Ordinal Ten, Esq.".to_vec().try_into().unwrap()),
.. Default::default()
..Default::default()
}
}
@@ -152,7 +139,7 @@ fn twenty() -> IdentityInfo<MaxAdditionalFields> {
IdentityInfo {
display: Data::Raw(b"twenty".to_vec().try_into().unwrap()),
legal: Data::Raw(b"The Right Ordinal Twenty, Esq.".to_vec().try_into().unwrap()),
.. Default::default()
..Default::default()
}
}
@@ -177,7 +164,10 @@ fn editing_subaccounts_should_work() {
assert_eq!(Balances::free_balance(10), 70);
// third sub account is too many
assert_noop!(Identity::add_sub(Origin::signed(10), 3, data(3)), Error::<Test>::TooManySubAccounts);
assert_noop!(
Identity::add_sub(Origin::signed(10), 3, data(3)),
Error::<Test>::TooManySubAccounts
);
// rename first sub account
assert_ok!(Identity::rename_sub(Origin::signed(10), 1, data(11)));
@@ -214,7 +204,10 @@ fn resolving_subaccount_ownership_works() {
assert_eq!(Balances::free_balance(10), 80);
assert_eq!(Balances::reserved_balance(10), 20);
// 20 cannot claim 1 now
assert_noop!(Identity::add_sub(Origin::signed(20), 1, data(1)), Error::<Test>::AlreadyClaimed);
assert_noop!(
Identity::add_sub(Origin::signed(20), 1, data(1)),
Error::<Test>::AlreadyClaimed
);
// 1 wants to be with 20 so it quits from 10
assert_ok!(Identity::quit_sub(Origin::signed(1)));
// 1 gets the 10 that 10 paid.
@@ -243,9 +236,10 @@ fn adding_registrar_should_work() {
assert_ok!(Identity::set_fee(Origin::signed(3), 0, 10));
let fields = IdentityFields(IdentityField::Display | IdentityField::Legal);
assert_ok!(Identity::set_fields(Origin::signed(3), 0, fields));
assert_eq!(Identity::registrars(), vec![
Some(RegistrarInfo { account: 3, fee: 10, fields })
]);
assert_eq!(
Identity::registrars(),
vec![Some(RegistrarInfo { account: 3, fee: 10, fields })]
);
});
}
@@ -370,7 +364,10 @@ fn setting_subaccounts_should_work() {
assert_eq!(Identity::super_of(40), None);
subs.push((20, Data::Raw(vec![40; 1].try_into().unwrap())));
assert_noop!(Identity::set_subs(Origin::signed(10), subs.clone()), Error::<Test>::TooManySubAccounts);
assert_noop!(
Identity::set_subs(Origin::signed(10), subs.clone()),
Error::<Test>::TooManySubAccounts
);
});
}
@@ -378,7 +375,10 @@ fn setting_subaccounts_should_work() {
fn clearing_account_should_remove_subaccounts_and_refund() {
new_test_ext().execute_with(|| {
assert_ok!(Identity::set_identity(Origin::signed(10), ten()));
assert_ok!(Identity::set_subs(Origin::signed(10), vec![(20, Data::Raw(vec![40; 1].try_into().unwrap()))]));
assert_ok!(Identity::set_subs(
Origin::signed(10),
vec![(20, Data::Raw(vec![40; 1].try_into().unwrap()))]
));
assert_ok!(Identity::clear_identity(Origin::signed(10)));
assert_eq!(Balances::free_balance(10), 100);
assert!(Identity::super_of(20).is_none());
@@ -389,7 +389,10 @@ fn clearing_account_should_remove_subaccounts_and_refund() {
fn killing_account_should_remove_subaccounts_and_not_refund() {
new_test_ext().execute_with(|| {
assert_ok!(Identity::set_identity(Origin::signed(10), ten()));
assert_ok!(Identity::set_subs(Origin::signed(10), vec![(20, Data::Raw(vec![40; 1].try_into().unwrap()))]));
assert_ok!(Identity::set_subs(
Origin::signed(10),
vec![(20, Data::Raw(vec![40; 1].try_into().unwrap()))]
));
assert_ok!(Identity::kill_identity(Origin::signed(2), 10));
assert_eq!(Balances::free_balance(10), 80);
assert!(Identity::super_of(20).is_none());
@@ -409,7 +412,10 @@ fn cancelling_requested_judgement_should_work() {
assert_noop!(Identity::cancel_request(Origin::signed(10), 0), Error::<Test>::NotFound);
assert_ok!(Identity::provide_judgement(Origin::signed(3), 0, 10, Judgement::Reasonable));
assert_noop!(Identity::cancel_request(Origin::signed(10), 0), Error::<Test>::JudgementGiven);
assert_noop!(
Identity::cancel_request(Origin::signed(10), 0),
Error::<Test>::JudgementGiven
);
});
}
@@ -419,19 +425,28 @@ fn requesting_judgement_should_work() {
assert_ok!(Identity::add_registrar(Origin::signed(1), 3));
assert_ok!(Identity::set_fee(Origin::signed(3), 0, 10));
assert_ok!(Identity::set_identity(Origin::signed(10), ten()));
assert_noop!(Identity::request_judgement(Origin::signed(10), 0, 9), Error::<Test>::FeeChanged);
assert_noop!(
Identity::request_judgement(Origin::signed(10), 0, 9),
Error::<Test>::FeeChanged
);
assert_ok!(Identity::request_judgement(Origin::signed(10), 0, 10));
// 10 for the judgement request, 10 for the identity.
assert_eq!(Balances::free_balance(10), 80);
// Re-requesting won't work as we already paid.
assert_noop!(Identity::request_judgement(Origin::signed(10), 0, 10), Error::<Test>::StickyJudgement);
assert_noop!(
Identity::request_judgement(Origin::signed(10), 0, 10),
Error::<Test>::StickyJudgement
);
assert_ok!(Identity::provide_judgement(Origin::signed(3), 0, 10, Judgement::Erroneous));
// Registrar got their payment now.
assert_eq!(Balances::free_balance(3), 20);
// Re-requesting still won't work as it's erroneous.
assert_noop!(Identity::request_judgement(Origin::signed(10), 0, 10), Error::<Test>::StickyJudgement);
assert_noop!(
Identity::request_judgement(Origin::signed(10), 0, 10),
Error::<Test>::StickyJudgement
);
// Requesting from a second registrar still works.
assert_ok!(Identity::add_registrar(Origin::signed(1), 4));
@@ -448,14 +463,24 @@ fn field_deposit_should_work() {
new_test_ext().execute_with(|| {
assert_ok!(Identity::add_registrar(Origin::signed(1), 3));
assert_ok!(Identity::set_fee(Origin::signed(3), 0, 10));
assert_ok!(Identity::set_identity(Origin::signed(10), IdentityInfo {
additional: vec![
(Data::Raw(b"number".to_vec().try_into().unwrap()), Data::Raw(10u32.encode().try_into().unwrap())),
(Data::Raw(b"text".to_vec().try_into().unwrap()), Data::Raw(b"10".to_vec().try_into().unwrap())),
]
.try_into()
.unwrap(), .. Default::default()
}));
assert_ok!(Identity::set_identity(
Origin::signed(10),
IdentityInfo {
additional: vec![
(
Data::Raw(b"number".to_vec().try_into().unwrap()),
Data::Raw(10u32.encode().try_into().unwrap())
),
(
Data::Raw(b"text".to_vec().try_into().unwrap()),
Data::Raw(b"10".to_vec().try_into().unwrap())
),
]
.try_into()
.unwrap(),
..Default::default()
}
));
assert_eq!(Balances::free_balance(10), 70);
});
}
@@ -465,7 +490,10 @@ fn setting_account_id_should_work() {
new_test_ext().execute_with(|| {
assert_ok!(Identity::add_registrar(Origin::signed(1), 3));
// account 4 cannot change the first registrar's identity since it's owned by 3.
assert_noop!(Identity::set_account_id(Origin::signed(4), 0, 3), Error::<Test>::InvalidIndex);
assert_noop!(
Identity::set_account_id(Origin::signed(4), 0, 3),
Error::<Test>::InvalidIndex
);
// account 3 can, because that's the registrar's current account.
assert_ok!(Identity::set_account_id(Origin::signed(3), 0, 4));
// account 4 can now, because that's their new ID.