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
@@ -15,26 +15,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::sync::Arc;
use node_runtime::{
Executive, Indices, Runtime, UncheckedExtrinsic,
};
use sp_application_crypto::AppKey;
use sp_core::{
offchain::{
TransactionPoolExt,
testing::TestTransactionPoolExt,
},
};
use sp_keystore::{KeystoreExt, SyncCryptoStore, testing::KeyStore};
use frame_system::{
offchain::{
Signer,
SubmitTransaction,
SendSignedTransaction,
}
};
use codec::Decode;
use frame_system::offchain::{SendSignedTransaction, Signer, SubmitTransaction};
use node_runtime::{Executive, Indices, Runtime, UncheckedExtrinsic};
use sp_application_crypto::AppKey;
use sp_core::offchain::{testing::TestTransactionPoolExt, TransactionPoolExt};
use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStore};
use std::sync::Arc;
pub mod common;
use self::common::*;
@@ -56,8 +43,10 @@ fn should_submit_unsigned_transaction() {
};
let call = pallet_im_online::Call::heartbeat(heartbeat_data, signature);
SubmitTransaction::<Runtime, pallet_im_online::Call<Runtime>>::submit_unsigned_transaction(call.into())
.unwrap();
SubmitTransaction::<Runtime, pallet_im_online::Call<Runtime>>::submit_unsigned_transaction(
call.into(),
)
.unwrap();
assert_eq!(state.read().transactions.len(), 1)
});
@@ -75,23 +64,26 @@ fn should_submit_signed_transaction() {
SyncCryptoStore::sr25519_generate_new(
&keystore,
sr25519::AuthorityId::ID,
Some(&format!("{}/hunter1", PHRASE))
).unwrap();
Some(&format!("{}/hunter1", PHRASE)),
)
.unwrap();
SyncCryptoStore::sr25519_generate_new(
&keystore,
sr25519::AuthorityId::ID,
Some(&format!("{}/hunter2", PHRASE))
).unwrap();
Some(&format!("{}/hunter2", PHRASE)),
)
.unwrap();
SyncCryptoStore::sr25519_generate_new(
&keystore,
sr25519::AuthorityId::ID,
Some(&format!("{}/hunter3", PHRASE))
).unwrap();
Some(&format!("{}/hunter3", PHRASE)),
)
.unwrap();
t.register_extension(KeystoreExt(Arc::new(keystore)));
t.execute_with(|| {
let results = Signer::<Runtime, TestAuthorityId>::all_accounts()
.send_signed_transaction(|_| {
let results =
Signer::<Runtime, TestAuthorityId>::all_accounts().send_signed_transaction(|_| {
pallet_balances::Call::transfer(Default::default(), Default::default())
});
@@ -112,18 +104,20 @@ fn should_submit_signed_twice_from_the_same_account() {
SyncCryptoStore::sr25519_generate_new(
&keystore,
sr25519::AuthorityId::ID,
Some(&format!("{}/hunter1", PHRASE))
).unwrap();
Some(&format!("{}/hunter1", PHRASE)),
)
.unwrap();
SyncCryptoStore::sr25519_generate_new(
&keystore,
sr25519::AuthorityId::ID,
Some(&format!("{}/hunter2", PHRASE))
).unwrap();
Some(&format!("{}/hunter2", PHRASE)),
)
.unwrap();
t.register_extension(KeystoreExt(Arc::new(keystore)));
t.execute_with(|| {
let result = Signer::<Runtime, TestAuthorityId>::any_account()
.send_signed_transaction(|_| {
let result =
Signer::<Runtime, TestAuthorityId>::any_account().send_signed_transaction(|_| {
pallet_balances::Call::transfer(Default::default(), Default::default())
});
@@ -131,8 +125,8 @@ fn should_submit_signed_twice_from_the_same_account() {
assert_eq!(state.read().transactions.len(), 1);
// submit another one from the same account. The nonce should be incremented.
let result = Signer::<Runtime, TestAuthorityId>::any_account()
.send_signed_transaction(|_| {
let result =
Signer::<Runtime, TestAuthorityId>::any_account().send_signed_transaction(|_| {
pallet_balances::Call::transfer(Default::default(), Default::default())
});
@@ -147,10 +141,7 @@ fn should_submit_signed_twice_from_the_same_account() {
}
let nonce1 = nonce(UncheckedExtrinsic::decode(&mut &*s.transactions[0]).unwrap());
let nonce2 = nonce(UncheckedExtrinsic::decode(&mut &*s.transactions[1]).unwrap());
assert!(
nonce1 != nonce2,
"Transactions should have different nonces. Got: {:?}", nonce1
);
assert!(nonce1 != nonce2, "Transactions should have different nonces. Got: {:?}", nonce1);
});
}
@@ -161,14 +152,12 @@ fn should_submit_signed_twice_from_all_accounts() {
t.register_extension(TransactionPoolExt::new(pool));
let keystore = KeyStore::new();
keystore.sr25519_generate_new(
sr25519::AuthorityId::ID,
Some(&format!("{}/hunter1", PHRASE))
).unwrap();
keystore.sr25519_generate_new(
sr25519::AuthorityId::ID,
Some(&format!("{}/hunter2", PHRASE))
).unwrap();
keystore
.sr25519_generate_new(sr25519::AuthorityId::ID, Some(&format!("{}/hunter1", PHRASE)))
.unwrap();
keystore
.sr25519_generate_new(sr25519::AuthorityId::ID, Some(&format!("{}/hunter2", PHRASE)))
.unwrap();
t.register_extension(KeystoreExt(Arc::new(keystore)));
t.execute_with(|| {
@@ -217,8 +206,10 @@ fn should_submit_signed_twice_from_all_accounts() {
#[test]
fn submitted_transaction_should_be_valid() {
use codec::Encode;
use sp_runtime::transaction_validity::{TransactionSource, TransactionTag};
use sp_runtime::traits::StaticLookup;
use sp_runtime::{
traits::StaticLookup,
transaction_validity::{TransactionSource, TransactionTag},
};
let mut t = new_test_ext(compact_code_unwrap(), false);
let (pool, state) = TestTransactionPoolExt::new();
@@ -227,13 +218,15 @@ fn submitted_transaction_should_be_valid() {
let keystore = KeyStore::new();
SyncCryptoStore::sr25519_generate_new(
&keystore,
sr25519::AuthorityId::ID, Some(&format!("{}/hunter1", PHRASE))
).unwrap();
sr25519::AuthorityId::ID,
Some(&format!("{}/hunter1", PHRASE)),
)
.unwrap();
t.register_extension(KeystoreExt(Arc::new(keystore)));
t.execute_with(|| {
let results = Signer::<Runtime, TestAuthorityId>::all_accounts()
.send_signed_transaction(|_| {
let results =
Signer::<Runtime, TestAuthorityId>::all_accounts().send_signed_transaction(|_| {
pallet_balances::Call::transfer(Default::default(), Default::default())
});
let len = results.len();
@@ -252,7 +245,7 @@ fn submitted_transaction_should_be_valid() {
let author = extrinsic.signature.clone().unwrap().0;
let address = Indices::lookup(author).unwrap();
let data = pallet_balances::AccountData { free: 5_000_000_000_000, ..Default::default() };
let account = frame_system::AccountInfo { data, .. Default::default() };
let account = frame_system::AccountInfo { data, ..Default::default() };
<frame_system::Account<Runtime>>::insert(&address, account);
// check validity
@@ -260,7 +253,8 @@ fn submitted_transaction_should_be_valid() {
source,
extrinsic,
frame_system::BlockHash::<Runtime>::get(0),
).unwrap();
)
.unwrap();
// We ignore res.priority since this number can change based on updates to weights and such.
assert_eq!(res.requires, Vec::<TransactionTag>::new());