Skip to content

Commit

Permalink
test: remove redundant sync after generate* calls in Bitcoin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Sep 30, 2024
1 parent b6a814f commit 239ebf7
Show file tree
Hide file tree
Showing 24 changed files with 0 additions and 87 deletions.
2 changes: 0 additions & 2 deletions test/functional/feature_blockfilterindex_prune.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def run_test(self):
assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getbestblockhash())['filter']), 0)
# Mine two batches of blocks to avoid hitting NODE_NETWORK_LIMITED_MIN_BLOCKS disconnection
self.generate(self.nodes[0], 250)
self.sync_all()
self.generate(self.nodes[0], 250)
self.sync_all()
self.sync_index(height=700)

self.log.info("prune some blocks")
Expand Down
2 changes: 0 additions & 2 deletions test/functional/feature_coinstatsindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ def _test_coin_stats_index(self):

# Include both txs in a block
self.generate(self.nodes[0], 1)
self.sync_all()

for hash_option in index_hash_options:
# Check all amounts were registered correctly
Expand Down Expand Up @@ -285,7 +284,6 @@ def _test_reorg_index(self):
# Add another block, so we don't depend on reconsiderblock remembering which
# blocks were touched by invalidateblock
self.generate(index_node, 1)
self.sync_all()

# Ensure that removing and re-adding blocks yields consistent results
block = index_node.getblockhash(99)
Expand Down
1 change: 0 additions & 1 deletion test/functional/feature_minchainwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def run_test(self):
# insufficient work chain, in which case we'd need to reconnect them to
# continue the test.

self.sync_all()
self.log.info("Blockcounts: %s", [n.getblockcount() for n in self.nodes])

self.log.info("Test that getheaders requests to node2 are not ignored")
Expand Down
7 changes: 0 additions & 7 deletions test/functional/interface_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ def run_test(self):
not_related_address = "yj949n1UH6fDhw6HtVE5VMj2iSTaSWBMcW"

self.generate(self.nodes[0], 1)
self.sync_all()
self.generatetoaddress(self.nodes[1], 100, not_related_address)
self.sync_all()

assert_equal(self.nodes[0].getbalance(), 500)

Expand Down Expand Up @@ -118,7 +116,6 @@ def run_test(self):
self.log.info("Query an unspent TXO using the /getutxos URI")

self.generatetoaddress(self.nodes[1], 1, not_related_address)
self.sync_all()
bb_hash = self.nodes[0].getbestblockhash()

assert_equal(self.nodes[1].getbalance(), Decimal("0.1"))
Expand Down Expand Up @@ -193,7 +190,6 @@ def run_test(self):
assert_equal(len(json_obj['utxos']), 0)

self.generate(self.nodes[0], 1)
self.sync_all()

json_obj = self.test_rest_request("/getutxos/{}-{}".format(*spending))
assert_equal(len(json_obj['utxos']), 1)
Expand All @@ -214,7 +210,6 @@ def run_test(self):
self.test_rest_request("/getutxos/checkmempool/{}".format(long_uri), http_method='POST', status=200)

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

self.log.info("Test the /block, /blockhashbyheight and /headers URIs")
bb_hash = self.nodes[0].getbestblockhash()
Expand Down Expand Up @@ -285,7 +280,6 @@ def run_test(self):

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

Expand Down Expand Up @@ -320,7 +314,6 @@ def run_test(self):

# Now mine the transactions
newblockhash = self.generate(self.nodes[1], 1)
self.sync_all()

# Check if the 3 tx show up in the new block
json_obj = self.test_rest_request("/block/{}".format(newblockhash[0]))
Expand Down
5 changes: 0 additions & 5 deletions test/functional/interface_zmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ def test_basic(self):
self.log.info("Generate %(n)d blocks (and %(n)d coinbase txes)" % {"n": num_blocks})
genhashes = self.generatetoaddress(self.nodes[0], num_blocks, ADDRESS_BCRT1_UNSPENDABLE)

self.sync_all()

for x in range(num_blocks):
# Should receive the coinbase txid.
txid = hashtx.receive()
Expand Down Expand Up @@ -344,7 +342,6 @@ def test_sequence(self):
# removed from the mempool by the block mining it.
mempool_size = len(self.nodes[0].getrawmempool())
c_block = self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)[0]
self.sync_all()
# Make sure the number of mined transactions matches the number of txs out of mempool
mempool_size_delta = mempool_size - len(self.nodes[0].getrawmempool())
assert_equal(len(self.nodes[0].getblock(c_block)["tx"])-1, mempool_size_delta)
Expand Down Expand Up @@ -384,7 +381,6 @@ def test_sequence(self):
# Other things may happen but aren't wallet-deterministic so we don't test for them currently
self.nodes[0].reconsiderblock(best_hash)
self.generatetoaddress(self.nodes[1], 1, ADDRESS_BCRT1_UNSPENDABLE)
self.sync_all()

