Skip to content

Commit a29ec97

Browse files
committed
add rate limit test helper
1 parent dd048ac commit a29ec97

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pallets/subtensor/tests/mock.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use frame_support::{
1010
use frame_system as system;
1111
use frame_system::{limits, EnsureNever, EnsureRoot, RawOrigin};
1212
use pallet_collective::MemberCount;
13+
use pallet_subtensor::utils::rate_limiting::TransactionType;
1314
use sp_core::{Get, H256, U256};
1415
use sp_runtime::Perbill;
1516
use sp_runtime::{
@@ -601,3 +602,13 @@ pub fn is_within_tolerance(actual: u64, expected: u64, tolerance: u64) -> bool {
601602
};
602603
difference <= tolerance
603604
}
605+
606+
// Helper function to wait for the rate limit
607+
#[allow(dead_code)]
608+
pub fn step_rate_limit(transaction_type: &TransactionType, netuid: u16) {
609+
// Check rate limit
610+
let limit = SubtensorModule::get_rate_limit(transaction_type, netuid);
611+
612+
// Step that many blocks
613+
step_block(limit as u16);
614+
}

0 commit comments

Comments
 (0)