Skip to content

Conversation

@jnewbery
Copy link
Contributor

@jnewbery jnewbery commented Dec 7, 2017

Add assert that only one NetworkThread exists at any time in functional tests, and fix cases where that wasn't true.

fixes #11776

@laanwj laanwj added the Tests label Dec 7, 2017
@meshcollider
Copy link
Contributor

utACK 5a201ed

@ryanofsky
Copy link
Contributor

Seems like an easy mistake to make. Could you add a check to make it fail reliably?

@jnewbery
Copy link
Contributor Author

jnewbery commented Dec 8, 2017

Seems like an easy mistake to make. Could you add a check to make it fail reliably?

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.

@jnewbery jnewbery changed the title [tests] fix example_test [tests] Assert that only one NetworkThread exists Dec 8, 2017
Copy link
Contributor

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?

Copy link
Contributor Author

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.
@jnewbery
Copy link
Contributor Author

rebased

@laanwj
Copy link
Member

laanwj commented Dec 12, 2017

Good idea. utACK 5c8ff26

@laanwj laanwj merged commit 5c8ff26 into bitcoin:master Dec 12, 2017
laanwj added a commit that referenced this pull request Dec 12, 2017
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
codablock pushed a commit to codablock/dash that referenced this pull request Oct 3, 2019
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[qa] example_test.py failed

5 participants