Skip to content

Commit 02325f3

Browse files
author
Samuel Dare
committed
bump spec , formats
1 parent 148bb10 commit 02325f3

File tree

3 files changed

+0
-117
lines changed

3 files changed

+0
-117
lines changed

pallets/subtensor/src/lib.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,20 +1347,10 @@ where
13471347
priority: Self::get_priority_vanilla(),
13481348
..Default::default()
13491349
}),
1350-
<<<<<<< HEAD
1351-
1352-
Ok(ValidTransaction {
1353-
priority: Self::get_priority_vanilla(),
1354-
..Default::default()
1355-
})
1356-
}
1357-
}
1358-
=======
13591350
Some(Call::dissolve_network { .. }) => Ok(ValidTransaction {
13601351
priority: Self::get_priority_vanilla(),
13611352
..Default::default()
13621353
}),
1363-
>>>>>>> origin/devnet-ready
13641354
_ => Ok(ValidTransaction {
13651355
priority: Self::get_priority_vanilla(),
13661356
..Default::default()

pallets/subtensor/tests/root.rs

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ use frame_system::{EventRecord, Phase};
77
use pallet_subtensor::migrations;
88
use pallet_subtensor::Error;
99
use sp_core::{Get, H256, U256};
10-
use sp_runtime::{
11-
traits::{DispatchInfoOf, SignedExtension},
12-
transaction_validity::{InvalidTransaction, TransactionValidityError},
13-
};
1410

1511
mod mock;
1612

@@ -983,103 +979,3 @@ fn test_dissolve_network_does_not_exist_err() {
983979
);
984980
});
985981
}
986-
987-
#[test]
988-
fn test_dissolve_network_validate() {
989-
fn generate_valid_pow(coldkey: &U256, block_number: u64, difficulty: U256) -> (H256, u64) {
990-
let mut nonce: u64 = 0;
991-
loop {
992-
let work = SubtensorModule::create_seal_hash(block_number, nonce, coldkey);
993-
if SubtensorModule::hash_meets_difficulty(&work, difficulty) {
994-
return (work, nonce);
995-
}
996-
nonce += 1;
997-
}
998-
}
999-
// Testing the signed extension validate function
1000-
// correctly filters the `dissolve_network` transaction.
1001-
1002-
new_test_ext(0).execute_with(|| {
1003-
let netuid: u16 = 1;
1004-
let delegate_coldkey = U256::from(1);
1005-
let delegate_hotkey = U256::from(2);
1006-
let new_coldkey = U256::from(3);
1007-
let current_block = 0u64;
1008-
1009-
add_network(netuid, 0, 0);
1010-
register_ok_neuron(netuid, delegate_hotkey, delegate_coldkey, 0);
1011-
1012-
// Make delegate a delegate
1013-
assert_ok!(SubtensorModule::become_delegate(
1014-
RuntimeOrigin::signed(delegate_coldkey),
1015-
delegate_hotkey
1016-
));
1017-
1018-
// Add more than 500 TAO of stake to the delegate's hotkey
1019-
let stake_amount = 501_000_000_000; // 501 TAO in RAO
1020-
let delegator = U256::from(4);
1021-
SubtensorModule::add_balance_to_coldkey_account(&delegator, stake_amount);
1022-
assert_ok!(SubtensorModule::add_stake(
1023-
RuntimeOrigin::signed(delegator),
1024-
delegate_hotkey,
1025-
stake_amount
1026-
));
1027-
1028-
// Ensure the delegate's coldkey has less than minimum balance
1029-
assert!(
1030-
SubtensorModule::get_coldkey_balance(&delegate_coldkey)
1031-
< MIN_BALANCE_TO_PERFORM_COLDKEY_SWAP,
1032-
"Delegate coldkey balance should be less than minimum required"
1033-
);
1034-
1035-
// Ensure the delegate's hotkey has more than 500 TAO delegated
1036-
assert!(
1037-
SubtensorModule::get_total_delegated_stake(&delegate_coldkey) >= 500_000_000_000,
1038-
"Delegate hotkey should have at least 500 TAO delegated"
1039-
);
1040-
1041-
// Generate valid PoW
1042-
let (work, nonce) = generate_valid_pow(
1043-
&delegate_coldkey,
1044-
current_block,
1045-
U256::from(4) * U256::from(BaseDifficulty::<Test>::get()),
1046-
);
1047-
1048-
// Schedule coldkey swap
1049-
assert_ok!(SubtensorModule::do_schedule_coldkey_swap(
1050-
&delegate_coldkey,
1051-
&new_coldkey,
1052-
work.to_fixed_bytes().to_vec(),
1053-
current_block,
1054-
nonce,
1055-
));
1056-
1057-
// Verify that the swap was scheduled
1058-
assert_eq!(
1059-
ColdkeySwapDestinations::<Test>::get(delegate_coldkey),
1060-
vec![new_coldkey]
1061-
);
1062-
1063-
// Check if the coldkey is in arbitration
1064-
assert!(
1065-
SubtensorModule::coldkey_in_arbitration(&delegate_coldkey),
1066-
"Delegate coldkey should be in arbitration after swap"
1067-
);
1068-
1069-
let who = delegate_coldkey; // The coldkey signs this transaction
1070-
let call = RuntimeCall::SubtensorModule(SubtensorCall::dissolve_network { netuid });
1071-
1072-
let info: DispatchInfo =
1073-
DispatchInfoOf::<<Test as frame_system::Config>::RuntimeCall>::default();
1074-
1075-
let extension = pallet_subtensor::SubtensorSignedExtension::<Test>::new();
1076-
1077-
// Submit to the signed extension validate function
1078-
let result_in_arbitration = extension.validate(&who, &call.clone(), &info, 10);
1079-
// Should fail with InvalidTransaction::Custom(6) because coldkey is in arbitration
1080-
assert_err!(
1081-
result_in_arbitration,
1082-
TransactionValidityError::Invalid(InvalidTransaction::Custom(6))
1083-
);
1084-
});
1085-
}

pallets/subtensor/tests/staking.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#![allow(clippy::unwrap_used)]
22
#![allow(clippy::arithmetic_side_effects)]
33

4-
use frame_support::pallet_prelude::{InvalidTransaction, TransactionValidity};
5-
use frame_support::traits::{OnFinalize, OnIdle, OnInitialize};
6-
use frame_support::weights::Weight;
74
use frame_support::{assert_err, assert_noop, assert_ok, traits::Currency};
85
use frame_system::Config;
96
mod mock;

0 commit comments

Comments
 (0)