Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
unconst authored and unconst committed Jul 23, 2024
1 parent bc19f08 commit 28ba654
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pallets/subtensor/src/coinbase/run_coinbase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,4 @@ impl<T: Config> Pallet<T> {
let remainder = block_plus_netuid.rem_euclid(tempo_plus_one);
(tempo as u64).saturating_sub(remainder)
}
}
}
2 changes: 1 addition & 1 deletion pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ pub mod pallet {
(H256, u64),
OptionQuery,
>;

/// ==================
/// ==== Genesis =====
/// ==================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use super::*;
use alloc::string::String;
use frame_support::{
pallet_prelude::{Identity, OptionQuery},
storage_alias,
traits::{Get, StorageVersion},
weights::Weight,
};
use alloc::string::String;
use sp_std::vec::Vec;

// TODO (camfairchild): TEST MIGRATION
Expand Down
6 changes: 5 additions & 1 deletion pallets/subtensor/src/subnets/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,11 @@ impl<T: Config> Pallet<T> {
// Copy the hotkey_bytes into the first half of full_bytes
full_bytes[..32].copy_from_slice(hotkey_bytes);
let keccak_256_seal_hash_vec: [u8; 32] = keccak_256(&full_bytes[..]);
let hash_u64: u64 = u64::from_le_bytes(keccak_256_seal_hash_vec[0..8].try_into().unwrap_or_default());
let hash_u64: u64 = u64::from_le_bytes(
keccak_256_seal_hash_vec[0..8]
.try_into()
.unwrap_or_default(),
);
hash_u64
}

Expand Down
4 changes: 2 additions & 2 deletions pallets/subtensor/src/swap/swap_coldkey.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
use frame_support::weights::Weight;
use sp_core::{Get};
use sp_core::Get;

impl<T: Config> Pallet<T> {
/// Swaps the coldkey associated with a set of hotkeys from an old coldkey to a new coldkey.
Expand Down Expand Up @@ -225,4 +225,4 @@ impl<T: Config> Pallet<T> {
// Return ok.
Ok(())
}
}
}
1 change: 1 addition & 0 deletions pallets/subtensor/tests/coinbase.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(unused, clippy::indexing_slicing, clippy::panic, clippy::unwrap_used)]
use crate::mock::*;
mod mock;
// use frame_support::{assert_err, assert_ok};
Expand Down
13 changes: 6 additions & 7 deletions pallets/subtensor/tests/migration.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![allow(clippy::unwrap_used)]

#![allow(unused, clippy::indexing_slicing, clippy::panic, clippy::unwrap_used)]
mod mock;
use frame_support::{assert_ok, weights::Weight};
use frame_system::Config;
Expand Down Expand Up @@ -283,7 +282,7 @@ fn test_migration_delete_subnet_21() {
#[test]
fn test_migrate_fix_total_coldkey_stake() {
new_test_ext(1).execute_with(|| {
let migration_name = "fix_total_coldkey_stake_v7";
let _migration_name = "fix_total_coldkey_stake_v7";
let coldkey = U256::from(0);
TotalColdkeyStake::<Test>::insert(coldkey, 0);
StakingHotkeys::<Test>::insert(coldkey, vec![U256::from(1), U256::from(2), U256::from(3)]);
Expand All @@ -299,7 +298,7 @@ fn test_migrate_fix_total_coldkey_stake() {
#[test]
fn test_migrate_fix_total_coldkey_stake_value_already_in_total() {
new_test_ext(1).execute_with(|| {
let migration_name = "fix_total_coldkey_stake_v7";
let _migration_name = "fix_total_coldkey_stake_v7";
let coldkey = U256::from(0);
TotalColdkeyStake::<Test>::insert(coldkey, 100000000);
StakingHotkeys::<Test>::insert(coldkey, vec![U256::from(1), U256::from(2), U256::from(3)]);
Expand All @@ -315,7 +314,7 @@ fn test_migrate_fix_total_coldkey_stake_value_already_in_total() {
#[test]
fn test_migrate_fix_total_coldkey_stake_no_entry() {
new_test_ext(1).execute_with(|| {
let migration_name = "fix_total_coldkey_stake_v7";
let _migration_name = "fix_total_coldkey_stake_v7";
let coldkey = U256::from(0);
StakingHotkeys::<Test>::insert(coldkey, vec![U256::from(1), U256::from(2), U256::from(3)]);
Stake::<Test>::insert(U256::from(1), U256::from(0), 10000);
Expand All @@ -330,7 +329,7 @@ fn test_migrate_fix_total_coldkey_stake_no_entry() {
#[test]
fn test_migrate_fix_total_coldkey_stake_no_entry_in_hotkeys() {
new_test_ext(1).execute_with(|| {
let migration_name = "fix_total_coldkey_stake_v7";
let _migration_name = "fix_total_coldkey_stake_v7";
let coldkey = U256::from(0);
TotalColdkeyStake::<Test>::insert(coldkey, 100000000);
StakingHotkeys::<Test>::insert(coldkey, vec![U256::from(1), U256::from(2), U256::from(3)]);
Expand All @@ -343,7 +342,7 @@ fn test_migrate_fix_total_coldkey_stake_no_entry_in_hotkeys() {
#[test]
fn test_migrate_fix_total_coldkey_stake_one_hotkey_stake_missing() {
new_test_ext(1).execute_with(|| {
let migration_name = "fix_total_coldkey_stake_v7";
let _migration_name = "fix_total_coldkey_stake_v7";
let coldkey = U256::from(0);
TotalColdkeyStake::<Test>::insert(coldkey, 100000000);
StakingHotkeys::<Test>::insert(coldkey, vec![U256::from(1), U256::from(2), U256::from(3)]);
Expand Down
2 changes: 1 addition & 1 deletion pallets/subtensor/tests/swap_coldkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1285,4 +1285,4 @@ fn test_coldkey_delegations() {
assert_eq!(Stake::<Test>::get(delegate, new_coldkey), 100);
assert_eq!(Stake::<Test>::get(delegate, coldkey), 0);
});
}
}

0 comments on commit 28ba654

Please sign in to comment.