Skip to content

Commit 917aa13

Browse files
committed
fix unit tests
1 parent a54ec37 commit 917aa13

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pallets/subtensor/src/staking/remove_stake.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,10 @@ impl<T: Config> Pallet<T> {
490490
.collect::<Vec<_>>();
491491

492492
for hot in hotkeys_in_subnet.iter() {
493-
for ((cold, _), share_u64f64) in Alpha::<T>::iter_prefix((hot,)) {
493+
for ((cold, this_netuid), share_u64f64) in Alpha::<T>::iter_prefix((hot,)) {
494+
if this_netuid != netuid {
495+
continue;
496+
}
494497
keys_to_remove.push((hot.clone(), cold.clone()));
495498
if !hotkeys_seen.contains(hot) {
496499
hotkeys_seen.push(hot.clone());

pallets/subtensor/src/tests/networks.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ fn dissolve_single_alpha_out_staker_gets_all_tao() {
106106
let pot: u64 = 99_999;
107107
SubnetTAO::<Test>::insert(net, TaoCurrency::from(pot));
108108
SubtensorModule::set_subnet_locked_balance(net, 0.into());
109+
TotalHotkeyAlpha::<Test>::insert(s_hot, net, AlphaCurrency::from(5_000u64));
109110

110111
// Cold-key balance before
111112
let before = SubtensorModule::get_coldkey_balance(&s_cold);
@@ -142,6 +143,9 @@ fn dissolve_two_stakers_pro_rata_distribution() {
142143
Alpha::<Test>::insert((s1_hot, s1_cold, net), U64F64::from_num(a1));
143144
Alpha::<Test>::insert((s2_hot, s2_cold, net), U64F64::from_num(a2));
144145

146+
TotalHotkeyAlpha::<Test>::insert(s1_hot, net, AlphaCurrency::from(a1 as u64));
147+
TotalHotkeyAlpha::<Test>::insert(s2_hot, net, AlphaCurrency::from(a2 as u64));
148+
145149
let pot: u64 = 10_000;
146150
SubnetTAO::<Test>::insert(net, TaoCurrency::from(pot));
147151
SubtensorModule::set_subnet_locked_balance(net, 5_000.into()); // owner refund path present; emission = 0
@@ -627,6 +631,7 @@ fn dissolve_alpha_out_but_zero_tao_no_rewards() {
627631
SubnetTAO::<Test>::insert(net, TaoCurrency::from(0)); // zero TAO
628632
SubtensorModule::set_subnet_locked_balance(net, TaoCurrency::from(0));
629633
Emission::<Test>::insert(net, Vec::<AlphaCurrency>::new());
634+
TotalHotkeyAlpha::<Test>::insert(sh, net, AlphaCurrency::from(1_000u64));
630635

631636
let before = SubtensorModule::get_coldkey_balance(&sc);
632637
assert_ok!(SubtensorModule::do_dissolve_network(net));
@@ -672,6 +677,9 @@ fn dissolve_rounding_remainder_distribution() {
672677
SubnetTAO::<Test>::insert(net, TaoCurrency::from(1)); // TAO pot = 1
673678
SubtensorModule::set_subnet_locked_balance(net, TaoCurrency::from(0));
674679

680+
TotalHotkeyAlpha::<Test>::insert(s1h, net, AlphaCurrency::from(3u64));
681+
TotalHotkeyAlpha::<Test>::insert(s2h, net, AlphaCurrency::from(2u64));
682+
675683
// Cold-key balances before
676684
let c1_before = SubtensorModule::get_coldkey_balance(&s1c);
677685
let c2_before = SubtensorModule::get_coldkey_balance(&s2c);
@@ -1874,6 +1882,7 @@ fn massive_dissolve_refund_and_reregistration_flow_is_lossless_and_cleans_state(
18741882
// Ordered α snapshot per net at **pair granularity** (pre‑LP):
18751883
let mut alpha_pairs_per_net: BTreeMap<NetUid, Vec<((U256, U256), u128)>> = BTreeMap::new();
18761884

1885+
18771886
// Register both hotkeys for each participating cold on each net and stake τ→α.
18781887
for (ni, &net) in nets.iter().enumerate() {
18791888
let participants = lp_sets_per_net[ni];

0 commit comments

Comments
 (0)