Skip to content

Commit

Permalink
test: remove redundant sync after generate* calls in Dash tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Sep 30, 2024
1 parent e532838 commit b6a814f
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 60 deletions.
9 changes: 0 additions & 9 deletions test/functional/feature_addressindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def run_test(self):
self.log.info("Mining blocks...")
mining_address = self.nodes[0].getnewaddress()
self.generatetoaddress(self.nodes[0], 105, mining_address)
self.sync_all()

chain_height = self.nodes[1].getblockcount()
assert_equal(chain_height, 105)
Expand Down Expand Up @@ -89,8 +88,6 @@ def run_test(self):
txidb2 = self.nodes[0].sendtoaddress("93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB", 20)
self.generate(self.nodes[0], 1)

self.sync_all()

txids = self.nodes[1].getaddresstxids("yMNJePdcKvXtWWQnFYHNeJ5u8TF2v1dfK4")
assert_equal(len(txids), 3)
assert_equal(txids[0], txid0)
Expand Down Expand Up @@ -142,7 +139,6 @@ def run_test(self):
sent_txid = self.nodes[0].sendrawtransaction(signed_tx["hex"], 0)

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

txidsmany = self.nodes[1].getaddresstxids("93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB")
assert_equal(len(txidsmany), 4)
Expand Down Expand Up @@ -171,7 +167,6 @@ def run_test(self):
signed_tx = self.nodes[0].signrawtransactionwithwallet(tx.serialize().hex())
spending_txid = self.nodes[0].sendrawtransaction(signed_tx["hex"], 0)
self.generate(self.nodes[0], 1)
self.sync_all()
balance1 = self.nodes[1].getaddressbalance(address2)
assert_equal(balance1["balance"], amount)

Expand All @@ -185,7 +180,6 @@ def run_test(self):
signed_tx = self.nodes[0].signrawtransactionwithwallet(tx.serialize().hex())
sent_txid = self.nodes[0].sendrawtransaction(signed_tx["hex"], 0)
self.generate(self.nodes[0], 1)
self.sync_all()

balance2 = self.nodes[1].getaddressbalance(address2)
assert_equal(balance2["balance"], change_amount)
Expand Down Expand Up @@ -239,7 +233,6 @@ def run_test(self):
self.generate(self.nodes[2], 1, sync_fun=self.no_op)
self.nodes[2].sendtoaddress(address2, 50)
self.generate(self.nodes[2], 1)
self.sync_all()

utxos3 = self.nodes[1].getaddressutxos({"addresses": [address2]})
assert_equal(len(utxos3), 3)
Expand Down Expand Up @@ -292,7 +285,6 @@ def run_test(self):
assert_equal(mempool[2]["index"], 1)

self.generate(self.nodes[2], 1)
self.sync_all()
mempool2 = self.nodes[2].getaddressmempool({"addresses": [address3]})
assert_equal(len(mempool2), 0)

Expand Down Expand Up @@ -323,7 +315,6 @@ def run_test(self):

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

utxos = self.nodes[1].getaddressutxos({"addresses": [address1]})
assert_equal(len(utxos), 1)
Expand Down
20 changes: 0 additions & 20 deletions test/functional/feature_asset_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ def generate_batch(self, count):
count -= batch
self.bump_mocktime(batch)
self.generate(self.nodes[1], batch)
self.sync_all()

# This functional test intentionally setup only 2 MN and only 2 Evo nodes
# to ensure that corner case of quorum with minimum amount of nodes as possible
Expand Down Expand Up @@ -256,7 +255,6 @@ def run_test(self):

self.set_sporks()
self.generate(node, 1)
self.sync_all()
self.mempool_size = 0

key = ECKey()
Expand Down Expand Up @@ -294,7 +292,6 @@ def test_asset_locks(self, node_wallet, node, pubkey):
assert_equal(self.get_credit_pool_balance(node=node), locked_1)
self.log.info("Generate a number of blocks to ensure this is the longest chain for later in the test when we reconsiderblock")
self.generate(node, 12)
self.sync_all()

self.validate_credit_pool_balance(locked_1)

