def test_make_result_protocol_version_state_proof(operation): request = SafeRequest(identifier="1" * 16, reqId=1, operation=operation, signature="signature") request.protocolVersion = PlenumProtocolVersion.STATE_PROOF_SUPPORT.value check_make_result(request, should_have_proof=True)
def test_make_result_protocol_version_less_than_state_proof(operation): request = SafeRequest(identifier="1" * 16, reqId=1, operation=operation, signature="signature") request.protocolVersion = 0 check_make_result(request, should_have_proof=False)
def test_revoc_reg_delta_schema_validation_missed_fields( build_get_revoc_reg_delta): req = copy.deepcopy(build_get_revoc_reg_delta) del req['operation'][REVOC_REG_DEF_ID] with pytest.raises(TypeError, match="missed fields - {}".format(REVOC_REG_DEF_ID)): SafeRequest(**req)
def write_schema_request(request): req = { 'operation': { 'type': '101', 'data': { 'version': '1.0', 'name': 'Degree', 'attr_names': [ 'undergrad', 'last_name', 'first_name', 'birth_date', 'postgrad', 'expiry_date' ] }, }, 'identifier': 'L5AD5g65TDQr1PPHHRoiGf', 'reqId': 1514280215504647, 'protocolVersion': 1, 'signature': '5ZTp9g4SP6t73rH2s8zgmtqdXyTuSMWwkLvfV1FD6ddHCpwTY5SAsp8YmLWnTgDnPXfJue3vJBWjy89bSHvyMSdS' } return SafeRequest(**req)
def write_claim_def_request(request): req = { 'operation': { 'type': '102', 'signature_type': 'CL1', 'ref': 18, 'tag': 'key111', 'data': { 'primary': { 'primaryKey1': 'a' }, 'revocation': { 'revocationKey1': 'b' } }, }, 'identifier': 'L5AD5g65TDQr1PPHHRoiGf', 'reqId': 1514280215504647, 'protocolVersion': 1, 'signature': '5ZTp9g4SP6t73rH2s8zgmtqdXyTuSMWwkLvfV1FD6ddHCpwTY5SAsp8YmLWnTgDnPXfJue3vJBWjy89bSHvyMSdS' } return SafeRequest(**req)
def test_revoc_reg_delta_schema_validation_missed_fields( looper, sdk_wallet_steward): req = build_get_revoc_reg_delta(looper, sdk_wallet_steward) del req['operation'][REVOC_REG_DEF_ID] with pytest.raises(TypeError, match="missed fields - {}".format(REVOC_REG_DEF_ID)): SafeRequest(**req)
def test_get_revoc_reg_entry_without_any_rev_entry( send_revoc_reg_def_by_default, build_get_revoc_reg_entry, txnPoolNodeSet): req = build_get_revoc_reg_entry req[OPERATION][TIMESTAMP] = int(time.time()) + 2 result = txnPoolNodeSet[0].read_manager.get_result((SafeRequest(**req))) assert result[DATA] is None assert result[f.SEQ_NO.nm] is None assert result[TXN_TIME] is None assert STATE_PROOF in result assert result[STATE_PROOF] is not None
def test_get_revoc_reg_entry_without_any_rev_entry(send_revoc_reg_def_by_default, build_get_revoc_reg_entry, txnPoolNodeSet): req = build_get_revoc_reg_entry req[OPERATION][TIMESTAMP] = int(time.time()) + 2 req_handler = txnPoolNodeSet[0].get_req_handler(DOMAIN_LEDGER_ID) result = req_handler.handleGetRevocRegReq(SafeRequest(**req)) assert result[DATA] is None assert result[f.SEQ_NO.nm] is None assert result[TXN_TIME] is None assert STATE_PROOF in result assert result[STATE_PROOF] is not None
def read_claim_def_request(): req = { 'operation': { 'type': '108', 'signature_type': 'CL1', 'ref': 18, 'tag': 'key111', 'origin': 'L5AD5g65TDQr1PPHHRoiGf' }, 'identifier': 'E5AD5g65TDQr1PPHHRoiGf', 'reqId': 1514280215504647, 'protocolVersion': 1 } return SafeRequest(**req)
def read_schema_request(): req = { 'operation': { 'type': '107', 'dest': 'L5AD5g65TDQr1PPHHRoiGf', 'data': { 'version': '1.0', 'name': 'Degree', } }, 'identifier': 'E5AD5g65TDQr1PPHHRoiGf', 'reqId': 1514280215504647, 'protocolVersion': 1 } return SafeRequest(**req)
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)
def test_validate_get_revoc_reg_entry(build_get_revoc_reg_entry): req = build_get_revoc_reg_entry SafeRequest(**req)
def test_make_result_no_protocol_version_by_default(operation): request = SafeRequest(identifier="1" * 16, reqId=1, operation=operation, signature="signature") check_make_result(request, should_have_proof=False)
def test_revoc_reg_delta_schema_validation_wrong_type( build_get_revoc_reg_delta): req = copy.deepcopy(build_get_revoc_reg_delta) req['operation'][FROM] = "10" with pytest.raises(TypeError, match="expected types 'int', got 'str'"): SafeRequest(**req)
def test_revoc_reg_delta_schema_validation_wrong_type(looper, sdk_wallet_steward): req = build_get_revoc_reg_delta(looper, sdk_wallet_steward) req['operation'][FROM] = "10" with pytest.raises(TypeError, match="expected types 'int', got 'str'"): SafeRequest(**req)
def test_validate_get_revoc_reg_entry(looper, sdk_wallet_steward): req = build_get_revoc_reg_entry(looper, sdk_wallet_steward) SafeRequest(**req)