#!/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 import time 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:4:4:4:5:1", "-persistmempool=0"] for _ in range(4)] self.set_dash_test_params(4, 3, 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:4:4:4: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 create_mnehf(self, versionBit, pubkey=None): # request ID = sha256("mnhf", versionBit) request_id_buf = ser_string(b"mnhf") + struct.pack("