Expand All @@ -305,14 +302,12 @@ def test_asset_locks(self, node_wallet, node, pubkey):
inode.invalidateblock(self.block_hash_1)
assert_equal(self.get_credit_pool_balance(node=inode), 0)
self.generate(node, 3)
self.sync_all()
self.validate_credit_pool_balance(0)
self.log.info("Resubmit asset lock tx to new chain...")
# NEW tx appears
asset_lock_tx_2 = self.create_assetlock(coin, locked_2, pubkey)
txid_in_block = self.send_tx(asset_lock_tx_2)
self.generate(node, 1)
self.sync_all()
self.validate_credit_pool_balance(locked_2)
self.log.info("Reconsider old blocks...")
for inode in self.nodes:
Expand Down Expand Up @@ -397,7 +392,6 @@ def test_asset_unlocks(self, node_wallet, node, pubkey):
self.check_mempool_size()
self.validate_credit_pool_balance(locked)
self.generate(node, 1)
self.sync_all()
assert_equal(rawtx["instantlock"], False)
assert_equal(rawtx["chainlock"], False)
rawtx = node.getrawtransaction(txid, 1)
Expand All @@ -420,14 +414,12 @@ def test_asset_unlocks(self, node_wallet, node, pubkey):
self.validate_credit_pool_balance(locked - 1 * COIN)
self.send_tx(asset_unlock_tx_late)
self.generate(node, 1)
self.sync_all()
self.validate_credit_pool_balance(locked - 2 * COIN)

self.log.info("Generating many blocks to make quorum far behind (even still active)...")
self.generate_batch(too_late_height - node.getblockcount() - 1)
self.check_mempool_result(tx=asset_unlock_tx_too_late, result_expected={'allowed': True, 'fees': {'base': Decimal(str(tiny_amount / COIN))}})
self.generate(node, 1)
self.sync_all()
self.check_mempool_result(tx=asset_unlock_tx_too_late,
result_expected={'allowed': False, 'reject-reason' : 'bad-assetunlock-too-late'})

Expand All @@ -452,7 +444,6 @@ def test_asset_unlocks(self, node_wallet, node, pubkey):
self.create_and_check_block([asset_unlock_tx_too_late], expected_error = "bad-assetunlock-not-active-quorum")

self.generate(node, 1)
self.sync_all()

self.validate_credit_pool_balance(locked - 2 * COIN)
self.validate_credit_pool_balance(block_hash=self.block_hash_1, expected=locked)
Expand All @@ -472,7 +463,6 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):

txid_in_block = self.send_tx(asset_unlock_tx_full)
self.generate(node, 1)
self.sync_all()

self.ensure_tx_is_not_mined(txid_in_block)

Expand All @@ -486,7 +476,6 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):
txid_in_block = self.send_tx(asset_unlock_tx_full)
expected_balance = (Decimal(self.get_credit_pool_balance()) - Decimal(tiny_amount))
self.generate(node, 1)
self.sync_all()
self.log.info("Check txid_in_block was mined")
block = node.getblock(node.getbestblockhash())
assert txid_in_block in block['tx']
Expand Down Expand Up @@ -524,7 +513,6 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):
self.log.info(f"Collecting coins in pool... Collected {total}/{10_901 * COIN}")
self.sync_mempools()
self.generate(node, 1)
self.sync_all()
credit_pool_balance_1 = self.get_credit_pool_balance()
assert_greater_than(credit_pool_balance_1, 10_901 * COIN)
limit_amount_1 = 1000 * COIN
Expand All @@ -544,7 +532,6 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):

self.sync_mempools()
self.generate(node, 1)
self.sync_all()

new_total = self.get_credit_pool_balance()
amount_actually_withdrawn = total - new_total
Expand All @@ -557,7 +544,6 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):
assert_equal(amount_actually_withdrawn, 900 * COIN + 10001)

self.generate(node, 1)
self.sync_all()
self.log.info("Checking that exactly 1 tx stayed in mempool...")
self.mempool_size = 1
self.check_mempool_size()
Expand All @@ -571,7 +557,6 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):
self.send_tx_simple(asset_unlock_tx)
self.sync_mempools()
self.generate(node, 1)
self.sync_all()
new_total = self.get_credit_pool_balance()
amount_actually_withdrawn = total - new_total
assert_equal(limit_amount_1, amount_actually_withdrawn)
Expand All @@ -595,18 +580,15 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):
asset_unlock_tx = self.create_assetunlock(index, limit_amount_2, pubkey)
self.send_tx(asset_unlock_tx)
self.generate(node, 1)
self.sync_all()
assert_equal(new_total, self.get_credit_pool_balance())
self.generate(node, 1)
self.sync_all()
new_total -= limit_amount_2
assert_equal(new_total, self.get_credit_pool_balance())
self.log.info("Trying to withdraw more... expecting to fail")
index += 1
asset_unlock_tx = self.create_assetunlock(index, COIN, pubkey)
self.send_tx(asset_unlock_tx)
self.generate(node, 1)
self.sync_all()

tip = self.nodes[0].getblockcount()
indexes_statuses_no_height = self.nodes[0].getassetunlockstatuses(["101", "102", "103"])
Expand Down Expand Up @@ -641,7 +623,6 @@ def test_mn_rr(self, node_wallet, node, pubkey):
assert_equal(platform_reward, 37015386)
assert_equal(locked, self.get_credit_pool_balance())
self.generate(node, 1)
self.sync_all()
locked += platform_reward
assert_equal(locked, self.get_credit_pool_balance())

Expand All @@ -650,7 +631,6 @@ def test_mn_rr(self, node_wallet, node, pubkey):
self.send_tx(self.create_assetlock(coin, COIN, pubkey))
locked += platform_reward + COIN
self.generate(node, 1)
self.sync_all()
assert_equal(locked, self.get_credit_pool_balance())


Expand Down
8 changes: 0 additions & 8 deletions test/functional/feature_dip3_deterministicmns.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def run_test(self):
dummy_txin = self.spend_mn_collateral(mns[i], with_dummy_input_output=True)
dummy_txins.append(dummy_txin)
self.generate(self.nodes[0], 1)
self.sync_all()
mns_tmp.remove(mns[i])
self.assert_mnlists(mns_tmp)
new_rpc_info = self.nodes[0].protx("info", old_protx_hash, old_blockhash)
Expand All @@ -145,15 +144,13 @@ def run_test(self):
self.log.info("cause a reorg with a double spend and check that mnlists are still correct on all nodes")
self.mine_double_spend(mns, self.nodes[0], dummy_txins, self.nodes[0].getnewaddress())
self.generate(self.nodes[0], spend_mns_count)
self.sync_all()
self.assert_mnlists(mns_tmp)

self.log.info("test mn payment enforcement with deterministic MNs")
for i in range(20):
node = self.nodes[i % len(self.nodes)]
self.test_invalid_mn_payment(mns, node)
self.generate(self.nodes[0], 1)
self.sync_all()

self.log.info("testing ProUpServTx")
for mn in mns:
Expand All @@ -176,7 +173,6 @@ def run_test(self):
expected_payee = bt['masternode'][0]['payee']
expected_amount = bt['masternode'][0]['amount']
self.generate(self.nodes[0], 1)
self.sync_all()
if expected_payee == multisig:
block = self.nodes[0].getblock(self.nodes[0].getbestblockhash())
cbtx = self.nodes[0].getrawtransaction(block['tx'][0], 1)
Expand All @@ -199,7 +195,6 @@ def run_test(self):
self.register_mn(self.nodes[0], new_mn)
mns[i] = new_mn
self.generate(self.nodes[0], 1)
self.sync_all()
self.assert_mnlists(mns)
self.log.info("restarting MN %s" % new_mn.alias)
self.stop_node(new_mn.idx)
Expand All @@ -218,7 +213,6 @@ def run_test(self):
node.sendtoaddress(mn.rewards_address, 0.001)
node.protx('update_registrar', mn.protx_hash, "", new_voting_address, "")
self.generate(node, 1)
self.sync_all()
new_dmnState = mn.node.masternode("status")["dmnState"]
new_voting_address_from_rpc = new_dmnState["votingAddress"]
assert new_voting_address_from_rpc == new_voting_address
Expand Down Expand Up @@ -296,15 +290,13 @@ def update_mn_payee(self, mn, payee):
self.nodes[0].sendtoaddress(mn.fundsAddr, 0.001)
self.nodes[0].protx('update_registrar', mn.protx_hash, '', '', payee, mn.fundsAddr)
self.generate(self.nodes[0], 1)
self.sync_all()
info = self.nodes[0].protx('info', mn.protx_hash)
assert info['state']['payoutAddress'] == payee

def test_protx_update_service(self, mn):
self.nodes[0].sendtoaddress(mn.fundsAddr, 0.001)
self.nodes[0].protx('update_service', mn.protx_hash, '127.0.0.2:%d' % mn.p2p_port, mn.blsMnkey, "", mn.fundsAddr)
self.generate(self.nodes[0], 1)
self.sync_all()
for node in self.nodes:
protx_info = node.protx('info', mn.protx_hash)
mn_list = node.masternode('list')
Expand Down
2 changes: 0 additions & 2 deletions test/functional/feature_llmq_is_cl_conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ def test_chainlock_overrides_islock_overrides_nonchainlock(self):
# Mine the conflicting TX into a block
good_tip = self.nodes[0].getbestblockhash()
self.generate(self.nodes[0], 2)
self.sync_all()

