Skip to content

Commit ef8e46d

Browse files
Fix set_validator_claim_type
1 parent fa61d93 commit ef8e46d

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

pallets/subtensor/src/macros/dispatches.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2453,7 +2453,10 @@ mod dispatches {
24532453

24542454
// Ensure the delegate claim type is not Delegated.
24552455
ensure!(
2456-
!matches!(new_claim_type, RootClaimTypeEnum::Delegated),
2456+
matches!(
2457+
new_claim_type,
2458+
RootClaimTypeEnum::Keep | RootClaimTypeEnum::Swap
2459+
),
24572460
Error::<T>::InvalidRootClaimType
24582461
);
24592462

pallets/subtensor/src/tests/claim_root.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,40 @@ fn test_claim_root_with_set_validator_claim_type() {
16201620
assert_eq!(ev_claim_type, new_claim_type);
16211621
assert_eq!(ev_netuid, netuid);
16221622
}
1623+
1624+
// Check possible options
1625+
assert_ok!(SubtensorModule::set_validator_claim_type(
1626+
RuntimeOrigin::signed(coldkey),
1627+
hotkey,
1628+
netuid,
1629+
RootClaimTypeEnum::Keep
1630+
),);
1631+
assert_ok!(SubtensorModule::set_validator_claim_type(
1632+
RuntimeOrigin::signed(coldkey),
1633+
hotkey,
1634+
netuid,
1635+
RootClaimTypeEnum::Swap
1636+
),);
1637+
assert_err!(
1638+
SubtensorModule::set_validator_claim_type(
1639+
RuntimeOrigin::signed(coldkey),
1640+
hotkey,
1641+
netuid,
1642+
RootClaimTypeEnum::Delegated
1643+
),
1644+
Error::<Test>::InvalidRootClaimType
1645+
);
1646+
assert_err!(
1647+
SubtensorModule::set_validator_claim_type(
1648+
RuntimeOrigin::signed(coldkey),
1649+
hotkey,
1650+
netuid,
1651+
RootClaimTypeEnum::KeepSubnets {
1652+
subnets: BTreeSet::from([netuid])
1653+
}
1654+
),
1655+
Error::<Test>::InvalidRootClaimType
1656+
);
16231657
});
16241658
}
16251659

0 commit comments

Comments
 (0)