Skip to content

Commit 52b5dc3

Browse files
committed
fix clippy
1 parent 258b9c7 commit 52b5dc3

File tree

3 files changed

+83
-23
lines changed

3 files changed

+83
-23
lines changed

pallets/subtensor/tests/block_emission.rs

+26
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
mod mock;
2+
23
use crate::mock::*;
34
use pallet_subtensor::*;
45
use sp_core::Get;
56

67
// 1. Test Zero Issuance
78
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_zero_issuance -- --exact --nocapture
89
#[test]
10+
#[allow(clippy::unwrap_used)]
911
fn test_zero_issuance() {
1012
new_test_ext(1).execute_with(|| {
1113
let result = SubtensorModule::get_block_emission_for_issuance(0);
@@ -18,6 +20,7 @@ fn test_zero_issuance() {
1820
// 2. Test Maximum Issuance (Equal to Total Supply)
1921
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_maximum_issuance -- --exact --nocapture
2022
#[test]
23+
#[allow(clippy::unwrap_used)]
2124
fn test_maximum_issuance() {
2225
new_test_ext(1).execute_with(|| {
2326
let total_supply = TotalSupply::<Test>::get();
@@ -31,6 +34,7 @@ fn test_maximum_issuance() {
3134
// 3. Test Issuance Just Below Total Supply
3235
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_issuance_just_below_total_supply -- --exact --nocapture
3336
#[test]
37+
#[allow(clippy::unwrap_used)]
3438
fn test_issuance_just_below_total_supply() {
3539
new_test_ext(1).execute_with(|| {
3640
let total_supply = TotalSupply::<Test>::get();
@@ -45,6 +49,7 @@ fn test_issuance_just_below_total_supply() {
4549
// 4. Test Minimum Non-Zero Issuance
4650
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_minimum_non_zero_issuance -- --exact --nocapture
4751
#[test]
52+
#[allow(clippy::unwrap_used)]
4853
fn test_minimum_non_zero_issuance() {
4954
new_test_ext(1).execute_with(|| {
5055
let result = SubtensorModule::get_block_emission_for_issuance(1);
@@ -58,6 +63,7 @@ fn test_minimum_non_zero_issuance() {
5863
// 5. Test Default Block Emission
5964
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_default_block_emission -- --exact --nocapture
6065
#[test]
66+
#[allow(clippy::unwrap_used)]
6167
fn test_default_block_emission() {
6268
new_test_ext(1).execute_with(|| {
6369
let result = SubtensorModule::get_block_emission();
@@ -93,6 +99,7 @@ fn test_logarithm_calculation_boundary() {
9399
// 7. Test Rounding Behavior
94100
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_rounding_behavior -- --exact --nocapture
95101
#[test]
102+
#[allow(clippy::unwrap_used)]
96103
fn test_rounding_behavior() {
97104
new_test_ext(1).execute_with(|| {
98105
let total_supply = TotalSupply::<Test>::get();
@@ -112,6 +119,7 @@ fn test_rounding_behavior() {
112119
// 8. Test Precision Loss
113120
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_precision_loss -- --exact --nocapture
114121
#[test]
122+
#[allow(clippy::unwrap_used)]
115123
fn test_precision_loss() {
116124
new_test_ext(1).execute_with(|| {
117125
let total_supply = TotalSupply::<Test>::get();
@@ -133,6 +141,7 @@ fn test_precision_loss() {
133141
// 9. Test Overflow Handling in Intermediate Calculations
134142
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_overflow_handling -- --exact --nocapture
135143
#[test]
144+
#[allow(clippy::unwrap_used)]
136145
fn test_overflow_handling() {
137146
new_test_ext(1).execute_with(|| {
138147
let total_supply = TotalSupply::<Test>::get();
@@ -151,6 +160,7 @@ fn test_overflow_handling() {
151160
// 10. Test Underflow Handling in Intermediate Calculations
152161
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_underflow_handling -- --exact --nocapture
153162
#[test]
163+
#[allow(clippy::unwrap_used)]
154164
fn test_underflow_handling() {
155165
new_test_ext(1).execute_with(|| {
156166
// Test with very small issuance values
@@ -167,6 +177,7 @@ fn test_underflow_handling() {
167177
// 11. Test Division by Zero Prevention
168178
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_division_by_zero_prevention -- --exact --nocapture
169179
#[test]
180+
#[allow(clippy::unwrap_used)]
170181
fn test_division_by_zero_prevention() {
171182
new_test_ext(1).execute_with(|| {
172183
let total_supply = TotalSupply::<Test>::get();
@@ -186,6 +197,7 @@ fn test_division_by_zero_prevention() {
186197
// 12. Test Emission Rate Decrease with Increasing Issuance
187198
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_emission_rate_decrease -- --exact --nocapture
188199
#[test]
200+
#[allow(clippy::unwrap_used)]
189201
fn test_emission_rate_decrease() {
190202
new_test_ext(1).execute_with(|| {
191203
let total_supply = TotalSupply::<Test>::get();
@@ -205,6 +217,7 @@ fn test_emission_rate_decrease() {
205217
// 14. Test Block Emission Storage Update
206218
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_block_emission_storage_update -- --exact --nocapture
207219
#[test]
220+
#[allow(clippy::unwrap_used)]
208221
fn test_block_emission_storage_update() {
209222
new_test_ext(1).execute_with(|| {
210223
let initial_emission = BlockEmission::<Test>::get();
@@ -232,6 +245,7 @@ fn test_block_emission_storage_update() {
232245
// 15. Test Consistency Between get_block_emission() and get_block_emission_for_issuance()
233246
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_emission_consistency -- --exact --nocapture
234247
#[test]
248+
#[allow(clippy::unwrap_used)]
235249
fn test_emission_consistency() {
236250
new_test_ext(1).execute_with(|| {
237251
let emission_from_get = SubtensorModule::get_block_emission().unwrap();
@@ -249,6 +263,7 @@ fn test_emission_consistency() {
249263
// 16. Test Performance with Large Issuance Values
250264
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_performance_large_issuance -- --exact --nocapture
251265
#[test]
266+
#[allow(clippy::unwrap_used)]
252267
fn test_performance_large_issuance() {
253268
new_test_ext(1).execute_with(|| {
254269
let large_issuance = TotalSupply::<Test>::get() - 1_000_000_000;
@@ -271,6 +286,7 @@ fn test_performance_large_issuance() {
271286
// 17. Test Performance with Small Issuance Values
272287
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_performance_small_issuance -- --exact --nocapture
273288
#[test]
289+
#[allow(clippy::unwrap_used)]
274290
fn test_performance_small_issuance() {
275291
new_test_ext(1).execute_with(|| {
276292
let small_issuance = 1000; // A small issuance value
@@ -294,6 +310,7 @@ fn test_performance_small_issuance() {
294310
// 18. Test Emission at Key Issuance Milestones (e.g., 25%, 50%, 75% of Total Supply)
295311
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_emission_at_key_milestones -- --exact --nocapture
296312
#[test]
313+
#[allow(clippy::unwrap_used)]
297314
fn test_emission_at_key_milestones() {
298315
new_test_ext(1).execute_with(|| {
299316
let total_supply = TotalSupply::<Test>::get();
@@ -321,6 +338,7 @@ fn test_emission_at_key_milestones() {
321338
// 19. Test Behavior Near Total Supply Limit
322339
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_behavior_near_total_supply -- --exact --nocapture
323340
#[test]
341+
#[allow(clippy::unwrap_used)]
324342
fn test_behavior_near_total_supply() {
325343
new_test_ext(1).execute_with(|| {
326344
let total_supply = TotalSupply::<Test>::get();
@@ -351,6 +369,7 @@ fn test_behavior_near_total_supply() {
351369
// 20. Test with Maximum u64 Value as Issuance
352370
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_maximum_u64_issuance -- --exact --nocapture
353371
#[test]
372+
#[allow(clippy::unwrap_used)]
354373
fn test_maximum_u64_issuance() {
355374
new_test_ext(1).execute_with(|| {
356375
let max_issuance = u64::MAX;
@@ -365,6 +384,7 @@ fn test_maximum_u64_issuance() {
365384
// 21. Test with Issuance Values That Cause Extreme Residuals
366385
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_extreme_residuals -- --exact --nocapture
367386
#[test]
387+
#[allow(clippy::unwrap_used)]
368388
fn test_extreme_residuals() {
369389
new_test_ext(1).execute_with(|| {
370390
let total_supply = TotalSupply::<Test>::get();
@@ -388,6 +408,7 @@ fn test_extreme_residuals() {
388408
// 22. Test Stability of Output Across Multiple Calls
389409
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_output_stability -- --exact --nocapture
390410
#[test]
411+
#[allow(clippy::unwrap_used)]
391412
fn test_output_stability() {
392413
new_test_ext(1).execute_with(|| {
393414
let test_issuance = 1_000_000_000; // 1 billion
@@ -408,6 +429,7 @@ fn test_output_stability() {
408429
// 25. Test with Issuance Values That Produce Very Small Emissions
409430
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_very_small_emissions -- --exact --nocapture
410431
#[test]
432+
#[allow(clippy::unwrap_used)]
411433
fn test_very_small_emissions() {
412434
new_test_ext(1).execute_with(|| {
413435
let total_supply = TotalSupply::<Test>::get();
@@ -429,6 +451,7 @@ fn test_very_small_emissions() {
429451
// 26. Test Emission Calculation Time Complexity
430452
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_emission_calculation_time_complexity -- --exact --nocapture
431453
#[test]
454+
#[allow(clippy::unwrap_used)]
432455
fn test_emission_calculation_time_complexity() {
433456
new_test_ext(1).execute_with(|| {
434457
use std::time::Instant;
@@ -460,6 +483,7 @@ fn test_emission_calculation_time_complexity() {
460483
// 27. Test Emission Values Across Full Range of Possible Issuances
461484
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_emission_values_across_issuance_range -- --exact --nocapture
462485
#[test]
486+
#[allow(clippy::unwrap_used)]
463487
fn test_emission_values_across_issuance_range() {
464488
new_test_ext(1).execute_with(|| {
465489
let total_supply = TotalSupply::<Test>::get();
@@ -487,6 +511,7 @@ fn test_emission_values_across_issuance_range() {
487511
// 28. Test Consistency of Emission Decrease Rate
488512
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_consistency_of_emission_decrease_rate -- --exact --nocapture
489513
#[test]
514+
#[allow(clippy::unwrap_used)]
490515
fn test_consistency_of_emission_decrease_rate() {
491516
new_test_ext(1).execute_with(|| {
492517
let total_supply = TotalSupply::<Test>::get();
@@ -524,6 +549,7 @@ fn test_consistency_of_emission_decrease_rate() {
524549
// 30. Test Impact of Floating Point Precision on Final Emission Value
525550
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test block_emission test_floating_point_precision_impact -- --exact --nocapture
526551
#[test]
552+
#[allow(clippy::unwrap_used)]
527553
fn test_floating_point_precision_impact() {
528554
new_test_ext(1).execute_with(|| {
529555
let total_supply = TotalSupply::<Test>::get();

0 commit comments

Comments
 (0)