Skip to content

Commit 0de5c96

Browse files
committed
make sure we check subsidize during those tests
1 parent 73dd0a2 commit 0de5c96

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

pallets/subtensor/src/tests/coinbase.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3022,11 +3022,13 @@ fn test_mining_emission_distribution_with_subsidy() {
30223022
U64F64::saturating_from_num(0.01),
30233023
);
30243024

3025+
// Make sure we ARE subsidizing, so we have root alpha divs.
3026+
let subsidy_mode = SubtensorModule::get_network_subsidy_mode(&[netuid]);
3027+
assert!(subsidy_mode, "Subsidy mode should be true");
3028+
30253029
// Run run_coinbase until emissions are drained
30263030
step_block(subnet_tempo);
30273031

3028-
log::info!("is_sub: Running epoch with subsidy");
3029-
30303032
let old_root_alpha_divs = PendingRootAlphaDivs::<Test>::get(netuid);
30313033
let per_block_emission = SubtensorModule::get_block_emission_for_issuance(
30323034
SubtensorModule::get_alpha_issuance(netuid).into(),
@@ -3118,7 +3120,6 @@ fn test_mining_emission_distribution_with_no_subsidy() {
31183120
let validator_miner_hotkey = U256::from(4);
31193121
let miner_coldkey = U256::from(5);
31203122
let miner_hotkey = U256::from(6);
3121-
let netuid = NetUid::from(1);
31223123
let subnet_tempo = 10;
31233124
let stake: u64 = 100_000_000_000;
31243125
let root_stake: u64 = 200_000_000_000; // 200 TAO
@@ -3129,8 +3130,11 @@ fn test_mining_emission_distribution_with_no_subsidy() {
31293130
NetworksAdded::<Test>::insert(NetUid::ROOT, true);
31303131

31313132
// Add network, register hotkeys, and setup network parameters
3132-
add_network(netuid, subnet_tempo, 0);
3133-
SubnetMechanism::<Test>::insert(netuid, 1); // Set mechanism to 1
3133+
let owner_hotkey = U256::from(10);
3134+
let owner_coldkey = U256::from(11);
3135+
let netuid = add_dynamic_network(&owner_hotkey, &owner_coldkey);
3136+
Tempo::<Test>::insert(netuid, 1);
3137+
FirstEmissionBlockNumber::<Test>::insert(netuid, 0);
31343138

31353139
// Setup large LPs to prevent slippage
31363140
SubnetTAO::<Test>::insert(netuid, TaoCurrency::from(1_000_000_000_000_000));
@@ -3201,19 +3205,22 @@ fn test_mining_emission_distribution_with_no_subsidy() {
32013205
SubtensorModule::set_tao_weight(u64::MAX / 10);
32023206

32033207
// Make subsidy not happen
3204-
// set price very high
3205-
// e.g. very little alpha in pool
3206-
//SubnetAlphaIn::<Test>::insert(netuid, AlphaCurrency::from(5));
3208+
// Set moving price > 1.0
3209+
// Set price > 1.0
32073210
pallet_subtensor_swap::AlphaSqrtPrice::<Test>::insert(
32083211
netuid,
32093212
U64F64::saturating_from_num(10.0),
32103213
);
32113214

3215+
SubnetMovingPrice::<Test>::insert(netuid, I96F32::from_num(2));
3216+
3217+
// Make sure we are not subsidizing, so we have root alpha divs.
3218+
let subsidy_mode = SubtensorModule::get_network_subsidy_mode(&[netuid]);
3219+
assert!(!subsidy_mode, "Subsidy mode should be false");
3220+
32123221
// Run run_coinbase until emissions are drained
32133222
step_block(subnet_tempo);
32143223

3215-
log::info!("is_sub: Running epoch with no subsidy");
3216-
32173224
let old_root_alpha_divs = PendingRootAlphaDivs::<Test>::get(netuid);
32183225
let miner_stake_before_epoch = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
32193226
&miner_hotkey,
@@ -3223,7 +3230,7 @@ fn test_mining_emission_distribution_with_no_subsidy() {
32233230

32243231
// step by one block
32253232
step_block(1);
3226-
// Verify that root alpha divs
3233+
// Verify root alpha divs
32273234
let new_root_alpha_divs = PendingRootAlphaDivs::<Test>::get(netuid);
32283235
// Check that we are NOT being subsidized, i.e. that root alpha divs are are changing
32293236
assert_ne!(

0 commit comments

Comments
 (0)