Пример #1
0
def test_make_result_no_protocol_version(looper, txnPoolNodeSet):
    request = SafeRequest(identifier="1" * 16,
                          reqId=1,
                          operation=randomOperation(),
                          signature="signature")
    request.protocolVersion = False
    check_result(txnPoolNodeSet, request, False)
Пример #2
0
def test_make_result_no_protocol_version(looper, txnPoolNodeSet):
    request = SafeRequest(identifier="1" * 16,
                          reqId=1,
                          operation=randomOperation(),
                          signature="signature",
                          protocolVersion=CURRENT_PROTOCOL_VERSION)
    request.protocolVersion = None
    check_result(txnPoolNodeSet, request, False)
Пример #3
0
def test_make_result_protocol_version_less_than_state_proof(
        looper, txnPoolNodeSet, client1, client1Connected, wallet1):
    request = SafeRequest(identifier="1" * 16,
                          reqId=1,
                          operation=randomOperation(),
                          signature="signature")
    request.protocolVersion = 0
    check_result(txnPoolNodeSet, request, client1, False)
Пример #4
0
def test_make_result_protocol_version_less_than_state_proof(
        looper, txnPoolNodeSet):
    request = SafeRequest(identifier="1" * 16,
                          reqId=1,
                          operation=randomOperation(),
                          signature="signature",
                          protocolVersion=CURRENT_PROTOCOL_VERSION)
    request.protocolVersion = 0
    check_result(txnPoolNodeSet, request, False)
def test_less_than_minimal_valid(operation):
    with pytest.raises(TypeError) as ex_info:
        SafeRequest(identifier="1" * 16, reqId=1)
    ex_info.match('missed fields - operation')

    with pytest.raises(TypeError) as ex_info:
        SafeRequest(identifier="1" * 16, operation=operation)
    ex_info.match('missed fields - reqId')

    with pytest.raises(TypeError) as ex_info:
        SafeRequest(reqId=1, operation=operation)
    ex_info.match('missed fields - identifier')
Пример #6
0
def test_make_result_no_protocol_version_in_request_by_default(
        looper, txnPoolNodeSet, client1, client1Connected, wallet1):
    request = SafeRequest(identifier="1" * 16,
                          reqId=1,
                          operation=randomOperation(),
                          signature="signature")
    check_result(txnPoolNodeSet, request, client1, False)
def test_all_operation_invalid(kwargs_all, operation_invalid):
    kwargs_all['operation'] = operation_invalid
    with pytest.raises(TypeError) as ex_info:
        SafeRequest(**kwargs_all)
    ex_info.match(
        r'\[ClientNYMOperation\]: b58 decoded value length 1 should be one of \[16, 32\]'
    )
def test_no_version_valid(operation):
    safeReq = SafeRequest(identifier="1" * 16,
                          reqId=1,
                          operation=operation,
                          protocolVersion=None)
    assert safeReq
    assert not safeReq.protocolVersion
Пример #9
0
 def wrapped(signed_req_dict):
     signed_req_obj = SafeRequest(**signed_req_dict)
     node_validator.write_manager.do_taa_validation(
         signed_req_obj,
         node_validator.master_replica.get_time_for_3pc_batch(),
         node_validator.config
     )
def test_all_signature_invalid(operation):
    with pytest.raises(TypeError) as ex_info:
        SafeRequest(identifier="1" * 16,
                    reqId=1,
                    operation=operation,
                    signature="",
                    protocolVersion=1)
    ex_info.match("signature can not be empty")
def test_all_version_invalid(operation):
    with pytest.raises(TypeError) as ex_info:
        SafeRequest(identifier="1" * 16,
                    reqId=1,
                    operation=operation,
                    signature="signature",
                    protocolVersion=-5)
    ex_info.match('Unknown protocol version value -5')
def test_all_identifier_invalid(operation):
    with pytest.raises(TypeError) as ex_info:
        SafeRequest(identifier="1" * 5,
                    reqId=1,
                    operation=operation,
                    signature="signature",
                    protocolVersion=1)
    ex_info.match(r'b58 decoded value length 5 should be one of \[16, 32\]')
def test_all_reqid_invalid(operation):
    with pytest.raises(TypeError) as ex_info:
        SafeRequest(identifier="1" * 16,
                    reqId=-500,
                    operation=operation,
                    signature="signature",
                    protocolVersion=1)
    ex_info.match('negative value')
def test_less_than_minimal_valid(kwargs_minimal):
    with pytest.raises(TypeError) as ex_info:
        SafeRequest(
            **{k: v
               for k, v in kwargs_minimal.items() if k != 'operation'})
    ex_info.match('missed fields - operation')

    with pytest.raises(TypeError) as ex_info:
        SafeRequest(
            **{k: v
               for k, v in kwargs_minimal.items() if k != 'reqId'})
    ex_info.match('missed fields - reqId')

    with pytest.raises(TypeError) as ex_info:
        SafeRequest(
            **{k: v
               for k, v in kwargs_minimal.items() if k != 'identifier'})
    ex_info.match('Missing both signatures and identifier')
