Page MenuHomePhabricator

Merge #14522: tests: add invalid P2P message tests
ClosedPublic

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

Details

Summary

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 p2p_invalid_messages.py: 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

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

Event Timeline

jasonbcox created this revision.Wed, May 20, 21:09
Herald added a reviewer: Restricted Project. · View Herald TranscriptWed, May 20, 21:09
jasonbcox requested review of this revision.Wed, May 20, 21:09
teamcity edited the summary of this revision. (Show Details)Wed, May 20, 21:09

[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 accepted this revision.Thu, May 21, 12:07
Fabien added a subscriber: Fabien.
Fabien added inline comments.
test/functional/p2p_invalid_messages.py
57 ↗(On Diff #20389)

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

This revision is now accepted and ready to land.Thu, May 21, 12:07
deadalnix accepted this revision.Thu, May 21, 12:08
jasonbcox updated this revision to Diff 20469.Thu, May 21, 16:26

Fix nits