Allow registering MNs without actually starting them

This can be done by calling prepare_masternode() when inside run_test.
Also implement remove_masternode() which spends the collateral.
This commit is contained in:
Alexander Block 2019-04-04 08:08:44 +02:00
parent ef6b6a1e64
commit ade5760a92

View File

@ -277,6 +277,9 @@ class DashTestFramework(BitcoinTestFramework):
def prepare_masternodes(self):
for idx in range(0, self.mn_count):
self.prepare_masternode(idx)
def prepare_masternode(self, idx):
bls = self.nodes[0].bls('generate')
address = self.nodes[0].getnewaddress()
txid = self.nodes[0].sendtoaddress(address, MASTERNODE_COLLATERAL)
@ -308,6 +311,15 @@ class DashTestFramework(BitcoinTestFramework):
self.mninfo.append(MasternodeInfo(proTxHash, ownerAddr, votingAddr, bls['public'], bls['secret'], address, txid, collateral_vout))
self.sync_all()
def remove_mastermode(self, idx):
mn = self.mninfo[idx]
rawtx = self.nodes[0].createrawtransaction([{"txid": mn.collateral_txid, "vout": mn.collateral_vout}], {self.nodes[0].getnewaddress(): 999.9999})
rawtx = self.nodes[0].signrawtransaction(rawtx)
self.nodes[0].sendrawtransaction(rawtx["hex"])
self.nodes[0].generate(1)
self.sync_all()
self.mninfo.remove(mn)
def prepare_datadirs(self):
# stop faucet node so that we can copy the datadir
stop_node(self.nodes[0], 0)