Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix set alpha disabled test #1140

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 29 additions & 31 deletions pallets/subtensor/src/tests/epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use super::mock::*;
use crate::epoch::math::safe_exp;
use crate::*;
use frame_support::assert_ok;
use frame_support::{assert_ok, assert_err};
// use frame_system::Config;
use rand::{distributions::Uniform, rngs::StdRng, seq::SliceRandom, thread_rng, Rng, SeedableRng};
use sp_core::U256;
Expand Down Expand Up @@ -1486,40 +1486,38 @@ fn test_bonds_with_liquid_alpha() {
});
}

//
//
#[test]
fn test_set_alpha_disabled() {
new_test_ext(1).execute_with(|| {
assert!(false);

// let netuid: u16 = 1;
// let hotkey: U256 = U256::from(1);
// let coldkey: U256 = U256::from(1 + 456);
// let signer = <<Test as Config>::RuntimeOrigin>::signed(coldkey);

// // Enable Liquid Alpha and setup
// SubtensorModule::set_liquid_alpha_enabled(netuid, true);
// migrations::migrate_create_root_network::migrate_create_root_network::<Test>();
// SubtensorModule::add_balance_to_coldkey_account(&coldkey, 1_000_000_000_000_000);
// assert_ok!(SubtensorModule::root_register(signer.clone(), hotkey,));
// assert_ok!(SubtensorModule::add_stake(signer.clone(), hotkey, 1000));
// // Only owner can set alpha values
// assert_ok!(SubtensorModule::register_network(signer.clone()));

// // Explicitly set to false
// SubtensorModule::set_liquid_alpha_enabled(netuid, false);
// assert_err!(
// SubtensorModule::do_set_alpha_values(signer.clone(), netuid, 12_u16, u16::MAX),
// Error::<Test>::LiquidAlphaDisabled
// );
let hotkey = U256::from(1);
let coldkey = U256::from(1 + 456);
let netuid = add_dynamic_network(&hotkey, &coldkey);
let signer = RuntimeOrigin::signed(coldkey);

// Enable Liquid Alpha and setup
SubtensorModule::set_liquid_alpha_enabled(netuid, true);
migrations::migrate_create_root_network::migrate_create_root_network::<Test>();
SubtensorModule::add_balance_to_coldkey_account(&coldkey, 1_000_000_000_000_000);
assert_ok!(SubtensorModule::root_register(signer.clone(), hotkey,));
assert_ok!(SubtensorModule::add_stake(signer.clone(), hotkey, netuid, 1000));
// Only owner can set alpha values
assert_ok!(SubtensorModule::register_network(signer.clone(), hotkey));

// Explicitly set to false
SubtensorModule::set_liquid_alpha_enabled(netuid, false);
assert_err!(
SubtensorModule::do_set_alpha_values(signer.clone(), netuid, 12_u16, u16::MAX),
Error::<Test>::LiquidAlphaDisabled
);

// SubtensorModule::set_liquid_alpha_enabled(netuid, true);
// assert_ok!(SubtensorModule::do_set_alpha_values(
// signer.clone(),
// netuid,
// 12_u16,
// u16::MAX
// ));
SubtensorModule::set_liquid_alpha_enabled(netuid, true);
assert_ok!(SubtensorModule::do_set_alpha_values(
signer.clone(),
netuid,
12_u16,
u16::MAX
));
});
}

Expand Down
Loading