def test_less_than_minimal_valid(operation):
    with pytest.raises(TypeError) as ex_info:
        SafeRequest(identifier="1" * 16,
                    reqId=1,
                    protocolVersion=CURRENT_PROTOCOL_VERSION)
    ex_info.match('missed fields - operation')

    with pytest.raises(TypeError) as ex_info:
        SafeRequest(identifier="1" * 16,
                    operation=operation,
                    protocolVersion=CURRENT_PROTOCOL_VERSION)
    ex_info.match('missed fields - reqId')

    with pytest.raises(TypeError) as ex_info:
        SafeRequest(reqId=1,
                    operation=operation,
                    protocolVersion=CURRENT_PROTOCOL_VERSION)
    ex_info.match('Missing both signatures and identifier')
def test_all_operation_invalid(operation_invalid):
    with pytest.raises(TypeError) as ex_info:
        SafeRequest(identifier="1" * 16,
                    reqId=1,
                    operation=operation_invalid,
                    signature="signature",
                    protocolVersion=1)
    ex_info.match(
        r'\[ClientNYMOperation\]: b58 decoded value length 1 should be one of \[16, 32\]'
    )
Пример #17
0
def test_client_safe_req_not_strict_by_default():
    operation = {
        TXN_TYPE: NYM,
        TARGET_NYM: TEST_TARGET_NYM,
        VERKEY: TEST_VERKEY_ABBREVIATED,
        "some_new_field_op1": "some_new_value_op1",
        "some_new_field_op2": "some_new_value_op2"
    }
    kwargs = {
        f.IDENTIFIER.nm: "1" * 16,
        f.REQ_ID.nm: 1,
        OPERATION: operation,
        f.SIG.nm: "signature",
        f.PROTOCOL_VERSION.nm: CURRENT_PROTOCOL_VERSION,
        "some_new_field1": "some_new_value1",
        "some_new_field2": "some_new_value2"
    }
    assert SafeRequest(**kwargs)
Пример #18
0
 def wrapped(signed_req_dict):
     signed_req_obj = SafeRequest(**signed_req_dict)
     node_validator.validateTaaAcceptance(
         signed_req_obj,
         node_validator.master_replica.get_time_for_3pc_batch())
def test_with_version_valid(kwargs_minimal):
    SafeRequest(**kwargs_minimal)
def test_with_taa_acceptance_valid(kwargs_minimal, taa_acceptance):
    kwargs_minimal[TXN_PAYLOAD_METADATA_TAA_ACCEPTANCE] = taa_acceptance
    SafeRequest(**kwargs_minimal)
def test_all_valid(kwargs_all):
    SafeRequest(**kwargs_all)
def test_all_identifier_invalid(kwargs_all):
    kwargs_all['identifier'] = '1' * 5
    with pytest.raises(TypeError) as ex_info:
        SafeRequest(**kwargs_all)
    ex_info.match(r'b58 decoded value length 5 should be one of \[16, 32\]')
def test_all_valid(operation):
    assert SafeRequest(identifier="1" * 16,
                       reqId=1,
                       operation=operation,
                       signature="signature",
                       protocolVersion=1)
def test_all_reqid_invalid(kwargs_all):
    kwargs_all['reqId'] = -500
    with pytest.raises(TypeError) as ex_info:
        SafeRequest(**kwargs_all)
    ex_info.match('negative value')
def test_with_version_valid(operation):
    assert SafeRequest(identifier="1" * 16,
                       reqId=1,
                       operation=operation,
                       protocolVersion=1)
def test_with_signature_valid(operation):
    assert SafeRequest(identifier="1" * 16,
                       reqId=1,
                       operation=operation,
                       signature="signature")
def test_no_version_by_default(operation):
    req = SafeRequest(identifier="1" * 16, reqId=1, operation=operation)
    assert not req.protocolVersion
def test_minimal_valid(operation):
    assert SafeRequest(identifier="1" * 16, reqId=1, operation=operation)
def test_all_signature_invalid(kwargs_all):
    kwargs_all['signature'] = ''
    with pytest.raises(TypeError) as ex_info:
        SafeRequest(**kwargs_all)
    ex_info.match("signature can not be empty")
def test_all_version_invalid(kwargs_all):
    kwargs_all['protocolVersion'] = -5
    with pytest.raises(TypeError) as ex_info:
        SafeRequest(**kwargs_all)
    ex_info.match('Unknown protocol version value. '
                  'Make sure that the latest LibIndy is used')
def test_with_signature_valid(kwargs_minimal):
    kwargs_minimal['signature'] = 'signature'
    SafeRequest(**kwargs_minimal)