Skip to content

Commit fa974f1

Browse files
author
MarcoFalke
committed
scripted-diff: Remove redundant sync_all and sync_blocks
The sync calls are redundant after a call to generate, because generate already syncs itself. -BEGIN VERIFY SCRIPT- perl -0777 -pi -e 's/(generate[^\n]*\)[^\n]*)(\n|\s)+self.sync_(all|blocks)\([^\)]*\)\n/\1\n/g' $(git grep -l generate ./test) -END VERIFY SCRIPT-
1 parent fad1399 commit fa974f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+0
-160
lines changed

test/functional/feature_backwards_compatibility.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ def setup_nodes(self):
6666
def run_test(self):
6767
self.generatetoaddress(self.nodes[0], COINBASE_MATURITY + 1, self.nodes[0].getnewaddress())
6868

69-
self.sync_blocks()
70-
7169
# Sanity check the test framework:
7270
res = self.nodes[self.num_nodes - 1].getblockchaininfo()
7371
assert_equal(res['blocks'], COINBASE_MATURITY + 1)
@@ -93,15 +91,13 @@ def run_test(self):
9391
self.nodes[0].sendtoaddress(address, 10)
9492
self.sync_mempools()
9593
self.generate(self.nodes[0], 1)
96-
self.sync_blocks()
9794
# Create a conflicting transaction using RBF
9895
return_address = self.nodes[0].getnewaddress()
9996
tx1_id = self.nodes[1].sendtoaddress(return_address, 1)
10097
tx2_id = self.nodes[1].bumpfee(tx1_id)["txid"]
10198
# Confirm the transaction
10299
self.sync_mempools()
103100
self.generate(self.nodes[0], 1)
104-
self.sync_blocks()
105101
# Create another conflicting transaction using RBF
106102
tx3_id = self.nodes[1].sendtoaddress(return_address, 1)
107103
tx4_id = self.nodes[1].bumpfee(tx3_id)["txid"]

test/functional/feature_blockfilterindex_prune.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ def run_test(self):
2626
assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getbestblockhash())['filter']), 0)
2727
# Mine two batches of blocks to avoid hitting NODE_NETWORK_LIMITED_MIN_BLOCKS disconnection
2828
self.generate(self.nodes[0], 250)
29-
self.sync_all()
3029
self.generate(self.nodes[0], 250)
31-
self.sync_all()
3230
self.sync_index(height=700)
3331

3432
self.log.info("prune some blocks")

test/functional/feature_coinstatsindex.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ def _test_coin_stats_index(self):
7272
node.sendtoaddress(address=address, amount=10, subtractfeefromamount=True)
7373
self.generate(node, 1)
7474

75-
self.sync_blocks(timeout=120)
76-
7775
self.log.info("Test that gettxoutsetinfo() output is consistent with or without coinstatsindex option")
7876
res0 = node.gettxoutsetinfo('none')
7977

@@ -170,7 +168,6 @@ def _test_coin_stats_index(self):
170168

171169
# Include both txs in a block
172170
self.generate(self.nodes[0], 1)
173-
self.sync_all()
174171

175172
for hash_option in index_hash_options:
176173
# Check all amounts were registered correctly
@@ -271,7 +268,6 @@ def _test_reorg_index(self):
271268
# Add another block, so we don't depend on reconsiderblock remembering which
272269
# blocks were touched by invalidateblock
273270
self.generate(index_node, 1)
274-
self.sync_all()
275271

276272
# Ensure that removing and re-adding blocks yields consistent results
277273
block = index_node.getblockhash(99)

test/functional/feature_fee_estimation.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ def transact_and_mine(self, numblocks, mining_node):
218218
self.fees_per_kb.append(float(fee) / tx_kbytes)
219219
self.sync_mempools(wait=.1)
220220
mined = mining_node.getblock(self.generate(mining_node, 1)[0], True)["tx"]
221-
self.sync_blocks(wait=.1)
222221
# update which txouts are confirmed
223222
newmem = []
224223
for utx in self.memutxo:
@@ -278,8 +277,6 @@ def sanity_check_estimates_range(self):
278277
# Finish by mining a normal-sized block:
279278
while len(self.nodes[1].getrawmempool()) > 0:
280279
self.generate(self.nodes[1], 1)
281-
282-
self.sync_blocks(self.nodes[0:3], wait=.1)
283280
self.log.info("Final estimates after emptying mempools")
284281
check_estimates(self.nodes[1], self.fees_per_kb)
285282

