-
Notifications
You must be signed in to change notification settings - Fork 28
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(starknet_mempool_p2p): test gateway client error on adding tx from p2p #2138
base: main
Are you sure you want to change the base?
Conversation
AlonLStarkWare
commented
Nov 18, 2024
- test(mempool_p2p): change p2p runner test to use automock for gateway client
- test(mempool_p2p): test gateway client error on adding tx from p2p
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, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 16 unresolved discussions (waiting on @AlonLStarkWare)
crates/starknet_mempool_p2p/src/runner/test.rs
line 81 at r2 (raw file):
mock_register_broadcast_topic().expect("Failed to create mock network"); let BroadcastTopicChannels { broadcasted_messages_receiver, broadcast_topic_client } = subscriber_channels; // used to created our node's p2p runner below, which will listen for incoming txs over broadcasted_messages_receiver.
Same as before, try to reduce the amount of comments
crates/starknet_mempool_p2p/src/runner/test.rs
line 92 at r2 (raw file):
// send an empty message on this channel to indicate that the tx reached the gateway client. let (add_tx_indicator_sender, add_tx_indicator_receiver) = futures::channel::oneshot::channel();
You don't need this. You can wait for the peer report instead
crates/starknet_mempool_p2p/src/runner/test.rs
line 124 at r2 (raw file):
// if the runner fails, there was a network issue => panic. // if the runner returns successfully, we panic because the runner should never terminate. res = tokio::time::timeout(Duration::from_secs(5), mempool_p2p_runner.start()) => {res.expect("Test timed out").expect("Runner failed - network stopped unexpectedly"); panic!("Runner terminated")},
Same as before. newlines and MempoolP2pRunner
crates/starknet_mempool_p2p/src/runner/test.rs
line 130 at r2 (raw file):
res.unwrap(); // After gateway client fails to add the tx, the p2p runner should have reported the peer. let peer_reported = mock_reported_messages_receiver.next().await.expect("Failed to receive message");
As I said before, put this future in the select arm instead
crates/starknet_mempool_p2p/src/runner/test.rs
line 130 at r2 (raw file):
res.unwrap(); // After gateway client fails to add the tx, the p2p runner should have reported the peer. let peer_reported = mock_reported_messages_receiver.next().await.expect("Failed to receive message");
Failed to receive report
crates/starknet_mempool_p2p/src/runner/test.rs
line 131 at r2 (raw file):
// After gateway client fails to add the tx, the p2p runner should have reported the peer. let peer_reported = mock_reported_messages_receiver.next().await.expect("Failed to receive message"); assert_eq!(peer_reported, message_metadata.originator_id.private_get_peer_id())
add a TODO to add this functionality to network manager test utils
crates/starknet_mempool_p2p/src/runner/test.rs
line 29 at r1 (raw file):
mock_register_broadcast_topic().expect("Failed to create mock network"); let BroadcastTopicChannels { broadcasted_messages_receiver, broadcast_topic_client } = subscriber_channels; // used to created our node's p2p runner below, which will listen for incoming txs over broadcasted_messages_receiver.
This comment seems unnecessary
crates/starknet_mempool_p2p/src/runner/test.rs
line 33 at r1 (raw file):
broadcasted_messages_sender: mut mock_broadcasted_messages_sender, .. } = mock_network; // other node sending tx to our p2p runner
This comment seems unnecessary
crates/starknet_mempool_p2p/src/runner/test.rs
line 38 at r1 (raw file):
let placeholder_network_manager = NetworkManager::new(NetworkConfig::default(), None); // send an empty message on this channel to indicate that the tx reached the gateway client.
This comment is incorrect. Change it to "Creating channels for sending ..."
crates/starknet_mempool_p2p/src/runner/test.rs
line 42 at r1 (raw file):
let mut mock_gateway_client = MockGatewayClient::new(); mock_gateway_client.expect_add_tx().return_once(move |_| {
You should assert that the transaction you've received is the one you've gotten from p2p. You can use automock's with function for that: https://docs.rs/mockall/latest/mockall/index.html#getting-started
crates/starknet_mempool_p2p/src/runner/test.rs
line 48 at r1 (raw file):
let mut mempool_p2p_runner = MempoolP2pRunner::new( Some(placeholder_network_manager), broadcasted_messages_receiver, // listen to incoming tx
This comment seems unnecessary
crates/starknet_mempool_p2p/src/runner/test.rs
line 49 at r1 (raw file):
Some(placeholder_network_manager), broadcasted_messages_receiver, // listen to incoming tx broadcast_topic_client, // broadcast tx or report peer
This comment seems unnecessary
crates/starknet_mempool_p2p/src/runner/test.rs
line 64 at r1 (raw file):
tokio::select! { // if the runner takes longer than 5 seconds to start, we panic.
This comment seems unnecessary. You have the expect for that
crates/starknet_mempool_p2p/src/runner/test.rs
line 67 at r1 (raw file):
// if the runner fails, there was a network issue => panic. // if the runner returns successfully, we panic because the runner should never terminate. res = tokio::time::timeout(Duration::from_secs(5), mempool_p2p_runner.start()) => {res.expect("Test timed out").expect("Runner failed - network stopped unexpectedly"); panic!("Runner terminated")},
Runner -> MempoolP2pRunner
crates/starknet_mempool_p2p/src/runner/test.rs
line 67 at r1 (raw file):
// if the runner fails, there was a network issue => panic. // if the runner returns successfully, we panic because the runner should never terminate. res = tokio::time::timeout(Duration::from_secs(5), mempool_p2p_runner.start()) => {res.expect("Test timed out").expect("Runner failed - network stopped unexpectedly"); panic!("Runner terminated")},
add newlines after the { and after each ;
crates/starknet_mempool_p2p/src/runner/test.rs
line 68 at r1 (raw file):
// if the runner returns successfully, we panic because the runner should never terminate. res = tokio::time::timeout(Duration::from_secs(5), mempool_p2p_runner.start()) => {res.expect("Test timed out").expect("Runner failed - network stopped unexpectedly"); panic!("Runner terminated")}, // if a message was received on this oneshot channel, the gateway client received the tx.
... and the test succeeded
0864b85
to
9c3f24d
Compare
Artifacts upload triggered. View details here |
Artifacts upload triggered. View details here |
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 3 files reviewed, 16 unresolved discussions (waiting on @ShahakShama)
crates/starknet_mempool_p2p/src/runner/test.rs
line 29 at r1 (raw file):
Previously, ShahakShama wrote…
This comment seems unnecessary
Done.
crates/starknet_mempool_p2p/src/runner/test.rs
line 33 at r1 (raw file):
Previously, ShahakShama wrote…
This comment seems unnecessary
Done.
crates/starknet_mempool_p2p/src/runner/test.rs
line 38 at r1 (raw file):
Previously, ShahakShama wrote…
This comment is incorrect. Change it to "Creating channels for sending ..."
Done.
crates/starknet_mempool_p2p/src/runner/test.rs
line 42 at r1 (raw file):
Previously, ShahakShama wrote…
You should assert that the transaction you've received is the one you've gotten from p2p. You can use automock's with function for that: https://docs.rs/mockall/latest/mockall/index.html#getting-started
Done.
crates/starknet_mempool_p2p/src/runner/test.rs
line 48 at r1 (raw file):
Previously, ShahakShama wrote…
This comment seems unnecessary
Done.
crates/starknet_mempool_p2p/src/runner/test.rs
line 49 at r1 (raw file):
Previously, ShahakShama wrote…
This comment seems unnecessary
Done.
crates/starknet_mempool_p2p/src/runner/test.rs
line 64 at r1 (raw file):
Previously, ShahakShama wrote…
This comment seems unnecessary. You have the expect for that
Done.
crates/starknet_mempool_p2p/src/runner/test.rs
line 67 at r1 (raw file):
Previously, ShahakShama wrote…
Runner -> MempoolP2pRunner
Done.
crates/starknet_mempool_p2p/src/runner/test.rs
line 67 at r1 (raw file):
Previously, ShahakShama wrote…
add newlines after the { and after each ;
Done.
crates/starknet_mempool_p2p/src/runner/test.rs
line 68 at r1 (raw file):
Previously, ShahakShama wrote…
... and the test succeeded
Done.
crates/starknet_mempool_p2p/src/runner/test.rs
line 81 at r2 (raw file):
Previously, ShahakShama wrote…
Same as before, try to reduce the amount of comments
Done.
crates/starknet_mempool_p2p/src/runner/test.rs
line 92 at r2 (raw file):
Previously, ShahakShama wrote…
You don't need this. You can wait for the peer report instead
Wouldn't we want to know if the gateway received the transaction if it wasn't reported? I think this helps narrow down the potential error.
crates/starknet_mempool_p2p/src/runner/test.rs
line 124 at r2 (raw file):
Previously, ShahakShama wrote…
Same as before. newlines and MempoolP2pRunner
Done.
crates/starknet_mempool_p2p/src/runner/test.rs
line 130 at r2 (raw file):
Previously, ShahakShama wrote…
As I said before, put this future in the select arm instead
This future can only be resolved after the transaction is received by the gateway, so it should be in this arm, IMO.
crates/starknet_mempool_p2p/src/runner/test.rs
line 130 at r2 (raw file):
Previously, ShahakShama wrote…
Failed to receive report
Done.
crates/starknet_mempool_p2p/src/runner/test.rs
line 131 at r2 (raw file):
Previously, ShahakShama wrote…
add a TODO to add this functionality to network manager test utils
Done.
9c3f24d
to
0691d17
Compare
0691d17
to
366fb70
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 3 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @AlonLStarkWare)
crates/starknet_mempool_p2p/src/runner/test.rs
line 92 at r2 (raw file):
Previously, AlonLStarkWare (Alon-Lukatch-Starkware) wrote…
Wouldn't we want to know if the gateway received the transaction if it wasn't reported? I think this helps narrow down the potential error.
ok
crates/starknet_mempool_p2p/src/runner/test.rs
line 142 at r6 (raw file):
// After gateway client fails to add the tx, the p2p runner should have reported the peer. let peer_reported = mock_reported_messages_receiver.next().await.expect("Failed to receive report"); // TODO: add this functionalionality to network manager test utils
spell error in functionalionality
366fb70
to
f93b1ae
Compare
Benchmark movements: |
f93b1ae
to
25183b9
Compare
} | ||
} | ||
|
||
// The p2p runner receives a tx from network, and the gateway decalines it, triggering report_peer. |
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.
Typo in comment: decalines
should be declines
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
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.
👍
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.
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 3 of 3 files at r9.
Reviewable status: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @graphite-app[bot])
} | ||
} | ||
|
||
// The p2p runner receives a tx from network, and the gateway decalines it, triggering report_peer. |
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.
👍
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: all files reviewed, 1 unresolved discussion (waiting on @graphite-app[bot])
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: complete! all files reviewed, all discussions resolved (waiting on @AlonLStarkWare)
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, 1 unresolved discussion (waiting on @graphite-app[bot])
25183b9
to
2c6dea4
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, 1 unresolved discussion (waiting on @ShahakShama)
} | ||
} | ||
|
||
// The p2p runner receives a tx from network, and the gateway decalines it, triggering report_peer. |
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.
Done.
Benchmark movements: |