• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python port_dispenser.genHa函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中stp_core.network.port_dispenser.genHa函数的典型用法代码示例。如果您正苦于以下问题:Python genHa函数的具体用法?Python genHa怎么用?Python genHa使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了genHa函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testZStackSendRecvHugeDataUnderLimit

def testZStackSendRecvHugeDataUnderLimit(set_info_log_level, tdir, looper, tconf):
    names = ['Alpha', 'Beta']
    genKeys(tdir, names)

    # we use json serializer now, so final form will be {'k':'vvv...vvv'}
    # so here we try to prepare exactly tconf.MSG_LEN_LIMIT bytes after serialization
    msg = {'k': 'v' * (tconf.MSG_LEN_LIMIT - len("{'k':''}"))}

    betaHandler = [False]

    def recvHandlerAlpha(wrpMsg):
        pass

    def recvHandlerBeta(wrpMsg):
        rmsg, frm = wrpMsg
        betaHandler[0] = True
        assert frm == 'Alpha'
        assert rmsg == msg

    alpha = ZStack(names[0], ha=genHa(), basedirpath=tdir, msgHandler=recvHandlerAlpha, restricted=True,
                   config=adict(**tconf.__dict__), msgRejectHandler=None)

    beta = ZStack(names[1], ha=genHa(), basedirpath=tdir, msgHandler=recvHandlerBeta, restricted=True,
                  config=adict(**tconf.__dict__), msgRejectHandler=None)

    assert len(alpha.serializeMsg(msg)) == tconf.MSG_LEN_LIMIT

    prepStacks(looper, *(alpha, beta), connect=True, useKeys=True)

    stat = alpha.send(msg, beta.name)
    assert stat[0] is True

    looper.runFor(5)

    assert betaHandler[0] is True
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:35,代码来源:test_zstack.py


示例2: getPoolTxnData

def getPoolTxnData(nodeAndClientInfoFilePath, poolId, newPoolTxnNodeNames):
    data={}
    data["seeds"]={}
    data["txns"]=[]
    for index, n in enumerate(newPoolTxnNodeNames, start=1):
        newStewardAlias = poolId + "Steward" + str(index)
        stewardSeed = (newStewardAlias + "0" * (32 - len(newStewardAlias))).encode()
        data["seeds"][newStewardAlias] = stewardSeed
        stewardSigner = SimpleSigner(seed=stewardSeed)
        data["txns"].append({
                TARGET_NYM: stewardSigner.verkey,
                ROLE: STEWARD, TXN_TYPE: NYM,
                ALIAS: poolId + "Steward" + str(index),
                TXN_ID: sha256("{}".format(stewardSigner.verkey).encode()).hexdigest()
        })

        newNodeAlias = n
        nodeSeed = (newNodeAlias + "0" * (32 - len(newNodeAlias))).encode()
        data["seeds"][newNodeAlias] = nodeSeed
        nodeSigner = SimpleSigner(seed=nodeSeed)
        data["txns"].append({
                TARGET_NYM: nodeSigner.verkey,
                TXN_TYPE: NODE,
                f.IDENTIFIER.nm: stewardSigner.verkey,
                DATA: {
                    CLIENT_IP: "127.0.0.1",
                    ALIAS: newNodeAlias,
                    NODE_IP: "127.0.0.1",
                    NODE_PORT: genHa()[1],
                    CLIENT_PORT: genHa()[1],
                    SERVICES: [VALIDATOR],
                },
                TXN_ID: sha256("{}".format(nodeSigner.verkey).encode()).hexdigest()
        })
    return data
开发者ID:dhh1128,项目名称:indy-client,代码行数:35,代码来源:helper.py


示例3: registry

def registry():
    return {
        'Alpha': genHa(),
        'Beta': genHa(),
        'Gamma': genHa(),
        'Delta': genHa()
    }
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:7,代码来源:test_node_to_node_quota.py


示例4: testManyMessages

