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

[CX_HARDENING] - Develop A Better Framework for Input Permutation #3207

Merged
merged 8 commits into from
May 31, 2024

Conversation

jparr721
Copy link
Contributor

@jparr721 jparr721 commented May 22, 2024

Closes #3161

This PR:

Inputs are mostly written for the happy path. The existing tests are written with a single stream of inputs, and this has bitten us in the past. However, as we see in the proposal_ordering tests, the permutation with index order is not sufficient and requires the implementor to arduously call a significant number of cases with manually prescribed indices. We can do better. We need a scalable and reliable way to permute inputs (and outputs) in a way that ensures that all possible orderings can be handled by the test.

This PR does just that, it adds a randomization layer over the inputs which can be specified by the new random and serial macros. These macros make it easier to declare a vec with the context that you're intending for it to be used in without any additional thought.

The new test script here will eventually completely replace the old one in script.rs

This PR does not:

This PR does not rewrite every test, that would make the PR large and any changes would be painful. I have updated one test and will update the rest in a follow on PR

Key places to review:

crates/testing/src/script.rs Outdated Show resolved Hide resolved
crates/testing/src/script.rs Outdated Show resolved Hide resolved
crates/testing/tests/tests_1/consensus_task.rs Outdated Show resolved Hide resolved
@jparr721 jparr721 marked this pull request as ready for review May 23, 2024 15:35
@jparr721 jparr721 reopened this May 30, 2024
@@ -179,6 +179,15 @@ pub struct Expectations<TYPES: NodeType, S> {
pub task_state_asserts: Vec<Box<dyn Predicate<S>>>,
}

impl<TYPES: NodeType, S> Expectations<TYPES, S> {
pub fn from_outputs(output_asserts: Vec<Box<dyn Predicate<Arc<HotShotEvent<TYPES>>>>>) -> Self {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ss-es I added this because we only assert in two tests in the entire codebase, so it was easier than writing the same line over and over, and I don't think it hurts readability, though I could be swayed on a different name.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good to me! Honestly, you could probably even just call it outputs.

@jparr721 jparr721 assigned bfish713 and rob-maron and unassigned shenkeyao May 31, 2024
ss-es
ss-es previously approved these changes May 31, 2024
Copy link
Contributor

@ss-es ss-es left a comment

Choose a reason for hiding this comment

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

Looks good to me if CI passes

crates/testing/tests/tests_1/consensus_task.rs Outdated Show resolved Hide resolved
@jparr721 jparr721 merged commit 9417280 into main May 31, 2024
24 checks passed
@jparr721 jparr721 deleted the jp/issue-3161 branch May 31, 2024 19:31
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.

[CX_HARDENING] - Develop A Better Framework for Input Permutation
5 participants