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

p2p: break out tests into separate crate #898

Merged
merged 1 commit into from
Jun 11, 2021

Conversation

xla
Copy link
Contributor

@xla xla commented Jun 10, 2021

In order to explore a path forward where testing utilities as well as
the assertions for a single and across crates, this change moves the
secret connection tests into the newly introduced test crate.

@xla xla self-assigned this Jun 10, 2021
@xla xla force-pushed the xla/p2p-separate-test-crate branch 2 times, most recently from 8d4aa7b to 0cb4e80 Compare June 10, 2021 13:35
@codecov-commenter
Copy link

Codecov Report

Merging #898 (30fb847) into master (4e0e61c) will increase coverage by 0.6%.
The diff coverage is 90.4%.

❗ Current head 30fb847 differs from pull request most recent head 0cb4e80. Consider uploading reports for the commit 0cb4e80 to get more accurate results
Impacted file tree graph

@@           Coverage Diff            @@
##           master    #898     +/-   ##
========================================
+ Coverage    69.7%   70.4%   +0.6%     
========================================
  Files         200     203      +3     
  Lines       16319   16189    -130     
========================================
+ Hits        11383   11400     +17     
+ Misses       4936    4789    -147     
Impacted Files Coverage Δ
p2p/src/error.rs 0.0% <ø> (ø)
p2p/src/secret_connection/protocol.rs 65.0% <55.5%> (ø)
p2p/src/secret_connection.rs 84.8% <71.1%> (-5.7%) ⬇️
test/src/pipe.rs 76.8% <83.3%> (ø)
test/src/test/unit/p2p/secret_connection.rs 98.8% <98.8%> (ø)
p2p/src/secret_connection/kdf.rs 100.0% <100.0%> (ø)
p2p/src/secret_connection/nonce.rs 100.0% <100.0%> (ø)
p2p/src/secret_connection/public_key.rs 96.1% <100.0%> (+12.3%) ⬆️
test/src/lib.rs 100.0% <100.0%> (ø)
test/src/test/unit/p2p/secret_connection/nonce.rs 100.0% <100.0%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e0e61c...0cb4e80. Read the comment docs.

Copy link
Contributor

@thanethomson thanethomson left a comment

Choose a reason for hiding this comment

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

So I understand that having a separate test crate for cross-crate integration testing makes sense, but I'm not totally clear on the reasoning behind moving (what appear to be, at least) unit tests into a separate crate.

@@ -7,13 +7,13 @@ use thiserror::Error;
pub enum Error {
/// Cryptographic operation failed
#[error("cryptographic error")]
CryptoError,
Crypto,
Copy link
Contributor

Choose a reason for hiding this comment

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

These would be considered API-breaking changes, right? If so, please add an entry to .changelog/unreleased/breaking-changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add an entry, could you double check that this correctly formatted?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems good - we can always tweak formatting during the next release.

@@ -0,0 +1 @@
mod unit;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just so I understand, why are these unit tests broken out into a separate crate? If they're unit tests, shouldn't they stay in the tendermint-p2p crate, alongside the secret connection code?

@xla
Copy link
Contributor Author

xla commented Jun 10, 2021

@thanethomson A main source of reconsidering the testing story in Rust comes from this article: https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html

Esp. the later parts where where it goes into detail how code including unit test code is treated during compilation.

@thanethomson
Copy link
Contributor

@thanethomson A main source of reconsidering the testing story in Rust comes from this article: https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html

Esp. the later parts where where it goes into detail how code including unit test code is treated during compilation.

Interesting! So this is effectively an optimization?

It does seem like a good idea to test all publicly exposed APIs from within a single crate. I suppose then that the only tests that would be located outside of the tests crate would be those that test private functionality?

@xla
Copy link
Contributor Author

xla commented Jun 11, 2021

Interesting! So this is effectively an optimization?

You can look at it that way for sure, for me that is a means to an end, in this case developer experience. Where we optimise for tight feedback loops by being adamant about how quickly things fail/pass.

It does seem like a good idea to test all publicly exposed APIs from within a single crate. I suppose then that the only tests that would be located outside of the tests crate would be those that test private functionality?

Exactly, I'd be surprised that there are more of a handful of cases for private functionality to be tested.

In order to explore a path forward where testing utilities as well as
the assertions for a single and across crates, this change moves the
secret connection tests into the newly introduced test crate.

Signed-off-by: Alexander Simmerl <a.simmerl@gmail.com>
@xla xla force-pushed the xla/p2p-separate-test-crate branch from 0cb4e80 to aa3f2db Compare June 11, 2021 10:07
@thanethomson thanethomson merged commit b262d0b into master Jun 11, 2021
@thanethomson thanethomson deleted the xla/p2p-separate-test-crate branch June 11, 2021 13:04
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