Skip to content

Commit cefe888

Browse files
committed
add more logging and write to map
1 parent e2e5ccf commit cefe888

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

pallets/subtensor/src/tests/migration.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,9 @@ fn test_migrate_dissolve_sn73_pays_out_subnet_tao() {
609609
(staker_0_hk, staker_0_ck, 100_000_000_000),
610610
(staker_1_hk, staker_1_ck, 200_000_000_000),
611611
(staker_2_hk, staker_2_ck, 123_456_789_000),
612-
(staker_2_hk, delegate_0_ck, 100_000_000_000), // delegates to hk 2
613-
(staker_2_hk, delegate_1_ck, 200_000_000_000), // delegates to hk 2
612+
(staker_2_hk, delegate_0_ck, 400_000_000_000), // delegates to hk 2
613+
(staker_2_hk, delegate_1_ck, 500_000_000_000), // delegates to hk 2
614+
(staker_1_hk, delegate_0_ck, 456_789_000_000), // delegate 0 also stakes to hk 1
614615
];
615616
let total_alpha = stakes.iter().map(|(_, _, stake)| stake).sum::<u64>();
616617

@@ -640,17 +641,27 @@ fn test_migrate_dissolve_sn73_pays_out_subnet_tao() {
640641
// Calculate expected balances
641642
let denom = I96F32::from_num(total_alpha);
642643
let subnet_tao_float = I96F32::from_num(subnet_tao);
644+
645+
log::debug!("Subnet TAO: {}", subnet_tao);
646+
log::debug!("Denom: {}", denom);
643647
let mut expected_balances: BTreeMap<U256, u64> = BTreeMap::new();
644648
for (hk, ck, stake) in stakes.iter() {
645649
// Calculate share of the subnetTAO expected for the coldkey
646650
let hotkey_alpha = I96F32::from_num(*stake);
647651
let hotkey_share = hotkey_alpha.saturating_div(denom);
648652
let hotkey_tao = hotkey_share.saturating_mul(subnet_tao_float);
649653

654+
log::debug!(
655+
"Expected: hk {}, ck {}, stake {}, hotkey_tao {}",
656+
hk,
657+
ck,
658+
stake,
659+
hotkey_tao
660+
);
650661
expected_balances
651662
.entry(*ck)
652-
.or_insert(0)
653-
.saturating_add(hotkey_tao.saturating_to_num::<u64>());
663+
.and_modify(|e| *e = e.saturating_add(hotkey_tao.saturating_to_num::<u64>()))
664+
.or_insert(hotkey_tao.saturating_to_num::<u64>());
654665
}
655666

656667
// Verify that each staker has received their share of the subnetTAO

0 commit comments

Comments
 (0)