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

-4
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

-2
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

-4
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

-5
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

-1
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

-5
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

-7
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

-4
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

-3
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

-1
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])

test/functional/p2p_blockfilters.py

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def run_test(self):
5757

5858
# Nodes 0 & 1 share the same first 999 blocks in the chain.
5959
self.generate(self.nodes[0], 999)
60-
self.sync_blocks(timeout=600)
6160

6261
# Stale blocks by disconnecting nodes 0 & 1, mining, then reconnecting
6362
self.disconnect_nodes(0, 1)

test/functional/p2p_compactblocks_hb.py

-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def relay_block_through(self, peer):
3131
"""Relay a new block through peer peer, and return HB status between 1 and [2,3,4,5]."""
3232
self.connect_nodes(peer, 0)
3333
self.generate(self.nodes[0], 1)
34-
self.sync_blocks()
3534
self.disconnect_nodes(peer, 0)
3635
status_to = [self.peer_info(1, i)['bip152_hb_to'] for i in range(2, 6)]
3736
status_from = [self.peer_info(i, 1)['bip152_hb_from'] for i in range(2, 6)]
@@ -45,7 +44,6 @@ def run_test(self):
4544
for i in range(1, 6):
4645
self.connect_nodes(i, 0)
4746
self.generate(self.nodes[0], 2)
48-
self.sync_blocks()
4947
for i in range(1, 6):
5048
self.disconnect_nodes(i, 0)
5149

test/functional/p2p_ibd_txrelay.py

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def run_test(self):
3030

3131
# Come out of IBD by generating a block
3232
self.generate(self.nodes[0], 1)
33-
self.sync_all()
3433

3534
self.log.info("Check that nodes reset minfilter after coming out of IBD")
3635
for node in self.nodes:

test/functional/p2p_permissions.py

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def run_test(self):
9494

9595
def check_tx_relay(self):
9696
block_op_true = self.nodes[0].getblock(self.generatetoaddress(self.nodes[0], 100, ADDRESS_BCRT1_P2WSH_OP_TRUE)[0])
97-
self.sync_all()
9897

9998
self.log.debug("Create a connection from a forcerelay peer that rebroadcasts raw txs")
10099
# A test framework p2p connection is needed to send the raw transaction directly. If a full node was used, it could only

test/functional/p2p_segwit.py

-7
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,6 @@ def test_standardness_v0(self):
578578
# Mine it on test_node to create the confirmed output.
579579
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_tx, with_witness=True, accepted=True)
580580
self.generate(self.nodes[0], 1)
581-
self.sync_blocks()
582581

583582
# Now test standardness of v0 P2WSH outputs.
584583
# Start by creating a transaction with two outputs.
@@ -651,7 +650,6 @@ def test_standardness_v0(self):
651650
test_transaction_acceptance(self.nodes[0], self.test_node, tx3, with_witness=True, accepted=True)
652651

653652
self.generate(self.nodes[0], 1)
654-
self.sync_blocks()
655653
self.utxo.pop(0)
656654
self.utxo.append(UTXO(tx3.sha256, 0, tx3.vout[0].nValue))
657655
assert_equal(len(self.nodes[1].getrawmempool()), 0)
@@ -1354,7 +1352,6 @@ def test_segwit_versions(self):
13541352
temp_utxo.append(UTXO(tx.sha256, 0, tx.vout[0].nValue))
13551353

13561354
self.generate(self.nodes[0], 1) # Mine all the transactions
1357-
self.sync_blocks()
13581355
assert len(self.nodes[0].getrawmempool()) == 0
13591356

13601357
# Finally, verify that version 0 -> version 2 transactions
@@ -1425,7 +1422,6 @@ def test_premature_coinbase_witness_spend(self):
14251422

14261423
# Now test a premature spend.
14271424
self.generate(self.nodes[0], 98)
1428-
self.sync_blocks()
14291425
block2 = self.build_next_block()
14301426
self.update_witness_block_with_transactions(block2, [spend_tx])
14311427
test_witness_block(self.nodes[0], self.test_node, block2, accepted=False, reason='bad-txns-premature-spend-of-coinbase')
@@ -1744,7 +1740,6 @@ def test_non_standard_witness_blinding(self):
17441740
tx.rehash()
17451741
test_transaction_acceptance(self.nodes[0], self.test_node, tx, False, True)
17461742
self.generate(self.nodes[0], 1)
1747-
self.sync_blocks()
17481743

17491744
# We'll add an unnecessary witness to this transaction that would cause
17501745
# it to be non-standard, to test that violating policy with a witness
@@ -1773,7 +1768,6 @@ def test_non_standard_witness_blinding(self):
17731768
test_transaction_acceptance(self.nodes[0], self.test_node, tx3, False, True)
17741769

17751770
self.generate(self.nodes[0], 1)
1776-
self.sync_blocks()
17771771

17781772
# Update our utxo list; we spent the first entry.
17791773
self.utxo.pop(0)
@@ -1808,7 +1802,6 @@ def test_non_standard_witness(self):
18081802
test_transaction_acceptance(self.nodes[0], self.test_node, tx, with_witness=False, accepted=True)
18091803

18101804
self.generate(self.nodes[0], 1)
1811-
self.sync_blocks()
18121805

18131806
# Creating transactions for tests
18141807
p2wsh_txs = []

test/functional/p2p_sendheaders.py

-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ def mine_reorg(self, length):
217217

218218
# make sure all invalidated blocks are node0's
219219
self.generatetoaddress(self.nodes[0], length, self.nodes[0].get_deterministic_priv_key().address)
220-
self.sync_blocks(self.nodes, wait=0.1)
221220
for x in self.nodes[0].p2ps:
222221
x.wait_for_block_announcement(int(self.nodes[0].getbestblockhash(), 16))
223222
x.clear_block_announcements()
@@ -226,7 +225,6 @@ def mine_reorg(self, length):
226225
hash_to_invalidate = self.nodes[1].getblockhash(tip_height - (length - 1))
227226
self.nodes[1].invalidateblock(hash_to_invalidate)
228227
all_hashes = self.generatetoaddress(self.nodes[1], length + 1, self.nodes[1].get_deterministic_priv_key().address) # Must be longer than the orig chain
229-
self.sync_blocks(self.nodes, wait=0.1)
230228
return [int(x, 16) for x in all_hashes]
231229

232230
def run_test(self):

test/functional/rpc_createmultisig.py

-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def run_test(self):
4646

4747
self.log.info('Generating blocks ...')
4848
self.generate(node0, 149)
49-
self.sync_all()
5049

5150
self.moved = 0
5251
for self.nkeys in [3, 5]:
@@ -117,7 +116,6 @@ def check_addmultisigaddress_errors(self):
117116
def checkbalances(self):
118117
node0, node1, node2 = self.nodes
119118
self.generate(node0, COINBASE_MATURITY)
120-
self.sync_all()
121119

122120
bal0 = node0.getbalance()
123121
bal1 = node1.getbalance()

0 commit comments

Comments
 (0)