Skip to content

Commit 2cb732c

Browse files
committed
use alpha emission for test
1 parent 045b317 commit 2cb732c

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

pallets/subtensor/src/tests/children.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3425,6 +3425,8 @@ fn test_parent_child_chain_emission() {
34253425
SubtensorModule::set_tao_weight(0);
34263426

34273427
let hardcoded_emission: I96F32 = I96F32::from_num(1_000_000); // 1 million (adjust as needed)
3428+
let emission_as_alpha =
3429+
I96F32::from_num(hardcoded_emission) / SubtensorModule::get_alpha_price(netuid);
34283430

34293431
// Set pending emission to 0
34303432
PendingEmission::<Test>::insert(netuid, 0);
@@ -3489,22 +3491,31 @@ fn test_parent_child_chain_emission() {
34893491
rel_stake_inc_c
34903492
);
34913493

3492-
let hotkeys = [hotkey_a, hotkey_b, hotkey_c];
3493-
let mut total_stake_now = 0;
3494-
for (hotkey, netuid,stake) in TotalHotkeyAlpha::<Test>::iter() {
3495-
if hotkeys.contains(&hotkey) {
3496-
total_stake_now += stake;
3497-
} else {
3498-
log::info!("hotkey: {:?}, netuid: {:?}, stake: {:?}", hotkey, netuid, stake);
3499-
}
3500-
}
3501-
log::info!("total_stake_now: {:?}, total_stake_new: {:?}", total_stake_now, total_stake_new);
3494+
let hotkeys = [hotkey_a, hotkey_b, hotkey_c];
3495+
let mut total_stake_now = 0;
3496+
for (hotkey, netuid, stake) in TotalHotkeyAlpha::<Test>::iter() {
3497+
if hotkeys.contains(&hotkey) {
3498+
total_stake_now += stake;
3499+
} else {
3500+
log::info!(
3501+
"hotkey: {:?}, netuid: {:?}, stake: {:?}",
3502+
hotkey,
3503+
netuid,
3504+
stake
3505+
);
3506+
}
3507+
}
3508+
log::info!(
3509+
"total_stake_now: {:?}, total_stake_new: {:?}",
3510+
total_stake_now,
3511+
total_stake_new
3512+
);
35023513

35033514
let eps: I96F32 = I96F32::from_num(10_000);
35043515
assert!(
3505-
(total_stake_new - (total_stake_old + hardcoded_emission)).abs() <= eps,
3516+
(total_stake_new - (total_stake_old + emission_as_alpha)).abs() <= eps,
35063517
"Total stake should have increased by the hardcoded emission amount {:?}",
3507-
total_stake_new - (total_stake_old + hardcoded_emission)
3518+
total_stake_new - (total_stake_old + emission_as_alpha)
35083519
);
35093520
});
35103521
}

0 commit comments

Comments
 (0)