def testManyMessages(set_info_log_level, tdir, looper, tconf):
    names = ['Alpha', 'Beta']
    genKeys(tdir, names)
    alphaP = Printer(names[0])
    betaMsgHandler = CounterMsgsHandler()

    alpha = ZStack(names[0],
                   ha=genHa(),
                   basedirpath=tdir,
                   msgHandler=alphaP.print,
                   restricted=True)
    beta = ZStack(names[1],
                  ha=genHa(),
                  basedirpath=tdir,
                  msgHandler=betaMsgHandler.handler,
                  restricted=True)
    prepStacks(looper, alpha, beta, connect=True, useKeys=True)

    looper.runFor(1)

    msgNum = BIG_NUM_OF_MSGS
    msgSender = MessageSender(msgNum, alpha, beta.name)
    looper.add(msgSender)

    def checkAllReceived():
        assert msgSender.sentMsgCount == msgNum
        assert betaMsgHandler.receivedMsgCount == msgNum

    looper.run(eventually(checkAllReceived,
                          retryWait=1,
                          timeout=60))
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:31,代码来源:test_quotas.py


示例5: testMessageQuota

def testMessageQuota(set_info_log_level, tdir, looper):
    names = ['Alpha', 'Beta']
    genKeys(tdir, names)
    alphaP = Printer(names[0])
    betaMsgHandler = CollectingMsgsHandler()

    alpha = ZStack(names[0], ha=genHa(), basedirpath=tdir, msgHandler=alphaP.print,
                   restricted=True)
    beta = ZStack(names[1], ha=genHa(), basedirpath=tdir, msgHandler=betaMsgHandler.handler,
                  restricted=True, onlyListener=True)

    prepStacks(looper, alpha, beta, connect=True, useKeys=True)

    messages = []
    numMessages = 150 * beta.listenerQuota
    for i in range(numMessages):
        msg = json.dumps({'random': randomSeed().decode()}).encode()
        if alpha.send(msg, beta.name):
            messages.append(json.loads(msg.decode()))

    def checkAllReceived():
        assert len(messages) == len(betaMsgHandler.receivedMessages)
        assert messages == betaMsgHandler.receivedMessages

    looper.run(eventually(checkAllReceived, retryWait=0.5,
                          timeout=5))
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:26,代码来源:test_quotas.py


示例6: testSimpleZStacksMsgs

def testSimpleZStacksMsgs(tdir, looper):
    names = ['Alpha', 'Beta']
    genKeys(tdir, names)
    names = ['Alpha', 'Beta']
    aseed = randomSeed()
    bseed = randomSeed()

    size = 100000
    msg = json.dumps({'random': randomSeed(size).decode()}).encode()

    def aHandler(m):
        str_m = "{}".format(m)
        print('{} printing... {}'.format(names[0], str_m[:100]))
        d, _ = m
        print('Message size is {}'.format(len(d['random'])))
        assert len(d['random']) == size

    def bHandler(m):
        print(beta.msgHandler)
        a = m[1]
        try:
            beta.listener.send_multipart([a, msg],
                                         flags=zmq.NOBLOCK)
        except zmq.Again:
            return False
        str_m = "{}".format(m)
        print('{} printing... {}'.format(names[1], str_m[:100]))

    stackParams = {
        "name": names[0],
        "ha": genHa(),
        "auto": 2,
        "basedirpath": tdir
    }
    alpha = SimpleZStack(stackParams, aHandler, aseed, False)

    stackParams = {
        "name": names[1],
        "ha": genHa(),
        "auto": 2,
        "basedirpath": tdir
    }
    beta = SimpleZStack(stackParams, bHandler, bseed, True)

    amotor = SMotor(alpha)
    looper.add(amotor)

    bmotor = SMotor(beta)
    looper.add(bmotor)

    alpha.connect(name=beta.name, ha=beta.ha,
                  verKeyRaw=beta.verKeyRaw, publicKeyRaw=beta.publicKeyRaw)

    looper.runFor(0.25)
    alpha.send({'greetings': 'hi'}, beta.name)
    looper.runFor(1)
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:56,代码来源:test_large_messages.py


示例7: testConsecutiveAddSameNodeWithNonAliasChange

