def testValidatorSuspensionByTrustee(trustee, trusteeWallet, looper, nodeSet): node = nodeSet[-1] nodeNym = hexToFriendly(node.nodestack.verhex) suspendNode(looper, trustee, trusteeWallet, nodeNym, node.name) for n in nodeSet[:-1]: looper.run(eventually(checkNodeNotInNodeReg, n, node.name)) looper.run(eventually(checkNodeNotInNodeReg, trustee, node.name))
def testValidatorSuspensionByTrustee(trustee, trusteeWallet, looper, nodeSet): node = nodeSet[-1] nodeNym = hexToFriendly(node.nodestack.verhex) suspendNode(looper, trustee, trusteeWallet, nodeNym, node.name) for n in nodeSet[:-1]: looper.run(eventually(checkNodeNotInNodeReg, n, node.name)) looper.run(eventually(checkNodeNotInNodeReg, trustee, node.name))
def testStewardSuspendsNode(looper, txnPoolNodeSet, tdirWithPoolTxns, tconf, steward1, stewardWallet, nodeThetaAdded, poolTxnStewardData, allPluginsPath): newSteward, newStewardWallet, newNode = nodeThetaAdded newNodeNym = hexToFriendly(newNode.nodestack.local.signer.verhex) suspendNode(looper, newSteward, newStewardWallet, newNodeNym, newNode.name) # Check suspended node does not exist in any nodeReg or remotes of # nodes or clients txnPoolNodeSet = txnPoolNodeSet[:-1] for node in txnPoolNodeSet: looper.run(eventually(checkNodeNotInNodeReg, node, newNode.name)) for client in (steward1, newSteward): looper.run(eventually(checkNodeNotInNodeReg, client, newNode.name)) # Check a client can send request and receive replies req = sendRandomRequest(newStewardWallet, newSteward) checkSufficientRepliesForRequests(looper, newSteward, [ req, ], timeoutPerReq=10) # Check that a restarted client or node does not connect to the suspended # node steward1.stop() looper.removeProdable(steward1) steward1, stewardWallet = buildPoolClientAndWallet(poolTxnStewardData, tdirWithPoolTxns) looper.add(steward1) ensureClientConnectedToNodesAndPoolLedgerSame(looper, steward1, *txnPoolNodeSet) looper.run(eventually(checkNodeNotInNodeReg, steward1, newNode.name)) newNode.stop() looper.removeProdable(newNode) # TODO: There is a bug that if a primary node is turned off, it sends # duplicate Pre-Prepare and gets blacklisted. Here is the gist # https://gist.github.com/lovesh/c16989616ebb6856f9fa2905c14dc4b7 oldNodeIdx, oldNode = [(i, n) for i, n in enumerate(txnPoolNodeSet) if not n.hasPrimary][0] oldNode.stop() looper.removeProdable(oldNode) oldNode = TestNode(oldNode.name, basedirpath=tdirWithPoolTxns, config=tconf, pluginPaths=allPluginsPath) looper.add(oldNode) txnPoolNodeSet[oldNodeIdx] = oldNode looper.run(checkNodesConnected(txnPoolNodeSet)) looper.run(eventually(checkNodeNotInNodeReg, oldNode, newNode.name)) # Check that a node whose suspension is revoked can reconnect to other # nodes and clients can also connect to that node cancelNodeSuspension(looper, newSteward, newStewardWallet, newNodeNym, newNode.name) nodeTheta = TestNode(newNode.name, basedirpath=tdirWithPoolTxns, config=tconf, pluginPaths=allPluginsPath, ha=newNode.nodestack.ha, cliha=newNode.clientstack.ha) looper.add(nodeTheta) txnPoolNodeSet.append(nodeTheta) looper.run(checkNodesConnected(txnPoolNodeSet, overrideTimeout=30)) ensureClientConnectedToNodesAndPoolLedgerSame(looper, steward1, *txnPoolNodeSet) ensureClientConnectedToNodesAndPoolLedgerSame(looper, newSteward, *txnPoolNodeSet)