# Assert that the conflicting tx got mined and the locked TX is not valid
assert self.nodes[0].getrawtransaction(rawtx1_txid, True)['confirmations'] > 0
Expand Down Expand Up @@ -255,7 +254,6 @@ def test_chainlock_overrides_islock_overrides_nonchainlock(self):
assert_raises_rpc_error(-26, "tx-txlock-conflict", self.nodes[0].sendrawtransaction, rawtx1)

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

for node in self.nodes:
self.wait_for_instantlock(rawtx2_txid, node)
Expand Down
1 change: 0 additions & 1 deletion test/functional/feature_llmq_simplepose.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ def repair_masternodes(self, restart):
# Make sure protxes are "safe" to mine even when InstantSend and ChainLocks are no longer functional
self.bump_mocktime(60 * 10 + 1)
self.generate(self.nodes[0], 1)
self.sync_all()

# Isolate and re-connect all MNs (otherwise there might be open connections with no MNAUTH for MNs which were banned before)
for mn in self.mninfo:
Expand Down
9 changes: 0 additions & 9 deletions test/functional/feature_mnehf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def slowly_generate_batch(self, amount):
amount -= next
self.bump_mocktime(next)
self.generate(self.nodes[1], next)
self.sync_all()

def create_mnehf(self, versionBit, pubkey=None):
# request ID = sha256("mnhf", versionBit)
Expand Down Expand Up @@ -157,8 +156,6 @@ def run_test(self):
self.log.info(f"unknown ehf tx: {ehf_unknown_tx_sent}")
self.sync_all()
ehf_blockhash = self.generate(self.nodes[1], 1)[0]
self.sync_blocks()
self.sync_all()

self.log.info(f"Check MnEhfTx {ehf_tx_sent} was mined in {ehf_blockhash}")
assert ehf_tx_sent in node.getblock(ehf_blockhash)['tx']
Expand All @@ -172,21 +169,18 @@ def run_test(self):
while (node.getblockcount() + 1) % 12 != 0:
self.check_fork('defined')
self.generate(node, 1)
self.sync_all()


self.restart_all_nodes()

for _ in range(12):
self.check_fork('started')
self.generate(node, 1)
self.sync_all()


for i in range(12):
self.check_fork('locked_in')
self.generate(node, 1)
self.sync_all()
if i == 7:
self.restart_all_nodes()

Expand All @@ -201,13 +195,11 @@ def run_test(self):
for _ in range(12):
self.check_fork('defined')
self.generate(node, 1)
self.sync_all()


self.log.info("Re-sending MnEHF for new fork")
tx_sent_2 = self.send_tx(ehf_tx)
ehf_blockhash_2 = self.generate(node, 1)[0]
self.sync_all()

self.log.info(f"Check MnEhfTx again {tx_sent_2} was mined in {ehf_blockhash_2}")
assert tx_sent_2 in node.getblock(ehf_blockhash_2)['tx']
Expand Down Expand Up @@ -253,7 +245,6 @@ def run_test(self):
self.log.info("Mine one block and ensure EHF tx for the new deployment is mined")
ehf_tx_sent = self.send_tx(ehf_tx_new_start)
tip_blockhash = self.generate(node, 1)[0]
self.sync_all()
block = node.getblock(tip_blockhash)
assert ehf_tx_sent in block['tx']

Expand Down
3 changes: 0 additions & 3 deletions test/functional/feature_spentindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def run_test(self):

self.log.info("Mining blocks...")
self.generate(self.nodes[0], 105)
self.sync_all()

chain_height = self.nodes[1].getblockcount()
assert_equal(chain_height, 105)
Expand All @@ -77,7 +76,6 @@ def run_test(self):
signed_tx = self.nodes[0].signrawtransactionwithwallet(tx.serialize().hex())
txid = self.nodes[0].sendrawtransaction(signed_tx["hex"], 0)
self.generate(self.nodes[0], 1)
self.sync_all()

self.log.info("Testing getspentinfo method...")

Expand Down Expand Up @@ -121,7 +119,6 @@ def run_test(self):

# Check the database index
self.generate(self.nodes[0], 1)
self.sync_all()

txVerbose4 = self.nodes[3].getrawtransaction(txid2, 1)
assert_equal(txVerbose4["vin"][0]["address"], address2)
Expand Down
Loading

0 comments on commit b6a814f

Please sign in to comment.