Skip to content

Commit 198b93e

Browse files
committed
test case for new error
1 parent 99d9ba1 commit 198b93e

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

pallets/subtensor/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,7 @@ pub mod pallet {
968968
StakeTooLowForRoot, // --- Thrown when a hotkey attempts to join the root subnet with too little stake
969969
AllNetworksInImmunity, // --- Thrown when all subnets are in the immunity period
970970
NotEnoughBalance,
971+
NoNeuronIdAvailable, // -- Thrown when no neuron id is available
971972
}
972973

973974
// ==================

pallets/subtensor/src/registration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<T: Config> Pallet<T> {
123123
// Possibly there is no neuron slots at all.
124124
ensure!(
125125
Self::get_max_allowed_uids(netuid) != 0,
126-
Error::<T>::NetworkDoesNotExist
126+
Error::<T>::NoNeuronIdAvailable
127127
);
128128

129129
if current_subnetwork_n < Self::get_max_allowed_uids(netuid) {

pallets/subtensor/tests/registration.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use frame_support::traits::Currency;
33
use crate::mock::*;
44
use frame_support::dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays};
55
use frame_support::sp_runtime::{transaction_validity::InvalidTransaction, DispatchError};
6-
use frame_support::{assert_err, assert_ok};
6+
use frame_support::{assert_err, assert_noop, assert_ok};
77
use frame_system::Config;
88
use pallet_subtensor::{AxonInfoOf, Error, SubtensorSignedExtension};
99
use sp_core::U256;
@@ -382,6 +382,33 @@ fn test_burned_registration_ok() {
382382
});
383383
}
384384

385+
#[test]
386+
fn test_burn_registration_without_neuron_slot() {
387+
new_test_ext(1).execute_with(|| {
388+
let netuid: u16 = 1;
389+
let tempo: u16 = 13;
390+
let hotkey_account_id = U256::from(1);
391+
let burn_cost = 1000;
392+
let coldkey_account_id = U256::from(667); // Neighbour of the beast, har har
393+
//add network
394+
SubtensorModule::set_burn(netuid, burn_cost);
395+
add_network(netuid, tempo, 0);
396+
// Give it some $$$ in his coldkey balance
397+
SubtensorModule::add_balance_to_coldkey_account(&coldkey_account_id, 10000);
398+
SubtensorModule::set_max_allowed_uids(netuid, 0);
399+
400+
// Subscribe and check extrinsic output
401+
assert_noop!(
402+
SubtensorModule::burned_register(
403+
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
404+
netuid,
405+
hotkey_account_id
406+
),
407+
Error::<Test>::NoNeuronIdAvailable
408+
);
409+
});
410+
}
411+
385412
#[test]
386413
fn test_burn_adjustment() {
387414
new_test_ext(1).execute_with(|| {

0 commit comments

Comments
 (0)