Skip to content

Commit ccb39d7

Browse files
committed
add swap test
1 parent c6d3ae3 commit ccb39d7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pallets/subtensor/src/tests/swap_hotkey.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,3 +1359,25 @@ fn test_swap_child_hotkey_childkey_maps() {
13591359
);
13601360
})
13611361
}
1362+
1363+
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey -- test_swap_hotkey_is_sn_owner_hotkey --exact --nocapture
1364+
#[test]
1365+
fn test_swap_hotkey_is_sn_owner_hotkey() {
1366+
new_test_ext(1).execute_with(|| {
1367+
let old_hotkey = U256::from(1);
1368+
let new_hotkey = U256::from(2);
1369+
let coldkey = U256::from(3);
1370+
let mut weight = Weight::zero();
1371+
1372+
// Create dynamic network
1373+
let netuid = add_dynamic_network(&old_hotkey, &coldkey);
1374+
// Check for SubnetOwnerHotkey
1375+
assert_eq!(SubnetOwnerHotkey::<Test>::get(netuid), old_hotkey);
1376+
1377+
// Perform the swap
1378+
SubtensorModule::perform_hotkey_swap(&old_hotkey, &new_hotkey, &coldkey, &mut weight);
1379+
1380+
// Check for SubnetOwnerHotkey
1381+
assert_eq!(SubnetOwnerHotkey::<Test>::get(netuid), new_hotkey);
1382+
});
1383+
}

0 commit comments

Comments
 (0)