Skip to content

Commit 5540907

Browse files
committed
Reformat
1 parent acd6093 commit 5540907

23 files changed

+67
-19639
lines changed

pallets/subtensor/src/tests/children.rs-E

Lines changed: 0 additions & 3704 deletions
This file was deleted.

pallets/subtensor/src/tests/epoch.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,16 @@
55
)]
66

77
use super::mock::*;
8-
use frame_support::{assert_err, assert_ok};
9-
use frame_system::Config;
108
use crate::epoch::math::safe_exp;
119
use crate::*;
10+
use frame_support::{assert_err, assert_ok};
11+
use frame_system::Config;
1212
use rand::{distributions::Uniform, rngs::StdRng, seq::SliceRandom, thread_rng, Rng, SeedableRng};
1313
use sp_core::U256;
1414
use sp_runtime::DispatchError;
1515
use std::time::Instant;
1616
use substrate_fixed::types::I32F32;
1717

18-
19-
20-
pub fn fixed(val: f32) -> I32F32 {
21-
I32F32::from_num(val)
22-
}
23-
24-
pub fn fixed_to_u16(x: I32F32) -> u16 {
25-
x.to_num::<u16>()
26-
}
27-
28-
pub fn fixed_proportion_to_u16(x: I32F32) -> u16 {
29-
fixed_to_u16(x * I32F32::from_num(u16::MAX))
30-
}
31-
3218
// Normalizes (sum to 1 except 0) the input vector directly in-place.
3319
#[allow(dead_code)]
3420
pub fn inplace_normalize(x: &mut [I32F32]) {

pallets/subtensor/src/tests/migration.rs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![allow(unused, clippy::indexing_slicing, clippy::panic, clippy::unwrap_used)]
22

3+
use super::mock::*;
4+
use crate::*;
35
use codec::{Decode, Encode};
46
use frame_support::{
57
assert_ok,
@@ -9,8 +11,6 @@ use frame_support::{
911
StorageHasher, Twox64Concat,
1012
};
1113
use frame_system::Config;
12-
use super::mock::*;
13-
use crate::*;
1414
use sp_core::{crypto::Ss58Codec, H256, U256};
1515
use sp_io::hashing::twox_128;
1616
use sp_runtime::traits::Zero;
@@ -99,7 +99,8 @@ fn test_migration_fix_total_stake_maps() {
9999
assert_ne!(SubtensorModule::get_total_stake(), total_stake_amount);
100100

101101
// Run the migration to fix the total stake maps
102-
crate::migrations::migrate_to_v2_fixed_total_stake::migrate_to_v2_fixed_total_stake::<Test>();
102+
crate::migrations::migrate_to_v2_fixed_total_stake::migrate_to_v2_fixed_total_stake::<Test>(
103+
);
103104

104105
// Verify that the total stake is now correct
105106
assert_eq!(SubtensorModule::get_total_stake(), total_stake_amount);
@@ -126,14 +127,8 @@ fn test_migration_fix_total_stake_maps() {
126127

127128
// Verify that the Stake map has no extra entries
128129
assert_eq!(crate::Stake::<Test>::iter().count(), 4); // 4 entries total
129-
assert_eq!(
130-
crate::Stake::<Test>::iter_key_prefix(hk1).count(),
131-
2
132-
); // 2 stake entries for hk1
133-
assert_eq!(
134-
crate::Stake::<Test>::iter_key_prefix(hk2).count(),
135-
2
136-
); // 2 stake entries for hk2
130+
assert_eq!(crate::Stake::<Test>::iter_key_prefix(hk1).count(), 2); // 2 stake entries for hk1
131+
assert_eq!(crate::Stake::<Test>::iter_key_prefix(hk2).count(), 2); // 2 stake entries for hk2
137132
})
138133
}
139134

@@ -322,7 +317,9 @@ fn test_migrate_fix_total_coldkey_stake() {
322317
Stake::<Test>::insert(U256::from(1), U256::from(0), 10000);
323318
Stake::<Test>::insert(U256::from(2), U256::from(0), 10000);
324319
Stake::<Test>::insert(U256::from(3), U256::from(0), 10000);
325-
crate::migrations::migrate_fix_total_coldkey_stake::do_migrate_fix_total_coldkey_stake::<Test>();
320+
crate::migrations::migrate_fix_total_coldkey_stake::do_migrate_fix_total_coldkey_stake::<
321+
Test,
322+
>();
326323
assert_eq!(TotalColdkeyStake::<Test>::get(coldkey), 30000);
327324
})
328325
}
@@ -338,7 +335,9 @@ fn test_migrate_fix_total_coldkey_stake_value_already_in_total() {
338335
Stake::<Test>::insert(U256::from(1), U256::from(0), 10000);
339336
Stake::<Test>::insert(U256::from(2), U256::from(0), 10000);
340337
Stake::<Test>::insert(U256::from(3), U256::from(0), 10000);
341-
crate::migrations::migrate_fix_total_coldkey_stake::do_migrate_fix_total_coldkey_stake::<Test>();
338+
crate::migrations::migrate_fix_total_coldkey_stake::do_migrate_fix_total_coldkey_stake::<
339+
Test,
340+
>();
342341
assert_eq!(TotalColdkeyStake::<Test>::get(coldkey), 30000);
343342
})
344343
}
@@ -353,7 +352,9 @@ fn test_migrate_fix_total_coldkey_stake_no_entry() {
353352
Stake::<Test>::insert(U256::from(1), U256::from(0), 10000);
354353
Stake::<Test>::insert(U256::from(2), U256::from(0), 10000);
355354
Stake::<Test>::insert(U256::from(3), U256::from(0), 10000);
356-
crate::migrations::migrate_fix_total_coldkey_stake::do_migrate_fix_total_coldkey_stake::<Test>();
355+
crate::migrations::migrate_fix_total_coldkey_stake::do_migrate_fix_total_coldkey_stake::<
356+
Test,
357+
>();
357358
assert_eq!(TotalColdkeyStake::<Test>::get(coldkey), 30000);
358359
})
359360
}
@@ -366,7 +367,9 @@ fn test_migrate_fix_total_coldkey_stake_no_entry_in_hotkeys() {
366367
let coldkey = U256::from(0);
367368
TotalColdkeyStake::<Test>::insert(coldkey, 100000000);
368369
StakingHotkeys::<Test>::insert(coldkey, vec![U256::from(1), U256::from(2), U256::from(3)]);
369-
crate::migrations::migrate_fix_total_coldkey_stake::do_migrate_fix_total_coldkey_stake::<Test>();
370+
crate::migrations::migrate_fix_total_coldkey_stake::do_migrate_fix_total_coldkey_stake::<
371+
Test,
372+
>();
370373
assert_eq!(TotalColdkeyStake::<Test>::get(coldkey), 0);
371374
})
372375
}
@@ -381,7 +384,9 @@ fn test_migrate_fix_total_coldkey_stake_one_hotkey_stake_missing() {
381384
StakingHotkeys::<Test>::insert(coldkey, vec![U256::from(1), U256::from(2), U256::from(3)]);
382385
Stake::<Test>::insert(U256::from(1), U256::from(0), 10000);
383386
Stake::<Test>::insert(U256::from(2), U256::from(0), 10000);
384-
crate::migrations::migrate_fix_total_coldkey_stake::do_migrate_fix_total_coldkey_stake::<Test>();
387+
crate::migrations::migrate_fix_total_coldkey_stake::do_migrate_fix_total_coldkey_stake::<
388+
Test,
389+
>();
385390
assert_eq!(TotalColdkeyStake::<Test>::get(coldkey), 20000);
386391
})
387392
}
@@ -430,7 +435,9 @@ fn test_migrate_fix_total_coldkey_stake_starts_with_value_no_stake_map_entries()
430435

431436
fn run_migration_and_check(migration_name: &'static str) -> frame_support::weights::Weight {
432437
// Execute the migration and store its weight
433-
let weight: frame_support::weights::Weight = crate::migrations::migrate_fix_total_coldkey_stake::migrate_fix_total_coldkey_stake::<Test>();
438+
let weight: frame_support::weights::Weight =
439+
crate::migrations::migrate_fix_total_coldkey_stake::migrate_fix_total_coldkey_stake::<Test>(
440+
);
434441

435442
// Check if the migration has been marked as completed
436443
assert!(HasMigrationRun::<Test>::get(
@@ -502,9 +509,7 @@ fn test_migrate_commit_reveal_2() {
502509
// ------------------------------
503510
// Step 2: Run the Migration
504511
// ------------------------------
505-
let weight =
506-
crate::migrations::migrate_commit_reveal_v2::migrate_commit_reveal_2::<Test>(
507-
);
512+
let weight = crate::migrations::migrate_commit_reveal_v2::migrate_commit_reveal_2::<Test>();
508513

509514
assert!(
510515
HasMigrationRun::<Test>::get(MIGRATION_NAME.as_bytes().to_vec()),

0 commit comments

Comments
 (0)