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

Feat: implement certificate chain builder for tests #1999

Merged
merged 16 commits into from
Oct 17, 2024

Conversation

jpraynaud
Copy link
Member

@jpraynaud jpraynaud commented Oct 11, 2024

Content

This PR includes the implementation of a Certificate Chain Builder for tests:

  • This part of the code is now more readable and maintainable
  • The certificate chains allows alteration of the genesis and standard certificates with closures
  • The computation of the number of signers per epoch is now configurable with a closure

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • No clippy warnings in the CI
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

@jpraynaud jpraynaud self-assigned this Oct 11, 2024
Copy link

github-actions bot commented Oct 11, 2024

Test Results

    4 files  ± 0     55 suites  ±0   10m 26s ⏱️ +58s
1 368 tests +13  1 368 ✅ +13  0 💤 ±0  0 ❌ ±0 
1 576 runs  +13  1 576 ✅ +13  0 💤 ±0  0 ❌ ±0 

Results for commit 335ee13. ± Comparison against base commit d1ce9a3.

♻️ This comment has been updated with latest results.

@jpraynaud jpraynaud force-pushed the jpraynaud/refactor-certificate-chain-test-setup branch 4 times, most recently from 732212c to bf2b315 Compare October 15, 2024 14:18
@jpraynaud jpraynaud marked this pull request as ready for review October 15, 2024 15:13
Copy link
Collaborator

@dlachaume dlachaume left a comment

Choose a reason for hiding this comment

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

LGTM 🚀, thanks for the tool, it will make testing cases on the certificate chain much easier 🙏.

Just a comment regarding the exposure of data in the certificate_chain_builder module.
It seems that we could set the following traits to private visibility:

  • GenesisCertificateProcessorFunc
  • StandardCertificateProcessorFunc
  • TotalSignersPerEpochProcessorFunc

The CertificateChainBuilderContext struct could also switch to private by adding a #[cfg(test)] attribute on the with_genesis_certificate_processor and with_standard_certificate_processor functions.

Do you think it could be a good idea?

Copy link
Collaborator

@sfauvel sfauvel left a comment

Choose a reason for hiding this comment

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

LGTM

mithril-common/src/test_utils/certificate_chain_builder.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@Alenar Alenar left a comment

Choose a reason for hiding this comment

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

LGTM

@jpraynaud jpraynaud force-pushed the jpraynaud/refactor-certificate-chain-test-setup branch from bf2b315 to 9b63c01 Compare October 16, 2024 13:49
@jpraynaud
Copy link
Member Author

Just a comment regarding the exposure of data in the certificate_chain_builder module. It seems that we could set the following traits to private visibility:

  • GenesisCertificateProcessorFunc
  • StandardCertificateProcessorFunc
  • TotalSignersPerEpochProcessorFunc

You're right. Done ✔️

The CertificateChainBuilderContext struct could also switch to private by adding a #[cfg(test)] attribute on the with_genesis_certificate_processor and with_standard_certificate_processor functions.

Do you think it could be a good idea?

The usage of #[cfg(test)] is not possible as we will use this builder in other crates.
Also the CertificateChainBuilderContext should keep its field public as they give valuable information when altering the certificate chain

And add a factory for the 'CertificateChainBuilderContext'.
@jpraynaud jpraynaud merged commit 3908e8a into main Oct 17, 2024
48 checks passed
@jpraynaud jpraynaud deleted the jpraynaud/refactor-certificate-chain-test-setup branch October 17, 2024 07:26
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.

4 participants