Skip to content

Commit 1bc4d6e

Browse files
committed
Fix tests
1 parent 0a99ee9 commit 1bc4d6e

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

pallets/subtensor/src/tests/staking.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,29 +2463,32 @@ fn test_max_amount_add_dynamic() {
24632463
#[test]
24642464
fn test_max_amount_remove_root() {
24652465
new_test_ext(0).execute_with(|| {
2466-
// 0 price on root => max is 0
2467-
assert_eq!(SubtensorModule::get_max_amount_remove(0, 0), 0);
2468-
2469-
// 0.999999... price on root => max is 0
2470-
assert_eq!(SubtensorModule::get_max_amount_remove(0, 999_999_999), 0);
2466+
// 0 price on root => max is u64::MAX
2467+
assert_eq!(SubtensorModule::get_max_amount_remove(0, 0), u64::MAX);
24712468

2472-
// 1.0 price on root => max is u64::MAX
2469+
// 0.5 price on root => max is u64::MAX
24732470
assert_eq!(
2474-
SubtensorModule::get_max_amount_remove(0, 1_000_000_000),
2471+
SubtensorModule::get_max_amount_remove(0, 500_000_000),
24752472
u64::MAX
24762473
);
24772474

2478-
// 1.000...001 price on root => max is u64::MAX
2475+
// 0.999999... price on root => max is u64::MAX
24792476
assert_eq!(
2480-
SubtensorModule::get_max_amount_remove(0, 1_000_000_001),
2477+
SubtensorModule::get_max_amount_remove(0, 999_999_999),
24812478
u64::MAX
24822479
);
24832480

2484-
// 2.0 price on root => max is u64::MAX
2481+
// 1.0 price on root => max is u64::MAX
24852482
assert_eq!(
2486-
SubtensorModule::get_max_amount_remove(0, 2_000_000_000),
2483+
SubtensorModule::get_max_amount_remove(0, 1_000_000_000),
24872484
u64::MAX
24882485
);
2486+
2487+
// 1.000...001 price on root => max is 0
2488+
assert_eq!(SubtensorModule::get_max_amount_remove(0, 1_000_000_001), 0);
2489+
2490+
// 2.0 price on root => max is 0
2491+
assert_eq!(SubtensorModule::get_max_amount_remove(0, 2_000_000_000), 0);
24892492
});
24902493
}
24912494

@@ -2495,13 +2498,13 @@ fn test_max_amount_remove_stable() {
24952498
let netuid: u16 = 1;
24962499
add_network(netuid, 1, 0);
24972500

2498-
// 0 price => max is 0
2499-
assert_eq!(SubtensorModule::get_max_amount_remove(netuid, 0), 0);
2501+
// 0 price => max is u64::MAX
2502+
assert_eq!(SubtensorModule::get_max_amount_remove(netuid, 0), u64::MAX);
25002503

2501-
// 0.999999... price => max is 0
2504+
// 0.999999... price => max is u64::MAX
25022505
assert_eq!(
25032506
SubtensorModule::get_max_amount_remove(netuid, 999_999_999),
2504-
0
2507+
u64::MAX
25052508
);
25062509

25072510
// 1.0 price => max is u64::MAX
@@ -2510,16 +2513,16 @@ fn test_max_amount_remove_stable() {
25102513
u64::MAX
25112514
);
25122515

2513-
// 1.000...001 price => max is u64::MAX
2516+
// 1.000...001 price => max is 0
25142517
assert_eq!(
25152518
SubtensorModule::get_max_amount_remove(netuid, 1_000_000_001),
2516-
u64::MAX
2519+
0
25172520
);
25182521

2519-
// 2.0 price => max is u64::MAX
2522+
// 2.0 price => max is 0
25202523
assert_eq!(
25212524
SubtensorModule::get_max_amount_remove(netuid, 2_000_000_000),
2522-
u64::MAX
2525+
0
25232526
);
25242527
});
25252528
}

0 commit comments

Comments
 (0)