Skip to content

Commit fa16a09

Browse files
author
MarcoFalke
committed
scripted-diff: use self.sync_* methods
-BEGIN VERIFY SCRIPT- sed -i -e 's/sync_blocks(self.nodes)/self.sync_blocks()/g' $(git grep -l 'sync_blocks(self.nodes)' ./test/functional/*.py) sed -i -e 's/sync_mempools(self.nodes)/self.sync_mempools()/g' $(git grep -l 'sync_mempools(self.nodes)' ./test/functional/*.py) sed -i -e 's/ sync_blocks(/ self.sync_blocks(/g' $(git grep -l sync_blocks ./test/functional/*.py) sed -i -e 's/ sync_mempools(/ self.sync_mempools(/g' $(git grep -l sync_mempools ./test/functional/*.py) -END VERIFY SCRIPT-
1 parent faf77f9 commit fa16a09

24 files changed

+86
-86
lines changed

test/functional/feature_bip68_sequence.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def activateCSV(self):
385385
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], "locked_in")
386386
self.nodes[0].generate(1)
387387
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], "active")
388-
sync_blocks(self.nodes)
388+
self.sync_blocks()
389389

390390
# Use self.nodes[1] to test that version 2 transactions are standard.
391391
def test_version2_relay(self):

test/functional/feature_fee_estimation.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ def transact_and_mine(self, numblocks, mining_node):
162162
self.memutxo, Decimal("0.005"), min_fee, min_fee)
163163
tx_kbytes = (len(txhex) // 2) / 1000.0
164164
self.fees_per_kb.append(float(fee) / tx_kbytes)
165-
sync_mempools(self.nodes[0:3], wait=.1)
165+
self.sync_mempools(self.nodes[0:3], wait=.1)
166166
mined = mining_node.getblock(mining_node.generate(1)[0], True)["tx"]
167-
sync_blocks(self.nodes[0:3], wait=.1)
167+
self.sync_blocks(self.nodes[0:3], wait=.1)
168168
# update which txouts are confirmed
169169
newmem = []
170170
for utx in self.memutxo:
@@ -237,7 +237,7 @@ def run_test(self):
237237
while len(self.nodes[1].getrawmempool()) > 0:
238238
self.nodes[1].generate(1)
239239

240-
sync_blocks(self.nodes[0:3], wait=.1)
240+
self.sync_blocks(self.nodes[0:3], wait=.1)
241241
self.log.info("Final estimates after emptying mempools")
242242
check_estimates(self.nodes[1], self.fees_per_kb)
243243

test/functional/feature_pruning.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def setup_network(self):
100100
connect_nodes(self.nodes[0], 2)
101101
connect_nodes(self.nodes[0], 3)
102102
connect_nodes(self.nodes[0], 4)
103-
sync_blocks(self.nodes[0:5])
103+
self.sync_blocks(self.nodes[0:5])
104104

105105
def setup_nodes(self):
106106
self.add_nodes(self.num_nodes, self.extra_args)
@@ -111,13 +111,13 @@ def setup_nodes(self):
111111
def create_big_chain(self):
112112
# Start by creating some coinbases we can spend later
113113
self.nodes[1].generate(200)
114-
sync_blocks(self.nodes[0:2])
114+
self.sync_blocks(self.nodes[0:2])
115115
self.nodes[0].generate(150)
116116

117117
# Then mine enough full blocks to create more than 550MiB of data
118118
mine_large_blocks(self.nodes[0], 645)
119119

120-
sync_blocks(self.nodes[0:5])
120+
self.sync_blocks(self.nodes[0:5])
121121

122122
def test_height_min(self):
123123
assert os.path.isfile(os.path.join(self.prunedir, "blk00000.dat")), "blk00000.dat is missing, pruning too early"
@@ -153,7 +153,7 @@ def create_chain_with_staleblocks(self):
153153
# Create connections in the order so both nodes can see the reorg at the same time
154154
connect_nodes(self.nodes[0], 1)
155155
connect_nodes(self.nodes[0], 2)
156-
sync_blocks(self.nodes[0:3])
156+
self.sync_blocks(self.nodes[0:3])
157157

158158
self.log.info("Usage can be over target because of high stale rate: %d" % calc_usage(self.prunedir))
159159

@@ -190,7 +190,7 @@ def reorg_test(self):
190190
self.log.info("Reconnect nodes")
191191
connect_nodes(self.nodes[0], 1)
192192
connect_nodes(self.nodes[1], 2)
193-
sync_blocks(self.nodes[0:3], timeout=120)
193+
self.sync_blocks(self.nodes[0:3], timeout=120)
194194

195195
self.log.info("Verify height on node 2: %d" % self.nodes[2].getblockcount())
196196
self.log.info("Usage possibly still high because of stale blocks in block files: %d" % calc_usage(self.prunedir))
@@ -345,7 +345,7 @@ def wallet_test(self):
345345
self.log.info("Syncing node 5 to test wallet")
346346
connect_nodes(self.nodes[0], 5)
347347
nds = [self.nodes[0], self.nodes[5]]
348-
sync_blocks(nds, wait=5, timeout=300)
348+
self.sync_blocks(nds, wait=5, timeout=300)
349349
self.stop_node(5) # stop and start to trigger rescan
350350
self.start_node(5, extra_args=["-prune=550"])
351351
self.log.info("Success")

test/functional/feature_segwit.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ def success_mine(self, node, txid, sign, redeem_script=""):
7676
send_to_witness(1, node, getutxo(txid), self.pubkey[0], False, Decimal("49.998"), sign, redeem_script)
7777
block = node.generate(1)
7878
assert_equal(len(node.getblock(block[0])["tx"]), 2)
79-
sync_blocks(self.nodes)
79+
self.sync_blocks()
8080

8181
def skip_mine(self, node, txid, sign, redeem_script=""):
8282
send_to_witness(1, node, getutxo(txid), self.pubkey[0], False, Decimal("49.998"), sign, redeem_script)
8383
block = node.generate(1)
8484
assert_equal(len(node.getblock(block[0])["tx"]), 1)
85-
sync_blocks(self.nodes)
85+
self.sync_blocks()
8686

8787
def fail_accept(self, node, error_msg, txid, sign, redeem_script=""):
8888
assert_raises_rpc_error(-26, error_msg, send_to_witness, use_p2wsh=1, node=node, utxo=getutxo(txid), pubkey=self.pubkey[0], encode_p2sh=False, amount=Decimal("49.998"), sign=sign, insert_redeem_script=redeem_script)
@@ -131,15 +131,15 @@ def run_test(self):
131131
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")))
132132

133133
self.nodes[0].generate(1) # block 163
134-
sync_blocks(self.nodes)
134+
self.sync_blocks()
135135

136136
# Make sure all nodes recognize the transactions as theirs
137137
assert_equal(self.nodes[0].getbalance(), balance_presetup - 60 * 50 + 20 * Decimal("49.999") + 50)
138138
assert_equal(self.nodes[1].getbalance(), 20 * Decimal("49.999"))
139139
assert_equal(self.nodes[2].getbalance(), 20 * Decimal("49.999"))
140140

141141
self.nodes[0].generate(260) # block 423
142-
sync_blocks(self.nodes)
142+
self.sync_blocks()
143143

144144
self.log.info("Verify witness txs are skipped for mining before the fork")
145145
self.skip_mine(self.nodes[2], wit_ids[NODE_2][WIT_V0][0], True) # block 424
@@ -156,7 +156,7 @@ def run_test(self):
156156
self.log.info("Verify previous witness txs skipped for mining can now be mined")
157157
assert_equal(len(self.nodes[2].getrawmempool()), 4)
158158
blockhash = self.nodes[2].generate(1)[0] # block 432 (first block with new rules; 432 = 144 * 3)
159-
sync_blocks(self.nodes)
159+
self.sync_blocks()
160160
assert_equal(len(self.nodes[2].getrawmempool()), 0)
161161
segwit_tx_list = self.nodes[2].getblock(blockhash)["tx"]
162162
assert_equal(len(segwit_tx_list), 5)
@@ -538,7 +538,7 @@ def mine_and_test_listunspent(self, script_list, ismine):
538538
signresults = self.nodes[0].signrawtransactionwithwallet(tx.serialize_without_witness().hex())['hex']
539539
txid = self.nodes[0].sendrawtransaction(signresults, 0)
540540
txs_mined[txid] = self.nodes[0].generate(1)[0]
541-
sync_blocks(self.nodes)
541+
self.sync_blocks()
542542
watchcount = 0
543543
spendcount = 0
544544
for i in self.nodes[0].listunspent():
@@ -590,7 +590,7 @@ def create_and_mine_tx_from_txids(self, txids, success=True):
590590
signresults = self.nodes[0].signrawtransactionwithwallet(tx.serialize_without_witness().hex())['hex']
591591
self.nodes[0].sendrawtransaction(signresults, 0)
592592
self.nodes[0].generate(1)
593-
sync_blocks(self.nodes)
593+
self.sync_blocks()
594594

595595

596596
if __name__ == '__main__':

test/functional/mempool_packages.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def run_test(self):
163163
# Check that prioritising a tx before it's added to the mempool works
164164
# First clear the mempool by mining a block.
165165
self.nodes[0].generate(1)
166-
sync_blocks(self.nodes)
166+
self.sync_blocks()
167167
assert_equal(len(self.nodes[0].getrawmempool()), 0)
168168
# Prioritise a transaction that has been mined, then add it back to the
169169
# mempool by using invalidateblock.
@@ -228,7 +228,7 @@ def run_test(self):
228228
# Test reorg handling
229229
# First, the basics:
230230
self.nodes[0].generate(1)
231-
sync_blocks(self.nodes)
231+
self.sync_blocks()
232232
self.nodes[1].invalidateblock(self.nodes[0].getbestblockhash())
233233
self.nodes[1].reconsiderblock(self.nodes[0].getbestblockhash())
234234

@@ -283,12 +283,12 @@ def run_test(self):
283283
rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
284284
signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx)
285285
txid = self.nodes[0].sendrawtransaction(signedtx['hex'])
286-
sync_mempools(self.nodes)
286+
self.sync_mempools()
287287

288288
# Now try to disconnect the tip on each node...
289289
self.nodes[1].invalidateblock(self.nodes[1].getbestblockhash())
290290
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
291-
sync_blocks(self.nodes)
291+
self.sync_blocks()
292292

293293
if __name__ == '__main__':
294294
MempoolPackagesTest().main()

test/functional/p2p_feefilter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def run_test(self):
5050
node0 = self.nodes[0]
5151
# Get out of IBD
5252
node1.generate(1)
53-
sync_blocks(self.nodes)
53+
self.sync_blocks()
5454

5555
self.nodes[0].add_p2p_connection(TestP2PConn())
5656

@@ -71,7 +71,7 @@ def run_test(self):
7171
# Change tx fee rate to 10 sat/byte and test they are no longer received
7272
node1.settxfee(Decimal("0.00010000"))
7373
[node1.sendtoaddress(node1.getnewaddress(), 1) for x in range(3)]
74-
sync_mempools(self.nodes) # must be sure node 0 has received all txs
74+
self.sync_mempools() # must be sure node 0 has received all txs
7575

7676
# Send one transaction from node0 that should be received, so that we
7777
# we can sync the test on receipt (if node1's txs were relayed, they'd

test/functional/p2p_node_network_limited.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def run_test(self):
6060
self.log.info("Mine enough blocks to reach the NODE_NETWORK_LIMITED range.")
6161
connect_nodes_bi(self.nodes, 0, 1)
6262
blocks = self.nodes[1].generatetoaddress(292, self.nodes[1].get_deterministic_priv_key().address)
63-
sync_blocks([self.nodes[0], self.nodes[1]])
63+
self.sync_blocks([self.nodes[0], self.nodes[1]])
6464

6565
self.log.info("Make sure we can max retrieve block at tip-288.")
6666
node.send_getdata_for_block(blocks[1]) # last block in valid range
@@ -86,7 +86,7 @@ def run_test(self):
8686
# because node 2 is in IBD and node 0 is a NODE_NETWORK_LIMITED peer, sync must not be possible
8787
connect_nodes_bi(self.nodes, 0, 2)
8888
try:
89-
sync_blocks([self.nodes[0], self.nodes[2]], timeout=5)
89+
self.sync_blocks([self.nodes[0], self.nodes[2]], timeout=5)
9090
except:
9191
pass
9292
# node2 must remain at height 0
@@ -96,7 +96,7 @@ def run_test(self):
9696
connect_nodes_bi(self.nodes, 1, 2)
9797

9898
# sync must be possible
99-
sync_blocks(self.nodes)
99+
self.sync_blocks()
100100

101101
# disconnect all peers
102102
self.disconnect_all()
@@ -108,7 +108,7 @@ def run_test(self):
108108
connect_nodes_bi(self.nodes, 0, 1)
109109

110110
# sync must be possible, node 1 is no longer in IBD and should therefore connect to node 0 (NODE_NETWORK_LIMITED)
111-
sync_blocks([self.nodes[0], self.nodes[1]])
111+
self.sync_blocks([self.nodes[0], self.nodes[1]])
112112

113113
if __name__ == '__main__':
114114
NodeNetworkLimitedTest().main()

test/functional/p2p_segwit.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def func_wrapper(self, *args, **kwargs):
283283
func(self, *args, **kwargs)
284284
# Each subtest should leave some utxos for the next subtest
285285
assert self.utxo
286-
sync_blocks(self.nodes)
286+
self.sync_blocks()
287287
# Assert segwit status is as expected at end of subtest
288288
assert_equal(get_bip9_status(self.nodes[0], 'segwit')['status'], self.segwit_status)
289289

@@ -644,7 +644,7 @@ def test_standardness_v0(self):
644644
# Mine it on test_node to create the confirmed output.
645645
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_tx, with_witness=True, accepted=True)
646646
self.nodes[0].generate(1)
647-
sync_blocks(self.nodes)
647+
self.sync_blocks()
648648

649649
# Now test standardness of v0 P2WSH outputs.
650650
# Start by creating a transaction with two outputs.
@@ -675,7 +675,7 @@ def test_standardness_v0(self):
675675
tx3 = CTransaction()
676676
# tx and tx2 were both accepted. Don't bother trying to reclaim the
677677
# P2PKH output; just send tx's first output back to an anyone-can-spend.
678-
sync_mempools([self.nodes[0], self.nodes[1]])
678+
self.sync_mempools([self.nodes[0], self.nodes[1]])
679679
tx3.vin = [CTxIn(COutPoint(tx.sha256, 0), b"")]
680680
tx3.vout = [CTxOut(tx.vout[0].nValue - 1000, CScript([OP_TRUE, OP_DROP] * 15 + [OP_TRUE]))]
681681
tx3.wit.vtxinwit.append(CTxInWitness())
@@ -694,7 +694,7 @@ def test_standardness_v0(self):
694694
test_transaction_acceptance(self.nodes[0], self.test_node, tx3, with_witness=True, accepted=True)
695695

696696
self.nodes[0].generate(1)
697-
sync_blocks(self.nodes)
697+
self.sync_blocks()
698698
self.utxo.pop(0)
699699
self.utxo.append(UTXO(tx3.sha256, 0, tx3.vout[0].nValue))
700700
assert_equal(len(self.nodes[1].getrawmempool()), 0)
@@ -732,7 +732,7 @@ def test_p2sh_witness(self):
732732
block = self.build_next_block()
733733
self.update_witness_block_with_transactions(block, [tx])
734734
test_witness_block(self.nodes[0], self.test_node, block, accepted=True, with_witness=True)
735-
sync_blocks(self.nodes)
735+
self.sync_blocks()
736736

737737
# Now test attempts to spend the output.
738738
spend_tx = CTransaction()
@@ -1377,7 +1377,7 @@ def test_segwit_versions(self):
13771377
for i in range(NUM_SEGWIT_VERSIONS):
13781378
self.utxo.append(UTXO(tx.sha256, i, split_value))
13791379

1380-
sync_blocks(self.nodes)
1380+
self.sync_blocks()
13811381
temp_utxo = []
13821382
tx = CTransaction()
13831383
witness_program = CScript([OP_TRUE])
@@ -1395,7 +1395,7 @@ def test_segwit_versions(self):
13951395
temp_utxo.append(UTXO(tx.sha256, 0, tx.vout[0].nValue))
13961396

13971397
self.nodes[0].generate(1) # Mine all the transactions
1398-
sync_blocks(self.nodes)
1398+
self.sync_blocks()
13991399
assert len(self.nodes[0].getrawmempool()) == 0
14001400

14011401
# Finally, verify that version 0 -> version 1 transactions
@@ -1432,7 +1432,7 @@ def test_segwit_versions(self):
14321432
block = self.build_next_block()
14331433
self.update_witness_block_with_transactions(block, [tx2, tx3])
14341434
test_witness_block(self.nodes[0], self.test_node, block, accepted=True)
1435-
sync_blocks(self.nodes)
1435+
self.sync_blocks()
14361436

14371437
# Add utxo to our list
14381438
self.utxo.append(UTXO(tx3.sha256, 0, tx3.vout[0].nValue))
@@ -1460,7 +1460,7 @@ def test_premature_coinbase_witness_spend(self):
14601460

14611461
# Now test a premature spend.
14621462
self.nodes[0].generate(98)
1463-
sync_blocks(self.nodes)
1463+
self.sync_blocks()
14641464
block2 = self.build_next_block()
14651465
self.update_witness_block_with_transactions(block2, [spend_tx])
14661466
test_witness_block(self.nodes[0], self.test_node, block2, accepted=False)
@@ -1470,7 +1470,7 @@ def test_premature_coinbase_witness_spend(self):
14701470
block2 = self.build_next_block()
14711471
self.update_witness_block_with_transactions(block2, [spend_tx])
14721472
test_witness_block(self.nodes[0], self.test_node, block2, accepted=True)
1473-
sync_blocks(self.nodes)
1473+
self.sync_blocks()
14741474

14751475
@subtest
14761476
def test_uncompressed_pubkey(self):
@@ -1600,7 +1600,7 @@ def test_signature_version_1(self):
16001600
block = self.build_next_block()
16011601
self.update_witness_block_with_transactions(block, [tx])
16021602
test_witness_block(self.nodes[0], self.test_node, block, accepted=True)
1603-
sync_blocks(self.nodes)
1603+
self.sync_blocks()
16041604
self.utxo.pop(0)
16051605

16061606
# Test each hashtype
@@ -1779,7 +1779,7 @@ def test_non_standard_witness_blinding(self):
17791779
tx.rehash()
17801780
test_transaction_acceptance(self.nodes[0], self.test_node, tx, False, True)
17811781
self.nodes[0].generate(1)
1782-
sync_blocks(self.nodes)
1782+
self.sync_blocks()
17831783

17841784
# We'll add an unnecessary witness to this transaction that would cause
17851785
# it to be non-standard, to test that violating policy with a witness
@@ -1808,7 +1808,7 @@ def test_non_standard_witness_blinding(self):
18081808
test_transaction_acceptance(self.nodes[0], self.test_node, tx3, False, True)
18091809

18101810
self.nodes[0].generate(1)
1811-
sync_blocks(self.nodes)
1811+
self.sync_blocks()
18121812

18131813
# Update our utxo list; we spent the first entry.
18141814
self.utxo.pop(0)
@@ -1844,7 +1844,7 @@ def test_non_standard_witness(self):
18441844
test_transaction_acceptance(self.nodes[0], self.test_node, tx, with_witness=False, accepted=True)
18451845

18461846
self.nodes[0].generate(1)
1847-
sync_blocks(self.nodes)
1847+
self.sync_blocks()
18481848

18491849
# Creating transactions for tests
18501850
p2wsh_txs = []
@@ -1908,7 +1908,7 @@ def test_non_standard_witness(self):
19081908

19091909
self.nodes[0].generate(1) # Mine and clean up the mempool of non-standard node
19101910
# Valid but non-standard transactions in a block should be accepted by standard node
1911-
sync_blocks(self.nodes)
1911+
self.sync_blocks()
19121912
assert_equal(len(self.nodes[0].getrawmempool()), 0)
19131913
assert_equal(len(self.nodes[1].getrawmempool()), 0)
19141914

@@ -1923,7 +1923,7 @@ def test_upgrade_after_activation(self):
19231923
self.start_node(2, extra_args=["-vbparams=segwit:0:999999999999"])
19241924
connect_nodes(self.nodes[0], 2)
19251925

1926-
sync_blocks(self.nodes)
1926+
self.sync_blocks()
19271927

19281928
# Make sure that this peer thinks segwit has activated.
19291929
assert get_bip9_status(self.nodes[2], 'segwit')['status'] == "active"
@@ -2020,7 +2020,7 @@ def test_witness_sigops(self):
20202020
test_witness_block(self.nodes[0], self.test_node, block_4, accepted=True)
20212021

20222022
# Reset the tip back down for the next test
2023-
sync_blocks(self.nodes)
2023+
self.sync_blocks()
20242024
for x in self.nodes:
20252025
x.invalidateblock(block_4.hash)
20262026

0 commit comments

Comments
 (0)