def testConsecutiveAddSameNodeWithNonAliasChange(be, do, newStewardCli,
                                                 newNodeVals, newNodeAdded):
    be(newStewardCli)
    nodeIp, nodePort = genHa()
    clientIp, clientPort = genHa()
    newNodeVals['newNodeData'][NODE_IP] = nodeIp
    newNodeVals['newNodeData'][NODE_PORT] = nodePort
    newNodeVals['newNodeData'][CLIENT_IP] = nodeIp
    newNodeVals['newNodeData'][CLIENT_PORT] = clientPort
    doSendNodeCmd(do, newNodeVals)
    exitFromCli(do)
开发者ID:Artemkaaas,项目名称:sovrin-node,代码行数:11,代码来源:test_node.py


示例8: testChangeNodeHaBack

def testChangeNodeHaBack(looper, txnPoolNodeSet,
                         sdk_pool_handle,
                         sdk_node_theta_added,
                         tconf, tdir):
    """
    The case:
        The Node HA is updated with some HA (let's name it 'correct' HA).
        Then the Steward makes a mistake and sends the NODE txn with other HA
        ('wrong' HA). The Steward replaces back 'wrong' HA by 'correct' HA sending
        yet another one NODE txn.
    """
    new_steward_wallet, new_node = sdk_node_theta_added
    client_ha = new_node.cliNodeReg['ThetaC']  # use the same client HA
    # do all exercises without the Node
    new_node.stop()
    looper.removeProdable(name=new_node.name)

    # step 1: set 'correct' HA
    correct_node_ha = genHa(1)

    node_dest = hexToFriendly(new_node.nodestack.verhex)
    sdk_send_update_node(looper, new_steward_wallet, sdk_pool_handle,
                         node_dest, new_node.name,
                         correct_node_ha.host, correct_node_ha.port,
                         client_ha.host, client_ha.port)

    # step 2: set 'wrong' HA
    wrong_node_ha = genHa(1)
    sdk_send_update_node(looper, new_steward_wallet, sdk_pool_handle,
                         node_dest, new_node.name,
                         wrong_node_ha.host, wrong_node_ha.port,
                         client_ha.host, client_ha.port)

    # step 3: set 'correct' HA back
    sdk_send_update_node(looper, new_steward_wallet, sdk_pool_handle,
                         node_dest, new_node.name,
                         correct_node_ha.host, correct_node_ha.port,
                         client_ha.host, client_ha.port)

    # In order to save the time the pool connection is not maintaining
    # during the steps, only the final result is checked.
    config_helper = PNodeConfigHelper(new_node.name, tconf, chroot=tdir)
    restartedNode = TestNode(new_node.name,
                             config_helper=config_helper,
                             config=tconf, ha=correct_node_ha, cliha=client_ha)
    looper.add(restartedNode)
    txnPoolNodeSet[-1] = restartedNode

    looper.run(checkNodesConnected(txnPoolNodeSet))
    # check Theta HA
    for n in txnPoolNodeSet:
        assert n.nodeReg['Theta'] == correct_node_ha
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:52,代码来源:test_nodes_ha_change_back.py


示例9: test_queue_size_limit_set

def test_queue_size_limit_set(tdir, tconf):
    stack = ZStack("Alpha", ha=genHa(), basedirpath=tdir, msgHandler=None,
                   restricted=False, seed=randomSeed(), config=tconf)
    stack.start()
    assert stack.listener.get_hwm() == 0
    stack.stop()

    queue_size = 100
    stack = ZStack("Alpha", ha=genHa(), basedirpath=tdir, msgHandler=None,
                   restricted=False, seed=randomSeed(), config=tconf, queue_size=queue_size)
    stack.start()
    assert stack.listener.get_hwm() == queue_size
    stack.stop()
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:13,代码来源:test_zstack.py


示例10: _

    def _(wallet, basedir=None):
        basedir = basedir or tdirWithPoolTxns
        _, port = genHa()
        _, clientPort = genHa()
        client = TestClient(randomString(6),
                            ha=("0.0.0.0", clientPort),
                            basedirpath=basedir)

        agent = WalletedAgent(name=wallet.name,
                              basedirpath=basedir,
                              client=client,
                              wallet=wallet,
                              port=port)

        return agent
开发者ID:Artemkaaas,项目名称:sovrin-node,代码行数:15,代码来源:conftest.py


