Merge bitcoin/bitcoin#24739: test: Fix intermittent test failure in wallet_listreceivedby.py

fa1f6df21e test: Fix intermittent test failure in wallet_listreceivedby.py (MarcoFalke)

Pull request description:

  * Remove not needed "Generate block to get out of IBD"
  * Sync blocks where possible to avoid incoming blocks on the p2p `msghand` thread while blocks are mined in the RPC thread. See https://github.com/bitcoin/bitcoin/issues/24730 for discussion.

Top commit has no ACKs.

Tree-SHA512: eca0242e7793886535555fec62f7acd4c0955bf26fab78725b4fe53f84f0b118cb12c9ee35627503fc68b83c3a228842e861fab89aab1226e08e18596357aaae
This commit is contained in:
MacroFake 2022-04-27 08:44:18 +02:00
commit f58c1f1a44
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -26,9 +26,6 @@ class ReceivedByTest(BitcoinTestFramework):
self.skip_if_no_cli() self.skip_if_no_cli()
def run_test(self): def run_test(self):
# Generate block to get out of IBD
self.generate(self.nodes[0], 1)
# save the number of coinbase reward addresses so far # save the number of coinbase reward addresses so far
num_cb_reward_addresses = len(self.nodes[1].listreceivedbyaddress(minconf=0, include_empty=True, include_watchonly=True)) num_cb_reward_addresses = len(self.nodes[1].listreceivedbyaddress(minconf=0, include_empty=True, include_watchonly=True))
@ -172,7 +169,7 @@ class ReceivedByTest(BitcoinTestFramework):
address = self.nodes[0].getnewaddress(label) address = self.nodes[0].getnewaddress(label)
reward = Decimal("25") reward = Decimal("25")
self.generatetoaddress(self.nodes[0], 1, address, sync_fun=self.no_op) self.generatetoaddress(self.nodes[0], 1, address)
hash = self.nodes[0].getbestblockhash() hash = self.nodes[0].getbestblockhash()
self.log.info("getreceivedbyaddress returns nothing with defaults") self.log.info("getreceivedbyaddress returns nothing with defaults")
@ -212,7 +209,7 @@ class ReceivedByTest(BitcoinTestFramework):
{"label": label, "amount": reward}) {"label": label, "amount": reward})
self.log.info("Generate 100 more blocks") self.log.info("Generate 100 more blocks")
self.generate(self.nodes[0], COINBASE_MATURITY, sync_fun=self.no_op) self.generate(self.nodes[0], COINBASE_MATURITY)
self.log.info("getreceivedbyaddress returns reward with defaults") self.log.info("getreceivedbyaddress returns reward with defaults")
balance = self.nodes[0].getreceivedbyaddress(address) balance = self.nodes[0].getreceivedbyaddress(address)