Skip to content

Commit

Permalink
chore: appease clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
camfairchild committed Sep 12, 2024
1 parent edc86b1 commit 87a5e3c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions pallets/subtensor/tests/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ fn test_migrate_fix_pending_emissions() {
let migration_name = "fix_pending_emission";

let null_account = U256::from(0); // The null account
let rand_coldkeys = vec![U256::from(1), U256::from(2), U256::from(3), U256::from(4)];
let rand_coldkeys = [U256::from(1), U256::from(2), U256::from(3), U256::from(4)];

let taostats_old_hotkey = "5Hddm3iBFD2GLT5ik7LZnT3XJUnRnN8PoeCFgGQgawUVKNm8";
let taostats_new_hotkey = "5GKH9FPPnWSUoeeTJp19wVtd84XqFW4pyK2ijV2GsFbhTrP1";
Expand All @@ -479,17 +479,17 @@ fn test_migrate_fix_pending_emissions() {
let datura_new_hk_account: AccountId = get_account_id_from_ss58(datura_new_hotkey);

// Setup the old Datura hotkey with a pending emission
PendingdHotkeyEmission::<Test>::insert(&datura_old_hk_account, 10_000);
PendingdHotkeyEmission::<Test>::insert(datura_old_hk_account, 10_000);
// Setup the NEW Datura hotkey with a pending emission
PendingdHotkeyEmission::<Test>::insert(&datura_new_hk_account, 123_456_789);
PendingdHotkeyEmission::<Test>::insert(datura_new_hk_account, 123_456_789);
let expected_datura_new_hk_pending_emission: u64 = 123_456_789 + 10_000;

// Setup the old TaoStats hotkey with a pending emission
PendingdHotkeyEmission::<Test>::insert(&taostats_old_hk_account, 987_654);
PendingdHotkeyEmission::<Test>::insert(taostats_old_hk_account, 987_654);
// Setup the new TaoStats hotkey with a pending emission
PendingdHotkeyEmission::<Test>::insert(&taostats_new_hk_account, 100_000);
PendingdHotkeyEmission::<Test>::insert(taostats_new_hk_account, 100_000);
// Setup the old TaoStats hotkey with a null-key stake entry
Stake::<Test>::insert(&taostats_old_hk_account, &null_account, 123_456_789);
Stake::<Test>::insert(taostats_old_hk_account, null_account, 123_456_789);
let expected_taostats_new_hk_pending_emission: u64 = 987_654 + 100_000 + 123_456_789;

// Run migration
Expand Down
8 changes: 4 additions & 4 deletions pallets/subtensor/tests/swap_coldkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1660,17 +1660,17 @@ fn test_coldkey_swap_last_add_stake_increase() {
100_000
));
// Check LastAddStakeIncrease
assert_eq!(LastAddStakeIncrease::<Test>::get(&hotkey, &old_coldkey), 10); // Just added stake
assert_eq!(LastAddStakeIncrease::<Test>::get(hotkey, old_coldkey), 10); // Just added stake

// Check the same for the new coldkey
assert_eq!(LastAddStakeIncrease::<Test>::get(&hotkey, &new_coldkey), 0); // No stake added ever
assert_eq!(LastAddStakeIncrease::<Test>::get(hotkey, new_coldkey), 0); // No stake added ever

// Perform the coldkey swap
assert_ok!(SubtensorModule::do_swap_coldkey(&old_coldkey, &new_coldkey));

// Check the LastAddStakeIncrease for the hotkey
assert_eq!(LastAddStakeIncrease::<Test>::get(&hotkey, &new_coldkey), 10); // Matches the old coldkey
assert_eq!(LastAddStakeIncrease::<Test>::get(&hotkey, &old_coldkey), 0);
assert_eq!(LastAddStakeIncrease::<Test>::get(hotkey, new_coldkey), 10); // Matches the old coldkey
assert_eq!(LastAddStakeIncrease::<Test>::get(hotkey, old_coldkey), 0);
// Should be reset to 0 (empty)
});
}
22 changes: 11 additions & 11 deletions pallets/subtensor/tests/swap_hotkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,24 +1132,24 @@ fn test_swap_hotkey_with_pending_emissions() {
add_network(netuid, 0, 1);

// Set up pending emissions
PendingdHotkeyEmission::<Test>::insert(&old_hotkey, pending_emission);
PendingdHotkeyEmission::<Test>::insert(old_hotkey, pending_emission);
// Verify the pending emissions are set
assert_eq!(
PendingdHotkeyEmission::<Test>::get(&old_hotkey),
PendingdHotkeyEmission::<Test>::get(old_hotkey),
pending_emission
);
// Verify the new hotkey does not have any pending emissions
assert!(!PendingdHotkeyEmission::<Test>::contains_key(&new_hotkey));
assert!(!PendingdHotkeyEmission::<Test>::contains_key(new_hotkey));

// Perform the swap
SubtensorModule::perform_hotkey_swap(&old_hotkey, &new_hotkey, &coldkey, &mut weight);

// Verify the pending emissions are transferred
assert_eq!(
PendingdHotkeyEmission::<Test>::get(&new_hotkey),
PendingdHotkeyEmission::<Test>::get(new_hotkey),
pending_emission
);
assert!(!PendingdHotkeyEmission::<Test>::contains_key(&old_hotkey));
assert!(!PendingdHotkeyEmission::<Test>::contains_key(old_hotkey));
});
}

Expand All @@ -1160,7 +1160,7 @@ fn test_swap_hotkeys_last_add_stake_increase() {
let old_hotkey = U256::from(1);
let new_hotkey = U256::from(2);
let coldkey = U256::from(3);
let new_coldkeys = vec![U256::from(4), U256::from(5)];
let new_coldkeys = [U256::from(4), U256::from(5)];
let netuid = 0u16;
let mut weight = Weight::zero();

Expand All @@ -1171,10 +1171,10 @@ fn test_swap_hotkeys_last_add_stake_increase() {

// Setup LastAddStakeIncrease map
for new_coldkey in new_coldkeys.iter() {
LastAddStakeIncrease::<Test>::insert(&old_hotkey, &new_coldkey, 100);
LastAddStakeIncrease::<Test>::insert(old_hotkey, new_coldkey, 100);
}
// Verify the LastAddStakeIncrease map is empty for the new hotkey
assert!(LastAddStakeIncrease::<Test>::iter_prefix(&new_hotkey)
assert!(LastAddStakeIncrease::<Test>::iter_prefix(new_hotkey)
.next()
.is_none());

Expand All @@ -1184,12 +1184,12 @@ fn test_swap_hotkeys_last_add_stake_increase() {
// Verify the LastAddStakeIncrease map is transferred
for new_coldkey in new_coldkeys.iter() {
assert_eq!(
LastAddStakeIncrease::<Test>::get(&new_hotkey, &new_coldkey),
LastAddStakeIncrease::<Test>::get(new_hotkey, new_coldkey),
100
);
assert!(!LastAddStakeIncrease::<Test>::contains_key(
&old_hotkey,
&new_coldkey
old_hotkey,
new_coldkey
));
}
});
Expand Down

0 comments on commit 87a5e3c

Please sign in to comment.