示例11: test_get_msgs_from_rxMsgs_queue

def test_get_msgs_from_rxMsgs_queue(create_node_and_not_start, looper):
    node = create_node_and_not_start
    node.view_changer = ViewChanger(node)
    node.view_changer.view_no = 0
    """pre_view_change stage"""
    node.view_changer.startViewChange(1)
    assert node.view_changer.view_no == 0
    prepare = Prepare(
        0,
        0,
        1,
        get_utc_epoch(),
        'f99937241d4c891c08e92a3cc25966607315ca66b51827b170d492962d58a9be',
        'CZecK1m7VYjSNCC7pGHj938DSW2tfbqoJp1bMJEtFqvG',
        '7WrAMboPTcMaQCU1raoj28vnhu2bPMMd2Lr9tEcsXeCJ')
    inst_change = InstanceChange(1, 25)
    m = node.nodeInBox.popleft()
    assert isinstance(m[0], ViewChangeStartMessage)
    node.nodestack.addRemote('someNode', genHa(), b'1DYuELN<SHbv1?NJ=][4De%^Hge887B0I!s<YGdD', 'pubkey')
    node.nodestack.rxMsgs.append((json.dumps(prepare._asdict()), 'pubkey'))
    node.nodestack.rxMsgs.append((json.dumps(inst_change._asdict()), 'pubkey'))
    node.msgHasAcceptableViewNo = lambda *args, **kwargs: True
    """While processing ViewChangeStartMessage from nodeInBox queue, should be:
    - move msgs from rxMsgs queue to nodeInBox queue
    - process all 3PC msgs (for Prepare msg it should be moved to inBox queue of master_replica)
    - add ViewChangeContinue msg into master_replica's inBox queue
    - all not 3PC msgs will be stashed in strategy queue"""
    looper.run(node.process_one_node_message(m))
    m = node.master_replica.inBox.popleft()
    assert isinstance(m[0], Prepare)
    m = node.master_replica.inBox.popleft()
    assert isinstance(m, ViewChangeContinueMessage)
    m = node.view_changer.pre_vc_strategy.stashedNodeInBox.popleft()
    assert isinstance(m[0], InstanceChange)
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:34,代码来源:test_vc_start_msg_strategy.py


示例12: put_load

