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

test: add p2p class sync happy flow test #1942

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

noamsp-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

noamsp-starkware commented Nov 11, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @noamsp-starkware and the rest of your teammates on Graphite Graphite

Copy link

codecov bot commented Nov 11, 2024

Codecov Report

Attention: Patch coverage is 18.18182% with 9 lines in your changes missing coverage. Please review.

Project coverage is 33.68%. Comparing base (e3165c4) to head (82219ff).
Report is 380 commits behind head on main.

Files with missing lines Patch % Lines
crates/papyrus_protobuf/src/converters/class.rs 18.18% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1942      +/-   ##
==========================================
- Coverage   40.10%   33.68%   -6.42%     
==========================================
  Files          26      102      +76     
  Lines        1895    12396   +10501     
  Branches     1895    12396   +10501     
==========================================
+ Hits          760     4176    +3416     
- Misses       1100     7536    +6436     
- Partials       35      684     +649     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @noamsp-starkware)


crates/papyrus_protobuf/src/converters/class.rs line 285 at r1 (raw file):

        });

        // This length check and default option is needed for ContractClass test instances that

For next time: IMO this can be a separate preliminary PR


crates/papyrus_p2p_sync/src/client/class_test.rs line 39 at r1 (raw file):

    // Asserting the constants so the test can assume there will be 2 state diff queries for a
    // single header query and the second will be smaller than the first.
    const_assert!(STATE_DIFF_QUERY_LENGTH < HEADER_QUERY_LENGTH);

Since we're not testing state diffs, we don't need this assertion


crates/papyrus_p2p_sync/src/client/class_test.rs line 53 at r1 (raw file):

    } = setup();

    let block_hashes_and_signatures =

Please extract all common code between this test and the state diff test
You can use this opportunity to also remove code duplication between state diff test and
Suggestion for the function:

pub fn run_state_diff_sync(
    header_state_diff_lengths: Vec<usize>,
    state_diff_chunks: Vec<usize>
) -> GenericReceiver<ClassTestPayload> {
    ...
}

crates/papyrus_p2p_sync/src/client/class_test.rs line 192 at r1 (raw file):

}

fn create_random_state_diff_chunk(rng: &mut ChaCha8Rng) -> StateDiffChunk {

Unite these two functions into create_random_state_diff_chunk_with_class. This way, you'll get rid of the unreachable section


crates/papyrus_p2p_sync/src/client/class_test.rs line 194 at r1 (raw file):

fn create_random_state_diff_chunk(rng: &mut ChaCha8Rng) -> StateDiffChunk {
    let class_hash = ClassHash(rng.next_u64().into());
    if rng.next_u32() % 2 == 0 {

use rng.gen_bool() instead (from the Rng trait)

Copy link
Contributor

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @noamsp-starkware)


crates/papyrus_p2p_sync/src/client/class_test.rs line 53 at r1 (raw file):

Previously, ShahakShama wrote…

Please extract all common code between this test and the state diff test
You can use this opportunity to also remove code duplication between state diff test and
Suggestion for the function:

pub fn run_state_diff_sync(
    header_state_diff_lengths: Vec<usize>,
    state_diff_chunks: Vec<usize>
) -> GenericReceiver<ClassTestPayload> {
    ...
}

*between state diff positive flow test and negative flow test

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.

3 participants