@@ -322,7 +319,6 @@ def sanity_check_rbf_estimates(self, utxos):
322319
for txid in txids_to_replace:
323320
miner.prioritisetransaction(txid=txid, fee_delta=-COIN)
324321
self.generate(miner, 1)
325-
self.sync_blocks(wait=.1, nodes=[node, miner])
326322
# RBF the low-fee transactions
327323
while True:
328324
try:
@@ -334,7 +330,6 @@ def sanity_check_rbf_estimates(self, utxos):
334330
# Mine the last replacement txs
335331
self.sync_mempools(wait=.1, nodes=[node, miner])
336332
self.generate(miner, 1)
337-
self.sync_blocks(wait=.1, nodes=[node, miner])
338333

339334
# Only 10% of the transactions were really confirmed with a low feerate,
340335
# the rest needed to be RBF'd. We must return the 90% conf rate feerate.

test/functional/feature_notifications.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ def run_test(self):
112112
self.log.info("test -walletnotify with conflicting transactions")
113113
self.nodes[0].rescanblockchain()
114114
self.generatetoaddress(self.nodes[0], 100, ADDRESS_BCRT1_UNSPENDABLE)
115-
self.sync_blocks()
116115

117116
# Generate transaction on node 0, sync mempools, and check for
118117
# notification on node 1.

test/functional/feature_segwit.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,13 @@ def run_test(self):
191191
p2sh_ids[n][v].append(send_to_witness(v, self.nodes[0], find_spendable_utxo(self.nodes[0], 50), self.pubkey[n], True, Decimal("49.999")))
192192

193193
self.generate(self.nodes[0], 1) # block 163
194-
self.sync_blocks()
195194

196195
# Make sure all nodes recognize the transactions as theirs
197196
assert_equal(self.nodes[0].getbalance(), balance_presetup - 60 * 50 + 20 * Decimal("49.999") + 50)
198197
assert_equal(self.nodes[1].getbalance(), 20 * Decimal("49.999"))
199198
assert_equal(self.nodes[2].getbalance(), 20 * Decimal("49.999"))
200199

201200
self.generate(self.nodes[0], 260) # block 423
202-
self.sync_blocks()
203201

204202
self.log.info("Verify witness txs are skipped for mining before the fork")
205203
self.skip_mine(self.nodes[2], wit_ids[NODE_2][P2WPKH][0], True) # block 424
@@ -216,7 +214,6 @@ def run_test(self):
216214
self.log.info("Verify previous witness txs skipped for mining can now be mined")
217215
assert_equal(len(self.nodes[2].getrawmempool()), 4)
218216
blockhash = self.generate(self.nodes[2], 1)[0] # block 432 (first block with new rules; 432 = 144 * 3)
219-
self.sync_blocks()
220217
assert_equal(len(self.nodes[2].getrawmempool()), 0)
221218
segwit_tx_list = self.nodes[2].getblock(blockhash)["tx"]
222219
assert_equal(len(segwit_tx_list), 5)
@@ -630,7 +627,6 @@ def mine_and_test_listunspent(self, script_list, ismine):
630627
signresults = self.nodes[0].signrawtransactionwithwallet(tx.serialize_without_witness().hex())['hex']
631628
txid = self.nodes[0].sendrawtransaction(hexstring=signresults, maxfeerate=0)
632629
txs_mined[txid] = self.generate(self.nodes[0], 1)[0]
633-
self.sync_blocks()
634630
watchcount = 0
635631
spendcount = 0
636632
for i in self.nodes[0].listunspent():
@@ -680,7 +676,6 @@ def create_and_mine_tx_from_txids(self, txids, success=True):
680676
signresults = self.nodes[0].signrawtransactionwithwallet(tx.serialize_without_witness().hex())['hex']
681677
self.nodes[0].sendrawtransaction(hexstring=signresults, maxfeerate=0)
682678
self.generate(self.nodes[0], 1)
683-
self.sync_blocks()
684679

685680

686681
if __name__ == '__main__':

test/functional/interface_rest.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ def run_test(self):
8181
not_related_address = "2MxqoHEdNQTyYeX1mHcbrrpzgojbosTpCvJ"
8282

8383
self.generate(self.nodes[0], 1)
84-
self.sync_all()
8584
self.generatetoaddress(self.nodes[1], 100, not_related_address)
86-
self.sync_all()
8785

8886
assert_equal(self.nodes[0].getbalance(), 50)
8987

@@ -108,7 +106,6 @@ def run_test(self):
108106
self.log.info("Query an unspent TXO using the /getutxos URI")
109107

110108
self.generatetoaddress(self.nodes[1], 1, not_related_address)
111-
self.sync_all()
112109
bb_hash = self.nodes[0].getbestblockhash()
113110

114111
assert_equal(self.nodes[1].getbalance(), Decimal("0.1"))
@@ -183,7 +180,6 @@ def run_test(self):
183180
assert_equal(len(json_obj['utxos']), 0)
184181

