-
Notifications
You must be signed in to change notification settings - Fork 37.7k
test: Check that message sends successfully when header is split across two buffers #19304
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
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.
Concept ACK
msg = msg_getdata([CInv(MSG_TX, 1)] * 50001) | ||
conn.send_and_ping(msg) | ||
with self.nodes[0].assert_debug_log(['Misbehaving', 'peer=4 (40 -> 60): headers message size = 2001']): | ||
with self.nodes[0].assert_debug_log(['Misbehaving', '(40 -> 60): headers message size = 2001']): |
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.
If #19272 if merged first, these changes in test_large_inv()
won't be needed.
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.
+1, I'm more than happy to rebase this one if #19272 goes in first
ACK. Thanks for adding the test, will test after assert_equal nit is addressed |
cf742ce
to
3cd538a
Compare
Compare c5904c8 to 3cd538a. Changed to assert_equal and made log more descriptive. Disconnects peer at the end of the test, I'll keep that discussion in #19272 and I'll follow the status quo here. Had to add a short sleep, as I was finding my RPC call occationally went before the first half of the message was received by the node. |
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.
Concept ACK, hi Troy 👋 😁 !
Came here because I made a suggestion that impacts this test in #19272 - oops. I definitely see the need to make sure all peers are disconnected since getnettotals
aggregates information across all peers.
I wrote some suggestions that build off of Marco's comment about races.
Side note: not sure if you already considered this, but if there's no other peers, you can also use getpeerinfo
to see information on pings received from conn
only.
0cf655e
to
cac346c
Compare
Implemented |
A message can be broken across two buffers, with the split inside its header. Usually this will occur when sending many messages, such that the first buffer fills. This test uses the RPC to verify that the message is actually being received in two pieces. There is a very rare chance of a race condition where the test framework sends a message in between the two halves of the message under test. In this case the peer will almost certainly disconnect and the test will fail. An assert has been added to help debugging that rare case.
cac346c
to
80d4423
Compare
And removed unused import. |
tested ACK 80d4423 (added an assert(false) to observe deterministic coverage) 🌦 Show signature and timestampSignature:
Timestamp of file with hash |
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.
ACK 80d4423 👊
Looks good to me, nits if you touch again and happy to re-ACK if you do.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. Coverage
Updated at: 2020-06-17T20:17:17.128362. |
Concept ACK: good to have this code path tested deterministically! |
@@ -42,13 +48,33 @@ def set_test_params(self): | |||
self.setup_clean_chain = True | |||
|
|||
def run_test(self): | |||
self.test_buffer() |
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.
This would allow not changing test_large_inv()
:
def run_test(self):
- self.test_buffer()
self.test_magic_bytes()
self.test_checksum()
self.test_size()
self.test_msgtype()
self.test_large_inv()
+ self.test_buffer()
self.test_resource_exhaustion()
Going to merge this. I think it is more important to have this test than it is to find the exact right location for this test. I picked an invalid message in #19302 to accomodate the file name, but if it really turns out to be problematic, one could add a comment like |
…ovements 56010f9 test: hoist p2p values to test framework constants (Jon Atack) 75447f0 test: improve msg sends and p2p disconnections in p2p_invalid_messages (Jon Atack) 5796019 test: refactor test_large_inv() into 3 tests with common method (Jon Atack) e2b21d8 test: add p2p_invalid_messages logging (Jon Atack) 9fa494d net: update misbehavior logging for oversized messages (Jon Atack) Pull request description: ...seen while reviewing #19264, #19252, #19304 and #19107: in `net_processing.cpp` - make the debug logging for oversized message size misbehavior the same for `addr`, `getdata`, `headers` and `inv` messages in `p2p_invalid_messages` - add missing logging - improve assertions/message sends, move cleanup disconnections outside the assertion scopes - split a slowish 3-part test into 3 order-independent tests - add a few p2p constants to the test framework ACKs for top commit: troygiorshev: reACK 56010f9 MarcoFalke: ACK 56010f9 🎛 Tree-SHA512: db67b70278f8d4c318907e105af54b54eb3afd15500f9aa0c98034f6fd4bd1cf9ad1663037bd9b237ff4890f3059b37291a6498d8d6ae2cc38efb9f045f73310
…der is split across two buffers Summary: 80d4423f997e15780bfa3f91bf4b4bf656b8ea45 Test buffered valid message (Troy Giorshev) Pull request description: This PR is a tweak of #19302. This sends a valid message. Additionally, this test includes logging in the same vein as #19272. --- Depends on D9513 Backport of [[bitcoin/bitcoin#19304 | core#19304]] Test Plan: ninja all && ./test/functional/test_runner.py p2p_invalid_messages Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Differential Revision: https://reviews.bitcoinabc.org/D9514
This PR is a tweak of #19302. This sends a valid message.
Additionally, this test includes logging in the same vein as #19272.