Skip to content

Conversation

vasild
Copy link
Contributor

@vasild vasild commented Jan 4, 2023

Add unit tests that write data to a mocked socket and inspect what CConnman/PeerManager have written back to the socket, or check the internal state to verify that the behavior is as expected.

This is now possible, after most of #21878 has been merged - we don't do any syscalls (e.g. connect(), recv()) from the high level code and using a mocked socket allows testing the entire networking stack without opening actual network connections.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 4, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/26812.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK Sjors
Stale ACK jonatack

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #33300 (fuzz: compact block harness by Crypt-iQ)
  • #33210 (fuzz: enhance wallet_fees by mocking mempool stuff by brunoerg)
  • #33191 (net: Provide block templates to peers on request by ajtowns)
  • #32747 (Introduce SockMan ("lite"): low-level socket handling for HTTP by pinheadmz)
  • #32724 (Musig2 tests by w0xlt)

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.

LLM Linter (✨ experimental)

Possible typos and grammar issues:

  • "Ensure initial messages exchange has completed..." -> "Ensure initial message exchange has completed..." [plural "messages exchange" is ungrammatical; use "message exchange" to mean the exchange of initial messages]

drahtbot_id_5_m

@DrahtBot DrahtBot added the Tests label Jan 4, 2023
@vasild
Copy link
Contributor Author

vasild commented Jan 12, 2023

9b7e9dad27...daee83c1c5: optimize the fuzz test a bit

@vasild
Copy link
Contributor Author

vasild commented Feb 9, 2023

32ab679f54...7c591c868d: rebase due to conflicts

@vasild
Copy link
Contributor Author

vasild commented Feb 20, 2023

7c591c868d...a81fe4ff9b: rebase and put the fuzz tests in fuzz/process_message.cpp instead of in a new file, as suggested.

@vasild
Copy link
Contributor Author

vasild commented Mar 20, 2025

53d2c8e0e2...c1c6a056a0: rebase due to conflicts

@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed.
Task tidy: https://github.com/bitcoin/bitcoin/runs/39128326309
LLM reason (✨ experimental): clang-tidy reported explicit errors due to deprecated headers in net_msg_tests.cpp, causing the CI to fail.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

@vasild
Copy link
Contributor Author

vasild commented Jun 13, 2025

c1c6a056a0...bfe72353c0: rebase and silence a new tidy error about headers - assert.h vs cassert

@vasild
Copy link
Contributor Author

vasild commented Sep 2, 2025

bfe72353c0...5d7b70161d: rebase due to conflicts

glozow added a commit that referenced this pull request Sep 23, 2025
2427939 test: forbid copying of DebugLogHelper (Daniel Pfeifer)
d6aa266 test: don't throw from the destructor of DebugLogHelper (Vasil Dimov)

Pull request description:

  Throwing an exception from the destructor of a class is a bad practice because the destructor will be called when an object of that type is alive on the stack and another exception is thrown, which will result in "exception during the exception". This would terminate the program without any messages.

  Instead print the message to the standard error output and call `std::abort()`.

  ---

  This change is part of #26812. It is an improvement on its own, so creating a separate PR for it following the discussion at #32604 (comment). Getting it in will reduce the size of #26812.

ACKs for top commit:
  Crypt-iQ:
    crACK 2427939
  l0rinc:
    Code review reACK 2427939
  optout21:
    crACK 2427939
  furszy:
    utACK 2427939

Tree-SHA512: 918c1e40d2db4ded6213cd78a18490ad10a9f43c0533df64bdf09f0b216715415030e444712981e4407c32ebf552fbb0e3cce718e048df10c2b8937caf015564
Extend `DebugLogHelper::~DebugLogHelper()` to be able to
optionally wait for messages, possibly logged from another thread, to
arrive before performing the final check.
…anager

Add tests that use a mocked socket to similate network IO and cover the
full `CConnman`, `PeerManager` and the interaction between them.
@vasild
Copy link
Contributor Author

vasild commented Sep 24, 2025

5d7b70161d...e4e13ce4c0: rebase due to conflicts

Part of this PR was merged via #33388, so drop that bit from here. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants