Add additional tests for v2 send module#554
Conversation
Pull Request Test Coverage Report for Build 13789274853Details
💛 - Coveralls |
spacebear21
left a comment
There was a problem hiding this comment.
Currently missing is the test for process_response which I was unable to make significant progress on as I was not able to parse what I anticipated as expected values for the ohttp encapsulation/decapsulation. Ideally we should have a test for that added so I have created a TODO there.
Since the response must come from the OHTTP relay, I think the only way to do this in a unit test would be to get a "real" OHTTP response from e.g. an integration test and all known parameters, and hardcode these into the unit test.
Until the test actually exists, we should remove the placeholder. Currently it results in a test "success" which is misleading since it doesn't actually test anything.
|
Ok! Yeah I was exploring the |
c68713f to
0dd746b
Compare
88f1cba to
7df2f64
Compare
f88b4d8 to
23bbd82
Compare
23bbd82 to
a81b432
Compare
a81b432 to
46f4642
Compare
payjoin/src/send/v2/mod.rs
Outdated
| let sender = create_sender_context()?; | ||
| let ohttp_relay = EXAMPLE_URL.clone(); | ||
| let result = sender.extract_v2(ohttp_relay); | ||
| assert!(result.is_ok(), "Expected Ok result, got: {:#?}", result.err()); |
There was a problem hiding this comment.
This is great! but I think unwrap() on the result is going to be more verbose, and better for debugging when the test does fail.
There was a problem hiding this comment.
I am doing my best to avoid .unwrap() in these tests just to keep in line with the remove unwrap even in tests issue I referenced at the beginning of this PR
There was a problem hiding this comment.
FWIW I think this line is equivalent to doing something likelet (request, context) = result.expect("result shoud be Ok"); - this avoids unwrap, saves a line, and provides a more verbose output on failure.
f7331ca to
728227d
Compare
This is an attempt to both add some additional test vectors and to create some headway on the tests deficiencies caught by cargo mutants. Currently missing is the test for process_response which I was unable to make significant progress on as that test currently expects an actual response from an ohttp relay. Until we can make any progress on that test I have left that test absent for now.
728227d to
53db3f8
Compare
spacebear21
left a comment
There was a problem hiding this comment.
ACK 53db3f8
@benalleng thank you very much for your diligent work on this PR, and thanks to all who reviewed and provided great feedback!
|
Wow, great to see this merged this morning. Thanks Ben, Spacebear, and the many others who came to review 🔥 |
Relates to #539
This is an attempt to both add some additional test vectors and to create some headway on the tests deficiencies caught by cargo mutants ahead of time.
Currently missing is the test for process_response which I was unable to make significant progress on as I was not able to parse what I anticipated as expected values for the ohttp encapsulation/decapsulation. Ideally we should have a test for that added so I have created a TODO there.
I have tried my best to keep the tests in accordance with the design laid out in #487
Below is the cargo mutants output for
send/v2/mod.rsas of df30f3bDetails
Note the 2 main improvements that can be made are for creating a test for
process_responseand catching thetest_extract_v2_fails_when_expiredslightly better