-
Notifications
You must be signed in to change notification settings - Fork 38.7k
[tests] Assert that only one NetworkThread exists #11849
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
|
utACK 5a201ed |
|
Seems like an easy mistake to make. Could you add a check to make it fail reliably? |
5a201ed to
08a6900
Compare
Excellent idea. I've repurposed this PR to add checking that only one NetworkThread is created. The extra checks have caught three additional potential bugs/races. |
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.
Why not keep this instance and check for it, instead of enumerating threads with a custom name?
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.
I can't see how that's any better. Perhaps you can push a branch to demonstrate what you mean.
Add network thread_start(), network_thread_running() and network_thread_join() utility functions in mininode.py and use network_thread_running() in network thread assertions.
assumevalid.py, example_test.py and p2p-acceptblocks.py add p2p_connections after the NetworkThread has been started. This isn't permitted. Fix test to restart the network thread when adding new connections. p2p-leaktest.py had a potential race condition if the NetworkThread hadn't terminated by the time we tried to restart it.
Check that P2PConnections aren't created after the NetworkThread has started and that at any time only one NetworkThread is running.
08a6900 to
5c8ff26
Compare
|
rebased |
|
Good idea. utACK 5c8ff26 |
5c8ff26 [tests] Add NetworkThread assertions (John Newbery) 34e08b3 [tests] Fix network threading in functional tests (John Newbery) 74e64f2 [tests] Use network_thread_start() in tests. (John Newbery) 5fc6e71 [tests] Add network_thread_ utility functions. (John Newbery) Pull request description: Add assert that only one NetworkThread exists at any time in functional tests, and fix cases where that wasn't true. fixes #11776 Tree-SHA512: fe5d1c59005f94bf66e11bb23ccf274b1cd9913741b56ea11dbcd21db4cc0b53b4413c0c4c16dbcd6ac611adad5e5cc2baaa39720598ce7b6393889945d06298
5c8ff26 [tests] Add NetworkThread assertions (John Newbery) 34e08b3 [tests] Fix network threading in functional tests (John Newbery) 74e64f2 [tests] Use network_thread_start() in tests. (John Newbery) 5fc6e71 [tests] Add network_thread_ utility functions. (John Newbery) Pull request description: Add assert that only one NetworkThread exists at any time in functional tests, and fix cases where that wasn't true. fixes bitcoin#11776 Tree-SHA512: fe5d1c59005f94bf66e11bb23ccf274b1cd9913741b56ea11dbcd21db4cc0b53b4413c0c4c16dbcd6ac611adad5e5cc2baaa39720598ce7b6393889945d06298
Add assert that only one NetworkThread exists at any time in functional tests, and fix cases where that wasn't true.
fixes #11776