def nonPrimaryReceivesCorrectNumberOfPREPREPAREs():
            """
            1. no of PRE-PREPARE received by non-primaries must be 1
            with zero faults in system, and 0 faults in system.
            """
            passes = 0
            for npr in nonPrimaryReplicas:
                l4 = len([param for param in
                          getAllArgs(npr._ordering_service,
                                     npr._ordering_service._add_to_pre_prepares)
                          if param['pp'].reqIdr[0] == propagated1.digest
                          and param['pp'].digest ==
                          OrderingService.generate_pp_digest([propagated1.digest, ],
                                                             get_original_viewno(param['pp']),
                                                             param['pp'].ppTime)])

                numOfMsgsWithZFN = 1
                numOfMsgsWithFaults = 0

                passes += msgCountOK(nodesSize,
                                     faultyNodes,
                                     l4,
                                     numOfMsgsWithZFN,
                                     numOfMsgsWithFaults)

            assert passes >= len(nonPrimaryReplicas) - faultyNodes, \
                '2Non-primary receives correct number of pre-prepare -- {}'.format(passes)
def pp(primary_orderer, ts_now, inst_id):
    return FakePrePrepare(
        instId=inst_id,
        viewNo=primary_orderer.view_no,
        ppSeqNo=(primary_orderer.last_ordered_3pc[1] + 1),
        ppTime=ts_now,
        reqIdr=tuple(),
        digest=OrderingService.generate_pp_digest([], primary_orderer.view_no,
                                                  ts_now),
        auditTxnRootHash="HSai3sMHKeAva4gWMabDrm1yNhezvPHfXnGyHf2ex1L4")
def test_msg_len_limit_large_enough_for_preprepare():
    config = getConfig()

    batch_size = config.Max3PCBatchSize
    requests = [Request(signatures={})] * batch_size
    req_idr = [req.digest for req in requests]
    tm = get_utc_epoch()
    digest = OrderingService.generate_pp_digest(req_idr, 0, tm)
    state_root = Base58Serializer().serialize(BLANK_ROOT)
    txn_root = Ledger.hashToStr(CompactMerkleTree().root_hash)

    pp = PrePrepare(0, 0, 0, tm, req_idr, init_discarded(), digest, 0,
                    state_root, txn_root, 0, True)

    assert len(ZStack.serializeMsg(pp)) <= config.MSG_LEN_LIMIT
Beispiel #4
0
def test_pp_storages_ordering(pre_prepare, orderer: OrderingService):
    orderer.generate_pp_digest(pre_prepare.reqIdr,
                               get_original_viewno(pre_prepare),
                               pre_prepare.ppTime)