185182
self.generate(self.nodes[0], 1)
186-
self.sync_all()
187183

188184
json_obj = self.test_rest_request(f"/getutxos/{spending[0]}-{spending[1]}")
189185
assert_equal(len(json_obj['utxos']), 1)
@@ -204,7 +200,6 @@ def run_test(self):
204200
self.test_rest_request(f"/getutxos/checkmempool/{long_uri}", http_method='POST', status=200)
205201

206202
self.generate(self.nodes[0], 1) # generate block to not affect upcoming tests
207-
self.sync_all()
208203

209204
self.log.info("Test the /block, /blockhashbyheight and /headers URIs")
210205
bb_hash = self.nodes[0].getbestblockhash()
@@ -275,7 +270,6 @@ def run_test(self):
275270

276271
# See if we can get 5 headers in one response
277272
self.generate(self.nodes[1], 5)
278-
self.sync_all()
279273
json_obj = self.test_rest_request(f"/headers/5/{bb_hash}")
280274
assert_equal(len(json_obj), 5) # now we should have 5 header objects
281275

@@ -310,7 +304,6 @@ def run_test(self):
310304

311305
# Now mine the transactions
312306
newblockhash = self.generate(self.nodes[1], 1)
313-
self.sync_all()
314307

315308
# Check if the 3 tx show up in the new block
316309
json_obj = self.test_rest_request(f"/block/{newblockhash[0]}")

test/functional/interface_zmq.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ def test_basic(self):
190190
self.log.info(f"Generate {num_blocks} blocks (and {num_blocks} coinbase txes)")
191191
genhashes = self.generatetoaddress(self.nodes[0], num_blocks, ADDRESS_BCRT1_UNSPENDABLE)
192192

193-
self.sync_all()
194-
195193
for x in range(num_blocks):
196194
# Should receive the coinbase txid.
197195
txid = hashtx.receive()
@@ -353,7 +351,6 @@ def test_sequence(self):
353351
# removed from the mempool by the block mining it.
354352
mempool_size = len(self.nodes[0].getrawmempool())
355353
c_block = self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)[0]
356-
self.sync_all()
357354
# Make sure the number of mined transactions matches the number of txs out of mempool
358355
mempool_size_delta = mempool_size - len(self.nodes[0].getrawmempool())
359356
assert_equal(len(self.nodes[0].getblock(c_block)["tx"])-1, mempool_size_delta)
@@ -393,7 +390,6 @@ def test_sequence(self):
393390
# Other things may happen but aren't wallet-deterministic so we don't test for them currently
394391
self.nodes[0].reconsiderblock(best_hash)
395392
self.generatetoaddress(self.nodes[1], 1, ADDRESS_BCRT1_UNSPENDABLE)
396-
self.sync_all()
397393

398394
self.log.info("Evict mempool transaction by block conflict")
399395
orig_txid = self.nodes[0].sendtoaddress(address=self.nodes[0].getnewaddress(), amount=1.0, replaceable=True)

test/functional/mempool_packages.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ def run_test(self):
192192
# Check that prioritising a tx before it's added to the mempool works
193193
# First clear the mempool by mining a block.
194194
self.generate(self.nodes[0], 1)
195-
self.sync_blocks()
196195
assert_equal(len(self.nodes[0].getrawmempool()), 0)
197196
# Prioritise a transaction that has been mined, then add it back to the
198197
# mempool by using invalidateblock.
@@ -283,7 +282,6 @@ def run_test(self):
283282
# Test reorg handling
284283
# First, the basics:
285284
self.generate(self.nodes[0], 1)
286-
self.sync_blocks()
287285
self.nodes[1].invalidateblock(self.nodes[0].getbestblockhash())
288286
self.nodes[1].reconsiderblock(self.nodes[0].getbestblockhash())
289287

@@ -330,7 +328,6 @@ def run_test(self):
330328

331329
# Mine these in a block
332330
self.generate(self.nodes[0], 1)
333-
self.sync_all()
334331

335332
# Now generate tx8, with a big fee
336333
inputs = [ {'txid' : tx1_id, 'vout': 0}, {'txid' : txid, 'vout': 0} ]

test/functional/mining_getblocktemplate_longpoll.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def run_test(self):
6464

6565
# Add enough mature utxos to the wallets, so that all txs spend confirmed coins
6666
self.generate(self.nodes[0], COINBASE_MATURITY)
67-
self.sync_blocks()
6867

6968
self.log.info("Test that introducing a new transaction into the mempool will terminate the longpoll")
7069
thr = LongpollThread(self.nodes[0])

0 commit comments

Comments
 (0)