Closes: #19080
This PR creates a wait_until method for the BitcoinTestFramework class, and replaces all uses of the global wait_until with the class method. If applicable, the mininode wait_until is used instead.
15 | from test_framework.util import ( 16 | assert_equal, 17 | disconnect_nodes, 18 | - connect_nodes, 19 | - wait_until, 20 | + connect_nodes
Any reason to remove the trailing comma in this line? (Same in the other changes)
No reason, I have since added back the trailing commas.
67 | + node0.wait_until(lambda: self.nodes[0].getblockcount() == 1000) 68 | stale_block_hash = self.nodes[0].getblockhash(1000) 69 | 70 | self.nodes[1].generate(1001) 71 | - wait_until(lambda: self.nodes[1].getblockcount() == 2000) 72 | + node1.wait_until(lambda: self.nodes[1].getblockcount() == 2000)
node1 is a mininode. self.nodes[1] is a TestNode.
It might be best to add a def wait_until(self, ...): to the test framework.
self.wait_until(lambda: self.nodes[1].getblockcount() == 2000)
Concept ACK
Concept ACK
In keeping with the goal of this PR, I also recommend changing the wait in feature_abortnode.py here to use wait_until_node_stopped so that it uses the test_node timeout factor.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
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.
82 | - def wait_for_block_announcement(self, block_hash, timeout=30): 83 | + def wait_for_block_announcement(self, block_hash): 84 | def received_hash(): 85 | return (block_hash in self.announced_blockhashes) 86 | - wait_until(received_hash, timeout=timeout, lock=mininode_lock) 87 | + self.wait_until(received_hash,)
Remove , if no other arguments being passed in.
97 | # Check that get*info() shows the versionbits unknown rules warning 98 | assert WARN_UNKNOWN_RULES_ACTIVE in node.getmininginfo()["warnings"] 99 | assert WARN_UNKNOWN_RULES_ACTIVE in node.getnetworkinfo()["warnings"] 100 | # Check that the alert file shows the versionbits unknown rules warning 101 | - wait_until(lambda: self.versionbits_in_alert_file(), timeout=60) 102 | + self.wait_until(lambda: self.versionbits_in_alert_file(), timeout=60)
You've defined the default as 60 seconds, so you can drop here and other places where you specify 60.
72 | @@ -73,23 +73,23 @@ def send_header_for_blocks(self, new_blocks): 73 | def request_headers_and_sync(self, locator, hashstop=0): 74 | self.clear_block_announcement() 75 | self.get_headers(locator, hashstop) 76 | - wait_until(self.received_block_announcement, timeout=30, lock=mininode_lock) 77 | + self.wait_until(self.received_block_announcement)
Also re the default timeout, are you intending to change these non-60 timeouts throughout?
No I was not. Thank you for the careful review, it's very helpful as I am still learning!
Concept ACK. A few questions on when you specify and omit timeouts.
Please squash your commits according to https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits
Concept ACK. Needs squash and rebase.
Concept ACK
I think you missed test/functional/p2p_ping.py. And in your current commit order you are using the TestFramework wait_until before it is added. But I am not sure if that is viewed as critical (so nit). Otherwise lgtm.
<!--cf906140f33d8803c4a75a2196329ecb-->
🐙 This pull request conflicts with the target branch and needs rebase.
@dboures Are you still working on this?
Going to close this as "up for grabs". @dboures Feel free to open a new pull request once you have all the code ready for review.