Skip to content

Commit 23f540c

Browse files
committed
add test for emission appends staking hotkeys map
1 parent eb4a57c commit 23f540c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

pallets/subtensor/tests/staking.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4719,3 +4719,35 @@ fn test_do_schedule_coldkey_swap_regular_user_passes_min_balance() {
47194719
);
47204720
});
47214721
}
4722+
4723+
// SKIP_WASM_BUILD=1 RUST_LOG=info cargo test --test staking -- test_emission_creates_staking_hotkeys_entry --exact --nocapture
4724+
#[test]
4725+
fn test_emission_creates_staking_hotkeys_entry() {
4726+
new_test_ext(1).execute_with(|| {
4727+
let hotkey0 = U256::from(1);
4728+
let hotkey1 = U256::from(2);
4729+
4730+
let coldkey = U256::from(3);
4731+
4732+
// Add to Owner map
4733+
Owner::<Test>::insert(hotkey0, coldkey);
4734+
Owner::<Test>::insert(hotkey1, coldkey);
4735+
OwnedHotkeys::<Test>::insert(coldkey, vec![hotkey0, hotkey1]);
4736+
4737+
// Emit through hotkey
4738+
SubtensorModule::emit_inflation_through_hotkey_account(&hotkey0, 0, 1_000);
4739+
4740+
// Verify StakingHotkeys has an entry
4741+
assert_eq!(StakingHotkeys::<Test>::get(coldkey).len(), 1);
4742+
assert!(StakingHotkeys::<Test>::get(coldkey).contains(&hotkey0));
4743+
4744+
// Try again with another emission on hotkey1
4745+
SubtensorModule::emit_inflation_through_hotkey_account(&hotkey1, 0, 2_000);
4746+
4747+
// Verify both hotkeys are now in the map
4748+
assert_eq!(StakingHotkeys::<Test>::get(coldkey).len(), 2);
4749+
let final_map = StakingHotkeys::<Test>::get(coldkey);
4750+
assert!(final_map.contains(&hotkey0));
4751+
assert!(final_map.contains(&hotkey1));
4752+
})
4753+
}

0 commit comments

Comments
 (0)