Skip to content

feat(block_hash): add basic block info command #173

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

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

yoavGrs
Copy link
Collaborator

@yoavGrs yoavGrs commented Jun 2, 2024

This change is Reviewable

@yoavGrs yoavGrs self-assigned this Jun 2, 2024
Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @yoavGrs)


crates/committer_cli/src/tests/python_tests.rs line 172 at r1 (raw file):

        "da mode: {}, data gas: {:?}, gas: {:?}",
        da_mode, data_gas, gas
    )

I suggest the following:

  1. define a struct S describing the inputs of the block hash (or reuse the starknet-api struct).
  2. define a function to deserialize a HashMap<String, Value> to an instance of S
  3. in this test, just call the S deserializer, and compare the result to an explicitly constructed S instance

Code quote:

    let da_mode_value = get_param_from_args(&test_args, "l1_da_mode");
    let da_mode: bool = da_mode_value.as_bool().expect("serialize da mode");

    let data_gas_value = get_param_from_args(&test_args, "l1_data_gas_price_per_token");
    let data_gas: GasPricePerToken =
        serde_json::from_value(data_gas_value.to_owned()).expect("serialize data gas");

    let gas_value = get_param_from_args(&test_args, "l1_gas_price_per_token");
    let gas: GasPricePerToken =
        serde_json::from_value(gas_value.to_owned()).expect("serialize gas");

    format!(
        "da mode: {}, data gas: {:?}, gas: {:?}",
        da_mode, data_gas, gas
    )

crates/committer_cli/src/tests/python_tests.rs line 178 at r1 (raw file):

    let error_message = format!("{} not found", param_name);
    test_args.get(param_name).expect(&error_message)
}

why not use get_key_or_not_found? just return a Result<String, PythonTestError> from your test function and propagate the error

Code quote:

fn get_param_from_args<'a>(test_args: &'a HashMap<String, Value>, param_name: &str) -> &'a Value {
    let error_message = format!("{} not found", param_name);
    test_args.get(param_name).expect(&error_message)
}

@yoavGrs yoavGrs force-pushed the yoav/block_hash/parse_block_info branch from 0020be3 to 9c72c08 Compare June 2, 2024 13:41
@codecov-commenter
Copy link

codecov-commenter commented Jun 2, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 61.88%. Comparing base (15f126d) to head (256ba4b).
Report is 4 commits behind head on main.

Files Patch % Lines
crates/committer_cli/src/block_hash.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #173      +/-   ##
==========================================
- Coverage   62.27%   61.88%   -0.40%     
==========================================
  Files          35       36       +1     
  Lines        1662     1721      +59     
  Branches     1662     1721      +59     
==========================================
+ Hits         1035     1065      +30     
- Misses        578      609      +31     
+ Partials       49       47       -2     

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

@yoavGrs yoavGrs force-pushed the yoav/block_hash/parse_block_info branch from 9c72c08 to 2ea1a51 Compare June 2, 2024 13:48
Copy link
Collaborator Author

@yoavGrs yoavGrs 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: 3 of 6 files reviewed, 2 unresolved discussions (waiting on @dorimedini-starkware)


crates/committer_cli/src/tests/python_tests.rs line 172 at r1 (raw file):

Previously, dorimedini-starkware wrote…

I suggest the following:

  1. define a struct S describing the inputs of the block hash (or reuse the starknet-api struct).
  2. define a function to deserialize a HashMap<String, Value> to an instance of S
  3. in this test, just call the S deserializer, and compare the result to an explicitly constructed S instance

This is a really good goal.
For now, I want to deserialize only a subset of S.


crates/committer_cli/src/tests/python_tests.rs line 178 at r1 (raw file):

Previously, dorimedini-starkware wrote…

why not use get_key_or_not_found? just return a Result<String, PythonTestError> from your test function and propagate the error

I did something simpler.

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 3 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @yoavGrs)

@yoavGrs yoavGrs force-pushed the yoav/block_hash/parse_block_info branch from 2ea1a51 to 8bd7345 Compare June 2, 2024 14:25
@yoavGrs yoavGrs force-pushed the yoav/block_hash/parse_block_info branch from 8bd7345 to 256ba4b Compare June 2, 2024 14:48
@yoavGrs yoavGrs added this pull request to the merge queue Jun 2, 2024
Merged via the queue into main with commit 89b1bca Jun 2, 2024
10 of 11 checks passed
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