Skip to content

Commit

Permalink
test: opt-out of post-generate* syncing in some Dash tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Sep 30, 2024
1 parent cc97aab commit e532838
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 60 deletions.
14 changes: 7 additions & 7 deletions test/functional/feature_addressindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ def run_test(self):
self.log.info("Testing p2pkh and p2sh address index...")

txid0 = self.nodes[0].sendtoaddress("yMNJePdcKvXtWWQnFYHNeJ5u8TF2v1dfK4", 10)
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)

txidb0 = self.nodes[0].sendtoaddress("93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB", 10)
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)

txid1 = self.nodes[0].sendtoaddress("yMNJePdcKvXtWWQnFYHNeJ5u8TF2v1dfK4", 15)
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)

txidb1 = self.nodes[0].sendtoaddress("93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB", 15)
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)

txid2 = self.nodes[0].sendtoaddress("yMNJePdcKvXtWWQnFYHNeJ5u8TF2v1dfK4", 20)
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)

txidb2 = self.nodes[0].sendtoaddress("93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB", 20)
self.generate(self.nodes[0], 1)
Expand Down Expand Up @@ -233,10 +233,10 @@ def run_test(self):
assert_equal(utxos2[0]["satoshis"], amount)

# Check sorting of utxos
self.generate(self.nodes[2], 150)
self.generate(self.nodes[2], 150, sync_fun=self.no_op)

self.nodes[2].sendtoaddress(address2, 50)
self.generate(self.nodes[2], 1)
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()
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_asset_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def test_asset_locks(self, node_wallet, node, pubkey):
assert_equal(rpc_tx["assetLockTx"]["creditOutputs"][0]["scriptPubKey"]["hex"], key_to_p2pkh_script(pubkey).hex())
assert_equal(rpc_tx["assetLockTx"]["creditOutputs"][1]["scriptPubKey"]["hex"], key_to_p2pkh_script(pubkey).hex())
self.validate_credit_pool_balance(0)
self.generate(node, 1)
self.generate(node, 1, sync_fun=self.no_op)
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)
Expand Down Expand Up @@ -503,7 +503,7 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):
self.check_mempool_result(tx=spend_withdrawal, result_expected={'allowed': True, 'fees': {'base': Decimal(str(tiny_amount / COIN))}})
spend_txid_in_block = self.send_tx(spend_withdrawal)

self.generate(node, 1)
self.generate(node, 1, sync_fun=self.no_op)
block = node.getblock(node.getbestblockhash())
assert spend_txid_in_block in block['tx']

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

# This tx should be completely valid, should be included in mempool and mined in the next block
assert txid in set(self.node.getrawmempool())
self.generate(self.node, 1)
self.generate(self.node, 1, sync_fun=self.no_op)
assert txid not in set(self.node.getrawmempool())

# Create spending tx
Expand All @@ -63,12 +63,12 @@ def run_test(self):
assert_raises_rpc_error(-26, DISABLED_OPCODE_ERROR, self.node.sendrawtransaction, tx0_hex)

# Generate enough blocks to activate DIP0020 opcodes
self.generate(self.node, 98)
self.generate(self.node, 98, sync_fun=self.no_op)
assert softfork_active(self.nodes[0], 'dip0020')

# Still need 1 more block for mempool to accept new opcodes
assert_raises_rpc_error(-26, DISABLED_OPCODE_ERROR, self.node.sendrawtransaction, tx0_hex)
self.generate(self.node, 1)
self.generate(self.node, 1, sync_fun=self.no_op)

# Should be spendable now
tx0id = self.node.sendrawtransaction(tx0_hex)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_dip3_deterministicmns.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def run_test(self):
self.log.info("register %s" % mn.alias)
self.register_mn(self.nodes[0], mn)

self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)

if not start:
self.start_mn(mn)
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_dip4_coinbasemerkleroots.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def activate_dip8(self, slow_mode=False):
self.log.info("Wait for dip0008 activation")
while self.nodes[0].getblockcount() < DIP0008_HEIGHT:
self.bump_mocktime(10)
self.generate(self.nodes[0], 10)
self.generate(self.nodes[0], 10, sync_fun=self.no_op)
if slow_mode:
self.sync_blocks()
self.sync_blocks()
Expand Down Expand Up @@ -301,7 +301,7 @@ def confirm_mns(self):
break
if not found_unconfirmed:
break
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.sync_blocks()

if __name__ == '__main__':
Expand Down
24 changes: 12 additions & 12 deletions test/functional/feature_governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def run_test(self):
isolated = self.nodes[payee_idx]

self.log.info("Move 1 block inside the Superblock maturity window on the isolated node")
self.generate(isolated, 1)
self.generate(isolated, 1, sync_fun=self.no_op)
self.bump_mocktime(1)
self.log.info("The isolated 'winner' should submit new trigger and vote for it")
self.wait_until(lambda: len(isolated.gobject("list", "valid", "triggers")) == 1, timeout=5)
Expand All @@ -203,7 +203,7 @@ def run_test(self):
assert_equal(more_votes, False)

self.log.info("Move 1 block enabling the Superblock maturity window on non-isolated nodes")
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.bump_mocktime(1)
assert_equal(self.nodes[0].getblockcount(), 150)
assert_equal(self.nodes[0].getblockchaininfo()["softforks"]["v20"]["active"], False)
Expand All @@ -214,7 +214,7 @@ def run_test(self):
assert_equal(has_trigger, False)

self.log.info("Move 1 block inside the Superblock maturity window on non-isolated nodes")
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.bump_mocktime(1)

self.log.info("There is now new 'winner' who should submit new trigger and vote for it")
Expand All @@ -232,7 +232,7 @@ def run_test(self):
assert(amount_str in payment_amounts_expected)

self.log.info("Move another block inside the Superblock maturity window on non-isolated nodes")
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.bump_mocktime(1)

self.log.info("Every non-isolated MN should vote for the same trigger now, no new triggers should be created")
Expand Down Expand Up @@ -268,7 +268,7 @@ def sync_gov(node):
assert_equal(more_triggers, False)

self.log.info("Move another block inside the Superblock maturity window")
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.bump_mocktime(1)
self.sync_blocks()

Expand All @@ -284,7 +284,7 @@ def sync_gov(node):

self.log.info("Move another block inside the Superblock maturity window")
with self.nodes[1].assert_debug_log(["CGovernanceManager::VoteGovernanceTriggers"]):
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.bump_mocktime(1)
self.sync_blocks()

Expand All @@ -298,7 +298,7 @@ def sync_gov(node):

self.log.info("Move remaining n blocks until actual Superblock")
for i in range(n):
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.bump_mocktime(1)
self.sync_blocks()
# comparing to 159 because bip9 forks are active when the tip is one block behind the activation height
Expand All @@ -310,7 +310,7 @@ def sync_gov(node):
self.log.info("Move a few block past the recent superblock height and make sure we have no new votes")
for _ in range(5):
with self.nodes[1].assert_debug_log("", [f"Voting NO-FUNDING for trigger:{winning_trigger_hash} success"]):
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.bump_mocktime(1)
self.sync_blocks()
# Votes on both triggers should NOT change
Expand All @@ -322,13 +322,13 @@ def sync_gov(node):

self.log.info("Move remaining n blocks until the next Superblock")
for _ in range(n - 1):
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.bump_mocktime(1)
self.sync_blocks()
self.log.info("Wait for new trigger and votes")
self.wait_until(lambda: have_trigger_for_height(self.nodes, 180))
self.log.info("Mine superblock")
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.bump_mocktime(1)
self.sync_blocks()
assert_equal(self.nodes[0].getblockcount(), 180)
Expand All @@ -337,14 +337,14 @@ def sync_gov(node):
self.log.info("Mine and check a couple more superblocks")
for i in range(2):
for _ in range(sb_cycle - 1):
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.bump_mocktime(1)
self.sync_blocks()
# Wait for new trigger and votes
sb_block_height = 180 + (i + 1) * sb_cycle
self.wait_until(lambda: have_trigger_for_height(self.nodes, sb_block_height))
# Mine superblock
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.bump_mocktime(1)
self.sync_blocks()
assert_equal(self.nodes[0].getblockcount(), sb_block_height)
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_governance_cl.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def run_test(self):
p1_collateral_prepare = self.prepare_object(1, uint256_to_string(0), proposal_time, 1, "Proposal_1", self.p1_amount, self.p1_payout_address)
self.bump_mocktime(60 * 10 + 1)

self.generate(self.nodes[0], 6)
self.generate(self.nodes[0], 6, sync_fun=self.no_op)
self.bump_mocktime(6 * 156)
self.sync_blocks()

Expand Down Expand Up @@ -158,7 +158,7 @@ def run_test(self):
self.log.info("Reconnect isolated node and confirm the next ChainLock will let it sync")
self.reconnect_isolated_node(5, 0)
assert_equal(self.nodes[5].mnsync("status")["IsSynced"], False)
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
# NOTE: bumping mocktime too much after recent reconnect can result in "timeout downloading block"
self.bump_mocktime(1)
self.sync_blocks()
Expand Down
34 changes: 17 additions & 17 deletions test/functional/feature_llmq_chainlocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def run_test(self):
self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=False)

# v20 is active, no quorums, no CLs - null CL in CbTx
nocl_block_hash = self.generate(self.nodes[0], 1)[0]
nocl_block_hash = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=True, expected_null_cl=True)
cbtx = self.nodes[0].getspecialtxes(nocl_block_hash, 5, 1, 0, 2)[0]
assert_equal(cbtx["instantlock"], False)
Expand All @@ -61,7 +61,7 @@ def run_test(self):


self.log.info("Mine single block, wait for chainlock")
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash())
self.test_coinbase_best_cl(self.nodes[0])

Expand All @@ -72,7 +72,7 @@ def run_test(self):
assert_equal(cbtx["chainlock"], True)

self.log.info("Mine many blocks, wait for chainlock")
self.generate(self.nodes[0], 20)
self.generate(self.nodes[0], 20, sync_fun=self.no_op)
# We need more time here due to 20 blocks being generated at once
self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash(), timeout=30)
self.test_coinbase_best_cl(self.nodes[0])
Expand All @@ -92,7 +92,7 @@ def run_test(self):
self.log.info("Generate new blocks and verify that they are not chainlocked")
previous_block_hash = self.nodes[0].getbestblockhash()
for _ in range(2):
block_hash = self.generate(self.nodes[0], 1)[0]
block_hash = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
self.wait_for_chainlocked_block_all_nodes(block_hash, expected=False)
assert self.nodes[0].getblock(previous_block_hash)["chainlock"]

Expand All @@ -103,18 +103,18 @@ def run_test(self):
self.isolate_node(0)
node0_mining_addr = self.nodes[0].getnewaddress()
node0_tip = self.nodes[0].getbestblockhash()
self.generatetoaddress(self.nodes[1], 5, node0_mining_addr)
self.generatetoaddress(self.nodes[1], 5, node0_mining_addr, sync_fun=self.no_op)
self.wait_for_chainlocked_block(self.nodes[1], self.nodes[1].getbestblockhash())
self.test_coinbase_best_cl(self.nodes[0])
assert self.nodes[0].getbestblockhash() == node0_tip
self.reconnect_isolated_node(0, 1)
self.generatetoaddress(self.nodes[1], 1, node0_mining_addr)
self.generatetoaddress(self.nodes[1], 1, node0_mining_addr, sync_fun=self.no_op)
self.wait_for_chainlocked_block_all_nodes(self.nodes[1].getbestblockhash())
self.test_coinbase_best_cl(self.nodes[0])

self.log.info("Isolate node, mine on another, reconnect and submit CL via RPC")
self.isolate_node(0)
self.generate(self.nodes[1], 1)
self.generate(self.nodes[1], 1, sync_fun=self.no_op)
self.wait_for_chainlocked_block(self.nodes[1], self.nodes[1].getbestblockhash())
best_0 = self.nodes[0].getbestchainlock()
best_1 = self.nodes[1].getbestchainlock()
Expand All @@ -136,13 +136,13 @@ def run_test(self):

self.log.info("Isolate node, mine on both parts of the network, and reconnect")
self.isolate_node(0)
bad_tip = self.generate(self.nodes[0], 5)[-1]
self.generatetoaddress(self.nodes[1], 1, node0_mining_addr)
bad_tip = self.generate(self.nodes[0], 5, sync_fun=self.no_op)[-1]
self.generatetoaddress(self.nodes[1], 1, node0_mining_addr, sync_fun=self.no_op)
good_tip = self.nodes[1].getbestblockhash()
self.wait_for_chainlocked_block(self.nodes[1], good_tip)
assert not self.nodes[0].getblock(self.nodes[0].getbestblockhash())["chainlock"]
self.reconnect_isolated_node(0, 1)
self.generatetoaddress(self.nodes[1], 1, node0_mining_addr)
self.generatetoaddress(self.nodes[1], 1, node0_mining_addr, sync_fun=self.no_op)
self.wait_for_chainlocked_block_all_nodes(self.nodes[1].getbestblockhash())
self.test_coinbase_best_cl(self.nodes[0])
assert self.nodes[0].getblock(self.nodes[0].getbestblockhash())["previousblockhash"] == good_tip
Expand All @@ -165,10 +165,10 @@ def run_test(self):
assert self.nodes[0].getbestblockhash() == good_tip
self.nodes[0].invalidateblock(good_tip)
self.log.info("Now try to reorg the chain")
self.generate(self.nodes[0], 2)
self.generate(self.nodes[0], 2, sync_fun=self.no_op)
time.sleep(6)
assert self.nodes[1].getbestblockhash() == good_tip
bad_tip = self.generate(self.nodes[0], 2)[-1]
bad_tip = self.generate(self.nodes[0], 2, sync_fun=self.no_op)[-1]
time.sleep(6)
assert self.nodes[0].getbestblockhash() == bad_tip
assert self.nodes[1].getbestblockhash() == good_tip
Expand All @@ -177,7 +177,7 @@ def run_test(self):
self.nodes[0].reconsiderblock(good_tip)
assert self.nodes[0].getbestblockhash() != good_tip
good_fork = good_tip
good_tip = self.generatetoaddress(self.nodes[1], 1, node0_mining_addr)[-1] # this should mark bad_tip as conflicting
good_tip = self.generatetoaddress(self.nodes[1], 1, node0_mining_addr, sync_fun=self.no_op)[-1] # this should mark bad_tip as conflicting
self.wait_for_chainlocked_block_all_nodes(good_tip)
self.test_coinbase_best_cl(self.nodes[0])
assert self.nodes[0].getbestblockhash() == good_tip
Expand Down Expand Up @@ -205,7 +205,7 @@ def run_test(self):
txs.append(self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1))
txs += self.create_chained_txs(self.nodes[0], 1)
self.log.info("Assert that after block generation these TXs are NOT included (as they are \"unsafe\")")
node0_tip = self.generate(self.nodes[0], 1)[-1]
node0_tip = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[-1]
for txid in txs:
tx = self.nodes[0].getrawtransaction(txid, 1)
assert "confirmations" not in tx
Expand All @@ -216,7 +216,7 @@ def run_test(self):
self.log.info("Disable LLMQ based InstantSend for a very short time (this never gets propagated to other nodes)")
self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 4070908800)
self.log.info("Now the TXs should be included")
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 0)
self.log.info("Assert that TXs got included now")
for txid in txs:
Expand Down Expand Up @@ -298,12 +298,12 @@ def test_coinbase_best_cl(self, node, expected_cl_in_cb=True, expected_null_cl=F
def test_bestCLHeightDiff(self, mn_rr_active):
# We need 2 blocks we can grab clsigs from
for _ in range(2):
self.wait_for_chainlocked_block_all_nodes(self.generate(self.nodes[0], 1)[0])
self.wait_for_chainlocked_block_all_nodes(self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0])
assert_equal(softfork_active(self.nodes[1], "mn_rr"), mn_rr_active)
tip1_hash = self.nodes[1].getbestblockhash()

self.isolate_node(1)
tip0_hash = self.generate(self.nodes[0], 1)[0]
tip0_hash = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
block_hex = self.nodes[0].getblock(tip0_hash, 0)
mal_block = CBlock()
mal_block.deserialize(BytesIO(bytes.fromhex(block_hex)))
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_llmq_dkgerrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def heal_masternodes(self, blockCount):
self.wait_for_sporks_same()
for _ in range(blockCount):
self.bump_mocktime(1)
self.generate(self.nodes[0], 1)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.sync_all()
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0)
self.wait_for_sporks_same()
Expand Down
Loading

0 comments on commit e532838

Please sign in to comment.