Page MenuHomePhabricator

Merge #14522: tests: add invalid P2P message tests

Authored by jasonbcox on May 20 2020, 21:09.



d20a9fa13d1c13f552e879798c0508be70190e71 tests: add tests for invalid P2P messages (James O'Beirne)
62f94d39f8de88a44bb0a8a2837d864f777aaacc tests: add P2PConnection.send_raw_message (James O'Beirne)
5aa31f6ef26f51ce461c917654dd1cfbbdd1409a tests: add utility to assert node memory usage hasn't increased (James O'Beirne)

Pull request description:

  • Adds tests based on behavior for dealing with invalid and malformed P2P messages. Includes a test verifying that we can't DoS a node by spamming it with large invalid messages.
  • Adds TestNode.assert_memory_usage_stable: a context manager that allows us to ensure memory usage doesn't significantly increase on a node during some test.
  • Adds P2PConnection.send_raw_message: which allows us to construct and send messages with tweaked headers.

Tree-SHA512: 720a4894c1e6d8f1551b2ae710e5b06c9e4f281524623957cb01599be9afea82671dc26d6152281de0acb87720f0c53b61e2b27d40434d30e525dd9e31fa671f

Merge #14672: tests: Send fewer spam messages in p2p_invalid_messages

3d305e3b89 Send fewer spam messages in p2p_invalid_messages (James O'Beirne)

Pull request description:

Builds on travis are failing because the test node isn't
able to drop all the bad messages sent within the given
timeout. Reduce the number of bad messages we're sending
and increase the timeout to avoid failures on travis.

Tree-SHA512: 11c389619d9590caf7eca74e0efe6d950469415d34220072770689024b350cc08a2d5ec90634237d87ff71ba8b638c1152b8a45ffbb2815a48bde6a88fbb8fc6

Backport of Core PR14522 and PR14672 (to reduce flakiness)

Test Plan

ninja check-functional

Diff Detail

rABC Bitcoin ABC
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

[Bot Message]
One or more PR numbers were detected in the summary.
Links to those PRs have been inserted into the summary for reference.

abc-invalid-message will eventually be replaced by p2p_invalid_messages once we've backported all of the test cases. But as of this patch, it still provides test coverage that p2p_invalid_messages does not.

Fabien added a subscriber: Fabien.
Fabien added inline comments.
57 ↗(On Diff #20389)

Nits (here and below): Comments on their own line

This revision is now accepted and ready to land.May 21 2020, 12:07