Skip to content

Commit 94d5ce1

Browse files
committed
added assert for remapped evm address
1 parent 7974e99 commit 94d5ce1

File tree

1 file changed

+22
-12
lines changed
  • pallets/admin-utils/src/tests

1 file changed

+22
-12
lines changed

pallets/admin-utils/src/tests/mod.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,34 +2492,34 @@ fn test_trim_to_max_allowed_uids() {
24922492
BlockAtRegistration::<Test>::set(netuid, 6, now);
24932493
BlockAtRegistration::<Test>::set(netuid, 11, now);
24942494

2495+
// And some temporally immune uids
2496+
Keys::<Test>::insert(netuid, 7, sn_owner_hotkey1);
2497+
Uids::<Test>::insert(netuid, sn_owner_hotkey1, 7);
2498+
Keys::<Test>::insert(netuid, 14, sn_owner_hotkey2);
2499+
Uids::<Test>::insert(netuid, sn_owner_hotkey2, 14);
2500+
24952501
// Set some evm addresses
24962502
AssociatedEvmAddress::<Test>::insert(
24972503
netuid,
24982504
6,
2499-
(sp_core::H160::from_slice(b"12345678901234567890"), now),
2505+
(sp_core::H160::from_slice(b"12345678901234567891"), now),
25002506
);
25012507
AssociatedEvmAddress::<Test>::insert(
25022508
netuid,
2503-
11,
2504-
(sp_core::H160::from_slice(b"A2345678901234567890"), now),
2509+
10,
2510+
(sp_core::H160::from_slice(b"12345678901234567892"), now),
25052511
);
25062512
AssociatedEvmAddress::<Test>::insert(
25072513
netuid,
2508-
7,
2509-
(sp_core::H160::from_slice(b"B2345678901234567890"), now),
2514+
12,
2515+
(sp_core::H160::from_slice(b"12345678901234567893"), now),
25102516
);
25112517
AssociatedEvmAddress::<Test>::insert(
25122518
netuid,
25132519
14,
2514-
(sp_core::H160::from_slice(b"C2345678901234567890"), now),
2520+
(sp_core::H160::from_slice(b"12345678901234567894"), now),
25152521
);
25162522

2517-
// And some temporally immune uids
2518-
Keys::<Test>::insert(netuid, 7, sn_owner_hotkey1);
2519-
Uids::<Test>::insert(netuid, sn_owner_hotkey1, 7);
2520-
Keys::<Test>::insert(netuid, 14, sn_owner_hotkey2);
2521-
Uids::<Test>::insert(netuid, sn_owner_hotkey2, 14);
2522-
25232523
// Populate Weights and Bonds storage items to test trimming
25242524
// Create weights and bonds that span across the range that will be trimmed
25252525
for uid in 0..max_n {
@@ -2661,6 +2661,16 @@ fn test_trim_to_max_allowed_uids() {
26612661
assert_eq!(uid, Some(i));
26622662
}
26632663

2664+
// EVM association have been remapped correctly (uids: 7 -> 2, 14 -> 7)
2665+
assert_eq!(
2666+
AssociatedEvmAddress::<Test>::get(netuid, 2),
2667+
Some((sp_core::H160::from_slice(b"12345678901234567891"), now))
2668+
);
2669+
assert_eq!(
2670+
AssociatedEvmAddress::<Test>::get(netuid, 7),
2671+
Some((sp_core::H160::from_slice(b"12345678901234567894"), now))
2672+
);
2673+
26642674
// Non existent subnet
26652675
assert_err!(
26662676
AdminUtils::sudo_trim_to_max_allowed_uids(

0 commit comments

Comments
 (0)