-
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
feat: add routes test (semi-integration test) #28
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.
Reviewed 2 of 3 files at r1, all commit messages.
Reviewable status: 2 of 3 files reviewed, 3 unresolved discussions (waiting on @elintul and @giladchase)
a discussion (no related file):
Nice!
- Why these tests are not part of
gateway_test
? - Are you planning to remove the identical test from
gateway_test
?
crates/gateway/tests/routing_test.rs
line 17 at r1 (raw file):
"DEPLOY_ACCOUNT" )] #[case("./src/json_files_for_testing/invoke_v3.json", "INVOKE")]
Why not "INVOKE_FUNCTION"?
This should be the expected type.
Code quote:
"INVOKE"
crates/gateway/tests/routing_test.rs
line 22 at r1 (raw file):
let tx_json = fs::read_to_string(json_file_path).unwrap(); let request = Request::post("/add_transaction") .header("content-type", "application/json")
Could you explain why you added this header?
Code quote:
.header("content-type", "application/json")
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: 2 of 3 files reviewed, 3 unresolved discussions (waiting on @elintul and @MohammadNassar1)
crates/gateway/tests/routing_test.rs
line 17 at r1 (raw file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
Why not "INVOKE_FUNCTION"?
This should be the expected type.
Just a dummy value for now, until we implement add_transaction
properly, it will be deleted very soon.
crates/gateway/tests/routing_test.rs
line 22 at r1 (raw file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
Could you explain why you added this header?
Looks like axum needs this explicitly in order to accept the JSON payload of the POST request.
Without this, the server hits 415, which means that it is refusing the request, probably being pedantic and not wanting to assume the string payload is a JSON without being told.
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: 2 of 3 files reviewed, 3 unresolved discussions (waiting on @elintul and @MohammadNassar1)
a discussion (no related file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
Nice!
- Why these tests are not part of
gateway_test
?- Are you planning to remove the identical test from
gateway_test
?
- Cause it's an integration test of sorts. Tests in
tests/
directory are compiled in separate crates, which simulates how our users will interact with our API. - Nope, the
add_transaction
test in gateway_test will evolve into a real (probably multiple) tests that test add_transaction functionality; and the routing test here will evolve into a very basic e2e test, that just sends a tx and checks that it was processed via add_transaction. Maybe once we have a proper flow test it will be removed, but for now its a sanity check that our gateway actually works.
9aa64ae
to
c55bea7
Compare
2499b1b
to
46ca88c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #28 +/- ##
===========================================
+ Coverage 34.84% 48.48% +13.63%
===========================================
Files 5 5
Lines 66 66
Branches 66 66
===========================================
+ Hits 23 32 +9
+ Misses 43 34 -9 ☔ View full report in Codecov by Sentry. |
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 1 of 1 files at r2, all commit messages.
Reviewable status: 3 of 4 files reviewed, all discussions resolved (waiting on @elintul)
0c80811
to
0ddc1ae
Compare
- tests that routes behave the way we expect, shouldn't have too much logic here, just test status codes and return values. Proper integration/flow tests will be in their own testing file. - add `tower` dependency that `axum` uses in order to simulate an HTTP request via the `oneshot` call: this simulates the HTTP request without having to spin up an actual server and perform IO. - Currently add_transaction test is identical to the one in gateway_test.rs, but they'll diverge once real logic kicks in. At that point the routes test will only test for success codes in basic scenarios. - is_alive is currently just a dummy test, since it isn't implemented yet.
46ca88c
to
0763a15
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 1 of 3 files at r1, 3 of 3 files at r3, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @elintul)
tower
dependency thataxum
uses in order to simulate an HTTP request via theoneshot
call: this simulates the HTTP request without having to spin up an actual server and perform IO.This change is