-
Notifications
You must be signed in to change notification settings - Fork 85
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
test(network): add register_broadcast_subscriber for test #2127
test(network): add register_broadcast_subscriber for test #2127
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2127 +/- ##
==========================================
- Coverage 68.32% 68.31% -0.02%
==========================================
Files 132 132
Lines 17599 17599
Branches 17599 17599
==========================================
- Hits 12025 12023 -2
Misses 4245 4245
- Partials 1329 1331 +2 ☔ 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 r1, all commit messages.
Reviewable status: all files reviewed, 12 unresolved discussions (waiting on @asmaastarkware, @DvirYo-starkware, and @matan-starkware)
crates/papyrus_network/src/network_manager/mod.rs
line 505 at r1 (raw file):
} #[cfg(test)]
Change to #[cfg(feature = "testing")]. Same in all other places
crates/papyrus_network/src/network_manager/mod.rs
line 509 at r1 (raw file):
#[cfg(test)] pub fn test_register_broadcast_subscriber<T, U>()
change test_ to mock_
crates/papyrus_network/src/network_manager/mod.rs
line 510 at r1 (raw file):
#[cfg(test)] pub fn test_register_broadcast_subscriber<T, U>() -> Result<TestSubscriberChannels<T, U>, SubscriptionError>
You can have just one T. T and U will always be the same
crates/papyrus_network/src/network_manager/mod.rs
line 530 at r1 (raw file):
let broadcasted_messages_receiver = broadcasted_messages_receiver.map(broadcasted_messages_fn); let network_subscribers =
Rename to subscriber_channels
crates/papyrus_network/src/network_manager/mod.rs
line 533 at r1 (raw file):
BroadcastSubscriberChannels { messages_to_broadcast_sender, broadcasted_messages_receiver }; let mock_messages_to_broadcast_fn: MockMessagesToBroadcastFn<U> =
Rename to mock_broadcasted_messages_fn and rename the type as well
crates/papyrus_network/src/network_manager/mod.rs
line 539 at r1 (raw file):
mock_broadcasted_messages_sender.with(mock_messages_to_broadcast_fn); let mock_broadcasted_messages_fn: fn(Bytes) -> U = |x| match U::try_from(x) {
Rename to mock_messages_to_broadcast_fn
crates/papyrus_network/src/network_manager/mod.rs
line 542 at r1 (raw file):
Ok(result) => result, Err(_) => { panic!("Failed to convert Bytes to U");
I guess using unwrap failed because of clippy. Try to do expect instead and see if it works
crates/papyrus_network/src/network_manager/mod.rs
line 548 at r1 (raw file):
mock_messages_to_broadcast_receiver.map(mock_broadcasted_messages_fn); let mock_network_subscribers = BroadcastNetworkMock {
Rename to mock_network
crates/papyrus_network/src/network_manager/mod.rs
line 594 at r1 (raw file):
} pub type TestSubscriberSender<T> = With<
Rename to MockBroadcastedMessagesSender
crates/papyrus_network/src/network_manager/mod.rs
line 594 at r1 (raw file):
} pub type TestSubscriberSender<T> = With<
Add cfg to all these types
crates/papyrus_network/src/network_manager/mod.rs
line 605 at r1 (raw file):
fn((T, ReportCallback)) -> Ready<Result<(Bytes, ReportCallback), SendError>>; pub type TestSubscriberReceiver<T> = Map<Receiver<Bytes>, fn(Bytes) -> T>;
Rename to MockMessagesToBroadcastReceiver
crates/papyrus_network/src/network_manager/mod.rs
line 612 at r1 (raw file):
} pub struct TestSubscriberChannels<T: TryFrom<Bytes>, U: TryFrom<Bytes>> {
This can be the same T to both types
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, 15 unresolved discussions (waiting on @asmaastarkware, @DvirYo-starkware, and @matan-starkware)
crates/papyrus_network/src/network_manager/mod.rs
line 560 at r1 (raw file):
#[allow(dead_code)] fn return_report_callback() -> ReportCallback {
pub
crates/papyrus_network/src/network_manager/mod.rs
line 560 at r1 (raw file):
#[allow(dead_code)] fn return_report_callback() -> ReportCallback {
Rename to dummy_report_callback
crates/papyrus_network/src/network_manager/mod.rs
line 560 at r1 (raw file):
#[allow(dead_code)] fn return_report_callback() -> ReportCallback {
cfg(feature = "testing")
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, 16 unresolved discussions (waiting on @asmaastarkware, @DvirYo-starkware, and @matan-starkware)
crates/papyrus_network/src/network_manager/mod.rs
line 542 at r1 (raw file):
Ok(result) => result, Err(_) => { panic!("Failed to convert Bytes to U");
Change the message to "Failed to convert Bytes that we received from conversion to bytes"
44a3496
to
4b65882
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, 16 unresolved discussions (waiting on @DvirYo-starkware, @matan-starkware, and @ShahakShama)
crates/papyrus_network/src/network_manager/mod.rs
line 505 at r1 (raw file):
Previously, ShahakShama wrote…
Change to #[cfg(feature = "testing")]. Same in all other places
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 509 at r1 (raw file):
Previously, ShahakShama wrote…
change test_ to mock_
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 510 at r1 (raw file):
Previously, ShahakShama wrote…
You can have just one T. T and U will always be the same
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 530 at r1 (raw file):
Previously, ShahakShama wrote…
Rename to subscriber_channels
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 533 at r1 (raw file):
Previously, ShahakShama wrote…
Rename to mock_broadcasted_messages_fn and rename the type as well
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 539 at r1 (raw file):
Previously, ShahakShama wrote…
Rename to mock_messages_to_broadcast_fn
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 542 at r1 (raw file):
Previously, ShahakShama wrote…
Change the message to "Failed to convert Bytes that we received from conversion to bytes"
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 542 at r1 (raw file):
Previously, ShahakShama wrote…
I guess using unwrap failed because of clippy. Try to do expect instead and see if it works
using expect or unwrap requires adding a Debug bound to the error type, to keep it simpler I used match
crates/papyrus_network/src/network_manager/mod.rs
line 548 at r1 (raw file):
Previously, ShahakShama wrote…
Rename to mock_network
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 560 at r1 (raw file):
Previously, ShahakShama wrote…
pub
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 560 at r1 (raw file):
Previously, ShahakShama wrote…
Rename to dummy_report_callback
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 560 at r1 (raw file):
Previously, ShahakShama wrote…
cfg(feature = "testing")
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 594 at r1 (raw file):
Previously, ShahakShama wrote…
Rename to MockBroadcastedMessagesSender
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 594 at r1 (raw file):
Previously, ShahakShama wrote…
Add cfg to all these types
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 605 at r1 (raw file):
Previously, ShahakShama wrote…
Rename to MockMessagesToBroadcastReceiver
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 612 at r1 (raw file):
Previously, ShahakShama wrote…
This can be the same T to both types
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.
Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @asmaastarkware, @DvirYo-starkware, and @matan-starkware)
crates/papyrus_network/src/network_manager/mod.rs
line 3 at r2 (raw file):
mod swarm_trait; #[cfg(feature = "testing")]
Not here. This should be cfg(test)
crates/papyrus_network/src/network_manager/mod.rs
line 553 at r2 (raw file):
} #[allow(dead_code)]
Try to see if clippy passes without this allow
4b65882
to
032b6ce
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: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @DvirYo-starkware, @matan-starkware, and @ShahakShama)
crates/papyrus_network/src/network_manager/mod.rs
line 3 at r2 (raw file):
Previously, ShahakShama wrote…
Not here. This should be cfg(test)
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 553 at r2 (raw file):
Previously, ShahakShama wrote…
Try to see if clippy passes without this allow
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.
Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @DvirYo-starkware and @matan-starkware)
This change is