self.log.info("Evict mempool transaction by block conflict")
orig_txid = self.nodes[0].sendtoaddress(address=self.nodes[0].getnewaddress(), amount=1.0)
Expand Down Expand Up @@ -429,7 +425,6 @@ def test_sequence(self):
assert_equal((orig_txid_2, "A", mempool_seq), seq.receive_sequence())
mempool_seq += 1
self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)
self.sync_all() # want to make sure we didn't break "consensus" for other tests

def test_mempool_sync(self):
"""
Expand Down
1 change: 0 additions & 1 deletion test/functional/mempool_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ def run_test(self):

# Mine these in a block
self.generate(self.nodes[0], 1)
self.sync_all()

# Now generate tx8, with a big fee
inputs = [ {'txid' : tx1_id, 'vout': 0}, {'txid' : txid, 'vout': 0} ]
Expand Down
1 change: 0 additions & 1 deletion test/functional/p2p_ibd_txrelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def run_test(self):

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

self.log.info("Check that nodes process the same transaction, even when unsolicited, when no longer in IBD")
peer_txer = self.nodes[0].add_p2p_connection(P2PInterface())
Expand Down
1 change: 0 additions & 1 deletion test/functional/p2p_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ def run_test(self):

def check_tx_relay(self):
block_op_true = self.nodes[0].getblock(self.generatetoaddress(self.nodes[0], 100, ADDRESS_BCRT1_P2SH_OP_TRUE)[0])
self.sync_all()

self.log.debug("Create a connection from a forcerelay peer that rebroadcasts raw txs")
# A test framework p2p connection is needed to send the raw transaction directly. If a full node was used, it could only
Expand Down
2 changes: 0 additions & 2 deletions test/functional/rpc_createmultisig.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def run_test(self):

self.log.info('Generating blocks ...')
self.generate(node0, 149)
self.sync_all()

self.moved = 0
for self.nkeys in [3, 5]:
Expand Down Expand Up @@ -102,7 +101,6 @@ def check_addmultisigaddress_errors(self):
def checkbalances(self):
node0, node1, node2 = self.nodes
self.generate(node0, 1)
self.sync_all()

bal0 = node0.getbalance()
bal1 = node1.getbalance()
Expand Down
12 changes: 0 additions & 12 deletions test/functional/rpc_fundrawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def run_test(self):
self.fee_tolerance = 2 * self.min_relay_tx_fee / 1000

self.generate(self.nodes[2], 1)
self.sync_all()
self.generate(self.nodes[0], 121)
self.sync_all()

self.test_change_position()
self.test_simple()
Expand Down Expand Up @@ -128,7 +126,6 @@ def test_change_position(self):
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 50)

self.generate(self.nodes[0], 1)
self.sync_all()

wwatch.unloadwallet()

Expand Down Expand Up @@ -492,7 +489,6 @@ def test_spend_2of2(self):
# send 12 DASH to msig addr
self.nodes[0].sendtoaddress(mSigObj, 12)
self.generate(self.nodes[0], 1)
self.sync_all()

oldBalance = self.nodes[1].getbalance()
inputs = []
Expand All @@ -503,7 +499,6 @@ def test_spend_2of2(self):
final_psbt = w2.finalizepsbt(signed_psbt['psbt'])
self.nodes[2].sendrawtransaction(final_psbt['hex'])
self.generate(self.nodes[2], 1)
self.sync_all()

# Make sure funds are received at node1.
assert_equal(oldBalance+Decimal('11.0000000'), self.nodes[1].getbalance())
Expand Down Expand Up @@ -565,7 +560,6 @@ def test_locked_wallet(self):
signedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex'])
self.nodes[1].sendrawtransaction(signedTx['hex'])
self.generate(self.nodes[1], 1)
self.sync_all()

# Make sure funds are received at node1.
assert_equal(oldBalance+Decimal('511.0000000'), self.nodes[0].getbalance())
Expand All @@ -577,12 +571,10 @@ def test_many_inputs_fee(self):
# Empty node1, send some small coins from node0 to node1.
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
self.generate(self.nodes[1], 1)
self.sync_all()

for _ in range(20):
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.generate(self.nodes[0], 1)
self.sync_all()

# Fund a tx with ~20 small inputs.
inputs = []
Expand All @@ -605,12 +597,10 @@ def test_many_inputs_send(self):
# Again, empty node1, send some small coins from node0 to node1.
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
self.generate(self.nodes[1], 1)
self.sync_all()

for _ in range(20):
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.generate(self.nodes[0], 1)
self.sync_all()

# Fund a tx with ~20 small inputs.
oldBalance = self.nodes[0].getbalance()
Expand All @@ -622,7 +612,6 @@ def test_many_inputs_send(self):
fundedAndSignedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex'])
self.nodes[1].sendrawtransaction(fundedAndSignedTx['hex'])
self.generate(self.nodes[1], 1)
self.sync_all()
assert_equal(oldBalance+Decimal('500.19000000'), self.nodes[0].getbalance()) #0.19+block reward

def test_op_return(self):
Expand Down Expand Up @@ -700,7 +689,6 @@ def test_all_watched_funds(self):
assert signedtx["complete"]
self.nodes[0].sendrawtransaction(signedtx["hex"])
self.generate(self.nodes[0], 1)
self.sync_all()

wwatch.unloadwallet()

Expand Down
1 change: 0 additions & 1 deletion test/functional/rpc_getblockstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def generate_test_data(self, filename):
address = self.nodes[0].get_deterministic_priv_key().address
self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=True)
self.generate(self.nodes[0], 1)
self.sync_all()

self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=True)
self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=False)
Expand Down
1 change: 0 additions & 1 deletion test/functional/rpc_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def test_getpeerinfo(self):
# Create a few getpeerinfo last_block/last_transaction values.
self.wallet.send_self_transfer(from_node=self.nodes[0]) # Make a transaction so we can see it in the getpeerinfo results
self.generate(self.nodes[1], 1)
self.sync_all()
time_now = self.mocktime
peer_info = [x.getpeerinfo() for x in self.nodes]
# Verify last_block and last_transaction keys/values.
Expand Down
5 changes: 0 additions & 5 deletions test/functional/rpc_psbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def run_test(self):
signed_tx = self.nodes[0].signrawtransactionwithwallet(rawtx['hex'])['hex']
txid = self.nodes[0].sendrawtransaction(signed_tx)
self.generate(self.nodes[0], 6)
self.sync_all()

# Find the output pos
p2sh_pos = -1
Expand Down Expand Up @@ -228,7 +227,6 @@ def run_test(self):
txid1 = self.nodes[0].sendtoaddress(node1_addr, 13)
txid2 = self.nodes[0].sendtoaddress(node2_addr, 13)
blockhash = self.generate(self.nodes[0], 6)[0]
self.sync_all()
vout1 = find_output(self.nodes[1], txid1, 13, blockhash=blockhash)
vout2 = find_output(self.nodes[2], txid2, 13, blockhash=blockhash)

Expand Down Expand Up @@ -256,7 +254,6 @@ def run_test(self):
finalized = self.nodes[0].finalizepsbt(combined)['hex']
self.nodes[0].sendrawtransaction(finalized)
self.generate(self.nodes[0], 6)
self.sync_all()

# Make sure change address wallet does not have P2SH innerscript access to results in success
# when attempting BnB coin selection
Expand Down Expand Up @@ -395,7 +392,6 @@ def test_psbt_input_keys(psbt_input, keys):
txid4 = self.nodes[0].sendtoaddress(addr4, 5)
vout4 = find_output(self.nodes[0], txid4, 5)
self.generate(self.nodes[0], 6)
self.sync_all()
psbt2 = self.nodes[1].createpsbt([{"txid":txid4, "vout":vout4}], {self.nodes[0].getnewaddress():Decimal('4.999')})
psbt2 = self.nodes[1].walletprocesspsbt(psbt2)['psbt']
psbt2_decoded = self.nodes[0].decodepsbt(psbt2)
Expand All @@ -408,7 +404,6 @@ def test_psbt_input_keys(psbt_input, keys):
addr = self.nodes[1].getnewaddress()
txid = self.nodes[0].sendtoaddress(addr, 7)
self.generate(self.nodes[0], 6)
self.sync_all()
vout = find_output(self.nodes[0], txid, 7)
psbt = self.nodes[1].createpsbt([{"txid":txid, "vout":vout}], {self.nodes[0].getnewaddress():Decimal('6.999')})
analyzed = self.nodes[0].analyzepsbt(psbt)
Expand Down
11 changes: 0 additions & 11 deletions test/functional/rpc_rawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,12 @@ def setup_network(self):
def run_test(self):
self.log.info('prepare some coins for multiple *rawtransaction commands')
self.generate(self.nodes[2], 1)
self.sync_all()
self.generate(self.nodes[0], COINBASE_MATURITY + 1)
self.sync_all()
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.5)
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.0)
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),5.0)
self.sync_all()
self.generate(self.nodes[0], 5)
self.sync_all()

self.log.info('Test getrawtransaction on genesis block coinbase returns an error')
block = self.nodes[0].getblock(self.nodes[0].getblockhash(0))
Expand Down Expand Up @@ -167,7 +164,6 @@ def run_test(self):
# make a tx by sending then generate 2 blocks; block1 has the tx in it
tx = self.nodes[2].sendtoaddress(self.nodes[1].getnewaddress(), 1)
block1, block2 = self.generate(self.nodes[2], 2)
self.sync_all()
# We should be able to get the raw transaction by providing the correct block
gottx = self.nodes[0].getrawtransaction(tx, True, block1)
assert_equal(gottx['txid'], tx)
Expand Down Expand Up @@ -218,7 +214,6 @@ def run_test(self):
txId = self.nodes[0].sendtoaddress(mSigObj, 1.2)
self.sync_all()
self.generate(self.nodes[0], 1)
self.sync_all()
assert_equal(self.nodes[2].getbalance(), bal+Decimal('1.20000000')) #node2 has both keys of the 2of2 ms addr., tx should affect the balance


Expand All @@ -239,7 +234,6 @@ def run_test(self):
rawTx = self.nodes[0].decoderawtransaction(decTx['hex'])
self.sync_all()
self.generate(self.nodes[0], 1)
self.sync_all()

#THIS IS AN INCOMPLETE FEATURE
#NODE2 HAS TWO OF THREE KEY AND THE FUNDS SHOULD BE SPENDABLE AND COUNT AT BALANCE CALCULATION
Expand All @@ -262,7 +256,6 @@ def run_test(self):
rawTx = self.nodes[0].decoderawtransaction(rawTxSigned['hex'])
self.sync_all()
self.generate(self.nodes[0], 1)
self.sync_all()
assert_equal(self.nodes[0].getbalance(), bal+Decimal('500.00000000')+Decimal('2.19000000')) #block reward + tx

# 2of2 test for combining transactions
Expand All @@ -282,7 +275,6 @@ def run_test(self):
rawTx2 = self.nodes[0].decoderawtransaction(decTx['hex'])
self.sync_all()
self.generate(self.nodes[0], 1)
self.sync_all()

assert_equal(self.nodes[2].getbalance(), bal) # the funds of a 2of2 multisig tx should not be marked as spendable

Expand All @@ -307,21 +299,18 @@ def run_test(self):
rawTx2 = self.nodes[0].decoderawtransaction(rawTxComb)
self.sync_all()
self.generate(self.nodes[0], 1)
self.sync_all()
assert_equal(self.nodes[0].getbalance(), bal+Decimal('500.00000000')+Decimal('2.19000000')) #block reward + tx


# Basic signrawtransaction test
addr = self.nodes[1].getnewaddress()
txid = self.nodes[0].sendtoaddress(addr, 10)
self.generate(self.nodes[0], 1)
self.sync_all()
vout = find_vout_for_address(self.nodes[1], txid, addr)
rawTx = self.nodes[1].createrawtransaction([{'txid': txid, 'vout': vout}], {self.nodes[1].getnewaddress(): 9.999})
rawTxSigned = self.nodes[1].signrawtransactionwithwallet(rawTx)
txId = self.nodes[1].sendrawtransaction(rawTxSigned['hex'])
self.generate(self.nodes[0], 1)
self.sync_all()

# getrawtransaction tests
# 1. valid parameters - only supply txid
Expand Down
2 changes: 0 additions & 2 deletions test/functional/rpc_txoutproof.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def run_test(self):
# Add enough mature utxos to the wallet, so that all txs spend confirmed coins
self.generate(miniwallet, 5)
self.generate(self.nodes[0], COINBASE_MATURITY)
self.sync_all()

chain_height = self.nodes[1].getblockcount()
assert_equal(chain_height, 5 + COINBASE_MATURITY)
Expand All @@ -59,7 +58,6 @@ def run_test(self):
tx3 = miniwallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=txin_spent)
txid3 = tx3['txid']
self.generate(self.nodes[0], 1)
self.sync_all()

txid_spent = txin_spent["txid"]
txid_unspent = txid1 # Input was change from txid2, so txid1 should be unspent
Expand Down
Loading

0 comments on commit 239ebf7

Please sign in to comment.