diff --git a/tests/TestHarness/Cluster.py b/tests/TestHarness/Cluster.py index 792ee02430..42ddcbfee2 100644 --- a/tests/TestHarness/Cluster.py +++ b/tests/TestHarness/Cluster.py @@ -481,6 +481,7 @@ def connectGroup(group, producerNodes, bridgeNodes) : node = Node(self.host, self.port + nodeNum, nodeNum, Path(instance.data_dir_name), Path(instance.config_dir_name), eosdcmd, unstarted=instance.dont_start, launch_time=launcher.launch_time, walletMgr=self.walletMgr, nodeosVers=self.nodeosVers) + node.keys = instance.keys if nodeNum == Node.biosNodeId: self.biosNode = node else: @@ -993,15 +994,13 @@ def parseClusterKeys(totalNodes): Utils.Print(f'Found {len(producerKeys)} producer keys') return producerKeys - def activateInstantFinality(self, launcher, biosFinalizer, pnodes): + def activateInstantFinality(self, biosFinalizer=True): # call setfinalizer numFins = 0 - for n in launcher.network.nodes.values(): - if not n.keys or not n.keys[0].blspubkey: + for n in (self.nodes + [self.biosNode]): + if not n or not n.keys or not n.keys[0].blspubkey: continue - if not n.producers: - continue - if n.index == Node.biosNodeId and not biosFinalizer: + if n.nodeId == Node.biosNodeId and not biosFinalizer: continue numFins = numFins + 1 @@ -1009,18 +1008,15 @@ def activateInstantFinality(self, launcher, biosFinalizer, pnodes): if threshold > 2 and threshold == numFins: # nodes are often stopped, so do not require all node votes threshold = threshold - 1 - # pnodes does not include biosNode - if Utils.Debug: Utils.Print(f"threshold: {threshold}, numFins: {numFins}, pnodes: {pnodes}") + if Utils.Debug: Utils.Print(f"threshold: {threshold}, numFins: {numFins}") setFinStr = f'{{"finalizer_policy": {{' setFinStr += f' "threshold": {threshold}, ' setFinStr += f' "finalizers": [' finNum = 1 - for n in launcher.network.nodes.values(): - if n.index == Node.biosNodeId and not biosFinalizer: - continue - if not n.keys or not n.keys[0].blspubkey: + for n in (self.nodes + [self.biosNode]): + if not n or not n.keys or not n.keys[0].blspubkey: continue - if not n.producers: + if n.nodeId == Node.biosNodeId and not biosFinalizer: continue setFinStr += f' {{"description": "finalizer #{finNum}", ' setFinStr += f' "weight":1, ' @@ -1109,7 +1105,7 @@ def bootstrap(self, launcher, biosNode, totalNodes, prodCount, totalProducers, return None if activateIF: - self.activateInstantFinality(launcher, biosFinalizer, self.productionNodesCount) + self.activateInstantFinality(biosFinalizer) Utils.Print("Creating accounts: %s " % ", ".join(producerKeys.keys())) producerKeys.pop(eosioName) diff --git a/tests/TestHarness/Node.py b/tests/TestHarness/Node.py index ddd2584038..d23f42d2f9 100644 --- a/tests/TestHarness/Node.py +++ b/tests/TestHarness/Node.py @@ -10,6 +10,7 @@ import sys from pathlib import Path from typing import List +from dataclasses import InitVar, dataclass, field, is_dataclass, asdict from datetime import datetime from datetime import timedelta @@ -21,6 +22,14 @@ from .testUtils import unhandledEnumType from .testUtils import ReturnType +@dataclass +class KeyStrings(object): + pubkey: str + privkey: str + blspubkey: str = None + blsprivkey: str = None + blspop: str = None + # pylint: disable=too-many-public-methods class Node(Transactions): # Node number is used as an addend to determine the node listen ports. @@ -66,6 +75,7 @@ def __init__(self, host, port, nodeId: int, data_dir: Path, config_dir: Path, cm self.config_dir=config_dir self.launch_time=launch_time self.isProducer=False + self.keys: List[KeyStrings] = field(default_factory=list) self.configureVersion() def configureVersion(self):