def test_replica_received_preprepare_with_ordered_request(looper,
                                                          txnPoolNodeSet,
                                                          sdk_pool_handle,
                                                          sdk_wallet_steward,
                                                          chkFreqPatched):
    sdk_send_random_and_check(looper, txnPoolNodeSet,
                              sdk_pool_handle, sdk_wallet_steward, 1)

    replica = txnPoolNodeSet[1].master_replica
    params = replica._ordering_service.spylog.getLastParams(OrderingService.process_preprepare)
    pp = params["pre_prepare"]
    sender = params["sender"]
    start_request_propagate_count = replica.node.spylog.count(Node.request_propagates)

    def discard(offendingMsg, reason, logger, cliOutput=False):
        assert offendingMsg == pp
        assert Suspicions.PPR_WITH_ORDERED_REQUEST.reason == reason

    replica.node.discard = discard

    register_pp_ts(replica, pp, sender)
    replica._ordering_service.process_preprepare(pp, sender)

    assert 0 == replica.node.spylog.count(Node.request_propagates) - start_request_propagate_count
    assert (pp, sender, set(pp.reqIdr)) not in replica._ordering_service.prePreparesPendingFinReqs
Exemplo n.º 2
0
def test_process_pre_prepare_validation_old_schema_no_audit(
        replica_with_requests, pre_prepare, mock_schema_audit_txn_root):
    serialized_pp = ZStack.serializeMsg(pre_prepare)
    deserialized_pp = ZStack.deserializeMsg(serialized_pp)
    assert f.AUDIT_TXN_ROOT_HASH.nm not in PrePrepare.schema

    pp = PrePrepare(**deserialized_pp)
    register_pp_ts(replica_with_requests, pp,
                   replica_with_requests.primaryName)
    replica_with_requests.processPrePrepare(pp,
                                            replica_with_requests.primaryName)
Exemplo n.º 3
0
def test_process_pre_prepare_validation_old_schema_no_pool(
        replica_with_requests, pre_prepare, mock_schema_pool_state_root):
    serialized_pp = ZStack.serializeMsg(pre_prepare)
    deserialized_pp = ZStack.deserializeMsg(serialized_pp)
    assert f.POOL_STATE_ROOT_HASH.nm not in PrePrepare.schema

    pp = PrePrepare(**deserialized_pp)
    register_pp_ts(replica_with_requests, pp,
                   replica_with_requests.primaryName)
    replica_with_requests.processPrePrepare(pp,
                                            replica_with_requests.primaryName)
Exemplo n.º 4
0
def test_process_pre_prepare_with_incorrect_pool_state_root(
        replica_with_requests, state_roots, txn_roots, multi_sig,
        fake_requests):
    expect_suspicious(replica_with_requests,
                      Suspicions.PPR_POOL_STATE_ROOT_HASH_WRONG.code)

    pre_prepare_params = create_pre_prepare_params(
        state_root=state_roots[DOMAIN_LEDGER_ID],
        ledger_id=DOMAIN_LEDGER_ID,
        txn_root=txn_roots[DOMAIN_LEDGER_ID],
        bls_multi_sig=multi_sig,
        view_no=replica_with_requests.viewNo,
        inst_id=replica_with_requests.instId,
        # INVALID!
        pool_state_root="HSai3sMHKeAva4gWMabDrm1yNhezvPHfXnGyHf2ex1L4",
        audit_txn_root=txn_roots[AUDIT_LEDGER_ID],
        reqs=fake_requests)
    pre_prepare = PrePrepare(*pre_prepare_params)
    register_pp_ts(replica_with_requests, pre_prepare,
                   replica_with_requests.primaryName)

    with pytest.raises(SuspiciousNode):
        replica_with_requests.processPrePrepare(
            pre_prepare, replica_with_requests.primaryName)
Exemplo n.º 5
0
def pre_prepare(r, _pre_prepare):
    register_pp_ts(r, _pre_prepare, r.primaryName)
    return _pre_prepare
Exemplo n.º 6
0
def pre_prepare(replica, _pre_prepare):
    register_pp_ts(replica, _pre_prepare, replica.primaryName)
    return _pre_prepare