本文整理汇总了Python中stp_core.loop.eventually.eventually函数的典型用法代码示例。如果您正苦于以下问题:Python eventually函数的具体用法?Python eventually怎么用?Python eventually使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eventually函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_propagate_of_ordered_request_doesnt_stash_requests_in_authenticator
def test_propagate_of_ordered_request_doesnt_stash_requests_in_authenticator(
looper, txnPoolNodeSet, sdk_pool_handle, sdk_wallet_client):
# Universal delayer
def stopAll(msg):
return 100000
def check_verified_req_list_is_empty():
for node in txnPoolNodeSet:
assert len(node.clientAuthNr._verified_reqs) == 0
# Order one request while cutting off last node
lastNode = txnPoolNodeSet[-1]
with delay_rules(lastNode.nodeIbStasher, stopAll), \
delay_rules(lastNode.clientIbStasher, stopAll):
sdk_send_random_and_check(looper, txnPoolNodeSet,
sdk_pool_handle,
sdk_wallet_client, 1)
old_propagates = [n.spylog.count('processPropagate') for n in txnPoolNodeSet]
def check_more_propagates_delivered():
new_propagates = [n.spylog.count('processPropagate') for n in txnPoolNodeSet]
assert all(old < new for old, new in zip(old_propagates, new_propagates))
# Wait until more propagates are delivered to all nodes
looper.run(eventually(check_more_propagates_delivered))
# Make sure that verified req list will be empty eventually
looper.run(eventually(check_verified_req_list_is_empty))
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:29,代码来源:test_req_authenticator.py
示例2: test_zstack_non_utf8
def test_zstack_non_utf8(tdir, looper, tconf):
"""
ZStack gets a non utf-8 message and does not hand it over to the
processing method
:return:
"""
names = ['Alpha', 'Beta']
genKeys(tdir, names)
(alpha, beta), (alphaP, betaP) = create_and_prep_stacks(names, tdir,
looper, tconf)
# Send a utf-8 message and see its received
for uid in alpha.remotes:
alpha.transmit(b'{"k1": "v1"}', uid, serialized=True)
looper.run(eventually(chkPrinted, betaP, {"k1": "v1"}))
# Send a non utf-8 message and see its not received (by the receiver method)
for uid in alpha.remotes:
alpha.transmit(b'{"k2": "v2\x9c"}', uid, serialized=True)
with pytest.raises(AssertionError):
looper.run(eventually(chkPrinted, betaP, {"k2": "v2\x9c"}))
# TODO: A better test where the output of the parsing method is checked
# requires spyable methods
# Again send a utf-8 message and see its received (checks if stack is
# functional after receiving a bad message)
for uid in alpha.remotes:
alpha.transmit(b'{"k3": "v3"}', uid, serialized=True)
looper.run(eventually(chkPrinted, betaP, {"k3": "v3"}))
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:29,代码来源:test_zstack.py
示例3: testValidatorSuspensionByTrustee
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))
开发者ID:chriswinc,项目名称:indy-node,代码行数:7,代码来源:test_suspension.py
示例4: testPrePrepareWithHighSeqNo
def testPrePrepareWithHighSeqNo(looper, txnPoolNodeSet, propagated1):
def chk():
for r in getNonPrimaryReplicas(txnPoolNodeSet, instId):
nodeSuspicions = len(getNodeSuspicions(
r.node, Suspicions.WRONG_PPSEQ_NO.code))
assert nodeSuspicions == 1
def checkPreprepare(replica, viewNo, ppSeqNo, req, numOfPrePrepares):
assert (replica.prePrepares[viewNo, ppSeqNo][0]) == \
(req.identifier, req.reqId, req.digest)
primary = getPrimaryReplica(txnPoolNodeSet, instId)
nonPrimaryReplicas = getNonPrimaryReplicas(txnPoolNodeSet, instId)
req = propagated1.reqDigest
primary.doPrePrepare(req)
timeout = waits.expectedPrePrepareTime(len(txnPoolNodeSet))
for np in nonPrimaryReplicas:
looper.run(
eventually(checkPreprepare, np, primary.viewNo,
primary.lastPrePrepareSeqNo - 1, req, 1,
retryWait=.5, timeout=timeout))
newReqDigest = (req.identifier, req.reqId + 1, req.digest)
incorrectPrePrepareReq = PrePrepare(instId,
primary.viewNo,
primary.lastPrePrepareSeqNo + 2,
*newReqDigest,
get_utc_epoch())
primary.send(incorrectPrePrepareReq, TPCStat.PrePrepareSent)
timeout = waits.expectedPrePrepareTime(len(txnPoolNodeSet))
looper.run(eventually(chk, retryWait=1, timeout=timeout))
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:32,代码来源:test_primary_sends_preprepare_of_high_num.py
示例5: do_view_change_with_unaligned_prepare_certificates
def do_view_change_with_unaligned_prepare_certificates(
slow_nodes, nodes, looper, sdk_pool_handle, sdk_wallet_client):
"""
Perform view change with some nodes reaching lower last prepared certificate than others.
With current implementation of view change this can result with view change taking a lot of time.
"""
fast_nodes = [n for n in nodes if n not in slow_nodes]
all_stashers = [n.nodeIbStasher for n in nodes]
slow_stashers = [n.nodeIbStasher for n in slow_nodes]
# Delay some PREPAREs and all COMMITs
with delay_rules(slow_stashers, pDelay()):
with delay_rules(all_stashers, cDelay()):
# Send request
request = sdk_send_random_request(looper, sdk_pool_handle, sdk_wallet_client)
# Wait until this request is prepared on fast nodes
looper.run(eventually(check_last_prepared_certificate, fast_nodes, (0, 1)))
# Make sure its not prepared on slow nodes
looper.run(eventually(check_last_prepared_certificate, slow_nodes, None))
# Trigger view change
for n in nodes:
n.view_changer.on_master_degradation()
# Now commits are processed
# Wait until view change is complete
looper.run(eventually(check_view_change_done, nodes, 1, timeout=60))
# Finish request gracefully
sdk_get_reply(looper, request)
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:32,代码来源:helper.py
示例6: test_request_older_than_stable_checkpoint_removed
def test_request_older_than_stable_checkpoint_removed(chkFreqPatched, looper, txnPoolNodeSet, sdk_pool_handle,
sdk_wallet_steward, reqs_for_checkpoint):
timeout = waits.expectedTransactionExecutionTime(len(txnPoolNodeSet))
max_batch_size = chkFreqPatched.Max3PCBatchSize
# Send some requests (insufficient for checkpoint),
# wait replies and check that current checkpoint is not stable
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle, sdk_wallet_steward, 2 * max_batch_size)
looper.run(eventually(chkChkpoints, txnPoolNodeSet, 1, retryWait=1, timeout=timeout))
checkRequestCounts(txnPoolNodeSet, 2 * max_batch_size, 2)
# From the steward send a request creating a user with None role
sdk_wallet_user = sdk_add_new_nym(looper, sdk_pool_handle, sdk_wallet_steward)
looper.run(eventually(chkChkpoints, txnPoolNodeSet, 1, retryWait=1, timeout=timeout))
checkRequestCounts(txnPoolNodeSet, 2 * max_batch_size + 1, 3)
# From the created user send a request creating another user.
# Dynamic validation of this request must fail since a user with None role cannot create users.
# However, the 3PC-batch with the sent request must be ordered.
with pytest.raises(RequestRejectedException):
sdk_add_new_nym(looper, sdk_pool_handle, sdk_wallet_user)
looper.run(eventually(chkChkpoints, txnPoolNodeSet, 1, retryWait=1, timeout=timeout))
checkRequestCounts(txnPoolNodeSet, 2 * max_batch_size + 2, 4)
# Send more requests to cause checkpoint stabilization
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle, sdk_wallet_steward, max_batch_size)
# Check that checkpoint is stable now
# and verify that requests for it were removed
looper.run(eventually(chkChkpoints, txnPoolNodeSet, 1, 0, retryWait=1, timeout=timeout))
checkRequestCounts(txnPoolNodeSet, 0, 0)
# Send more requests to cause new checkpoint
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle, sdk_wallet_steward, reqs_for_checkpoint + 1)
looper.run(eventually(chkChkpoints, txnPoolNodeSet, 2, 0, retryWait=1, timeout=timeout))
checkRequestCounts(txnPoolNodeSet, 1, 1)
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:35,代码来源:test_stable_checkpoint.py
示例7: testRescheduleUpgradeToLowerVersionThanPreviouslyScheduled
def testRescheduleUpgradeToLowerVersionThanPreviouslyScheduled(
looper, tconf, nodeSet, validUpgrade, trustee, trusteeWallet):
"""
A node starts at version 1.2 running has scheduled upgrade for version 1.5
but get a txn for upgrade 1.4, it will schedule it and cancel upgrade to 1.5.
"""
upgr1 = deepcopy(validUpgrade)
upgr2 = deepcopy(upgr1)
upgr2[VERSION] = bumpVersion(upgr1[VERSION])
upgr2[NAME] += randomString(3)
# upgr2[SHA256] = get_valid_code_hash()
upgr2[SHA256] = 'ef9c3984e7a31994d4f692139116120bd0dd1ff7e270b6a2d773f8f2f9214d4c'
# An upgrade for higher version scheduled, it should pass
ensureUpgradeSent(looper, trustee, trusteeWallet, upgr2)
looper.run(
eventually(
checkUpgradeScheduled,
nodeSet,
upgr2[VERSION],
retryWait=1,
timeout=waits.expectedUpgradeScheduled()))
# An upgrade for lower version scheduled, the transaction should pass and
# the upgrade should be scheduled
ensureUpgradeSent(looper, trustee, trusteeWallet, upgr1)
looper.run(
eventually(
checkUpgradeScheduled,
nodeSet,
upgr1[VERSION],
retryWait=1,
timeout=waits.expectedUpgradeScheduled()))
开发者ID:chriswinc,项目名称:indy-node,代码行数:34,代码来源:test_reschedule_upgrade_lower_version.py
示例8: test_send_proof_works
def test_send_proof_works(aliceAgent, aliceAcceptedFaber, aliceAcceptedAcme,
acmeAgent, emptyLooper):
# 1. request Claims from Faber
faberLink = aliceAgent.wallet.getLink('Faber College')
name, version, origin = faberLink.availableClaims[0]
schemaKey = SchemaKey(name, version, origin)
aliceAgent.sendReqClaim(faberLink, schemaKey)
# 2. check that claim is received from Faber
async def chkClaims():
claim = await aliceAgent.prover.wallet.getClaimSignature(ID(schemaKey))
assert claim.primaryClaim
emptyLooper.run(eventually(chkClaims, timeout=waits.expectedClaimsReceived()))
# 3. send Proof Request to Alice
alice_link = acmeAgent.wallet.getLink('Alice')
acmeAgent.sendProofReq(alice_link, 'Job-Application-v0.3')
def chkProofRequest():
assert len(aliceAgent.wallet.getMatchingLinksWithProofReq("Job-Application-2", "Acme Corp")) > 0
emptyLooper.run(eventually(chkProofRequest, timeout=waits.expectedClaimsReceived()))
# 4. send proof to Acme
acme_link, acme_proof_req = aliceAgent.wallet.getMatchingLinksWithProofReq("Job-Application-2", "Acme Corp")[0]
aliceAgent.sendProof(acme_link, acme_proof_req)
# 5. check that proof is verified by Acme
def chkProof():
internalId = acmeAgent.get_internal_id_by_nonce(acme_link.invitationNonce)
link = acmeAgent.wallet.getLinkBy(internalId=internalId)
assert "Job-Application-2" in link.verifiedClaimProofs
emptyLooper.run(eventually(chkProof, timeout=waits.expectedClaimsReceived()))
开发者ID:Artemkaaas,项目名称:sovrin-node,代码行数:35,代码来源:test_anoncreds_send_proof_request.py
示例9: testOrderingCase1
def testOrderingCase1(looper, txnPoolNodeSet, sdk_wallet_client, sdk_pool_handle):
"""
Scenario -> PRE-PREPARE not received by the replica, Request not received
for ordering by the replica, but received enough commits to start ordering.
It queues up the request so when a PRE-PREPARE is received or request is
receievd for ordering, an order can be triggered
https://www.pivotaltracker.com/story/show/125239401
Reproducing by - Pick a node with no primary replica, replica ignores
forwarded request to replica and delay reception of PRE-PREPARE sufficiently
so that enough COMMITs reach to trigger ordering.
"""
delay = 10
replica = getNonPrimaryReplicas(txnPoolNodeSet, instId=0)[0]
delaysPrePrepareProcessing(replica.node, delay=delay, instId=0)
def doNotProcessReqDigest(self, _):
pass
patchedMethod = types.MethodType(doNotProcessReqDigest, replica)
replica.processRequest = patchedMethod
def chk(n):
assert replica.spylog.count(replica.doOrder.__name__) == n
sdk_send_random_request(looper, sdk_pool_handle, sdk_wallet_client)
timeout = delay - 5
looper.run(eventually(chk, 0, retryWait=1, timeout=timeout))
timeout = delay + 5
looper.run(eventually(chk, 1, retryWait=1, timeout=timeout))
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:30,代码来源:test_request_ordering_1.py
示例10: test_resend_instance_change_messages
def test_resend_instance_change_messages(looper,
txnPoolNodeSet,
tconf,
sdk_wallet_steward,
sdk_pool_handle):
primary_node = txnPoolNodeSet[0]
old_view_no = checkViewNoForNodes(txnPoolNodeSet, 0)
assert primary_node.master_replica.isPrimary
for n in txnPoolNodeSet:
n.nodeIbStasher.delay(icDelay(3 * tconf.INSTANCE_CHANGE_TIMEOUT))
assert set([n.view_changer.instance_change_rounds for n in txnPoolNodeSet]) == {0}
disconnect_node_and_ensure_disconnected(looper,
txnPoolNodeSet,
primary_node,
stopNode=False)
txnPoolNodeSet.remove(primary_node)
looper.run(eventually(partial(check_count_connected_node, txnPoolNodeSet, 4),
timeout=5,
acceptableExceptions=[AssertionError]))
looper.runFor(2*tconf.INSTANCE_CHANGE_TIMEOUT)
assert set([n.view_changer.instance_change_rounds for n in txnPoolNodeSet]) == {1}
looper.runFor(tconf.INSTANCE_CHANGE_TIMEOUT)
looper.run(eventually(partial(checkViewNoForNodes, txnPoolNodeSet, expectedViewNo=old_view_no + 1),
timeout=tconf.VIEW_CHANGE_TIMEOUT))
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle, sdk_wallet_steward, 5)
ensure_all_nodes_have_same_data(looper, txnPoolNodeSet)
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:27,代码来源:test_resend_instance_change_messages.py
示例11: test_api
def test_api():
loop = asyncio.get_event_loop()
with pytest.raises(PlenumValueError):
loop.run_until_complete(eventually(lambda x: True, timeout=0))
with pytest.raises(PlenumValueError):
loop.run_until_complete(eventually(lambda x: True, timeout=250))
loop.close()
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:7,代码来源:test_eventually.py
示例12: nymsAddedInQuickSuccession
def nymsAddedInQuickSuccession(nodeSet, addedTrustAnchor, looper,
trustAnchor, trustAnchorWallet):
usigner = DidSigner()
nym = usigner.verkey
idy = Identity(identifier=nym)
trustAnchorWallet.addTrustAnchoredIdentity(idy)
# Creating a NYM request with same nym again
req = idy.ledgerRequest()
trustAnchorWallet._pending.appendleft((req, idy.identifier))
reqs = trustAnchorWallet.preparePending()
trustAnchor.submitReqs(*reqs)
def check():
assert trustAnchorWallet._trustAnchored[nym].seqNo
timeout = waits.expectedTransactionExecutionTime(len(nodeSet))
looper.run(eventually(check, timeout=timeout))
timeout = waits.expectedReqNAckQuorumTime()
looper.run(eventually(checkNacks,
trustAnchor,
req.reqId,
"is already added",
retryWait=1, timeout=timeout))
count = 0
for node in nodeSet:
for seq, txn in node.domainLedger.getAllTxn():
if txn[TXN_TYPE] == NYM and txn[TARGET_NYM] == usigner.identifier:
count += 1
assert(count == len(nodeSet))
开发者ID:Artemkaaas,项目名称:sovrin-node,代码行数:31,代码来源:test_nym_attrib.py
示例13: testMultipleInstanceChangeMsgsMarkNodeAsSuspicious
def testMultipleInstanceChangeMsgsMarkNodeAsSuspicious(looper, txnPoolNodeSet):
maliciousNode = txnPoolNodeSet[0]
for i in range(0, 5):
maliciousNode.send(maliciousNode.view_changer._create_instance_change_msg(i, 0))
def chk(instId):
for node in txnPoolNodeSet:
if node.name != maliciousNode.name:
args = getAllArgs(node, ViewChanger.process_instance_change_msg)
assert len(args) == 5
for arg in args:
assert arg['frm'] == maliciousNode.name
numOfNodes = len(txnPoolNodeSet)
instanceChangeTimeout = waits.expectedPoolViewChangeStartedTimeout(
numOfNodes)
for i in range(0, 5):
looper.run(eventually(chk, i, retryWait=1,
timeout=instanceChangeTimeout))
def g():
for node in txnPoolNodeSet:
if node.name != maliciousNode.name:
frm, reason, code = getAllArgs(node, Node.reportSuspiciousNode)
assert frm == maliciousNode.name
assert isinstance(reason, SuspiciousNode)
suspectingNodes = \
getNodeSuspicions(node,
Suspicions.FREQUENT_INST_CHNG.code)
assert len(suspectingNodes) == 13
timeout = waits.expectedTransactionExecutionTime(numOfNodes)
looper.run(eventually(g, retryWait=1, timeout=timeout))
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:34,代码来源:test_multiple_instance_change_msgs.py
示例14: testPropagateRecvdBeforeRequest
def testPropagateRecvdBeforeRequest(setup, looper, txnPoolNodeSet, sent1):
A, B, C, D = txnPoolNodeSet
def x():
# A should not have received a request from the client
assert len(recvdRequest(A)) == 0
# A should have received only one PROPAGATE
assert len(recvdPropagate(A)) == 1
# A should have sent only one PROPAGATE
assert len(sentPropagate(A)) == 1
timeout = waits.expectedNodeToNodeMessageDeliveryTime() + delaySec - 2
looper.run(eventually(x, retryWait=.5, timeout=timeout))
def y():
# A should have received a request from the client
assert len(recvdRequest(A)) == 1
# A should still have sent only one PROPAGATE
assert len(sentPropagate(A)) == 1
timeout = waits.expectedNodeToNodeMessageDeliveryTime() + delaySec + 2
looper.run(eventually(y, retryWait=.5, timeout=timeout))
def chk():
# A should have forwarded the request
assertLength(forwardedRequest(A), 1)
timeout = waits.expectedClientRequestPropagationTime(
len(txnPoolNodeSet)) + delaySec
looper.run(eventually(chk, retryWait=1, timeout=timeout))
auth_obj = A.authNr(0).core_authenticator
auth_calling_count = get_count(auth_obj, auth_obj.authenticate)
assert auth_calling_count == reqCount
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:33,代码来源:test_propagate_recvd_before_request.py
示例15: do_view_change_with_delayed_commits_on_all_but_one
def do_view_change_with_delayed_commits_on_all_but_one(nodes, nodes_without_one_stashers,
except_node,
looper,
sdk_pool_handle,
sdk_wallet_client):
new_view_no = except_node.viewNo + 1
old_last_ordered = except_node.master_replica.last_ordered_3pc
# delay commits for all nodes except node X
with delay_rules(nodes_without_one_stashers, cDelay(sys.maxsize)):
# send one request
requests2 = sdk_send_random_requests(looper, sdk_pool_handle,
sdk_wallet_client, 1)
def last_ordered(node: Node, last_ordered):
assert node.master_replica.last_ordered_3pc == last_ordered
# wait until except_node ordered txn
looper.run(
eventually(last_ordered, except_node, (except_node.viewNo,
old_last_ordered[1] + 1)))
# trigger view change on all nodes
for node in nodes:
node.view_changer.on_master_degradation()
# wait for view change done on all nodes
looper.run(eventually(view_change_done, nodes, new_view_no))
sdk_get_replies(looper, requests2)
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:29,代码来源:test_view_change_with_advancing_node.py
示例16: disconnect
def disconnect(looper, disconnected_stack, connection_timeout):
disconnected_motor, other_stacks = disconnected_stack
looper.run(eventually(
checkStackDisonnected, disconnected_motor.stack, other_stacks,
retryWait=1, timeout=connection_timeout))
looper.run(eventually(
checkStacksConnected, other_stacks, retryWait=1, timeout=connection_timeout))
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:7,代码来源:test_reconnect.py
示例17: testPropagateRecvdAfterRequest
def testPropagateRecvdAfterRequest(setup, looper, txnPoolNodeSet):
A, B, C, D = txnPoolNodeSet # type: TestNode
sent1 = sdk_json_to_request_object(setup[0][0])
def x():
# A should have received a request from the client
assert len(recvdRequest(A)) == 1
# A should not have received a PROPAGATE
assert len(recvdPropagate(A)) == 0
# A should have sent a PROPAGATE
assert len(sentPropagate(A)) == 1
timeout = howlong - 2
looper.run(eventually(x, retryWait=.5, timeout=timeout))
for n in txnPoolNodeSet:
n.nodeIbStasher.resetDelays()
def y():
# A should have received 3 PROPAGATEs
assert len(recvdPropagate(A)) == 3
# A should have total of 4 PROPAGATEs (3 from other nodes and 1 from
# itself)
key = sent1.digest
assert key in A.requests
assert len(A.requests[key].propagates) == 4
# A should still have sent only one PROPAGATE
assert len(sentPropagate(A)) == 1
timeout = howlong + 2
looper.run(eventually(y, retryWait=.5, timeout=timeout))
auth_obj = A.authNr(0).core_authenticator
auth_calling_count = get_count(auth_obj, auth_obj.authenticate)
assert auth_calling_count == reqCount
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:33,代码来源:test_propagate_recvd_after_request.py
示例18: test_all_replicas_hold_request_keys
def test_all_replicas_hold_request_keys(
perf_chk_patched,
looper,
txnPoolNodeSet,
sdk_wallet_client,
sdk_pool_handle):
"""
All replicas whether primary or non primary hold request keys of forwarded
requests. Once requests are ordered, they request keys are removed from replica.
"""
tconf = perf_chk_patched
delay_3pc = 2
delay_3pc_messages(txnPoolNodeSet, 0, delay_3pc)
delay_3pc_messages(txnPoolNodeSet, 1, delay_3pc)
def chk(count):
# All replicas have same amount of forwarded request keys and all keys
# are finalised.
for node in txnPoolNodeSet:
for r in node.replicas.values():
if r.isPrimary is False:
assert len(r.requestQueues[DOMAIN_LEDGER_ID]) == count
for i in range(count):
k = r.requestQueues[DOMAIN_LEDGER_ID][i]
assert r.requests[k].finalised
elif r.isPrimary is True:
assert len(r.requestQueues[DOMAIN_LEDGER_ID]) == 0
reqs = sdk_signed_random_requests(looper,
sdk_wallet_client,
tconf.Max3PCBatchSize - 1)
req_resps = sdk_send_signed_requests(sdk_pool_handle, reqs)
# Only non primary replicas should have all request keys with them
looper.run(eventually(chk, tconf.Max3PCBatchSize - 1))
sdk_get_replies(looper, req_resps, timeout=sdk_eval_timeout(
tconf.Max3PCBatchSize - 1, len(txnPoolNodeSet),
add_delay_to_timeout=delay_3pc))
# Replicas should have no request keys with them since they are ordered
looper.run(eventually(chk, 0)) # Need to wait since one node might not
# have processed it.
delay = 1
for node in txnPoolNodeSet:
node.nodeIbStasher.delay(nom_delay(delay))
ensure_view_change(looper, txnPoolNodeSet)
reqs = sdk_signed_random_requests(looper,
sdk_wallet_client,
2 * tconf.Max3PCBatchSize)
req_resps = sdk_send_signed_requests(sdk_pool_handle, reqs)
looper.run(eventually(chk, 2 * tconf.Max3PCBatchSize))
# Since each nomination is delayed and there will be multiple nominations
# so adding some extra time
timeout = waits.expectedPoolElectionTimeout(len(txnPoolNodeSet)) + \
len(txnPoolNodeSet) * delay
ensureElectionsDone(looper, txnPoolNodeSet, customTimeout=timeout)
sdk_get_replies(looper, req_resps, timeout=timeout)
looper.run(eventually(chk, 0))
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:59,代码来源:test_request_forwarding.py
示例19: test_req_drop_on_propagate_phase_on_non_primary_and_then_ordered
def test_req_drop_on_propagate_phase_on_non_primary_and_then_ordered(
tconf, setup, looper, txnPoolNodeSet,
sdk_wallet_client, sdk_pool_handle):
global initial_ledger_size
A, B, C, D = txnPoolNodeSet # type: TestNode
sent1 = sdk_json_to_request_object(setup[0][0])
lagged_node = C
def check_propagates_and_3pc_delayed():
# Node should have received a request from the client
assert len(recvdRequest(lagged_node)) == 1
# Node should not have received a PROPAGATE
assert len(recvdPropagate(lagged_node)) == 0
# Node should have sent a PROPAGATE
assert len(sentPropagate(lagged_node)) == 1
# Node should have not received PrePrepares for master instance
assert len(recvdPrePrepareForInstId(lagged_node, 0)) == 0
# Node should have not received Prepares for master instance
assert len(recvdPrepareForInstId(lagged_node, 0)) == 0
# Node should have not received Commits for master instance
assert len(recvdCommitForInstId(lagged_node, 0)) == 0
# Node should have 1 request in requests queue
assert len(lagged_node.requests) == 1
timeout = howlong - 2
looper.run(eventually(check_propagates_and_3pc_delayed, retryWait=.5, timeout=timeout))
def check_drop():
assert len(lagged_node.requests) == 0
timeout = tconf.PROPAGATES_PHASE_REQ_TIMEOUT + tconf.OUTDATED_REQS_CHECK_INTERVAL + 1
looper.run(eventually(check_drop, retryWait=.5, timeout=timeout))
for n in txnPoolNodeSet:
n.nodeIbStasher.resetDelays()
def check_propagates_received():
# Node should have received 3 PROPAGATEs
assert len(recvdPropagate(lagged_node)) == 3
# Node should have total of 4 PROPAGATEs (3 from other nodes and 1 from
# itself)
key = sent1.digest
assert key in lagged_node.requests
assert len(lagged_node.requests[key].propagates) == 4
# Node should still have sent two PROPAGATEs since request
# was dropped and re-received over propagate
assert len(sentPropagate(lagged_node)) == 2
timeout = howlong + 2
looper.run(eventually(check_propagates_received, retryWait=.5, timeout=timeout))
def check_ledger_size():
# The request should be eventually ordered
for n in txnPoolNodeSet:
assert n.domainLedger.size - initial_ledger_size == 1
looper.run(eventually(check_ledger_size, retryWait=.5, timeout=timeout))
sdk_ensure_pool_functional(looper, txnPoolNodeSet, sdk_wallet_client, sdk_pool_handle)
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:59,代码来源:test_req_drop_on_propagate_phase_non_primary.py
示例20: test_no_propagate_request_on_different_prepares_on_backup_before_vc
def test_no_propagate_request_on_different_prepares_on_backup_before_vc(looper, txnPoolNodeSet,
sdk_pool_handle, sdk_wallet_client):
''' Send random request and do view change then fast_nodes (2,3 - with
primary backup replica) will have prepare or send preprepare on backup
replicas and slow_nodes are have not and transaction will ordered on all
master replicas. Check last ordered after view change and after another
one request.'''
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle,
sdk_wallet_client, 1)
slow_instance = 1
slow_nodes = txnPoolNodeSet[1:3]
fast_nodes = [n for n in txnPoolNodeSet if n not in slow_nodes]
nodes_stashers = [n.nodeIbStasher for n in slow_nodes]
old_last_ordered = txnPoolNodeSet[0].master_replica.last_ordered_3pc
with delay_rules(nodes_stashers, pDelay(instId=slow_instance)):
with delay_rules(nodes_stashers, ppDelay(instId=slow_instance)):
# send one request
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle,
sdk_wallet_client, 1)
old_view_no = txnPoolNodeSet[0].viewNo
looper.run(
eventually(is_prepared,
fast_nodes,
2,
slow_instance))
# trigger view change on all nodes
ensure_view_change(looper, txnPoolNodeSet)
# wait for view change done on all nodes
ensureElectionsDone(looper, txnPoolNodeSet)
primary = getPrimaryReplica(txnPoolNodeSet, slow_instance).node
non_primaries = [n for n in txnPoolNodeSet if n is not primary]
check_last_ordered(non_primaries,
slow_instance,
(old_view_no, old_last_ordered[1] + 1))
# Backup primary replica must not advance last_ordered_3pc
# up to the master's value
check_last_ordered([primary],
slow_instance,
(old_view_no, old_last_ordered[1]))
check_last_ordered(txnPoolNodeSet,
txnPoolNodeSet[0].master_replica.instId,
(old_last_ordered[0], old_last_ordered[1] + 1))
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle,
sdk_wallet_client, 1)
looper.run(
eventually(check_last_ordered,
txnPoolNodeSet,
slow_instance,
(txnPoolNodeSet[0].viewNo, 1)))
assert all(0 == node.spylog.count(node.request_propagates)
for node in txnPoolNodeSet)
开发者ID:michaeldboyd,项目名称:indy-plenum,代码行数:57,代码来源:test_no_propagate_request_on_different_last_ordered_before_vc.py
注:本文中的stp_core.loop.eventually.eventually函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论