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(JSON-RPC): support version without patch #929

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

nagmo-starkware
Copy link
Contributor

@nagmo-starkware nagmo-starkware commented Jul 30, 2023

Pull Request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this introduce a breaking change?

  • Yes
  • No

Other information


This change is Reviewable

@nagmo-starkware nagmo-starkware mentioned this pull request Jul 30, 2023
9 tasks
@nagmo-starkware
Copy link
Contributor Author

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@codecov
Copy link

codecov bot commented Jul 30, 2023

Codecov Report

Merging #929 (82e968e) into main (40008f1) will increase coverage by 1.76%.
Report is 7 commits behind head on main.
The diff coverage is 72.72%.

@@            Coverage Diff             @@
##             main     #929      +/-   ##
==========================================
+ Coverage   74.34%   76.11%   +1.76%     
==========================================
  Files          61       61              
  Lines        4977     5450     +473     
  Branches     4977     5450     +473     
==========================================
+ Hits         3700     4148     +448     
- Misses        569      600      +31     
+ Partials      708      702       -6     
Files Changed Coverage Δ
crates/papyrus_gateway/src/v0_3_0/api/api_impl.rs 86.23% <ø> (+0.52%) ⬆️
crates/papyrus_gateway/src/v0_3_0/api/mod.rs 0.00% <0.00%> (ø)
crates/papyrus_gateway/src/v0_4_0/api/api_impl.rs 86.84% <ø> (+1.12%) ⬆️
crates/papyrus_gateway/src/v0_4_0/api/mod.rs 0.00% <0.00%> (ø)
crates/papyrus_gateway/src/version_config.rs 66.66% <75.00%> (+16.66%) ⬆️
crates/papyrus_gateway/src/api.rs 72.00% <100.00%> (-5.78%) ⬇️
crates/papyrus_gateway/src/middleware.rs 82.45% <100.00%> (ø)

... and 11 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Base automatically changed from middlware_tests_improv to main July 30, 2023 07:33
Copy link
Contributor

@DvirYo-starkware DvirYo-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 14 of 14 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @nagmo-starkware)


crates/papyrus_gateway/src/gateway_test.rs line 122 at r1 (raw file):

#[tokio::test]
async fn test_version_middleware() {

What should happen with a version with a lower patch than we have?


crates/papyrus_gateway/src/gateway_test.rs line 125 at r1 (raw file):

    let base_uri = "http://localhost:8080/rpc/";
    let mut path_options = vec![];
    VERSION_CONFIG.iter().for_each(|(version_id, _)| {

Consider adding a version name with patch and lowercase v.


crates/papyrus_gateway/src/gateway_test.rs line 165 at r1 (raw file):

    };
    let mut rng = get_rng();
    let version_id = VERSION_CONFIG.choose(&mut rng).unwrap().0;

Instead of first declaring the variable rng you can do:
let version_id = VERSION_CONFIG.choose(&mut get_rng()).unwrap().0;


crates/papyrus_gateway/src/middleware.rs line 101 at r1 (raw file):

        return Err(BoxError::from(msg));
    };
    let version_comps = temp_version.split('_').collect::<Vec<_>>();

Consider doing the same thing by finding the first and last indexes of ''; if those equal no patch, else there is a patch. Then the version variable will be the String slice from the beginning to the first '' index.
Not very important...

Copy link
Contributor Author

@nagmo-starkware nagmo-starkware 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: 13 of 14 files reviewed, 3 unresolved discussions (waiting on @DvirYo-starkware)


crates/papyrus_gateway/src/gateway_test.rs line 122 at r1 (raw file):

Previously, DvirYo-starkware wrote…

What should happen with a version with a lower patch than we have?

the requirement we got from product says he'll get the latest version we have. we promise to provide you with the same minor version and a patch that is gte then what you asked for.
I guess I can add a test for that but I'm not sure if it's overkill. what do you think?


crates/papyrus_gateway/src/gateway_test.rs line 125 at r1 (raw file):

Previously, DvirYo-starkware wrote…

Consider adding a version name with patch and lowercase v.

I think it's unnecessary since if we see that the test supports both lowercase and capital v and also both with and without patch then we covered all the cases. can you think of a scenario it can break?


crates/papyrus_gateway/src/middleware.rs line 101 at r1 (raw file):

Previously, DvirYo-starkware wrote…

Consider doing the same thing by finding the first and last indexes of ''; if those equal no patch, else there is a patch. Then the version variable will be the String slice from the beginning to the first '' index.
Not very important...

did you mean _? if so then this wouldn't work since we have two underscores i.e. v0_3_0 and the last zero is the patch.
also that means iterating twice instead of once but it's less important since it's a short string anyway

Copy link
Contributor

@DvirYo-starkware DvirYo-starkware 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: 13 of 14 files reviewed, 3 unresolved discussions (waiting on @nagmo-starkware)


crates/papyrus_gateway/src/gateway_test.rs line 122 at r1 (raw file):

Previously, nagmo-starkware wrote…

the requirement we got from product says he'll get the latest version we have. we promise to provide you with the same minor version and a patch that is gte then what you asked for.
I guess I can add a test for that but I'm not sure if it's overkill. what do you think?

I think we should add a test for that.


crates/papyrus_gateway/src/gateway_test.rs line 125 at r1 (raw file):

Previously, nagmo-starkware wrote…

I think it's unnecessary since if we see that the test supports both lowercase and capital v and also both with and without patch then we covered all the cases. can you think of a scenario it can break?

It will be nice to know we cover all the cases here, and there are no actual costs for that (test runtime...).


crates/papyrus_gateway/src/middleware.rs line 101 at r1 (raw file):

Previously, nagmo-starkware wrote…

did you mean _? if so then this wouldn't work since we have two underscores i.e. v0_3_0 and the last zero is the patch.
also that means iterating twice instead of once but it's less important since it's a short string anyway

This is a minor optimization; you can forget it.
This is only one pass, to the first from the start and to the last from the end.
I don't understand the first point, but you can ignore this.

Copy link
Contributor Author

@nagmo-starkware nagmo-starkware 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: 13 of 14 files reviewed, 2 unresolved discussions (waiting on @DvirYo-starkware)


crates/papyrus_gateway/src/gateway_test.rs line 122 at r1 (raw file):

Previously, DvirYo-starkware wrote…

I think we should add a test for that.

added, but currently we don't have a case that checks this. look at the code and I think you'll understand


crates/papyrus_gateway/src/gateway_test.rs line 125 at r1 (raw file):

Previously, DvirYo-starkware wrote…

It will be nice to know we cover all the cases here, and there are no actual costs for that (test runtime...).

added it

@DvirYo-starkware DvirYo-starkware force-pushed the support_version_without_patch branch 2 times, most recently from 0461f1d to 82e968e Compare July 31, 2023 10:25
Copy link
Contributor

@DvirYo-starkware DvirYo-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:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @DvirYo-starkware)

@nagmo-starkware nagmo-starkware added this pull request to the merge queue Jul 31, 2023
Merged via the queue into main with commit 02d6938 Jul 31, 2023
32 checks passed
@nagmo-starkware nagmo-starkware deleted the support_version_without_patch branch July 31, 2023 13:59
@github-actions github-actions bot locked and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants