Add P2P addr/addrv2 tests + oversized/spam message checks#897
Draft
moisesPompilio wants to merge 6 commits intogetfloresta:masterfrom
Draft
Add P2P addr/addrv2 tests + oversized/spam message checks#897moisesPompilio wants to merge 6 commits intogetfloresta:masterfrom
moisesPompilio wants to merge 6 commits intogetfloresta:masterfrom
Conversation
…in getblock/gettxout Replaced manual waiting logic with the `wait_until` utility in the getblock and gettxout tests. The `wait_until` function periodically evaluates a given predicate and returns `True` when the condition is met. If the condition is not met within the timeout, it raises an exception.
…dle GetAddr properly Fixed the handling of SendAddrV2 messages received after the handshake. Peers that send this message post-handshake are now disconnected, as this behavior is not allowed. Adjusted the response to GetAddr messages to conditionally send AddrV2 or Addr based on the peer's support for AddrV2. If the peer does not support AddrV2, the node will now send Addr instead.
…nection functions Added a file from the Bitcoin Core project related to P2P testing. This includes utilities for simulating P2P nodes and interacting with the P2P protocol in integration tests. Exposed functions to connect a node with the P2P interface, enabling the use of a simulated node to send and receive P2P messages during functional tests.
Added a test suite for P2P address relay functionality in Floresta. The test verifies that Floresta correctly handles address messages (addr and addrv2), enforces message size limits, and responds appropriately to getaddr requests. The suite also tests Floresta's tolerance to oversized messages and its behavior when receiving sendaddrv2 messages after the handshake between nodes.
3aae2a5 to
3c64367
Compare
Add TestP2pOversizedMessages to verify Floresta correctly rejects and disconnects peers sending messages exceeding MAX_PROTOCOL_MESSAGE_LENGTH. Tests all message types across v1 and v2 P2P protocol versions.
cb4c249 to
8c42d8c
Compare
Add TestP2pSpamMessages to verify Floresta correctly disconnects peers that flood the node with excessive messages exceeding MAX_MSG_PER_SECOND. Tests all message types across v1 and v2 P2P protocol versions.
8c42d8c to
7a7e8ff
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description and Notes
This PR introduces the
p2ptest suite to the integration tests for the Floresta project. The main enhancements include:p2p_addr_relay.pytest to verify the behavior of Floresta regarding the handling ofaddr,addrv2,sendaddr2, andgetaddrmessages. This includes the following fixes:sendaddrv2messages after the P2P handshake.addrmessages (instead ofaddrv2) to peers that do not signal support foraddrv2.p2p_oversized_msg.py).p2p_spam_msg.py).These resilience tests ensure robustness and address potential vulnerabilities. Note that the oversized/spam message tests depend on the changes in PR #880 to function correctly.
How to verify the changes you have done?
To verify the changes, execute the functional tests as follows:
./tests/run.sh -t p2p -k p2p_addr_relay.py: Run the P2P Address Relay test../tests/run.sh -t p2p -k p2p_oversized_msg.py: Run the P2P Oversized Message test../tests/run.sh -t p2p -k p2p_spam_msg.py: Run the P2P Spam Message test.Ensure that all tests pass successfully and validate the scenarios introduced in this PR. Note that
p2p_oversized_msg.pyandp2p_spam_msg.pyrequire PR #880 to run properly.