Skip to content

Commit 73dd0a2

Browse files
committed
test pending em
1 parent 920103e commit 73dd0a2

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

pallets/subtensor/src/tests/coinbase.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,15 +661,27 @@ fn test_owner_cut_base() {
661661
#[test]
662662
fn test_pending_emission() {
663663
new_test_ext(1).execute_with(|| {
664-
let netuid = NetUid::from(1);
665664
let emission: u64 = 1_000_000;
666-
add_network(netuid, 1, 0);
665+
let hotkey = U256::from(1);
666+
let coldkey = U256::from(2);
667+
let netuid = add_dynamic_network(&hotkey, &coldkey);
668+
Tempo::<Test>::insert(netuid, 1);
669+
FirstEmissionBlockNumber::<Test>::insert(netuid, 0);
670+
667671
mock::setup_reserves(netuid, 1_000_000.into(), 1.into());
668672
SubtensorModule::run_coinbase(U96F32::from_num(0));
669673
SubnetTAO::<Test>::insert(NetUid::ROOT, TaoCurrency::from(1_000_000_000)); // Add root weight.
670674
SubtensorModule::run_coinbase(U96F32::from_num(0));
671675
SubtensorModule::set_tempo(netuid, 10000); // Large number (dont drain)
672676
SubtensorModule::set_tao_weight(u64::MAX); // Set TAO weight to 1.0
677+
678+
// Set moving price > 1.0
679+
SubnetMovingPrice::<Test>::insert(netuid, I96F32::from_num(2));
680+
681+
// Make sure we are not subsidizing, so we have root alpha divs.
682+
let subsidy_mode = SubtensorModule::get_network_subsidy_mode(&[netuid]);
683+
assert!(!subsidy_mode, "Subsidy mode should be false");
684+
673685
SubtensorModule::run_coinbase(U96F32::from_num(0));
674686
// 1 TAO / ( 1 + 3 ) = 0.25 * 1 / 2 = 125000000
675687

@@ -678,6 +690,12 @@ fn test_pending_emission() {
678690
1_000_000_000 - 125000000,
679691
epsilon = 1
680692
); // 1 - swapped.
693+
694+
assert_abs_diff_eq!(
695+
u64::from(PendingRootAlphaDivs::<Test>::get(netuid)),
696+
125000000,
697+
epsilon = 1
698+
); // 1 / 2 = 125000000
681699
});
682700
}
683701

0 commit comments

Comments
 (0)