Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexed Preexecution Errors #788

Open
wants to merge 6 commits into
base: devnet-ready
Choose a base branch
from

Conversation

JohnReedV
Copy link
Contributor

@JohnReedV JohnReedV commented Sep 8, 2024

Description

This PR modifies the preexecution error codes to ensure that the code matches its index in the metadata.

Related Issue(s)

  • Closes #[issue number]

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Breaking Change

@JohnReedV JohnReedV changed the title Indexed Predispatch Errors Indexed Preexecution Errors Sep 8, 2024
@JohnReedV JohnReedV marked this pull request as ready for review September 16, 2024 14:17
Comment on lines 1057 to 1084
fn test_error_into_u8_conversion() {
new_test_ext(1).execute_with(|| {
let errors: Vec<Error<Test>> = vec![
Error::<Test>::ColdkeyInSwapSchedule,
Error::<Test>::CommitWeightsBelowMinStake,
Error::<Test>::RevealWeightsBelowMinStake,
Error::<Test>::SetWeightsBelowMinStake,
Error::<Test>::SetRootWeightsBelowMinStake,
Error::<Test>::MaxIntervalRegistrationsReached,
Error::<Test>::SubNetworkDoesNotExist,
];

for error in errors {
let expected_value: u8 = match &error {
Error::<Test>::ColdkeyInSwapSchedule => 89,
Error::<Test>::CommitWeightsBelowMinStake => 90,
Error::<Test>::RevealWeightsBelowMinStake => 91,
Error::<Test>::SetWeightsBelowMinStake => 92,
Error::<Test>::SetRootWeightsBelowMinStake => 93,
Error::<Test>::MaxIntervalRegistrationsReached => 94,
_ => u8::MAX,
};

let value: u8 = error.into();
assert_eq!(value, expected_value);
}
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually the whole point is you want to do a match on the enum itself so you get a compile error if something is missing / added, so this wouldn't be sufficient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants