コード例 #1
0
 def chkSusp():
     for r in nonPrimaryReps:
         # Every node with non primary replicas of instance 0 should raise
         # suspicion twice, once for each extra PRE-PREPARE request
         assert len(getNodeSuspicions(r.node,
                                      Suspicions.DUPLICATE_PPR_SENT.code)) == 2
         # Each non primary replica should just send one PREPARE
         assert len(sentPrepare(r)) == 1
コード例 #2
0
 def chkSusp():
     for r in (primaryRep, *nonPrimaryReps):
         if r.name != faultyRep.name:
             # Every node except the one from which PREPARE with incorrect
             # digest was sent should raise suspicion for the PREPARE
             # message
             assert len(getNodeSuspicions(r.node,
                                          Suspicions.PR_DIGEST_WRONG.code)) == 1
コード例 #3
0
 def chk():
     for r in (primaryReplica, *remainingNpr):
         recvdPps = recvdPrePrepare(r)
         assert len(recvdPps) == 1
         assert recvdPps[0]['pp'] == ppr
         nodeSuspicions = len(getNodeSuspicions(
             r.node, Suspicions.PPR_FRM_NON_PRIMARY.code))
         assert nodeSuspicions == 1
コード例 #4
0
 def g():
     for node in nodeSet:
         if node.name != maliciousNode.name:
             frm, reason, code = getAllArgs(node, Node.reportSuspiciousNode)
             assert frm == maliciousNode.name
             assert isinstance(reason, SuspiciousNode)
             assert len(getNodeSuspicions(node,
                                          Suspicions.FREQUENT_INST_CHNG.code)) == 13
コード例 #5
0
 def chkSusp():
     for r in nonPrimaryReps:
         # Every node with non primary replicas of instance 0 should raise
         # suspicion
         assert len(getNodeSuspicions(r.node,
                                      Suspicions.PPR_DIGEST_WRONG.code)) == 1
         # No non primary replica should send any PREPARE
         assert len(sentPrepare(r)) == 0
コード例 #6
0
 def chkSusp():
     for r in (primaryRep, *nonPrimaryReps):
         if r.name != faultyRep.name:
             # Every node except the one from which duplicate PREPARE was
             # sent should raise suspicion twice, once for each extra
             # PREPARE request
             assert len(getNodeSuspicions(r.node,
                                          Suspicions.DUPLICATE_PR_SENT.code)) \
                    == 2
def testPrimarySendsAPrepareAndMarkedSuspicious(looper, nodeSet, preprepared1):
    def sendPrepareFromPrimary(instId):
        primary = getPrimaryReplica(nodeSet, instId)
        preprepared1.viewNo = instId
        preprepared1.ppSeqNo = primary.prePrepareSeqNo
        primary.sendPrepare(preprepared1)
        for r in getNonPrimaryReplicas(nodeSet, instId):
            l = len([param for param in getAllArgs(r, r.processPrepare)
                     if param['sender'] == primary.name])
            assert l == 1

        sendPrepareFromPrimary(0)

    for node in nodeSet:
        if node in getNonPrimaryReplicas(nodeSet, 0):
            frm, reason, code = getAllArgs(node, Node.reportSuspiciousNode)
            assert frm == getPrimaryReplica(nodeSet, 0).node.name
            assert isinstance(reason, SuspiciousNode)
            assert len(getNodeSuspicions(node, Suspicions.PR_FRM_PRIMARY.code)) \
                   == 10