def put_load():
    port = genHa()[1]
    ha = HA('0.0.0.0', port)
    name = "hello"
    wallet = Wallet(name)
    wallet.addIdentifier(
        signer=DidSigner(seed=b'000000000000000000000000Steward1'))
    client = Client(name, ha=ha)
    with Looper(debug=getConfig().LOOPER_DEBUG) as looper:
        looper.add(client)
        print('Will send {} reqs in all'.format(numReqs))
        requests = sendRandomRequests(wallet, client, numReqs)
        start = perf_counter()
        for i in range(0, numReqs, numReqs // splits):
            print('Will wait for {} now'.format(numReqs // splits))
            s = perf_counter()
            reqs = requests[i:i + numReqs // splits + 1]
            waitForSufficientRepliesForRequests(looper, client, requests=reqs,
                                                customTimeoutPerReq=100,
                                                override_timeout_limit=True)
            print('>>> Got replies for {} requests << in {}'.
                  format(numReqs // splits, perf_counter() - s))
        end = perf_counter()
        print('>>>Total {} in {}<<<'.format(numReqs, end - start))
        exit(0)
开发者ID:chriswinc,项目名称:indy-node,代码行数:25,代码来源:load.py


示例13: prepare_new_node_data

def prepare_new_node_data(tconf, tdir, newNodeName, configClass=PNodeConfigHelper):
    sigseed = randomString(32).encode()
    (nodeIp, nodePort), (clientIp, clientPort) = genHa(2)
    config_helper = configClass(newNodeName, tconf, chroot=tdir)
    pubkey, verkey, bls_key, key_proof = initNodeKeysForBothStacks(newNodeName, config_helper.keys_dir,
                                                   sigseed, override=True)
    return sigseed, verkey, bls_key, nodeIp, nodePort, clientIp, clientPort, key_proof
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:7,代码来源:helper.py


示例14: testChangeHaPersistsPostNodesRestart

def testChangeHaPersistsPostNodesRestart(looper, txnPoolNodeSet,
                                         tdir, tconf,
                                         sdk_pool_handle,
                                         sdk_wallet_client,
                                         sdk_wallet_steward):
    new_steward_wallet, new_node = \
        sdk_add_new_steward_and_node(looper,
                                     sdk_pool_handle,
                                     sdk_wallet_steward,
                                     'AnotherSteward' + randomString(4),
                                     'AnotherNode' + randomString(4),
                                     tdir,
                                     tconf)
    txnPoolNodeSet.append(new_node)
    looper.run(checkNodesConnected(txnPoolNodeSet))
    sdk_pool_refresh(looper, sdk_pool_handle)

    node_new_ha, client_new_ha = genHa(2)
    logger.debug("{} changing HAs to {} {}".format(new_node, node_new_ha,
                                                   client_new_ha))

    # Making the change HA txn an confirming its succeeded
    node_dest = hexToFriendly(new_node.nodestack.verhex)
    sdk_send_update_node(looper, new_steward_wallet, sdk_pool_handle,
                         node_dest, new_node.name,
                         node_new_ha.host, node_new_ha.port,
                         client_new_ha.host, client_new_ha.port)

    # Stopping existing nodes
    for node in txnPoolNodeSet:
        node.stop()
        looper.removeProdable(node)

    # Starting nodes again by creating `Node` objects since that simulates
    # what happens when starting the node with script
    restartedNodes = []
    for node in txnPoolNodeSet[:-1]:
        config_helper = PNodeConfigHelper(node.name, tconf, chroot=tdir)
        restartedNode = TestNode(node.name,
                                 config_helper=config_helper,
                                 config=tconf, ha=node.nodestack.ha,
                                 cliha=node.clientstack.ha)
        looper.add(restartedNode)
        restartedNodes.append(restartedNode)

    # Starting the node whose HA was changed
    config_helper = PNodeConfigHelper(new_node.name, tconf, chroot=tdir)
    node = TestNode(new_node.name,
                    config_helper=config_helper,
                    config=tconf,
                    ha=node_new_ha, cliha=client_new_ha)
    looper.add(node)
    restartedNodes.append(node)

    looper.run(checkNodesConnected(restartedNodes))
    waitNodeDataEquality(looper, node, *restartedNodes[:-1])
    sdk_pool_refresh(looper, sdk_pool_handle)
    sdk_ensure_pool_functional(looper, restartedNodes, sdk_wallet_client, sdk_pool_handle)
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:58,代码来源:test_change_ha_persists_post_nodes_restart.py


示例15: getPoolTxnData

def getPoolTxnData(poolId, newPoolTxnNodeNames):
    data = {}
    data["seeds"] = {}
    data["txns"] = []
    data['nodesWithBls'] = {}
    for index, n in enumerate(newPoolTxnNodeNames, start=1):
        newStewardAlias = poolId + "Steward" + str(index)
        stewardSeed = (newStewardAlias + "0" *
                       (32 - len(newStewardAlias))).encode()
        data["seeds"][newStewardAlias] = stewardSeed
        stewardSigner = SimpleSigner(seed=stewardSeed)
        data["txns"].append({
            TARGET_NYM: stewardSigner.verkey,
            ROLE: STEWARD, TXN_TYPE: NYM,
            ALIAS: poolId + "Steward" + str(index),
            TXN_ID: sha256("{}".format(stewardSigner.verkey).encode()).hexdigest()
        })

        newNodeAlias = n
        nodeSeed = (newNodeAlias + "0" * (32 - len(newNodeAlias))).encode()
        data["seeds"][newNodeAlias] = nodeSeed
        nodeSigner = SimpleSigner(seed=nodeSeed)
        node_txn = {
            TARGET_NYM: nodeSigner.verkey,
            TXN_TYPE: NODE,
            f.IDENTIFIER.nm: stewardSigner.verkey,
            DATA: {
                CLIENT_IP: "127.0.0.1",
                ALIAS: newNodeAlias,
                NODE_IP: "127.0.0.1",
                NODE_PORT: genHa()[1],
                CLIENT_PORT: genHa()[1],
                SERVICES: [VALIDATOR],
            },
            TXN_ID: sha256("{}".format(nodeSigner.verkey).encode()).hexdigest()
        }

        _, bls_key = create_default_bls_crypto_factory().generate_bls_keys(
            seed=data['seeds'][n])
        node_txn[DATA][BLS_KEY] = bls_key
        data['nodesWithBls'][n] = True

        data["txns"].append(node_txn)

    return data
开发者ID:chriswinc,项目名称:indy-node,代码行数:45,代码来源:helper.py


示例16: genNodeReg

def genNodeReg(count=None, names=None) -> Dict[str, NodeDetail]:
    """

    :param count: number of nodes, mutually exclusive with names
    :param names: iterable with names of nodes, mutually exclusive with count
    :return: dictionary of name: (node stack HA, client stack name, client stack HA)
    """
    if names is None:
        names = genNodeNames(count)
    nodeReg = OrderedDict(
        (n, NodeDetail(genHa(), n + CLIENT_STACK_SUFFIX, genHa())) for n in
        names)

    def extractCliNodeReg(self):
        return OrderedDict((n.cliname, n.cliha) for n in self.values())

    nodeReg.extractCliNodeReg = types.MethodType(extractCliNodeReg, nodeReg)
    return nodeReg
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:18,代码来源:test_node.py


示例17: getPoolTxnData

def getPoolTxnData(poolId, newPoolTxnNodeNames):
    data = {}
    data["seeds"] = {}
    data["txns"] = []
    data['nodesWithBls'] = {}
    for index, n in enumerate(newPoolTxnNodeNames, start=1):
        newStewardAlias = poolId + "Steward" + str(index)
        stewardSeed = (newStewardAlias + "0" *
                       (32 - len(newStewardAlias))).encode()
        data["seeds"][newStewardAlias] = stewardSeed
        stewardSigner = SimpleSigner(seed=stewardSeed)
        data["txns"].append(
            Member.nym_txn(nym=stewardSigner.identifier,
                           verkey=stewardSigner.verkey,
                           role=STEWARD,
                           name=poolId + "Steward" + str(index),
                           seq_no=index,
                           txn_id=sha256("{}".format(stewardSigner.verkey).encode()).hexdigest()))

        newNodeAlias = n
        nodeSeed = (newNodeAlias + "0" * (32 - len(newNodeAlias))).encode()
        data["seeds"][newNodeAlias] = nodeSeed
        nodeSigner = SimpleSigner(seed=nodeSeed)

        _, bls_key = create_default_bls_crypto_factory().generate_bls_keys(
            seed=data['seeds'][n])
        data['nodesWithBls'][n] = True

        node_txn = Steward.node_txn(
            steward_nym=stewardSigner.verkey,
            node_name=newNodeAlias,
            nym=nodeSigner.verkey,
            ip="127.0.0.1",
            node_port=genHa()[1],
            client_port=genHa()[1],
            client_ip="127.0.0.1",
            blskey=bls_key,
            services=[VALIDATOR],
            txn_id=sha256("{}".format(nodeSigner.verkey).encode()).hexdigest()
        )

        data["txns"].append(node_txn)

    return data
开发者ID:dougives,项目名称:indy-node,代码行数:44,代码来源:helper.py


示例18: changeNodeHa

def changeNodeHa(looper, txnPoolNodeSet,
                 tconf, shouldBePrimary, tdir,
                 sdk_pool_handle, sdk_wallet_stewards,
                 sdk_wallet_client):
    # prepare new ha for node and client stack
    subjectedNode = None
    node_index = None

    for nodeIndex, n in enumerate(txnPoolNodeSet):
        if shouldBePrimary == n.has_master_primary:
            subjectedNode = n
            node_index = nodeIndex
            break

    nodeStackNewHA, clientStackNewHA = genHa(2)
    logger.debug("change HA for node: {} to {}".format(
        subjectedNode.name, (nodeStackNewHA, clientStackNewHA)))

    # change HA
    sdk_wallet_steward = sdk_wallet_stewards[node_index]
    node_dest = hexToFriendly(subjectedNode.nodestack.verhex)
    sdk_send_update_node(looper, sdk_wallet_steward,
                         sdk_pool_handle,
                         node_dest, subjectedNode.name,
                         nodeStackNewHA[0], nodeStackNewHA[1],
                         clientStackNewHA[0], clientStackNewHA[1],
                         services=[VALIDATOR])

    # stop node for which HA will be changed
    subjectedNode.stop()
    looper.removeProdable(subjectedNode)

    # start node with new HA
    config_helper = PNodeConfigHelper(subjectedNode.name, tconf, chroot=tdir)
    restartedNode = TestNode(subjectedNode.name,
                             config_helper=config_helper,
                             config=tconf, ha=nodeStackNewHA,
                             cliha=clientStackNewHA)
    looper.add(restartedNode)
    txnPoolNodeSet[nodeIndex] = restartedNode
    looper.run(checkNodesConnected(txnPoolNodeSet, customTimeout=70))


    electionTimeout = waits.expectedPoolElectionTimeout(
        nodeCount=len(txnPoolNodeSet),
        numOfReelections=3)
    ensureElectionsDone(looper,
                        txnPoolNodeSet,
                        retryWait=1,
                        customTimeout=electionTimeout)

    sdk_pool_refresh(looper, sdk_pool_handle)
    sdk_send_random_and_check(looper, txnPoolNodeSet,
                              sdk_pool_handle,
                              sdk_wallet_client,
                              8)
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:56,代码来源:helper.py


示例19: testZStackRecvHugeDataOverLimit

def testZStackRecvHugeDataOverLimit(set_info_log_level, tdir, looper, tconf):
    names = ['Alpha', 'Beta']
    genKeys(tdir, names)

    # we use json serializer now, so final form will be {'k':'vvv...vvv'}
    # so here we try to prepare exactly tconf.MSG_LEN_LIMIT + 1 bytes after serialization
    msg = {'k': 'v' * (tconf.MSG_LEN_LIMIT - len("{'k':''}") + 1)}

    betaHandlers = [False, False]

    def recvHandlerAlpha(wrpMsg):
        pass

    def recvHandlerBeta(wrpMsg):
        rmsg, frm = wrpMsg
        betaHandlers[0] = True
        assert frm is not None
        assert rmsg is not None

    def rejectHandlerBeta(reason, frm):
        betaHandlers[1] = True
        assert 'exceeded allowed limit of {}'.format(
            tconf.MSG_LEN_LIMIT) in reason
        assert frm == 'Alpha'

    alpha = ZStack(names[0], ha=genHa(), basedirpath=tdir, msgHandler=recvHandlerAlpha, restricted=True,
                   config=adict(**tconf.__dict__), msgRejectHandler=None)

    beta = ZStack(names[1], ha=genHa(), basedirpath=tdir, msgHandler=recvHandlerBeta, restricted=True,
                  config=adict(**tconf.__dict__), msgRejectHandler=rejectHandlerBeta)

    bytemsg = alpha.serializeMsg(msg)
    assert len(bytemsg) == (tconf.MSG_LEN_LIMIT + 1)

    prepStacks(looper, *(alpha, beta), connect=True, useKeys=True)

    stat = alpha._remotes['Beta'].socket.send(bytemsg, copy=False, track=True)
    assert stat

    looper.runFor(5)

    assert betaHandlers[0] is False
    assert betaHandlers[1] is True
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:43,代码来源:test_zstack.py


示例20: createClientAndWalletWithSeed

def createClientAndWalletWithSeed(name, seed, ha=None):
    if isinstance(seed, str):
        seed = seed.encode()
    if not ha:
        port = genHa()[1]
        ha = HA('0.0.0.0', port)
    wallet = Wallet(name)
    wallet.addIdentifier(signer=DidSigner(seed=seed))
    client = Client(name, ha=ha)
    return client, wallet
开发者ID:chriswinc,项目名称:indy-node,代码行数:10,代码来源:load_test.py



注:本文中的stp_core.network.port_dispenser.genHa函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python strFunctions.cap函数代码示例发布时间:2022-05-27
下一篇:
Python eventually.eventually函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap