Skip to content

Commit

Permalink
suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 authored and ogabrielides committed Nov 9, 2023
1 parent 626ecfb commit 33dbf15
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
45 changes: 17 additions & 28 deletions test/functional/feature_llmq_chainlocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,34 +187,23 @@ def run_test(self):
self.reconnect_isolated_node(0, 1)
self.wait_for_chainlocked_block(self.nodes[0], self.nodes[0].getbestblockhash(), timeout=30)

self.log.info("Add a new node and let it sync")
added_mn_info_0 = self.dynamically_add_masternode(evo=False)
assert_raises_rpc_error(-32603, "Unable to find any chainlock", self.nodes[added_mn_info_0.idx].getbestchainlock)

self.log.info("Test that new node can mine without Chainlock info")
tip_0 = self.nodes[0].getblock(self.nodes[0].getbestblockhash(), 2)
self.nodes[added_mn_info_0.idx].generate(1)
self.sync_blocks(self.nodes)
tip_1 = self.nodes[0].getblock(self.nodes[0].getbestblockhash(), 2)
assert_equal(tip_1['cbTx']['bestCLSignature'], tip_0['cbTx']['bestCLSignature'])
assert_equal(tip_1['cbTx']['bestCLHeightDiff'], tip_0['cbTx']['bestCLHeightDiff'] + 1)

self.log.info("Disable Chainlock")
self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 4070908800)
self.wait_for_sporks_same()

self.log.info("Add a new node and let it sync")
added_mn_info_1 = self.dynamically_add_masternode(evo=False)
assert_raises_rpc_error(-32603, "Unable to find any chainlock", self.nodes[added_mn_info_1.idx].getbestchainlock)

self.log.info("Test that new node can mine without Chainlock info")
tip_0 = self.nodes[0].getblock(self.nodes[0].getbestblockhash(), 2)
self.nodes[added_mn_info_1.idx].generate(1)
self.sync_blocks(self.nodes)
tip_1 = self.nodes[0].getblock(self.nodes[0].getbestblockhash(), 2)
assert_equal(tip_1['cbTx']['bestCLSignature'], tip_0['cbTx']['bestCLSignature'])
assert_equal(tip_1['cbTx']['bestCLHeightDiff'], tip_0['cbTx']['bestCLHeightDiff'] + 1)

for i in range(2):
self.log.info(f"{'Disable' if i == 0 else 'Enable'} Chainlock")
self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 4070908800 if i == 0 else 0)
self.wait_for_sporks_same()

self.log.info("Add a new node and let it sync")
self.dynamically_add_masternode(evo=False)
added_idx = len(self.nodes) - 1
assert_raises_rpc_error(-32603, "Unable to find any chainlock", self.nodes[added_idx].getbestchainlock)

self.log.info("Test that new node can mine without Chainlock info")
tip_0 = self.nodes[0].getblock(self.nodes[0].getbestblockhash(), 2)
self.nodes[added_idx].generate(1)
self.sync_blocks(self.nodes)
tip_1 = self.nodes[0].getblock(self.nodes[0].getbestblockhash(), 2)
assert_equal(tip_1['cbTx']['bestCLSignature'], tip_0['cbTx']['bestCLSignature'])
assert_equal(tip_1['cbTx']['bestCLHeightDiff'], tip_0['cbTx']['bestCLHeightDiff'] + 1)

def create_chained_txs(self, node, amount):
txid = node.sendtoaddress(node.getnewaddress(), amount)
Expand Down
5 changes: 2 additions & 3 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ def is_bdb_compiled(self):
EVONODE_COLLATERAL = 4000

class MasternodeInfo:
def __init__(self, proTxHash, ownerAddr, votingAddr, pubKeyOperator, keyOperator, collateral_address, collateral_txid, collateral_vout, addr, idx, evo=False):
def __init__(self, proTxHash, ownerAddr, votingAddr, pubKeyOperator, keyOperator, collateral_address, collateral_txid, collateral_vout, addr, evo=False):
self.proTxHash = proTxHash
self.ownerAddr = ownerAddr
self.votingAddr = votingAddr
Expand All @@ -1009,7 +1009,6 @@ def __init__(self, proTxHash, ownerAddr, votingAddr, pubKeyOperator, keyOperator
self.collateral_txid = collateral_txid
self.collateral_vout = collateral_vout
self.addr = addr
self.idx = idx
self.evo = evo


Expand Down Expand Up @@ -1232,7 +1231,7 @@ def dynamically_prepare_masternode(self, idx, node_p2p_port, evo=False, rnd=None
self.sync_all(self.nodes)

assert_equal(self.nodes[0].getrawtransaction(protx_result, 1, tip)['confirmations'], 1)
mn_info = MasternodeInfo(protx_result, owner_address, voting_address, bls['public'], bls['secret'], collateral_address, collateral_txid, collateral_vout, ipAndPort, idx, evo)
mn_info = MasternodeInfo(protx_result, owner_address, voting_address, bls['public'], bls['secret'], collateral_address, collateral_txid, collateral_vout, ipAndPort, evo)
self.mninfo.append(mn_info)

mn_type_str = "EvoNode" if evo else "MN"
Expand Down

0 comments on commit 33dbf15

Please sign in to comment.