Skip to content

Commit

Permalink
Merge pull request #718 from opentensor/fix-collapsible-match-clippy
Browse files Browse the repository at this point in the history
fix clippy
  • Loading branch information
unconst authored Aug 7, 2024
2 parents 88f6b57 + 4734542 commit f603944
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 21 deletions.
17 changes: 8 additions & 9 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2403,18 +2403,17 @@ where
_len: usize,
) -> TransactionValidity {
// Check if the call is one of the balance transfer types we want to reject
if let Some(balances_call) = call.is_sub_type() {
match balances_call {
BalancesCall::transfer_allow_death { .. }
| BalancesCall::transfer_keep_alive { .. }
| BalancesCall::transfer_all { .. } => {
if Pallet::<T>::coldkey_in_arbitration(who) {
return Err(TransactionValidityError::Invalid(InvalidTransaction::Call));
}
match call.is_sub_type() {
Some(BalancesCall::transfer_allow_death { .. })
| Some(BalancesCall::transfer_keep_alive { .. })
| Some(BalancesCall::transfer_all { .. }) => {
if Pallet::<T>::coldkey_in_arbitration(who) {
return Err(TransactionValidityError::Invalid(InvalidTransaction::Call));
}
_ => {} // Other Balances calls are allowed
}
_ => {} // Other Balances calls are allowed
}

match call.is_sub_type() {
Some(Call::commit_weights { netuid, .. }) => {
if Self::check_weights_min_stake(who) {
Expand Down
1 change: 0 additions & 1 deletion pallets/subtensor/tests/difficulty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod mock;
use sp_core::U256;

#[test]
#[cfg(not(tarpaulin))]
fn test_registration_difficulty_adjustment() {
new_test_ext(1).execute_with(|| {
// Create Net 1
Expand Down
1 change: 0 additions & 1 deletion pallets/subtensor/tests/epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2107,7 +2107,6 @@ fn test_zero_weights() {

// Test that epoch assigns validator permits to highest stake uids, varies uid interleaving and stake values.
#[test]
#[cfg(not(tarpaulin))]
fn test_validator_permits() {
let netuid: u16 = 1;
let tempo: u16 = u16::MAX - 1; // high tempo to skip automatic epochs in on_initialize, use manual epochs instead
Expand Down
4 changes: 4 additions & 0 deletions pallets/subtensor/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ impl CollectiveInterface<AccountId, H256, u32> for TriumvirateVotes {
}

// We call pallet_collective TriumvirateCollective
#[allow(unused)]
type TriumvirateCollective = pallet_collective::Instance1;
impl pallet_collective::Config<TriumvirateCollective> for Test {
type RuntimeOrigin = RuntimeOrigin;
Expand All @@ -279,6 +280,7 @@ impl pallet_collective::Config<TriumvirateCollective> for Test {
}

// We call council members Triumvirate
#[allow(unused)]
type TriumvirateMembership = pallet_membership::Instance1;
impl pallet_membership::Config<TriumvirateMembership> for Test {
type RuntimeEvent = RuntimeEvent;
Expand All @@ -295,6 +297,7 @@ impl pallet_membership::Config<TriumvirateMembership> for Test {

// This is a dummy collective instance for managing senate members
// Probably not the best solution, but fastest implementation
#[allow(unused)]
type SenateCollective = pallet_collective::Instance2;
impl pallet_collective::Config<SenateCollective> for Test {
type RuntimeOrigin = RuntimeOrigin;
Expand All @@ -312,6 +315,7 @@ impl pallet_collective::Config<SenateCollective> for Test {
}

// We call our top K delegates membership Senate
#[allow(unused)]
type SenateMembership = pallet_membership::Instance2;
impl pallet_membership::Config<SenateMembership> for Test {
type RuntimeEvent = RuntimeEvent;
Expand Down
1 change: 0 additions & 1 deletion pallets/subtensor/tests/neuron_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ fn test_get_neuron_none() {
}

#[test]
#[cfg(not(tarpaulin))]
fn test_get_neuron_some() {
new_test_ext(1).execute_with(|| {
let netuid: u16 = 1;
Expand Down
1 change: 0 additions & 1 deletion pallets/subtensor/tests/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,6 @@ fn test_burn_adjustment() {
}

#[test]
#[cfg(not(tarpaulin))]
fn test_registration_too_many_registrations_per_block() {
new_test_ext(1).execute_with(|| {
let netuid: u16 = 1;
Expand Down
2 changes: 0 additions & 2 deletions pallets/subtensor/tests/serving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ fn test_serving_set_metadata_update() {
}

#[test]
#[cfg(not(tarpaulin))]
fn test_axon_serving_rate_limit_exceeded() {
new_test_ext(1).execute_with(|| {
let hotkey_account_id = U256::from(1);
Expand Down Expand Up @@ -379,7 +378,6 @@ fn test_prometheus_serving_set_metadata_update() {
}

#[test]
#[cfg(not(tarpaulin))]
fn test_prometheus_serving_rate_limit_exceeded() {
new_test_ext(1).execute_with(|| {
let hotkey_account_id = U256::from(1);
Expand Down
3 changes: 0 additions & 3 deletions pallets/subtensor/tests/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use sp_runtime::traits::SignedExtension;
************************************************************/

#[test]
#[cfg(not(tarpaulin))]
fn test_add_stake_dispatch_info_ok() {
new_test_ext(1).execute_with(|| {
let hotkey = U256::from(0);
Expand Down Expand Up @@ -528,7 +527,6 @@ fn test_remove_stake_rate_limit_exceeded() {
}

#[test]
#[cfg(not(tarpaulin))]
fn test_remove_stake_dispatch_info_ok() {
new_test_ext(1).execute_with(|| {
let hotkey = U256::from(0);
Expand Down Expand Up @@ -1201,7 +1199,6 @@ fn test_delegate_stake_division_by_zero_check() {
}

#[test]
#[cfg(not(tarpaulin))]
fn test_full_with_delegating() {
new_test_ext(1).execute_with(|| {
let netuid = 1;
Expand Down
3 changes: 0 additions & 3 deletions pallets/subtensor/tests/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use substrate_fixed::types::I32F32;

// Test the call passes through the subtensor module.
#[test]
#[cfg(not(tarpaulin))]
fn test_set_weights_dispatch_info_ok() {
new_test_ext(0).execute_with(|| {
let dests = vec![1, 1];
Expand All @@ -41,7 +40,6 @@ fn test_set_weights_dispatch_info_ok() {
});
}
#[test]
#[cfg(not(tarpaulin))]
fn test_set_rootweights_dispatch_info_ok() {
new_test_ext(0).execute_with(|| {
let dests = vec![1, 1];
Expand Down Expand Up @@ -404,7 +402,6 @@ fn test_weights_err_no_validator_permit() {

// To execute this test: cargo test --package pallet-subtensor --test weights test_set_weights_min_stake_failed -- --nocapture`
#[test]
#[cfg(not(tarpaulin))]
fn test_set_weights_min_stake_failed() {
new_test_ext(0).execute_with(|| {
let dests = vec![0];
Expand Down
2 changes: 2 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ impl pallet_collective::Config<TriumvirateCollective> for Runtime {
}

// We call council members Triumvirate
#[allow(unused)]
type TriumvirateMembership = pallet_membership::Instance1;
impl pallet_membership::Config<TriumvirateMembership> for Runtime {
type RuntimeEvent = RuntimeEvent;
Expand All @@ -531,6 +532,7 @@ impl pallet_membership::Config<TriumvirateMembership> for Runtime {
}

// We call our top K delegates membership Senate
#[allow(unused)]
type SenateMembership = pallet_membership::Instance2;
impl pallet_membership::Config<SenateMembership> for Runtime {
type RuntimeEvent = RuntimeEvent;
Expand Down

0 comments on commit f603944

Please sign in to comment.