-
Notifications
You must be signed in to change notification settings - Fork 11
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
refactor: use axum instead of hyper #17
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ayeletstarkware and @giladchase)
-- commits
line 5 at r1:
Please squash.
Code quote:
- b8a41a2: Implement add_transaction in Gateway
- ca6fa8f: refactor(gateway): use axum instead of hyper
crates/gateway/src/gateway_test.rs
line 18 at r1 (raw file):
async fn test_add_transaction(#[case] json_file_path: &str, #[case] expected_response: &str) { let json_str = std::fs::read_to_string(json_file_path).expect("Failed to read JSON file"); let json: ExternalTransaction = serde_json::from_str(&json_str).expect("Failed to parse JSON");
Suggestion:
transaction
crates/gateway/src/gateway_test.rs
line 19 at r1 (raw file):
let json_str = std::fs::read_to_string(json_file_path).expect("Failed to read JSON file"); let json: ExternalTransaction = serde_json::from_str(&json_str).expect("Failed to parse JSON"); let response = add_transaction(json.clone().into()).await.into_response();
Why clone is needed here?
Code quote:
json.clone()
0b0e349
to
ff48db7
Compare
ca6fa8f
to
77417a6
Compare
There was a problem hiding this 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, 2 unresolved discussions (waiting on @giladchase and @MohammadNassar1)
Previously, MohammadNassar1 (mohammad-starkware) wrote…
Please squash.
Done.
crates/gateway/src/gateway_test.rs
line 19 at r1 (raw file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
Why clone is needed here?
not needed
ef951a0
to
1c3d503
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 4 files at r1.
Reviewable status: 1 of 4 files reviewed, 6 unresolved discussions (waiting on @ayeletstarkware and @MohammadNassar1)
crates/gateway/src/gateway.rs
line 29 at r1 (raw file):
.route("/add_transaction", post(add_transaction)); let _ = axum::Server::bind(&addr)
Plz add comment on what this does and how it behaves
crates/gateway/src/gateway.rs
line 32 at r1 (raw file):
.serve(app.into_make_service()) .await .map_err(|_| GatewayError::ServerStartError);
This should be a ?
, and also I'm not sure how this works because the actual error is suppressed (with _
).
Let's adhere to the docs and unwrap
here, but add a TODO to check this out, could this fail with network error? if it can then it should be returned as an error to the user (so they'll fix their network issue)
Code quote:
.map_err(|_| GatewayError::ServerStartError);
crates/gateway/src/gateway_test.rs
line 16 at r1 (raw file):
#[case("./src/json_files_for_testing/invoke_v3.json", "INVOKE")] #[tokio::test] async fn test_add_transaction(#[case] json_file_path: &str, #[case] expected_response: &str) {
add negative test, separate test.
crates/gateway/src/gateway_test.rs
line 18 at r1 (raw file):
async fn test_add_transaction(#[case] json_file_path: &str, #[case] expected_response: &str) { let json_str = std::fs::read_to_string(json_file_path).expect("Failed to read JSON file"); let json: ExternalTransaction = serde_json::from_str(&json_str).expect("Failed to parse JSON");
Always prefer from_reader over from_string if all you want it so parse a json file
Code quote:
let json_str = std::fs::read_to_string(json_file_path).expect("Failed to read JSON file");
let json: ExternalTransaction = serde_json::from_str(&json_str).expect("Failed to parse JSON");
77417a6
to
3a233e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 4 files reviewed, 6 unresolved discussions (waiting on @giladchase and @MohammadNassar1)
crates/gateway/src/gateway.rs
line 29 at r1 (raw file):
Previously, giladchase wrote…
Plz add comment on what this does and how it behaves
Done.
crates/gateway/src/gateway.rs
line 32 at r1 (raw file):
Previously, giladchase wrote…
This should be a
?
, and also I'm not sure how this works because the actual error is suppressed (with_
).Let's adhere to the docs and
unwrap
here, but add a TODO to check this out, could this fail with network error? if it can then it should be returned as an error to the user (so they'll fix their network issue)
Done.
crates/gateway/src/gateway_test.rs
line 18 at r1 (raw file):
Previously, giladchase wrote…
Always prefer from_reader over from_string if all you want it so parse a json file
Done.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17 +/- ##
===========================================
- Coverage 47.72% 23.07% -24.66%
===========================================
Files 2 2
Lines 44 26 -18
Branches 44 26 -18
===========================================
- Hits 21 6 -15
- Misses 19 20 +1
+ Partials 4 0 -4 ☔ View full report in Codecov by Sentry. |
3a233e8
to
56fe055
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 4 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ayeletstarkware and @MohammadNassar1)
There was a problem hiding this 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, 3 unresolved discussions (waiting on @giladchase and @MohammadNassar1)
crates/gateway/src/gateway_test.rs
line 16 at r1 (raw file):
Previously, giladchase wrote…
add negative test, separate test.
Done.
There was a problem hiding this 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, 3 unresolved discussions (waiting on @giladchase and @MohammadNassar1)
crates/gateway/src/gateway_test.rs
line 16 at r1 (raw file):
Previously, ayeletstarkware (Ayelet Zilber) wrote…
Done.
will be done in next PR
There was a problem hiding this 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, 3 unresolved discussions (waiting on @giladchase and @MohammadNassar1)
crates/gateway/src/gateway_test.rs
line 16 at r1 (raw file):
Previously, ayeletstarkware (Ayelet Zilber) wrote…
will be done in next PR
when checking build_server
There was a problem hiding this 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, 2 unresolved discussions (waiting on @MohammadNassar1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ayeletstarkware)
This change is