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

Replace generate_* functions with methods of HpkeKeypair #3287

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

inahga
Copy link
Contributor

@inahga inahga commented Jul 9, 2024

Small refactor. generate_test_hpke_config_and_private_key_with_id_and_ciphersuite() is a pretty incredible name, so let's shorten that up by making these functions methods on HpkeKeypair.

A lot of ways this could be cleaned up, e.g. builder pattern, impl Distribution, but this seemed the most straightforward win to me.

@inahga inahga requested a review from a team as a code owner July 9, 2024 16:42
Comment on lines +1085 to +1086
let leader_hpke_keypairs = [HpkeKeypair::test(), HpkeKeypair::test_with_id(1)];
let helper_hpke_keypairs = [HpkeKeypair::test(), HpkeKeypair::test_with_id(1)];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will fix this flake in another PR. I'm surprised this has never flaked on me before.

Copy link
Member

@branlwyd branlwyd left a comment

Choose a reason for hiding this comment

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

just a couple of minor code-golfing comments

pub fn generate_test_hpke_config_and_private_key() -> HpkeKeypair {
generate_hpke_config_and_private_key(
impl HpkeKeypair {
pub fn test() -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

nit: this could fall through to a call to test_with_id

@@ -341,8 +336,8 @@ pub mod test_util {
.unwrap()
}

pub fn generate_test_hpke_config_and_private_key_with_id(id: u8) -> HpkeKeypair {
generate_hpke_config_and_private_key(
pub fn test_with_id(id: u8) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

nit: this could fall through to a call to test_with_ciphersuite

@inahga inahga merged commit 8804cb3 into main Jul 9, 2024
9 checks passed
@inahga inahga deleted the inahga/cleanup_test_hpke_functions branch July 9, 2024 19:01
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.

None yet

3 participants