#!/usr/bin/env python3 # Copyright (c) 2023 The Dash Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. import struct from io import BytesIO from test_framework.authproxy import JSONRPCException from test_framework.key import ECKey from test_framework.messages import ( CMnEhf, CTransaction, hash256, ser_string, ) from test_framework.test_framework import DashTestFramework from test_framework.util import ( assert_equal, get_bip9_details, ) class MnehfTest(DashTestFramework): def set_test_params(self): extra_args = [["-vbparams=testdummy:0:999999999999:0:12:12:12:5:1", "-persistmempool=0"] for _ in range(4)] self.set_dash_test_params(4, 3, fast_dip3_enforcement=True, extra_args=extra_args) def skip_test_if_missing_module(self): self.skip_if_no_wallet() def restart_all_nodes(self, params=None): for inode in range(self.num_nodes): self.log.info(f"Restart node {inode} with {self.extra_args[inode]}") if params is not None: self.extra_args[inode][0] = f"-vbparams=testdummy:{params[0]}:{params[1]}:0:12:12:12:5:1" self.log.info(f"Actual restart options: {self.extra_args[inode]}") self.restart_node(0) for mn in self.mninfo: index = mn.node.index self.stop_node(index) self.start_masternode(mn) for i in range(1, self.num_nodes): self.connect_nodes(i, 0) def slowly_generate_batch(self, amount): self.log.info(f"Slowly generate {amount} blocks") while amount > 0: self.log.info(f"Generating batch of blocks {amount} left") next = min(10, amount) amount -= next self.bump_mocktime(next) self.nodes[1].generate(next) self.sync_all() def create_mnehf(self, versionBit, pubkey=None): # request ID = sha256("mnhf", versionBit) request_id_buf = ser_string(b"mnhf") + struct.pack("