Skip to content

Commit 69e35f5

Browse files
committed
Merge bitcoin/bitcoin#31403: test: Call generate RPCs through test framework only
fa6e599 test: Call generate through test framework only (MarcoFalke) Pull request description: The generate RPCs are special in that they should only be called by the test framework itself. This way, they will call the sync function on the nodes, which can avoid intermittent test issues. Also, when the sync is disabled, it will happen explicitly by setting the `sync_fun`. Apply this rule here, so that all generate calls are written consistently. ACKs for top commit: achow101: ACK fa6e599 rkrux: tACK fa6e599 hodlinator: ACK fa6e599 i-am-yuvi: Tested ACK fa6e599 Tree-SHA512: 31079997f1e17031ecd577904457e0560388aa53cadb1bbda281865271e8e4cf244bc6bf315838a717bf9d6620c201093e30039aa0007bec3629f7ca56abfba3
2 parents 17db84d + fa6e599 commit 69e35f5

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

test/functional/mempool_ephemeral_dust.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def test_reorgs(self):
325325
dusty_tx, _ = self.create_ephemeral_dust_package(tx_version=3)
326326
assert_raises_rpc_error(-26, "min relay fee not met", self.nodes[0].sendrawtransaction, dusty_tx["hex"])
327327

328-
block_res = self.nodes[0].rpc.generateblock(self.wallet.get_address(), [dusty_tx["hex"]])
328+
block_res = self.generateblock(self.nodes[0], self.wallet.get_address(), [dusty_tx["hex"]], sync_fun=self.no_op)
329329
self.nodes[0].invalidateblock(block_res["hash"])
330330
assert_mempool_contents(self, self.nodes[0], expected=[dusty_tx["tx"]], sync=False)
331331

@@ -335,7 +335,7 @@ def test_reorgs(self):
335335
assert_raises_rpc_error(-26, "min relay fee not met", self.nodes[0].sendrawtransaction, sweep_tx["hex"])
336336

337337
# Mine the sweep then re-org, the sweep will not make it back in due to spend checks
338-
block_res = self.nodes[0].rpc.generateblock(self.wallet.get_address(), [dusty_tx["hex"], sweep_tx["hex"]])
338+
block_res = self.generateblock(self.nodes[0], self.wallet.get_address(), [dusty_tx["hex"], sweep_tx["hex"]], sync_fun=self.no_op)
339339
self.nodes[0].invalidateblock(block_res["hash"])
340340
assert_mempool_contents(self, self.nodes[0], expected=[dusty_tx["tx"]], sync=False)
341341

@@ -344,7 +344,7 @@ def test_reorgs(self):
344344
self.add_output_to_create_multi_result(sweep_tx_2)
345345
assert_raises_rpc_error(-26, "min relay fee not met", self.nodes[0].sendrawtransaction, sweep_tx_2["hex"])
346346

347-
reconsider_block_res = self.nodes[0].rpc.generateblock(self.wallet.get_address(), [dusty_tx["hex"], sweep_tx_2["hex"]])
347+
reconsider_block_res = self.generateblock(self.nodes[0], self.wallet.get_address(), [dusty_tx["hex"], sweep_tx_2["hex"]], sync_fun=self.no_op)
348348
self.nodes[0].invalidateblock(reconsider_block_res["hash"])
349349
assert_mempool_contents(self, self.nodes[0], expected=[dusty_tx["tx"], sweep_tx_2["tx"]], sync=False)
350350

@@ -357,13 +357,13 @@ def test_reorgs(self):
357357

358358
self.log.info("Test that ephemeral dust tx with fees or multi dust don't enter mempool via reorg")
359359
multi_dusty_tx, _ = self.create_ephemeral_dust_package(tx_version=3, num_dust_outputs=2)
360-
block_res = self.nodes[0].rpc.generateblock(self.wallet.get_address(), [multi_dusty_tx["hex"]])
360+
block_res = self.generateblock(self.nodes[0], self.wallet.get_address(), [multi_dusty_tx["hex"]], sync_fun=self.no_op)
361361
self.nodes[0].invalidateblock(block_res["hash"])
362362
assert_equal(self.nodes[0].getrawmempool(), [])
363363

364364
# With fee and one dust
365365
dusty_fee_tx, _ = self.create_ephemeral_dust_package(tx_version=3, dust_tx_fee=1)
366-
block_res = self.nodes[0].rpc.generateblock(self.wallet.get_address(), [dusty_fee_tx["hex"]])
366+
block_res = self.generateblock(self.nodes[0], self.wallet.get_address(), [dusty_fee_tx["hex"]], sync_fun=self.no_op)
367367
self.nodes[0].invalidateblock(block_res["hash"])
368368
assert_equal(self.nodes[0].getrawmempool(), [])
369369

test/functional/rpc_getdescriptoractivity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def run_test(self):
2020
node = self.nodes[0]
2121
wallet = MiniWallet(node)
2222
node.setmocktime(node.getblockheader(node.getbestblockhash())['time'])
23-
wallet.generate(200, invalid_call=False)
23+
self.generate(wallet, 200)
2424

2525
self.test_no_activity(node)
2626
self.test_activity_in_block(node, wallet)
@@ -195,7 +195,7 @@ def test_receive_then_spend(self, node, wallet):
195195

196196
def test_no_address(self, node, wallet):
197197
raw_wallet = MiniWallet(self.nodes[0], mode=MiniWalletMode.RAW_P2PK)
198-
raw_wallet.generate(100, invalid_call=False)
198+
self.generate(raw_wallet, 100)
199199

200200
no_addr_tx = raw_wallet.send_self_transfer(from_node=node)
201201
raw_desc = raw_wallet.get_descriptor()

test/functional/wallet_migration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2020-2022 The Bitcoin Core developers
2+
# Copyright (c) 2020-present The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test Migrating a wallet from legacy to descriptor."""
@@ -463,7 +463,7 @@ def test_pk_coinbases(self):
463463
addr_info = wallet.getaddressinfo(addr)
464464
desc = descsum_create("pk(" + addr_info["pubkey"] + ")")
465465

466-
self.master_node.generatetodescriptor(1, desc, invalid_call=False)
466+
self.generatetodescriptor(self.master_node, 1, desc)
467467

468468
bals = wallet.getbalances()
469469

0 commit comments

Comments
 (0)