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

chaincfg: Rework init time deployment val logic. #3056

Merged

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Feb 15, 2023

This reworks the deployment validation logic that runs at initialization time to make it easier to modify and bring it more in line with the more modern coding practices used in the codebase. Similarly, it also reworks the associated deployment validation tests to make them more consistent with modern practices in the code as well as to simplify them and make them more flexible by moving the primary logic for all of the expected results into the test definitions themselves.

The following is a high-level overview of the changes:

  • Use math/bits from the stdlib for population and trailing zero counts
  • Rework error handling to use wrapped errors for better error messages while still allowing testability
  • Rename several internal errors to better describe what they represent
  • Add additional checks for missing abstain and no choices
  • Modify validateDeployments to accept all deployments for all versions
  • Return errors from validateDeployments
  • Only panic directly in the init func
  • Add missing comments and make the existing ones match reality
  • Rework associated deployment validation tests
  • Adds test for the missing abstain and missing no choice cases

@davecgh davecgh added this to the 1.8.0 milestone Feb 15, 2023
@davecgh davecgh added the test coverage Discussion and pull requests for improving test coverage. label Feb 15, 2023
chaincfg/init_test.go Outdated Show resolved Hide resolved
chaincfg/init.go Outdated Show resolved Hide resolved
@davecgh davecgh force-pushed the chaincfg_rework_init_time_deployment_val_logic branch from 113722c to 9932f48 Compare February 15, 2023 15:33
This reworks the deployment validation logic that runs at initialization
time to make it easier to modify  and bring it more in line with the
more modern coding practices used in the codebase.

The following is a high-level overview of the changes:

- Use math/bits from the stdlib for population and trailing zero counts
- Rework error handling to use wrapped errors for better error messages
  while still allowing testability
- Rename several internal errors to better describe what they represent
- Add additional checks for missing abstain and no choices
- Modify validateDeployments to accept all deployments for all versions
- Return errors from validateDeployments
- Only panic directly in the init func
- Add missing comments and make the existing ones match reality
This reworks the deployment validation tests to make them more
consistent with modern practices in the code as well as to simplify them
and make them more flexible by moving the primary logic for all of the
expected results into the test definitions themselves.

It also tests for the missing abstain and missing no choice cases.
@davecgh davecgh force-pushed the chaincfg_rework_init_time_deployment_val_logic branch from 9932f48 to 974b1b3 Compare February 24, 2023 08:48
@davecgh davecgh merged commit 974b1b3 into decred:master Feb 24, 2023
@davecgh davecgh deleted the chaincfg_rework_init_time_deployment_val_logic branch February 24, 2023 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test coverage Discussion and pull requests for improving test coverage.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants