async def test_receive_pres(self):
    connection_record = async_mock.MagicMock(connection_id=CONN_ID)
    indy_proof = {'proof': {'proofs': [{'primary_proof': {'eq_proof': '...', 'ge_proofs': [{'...': '...', 'predicate': {'attr_name': 'highscore', 'p_type': 'GE', 'value': 1000000}}]}}]}, 'requested_proof': {'revealed_attrs': {'0_player_uuid': {'sub_proof_index': 0, 'raw': 'Richie Knucklez', 'encoded': '12345678901234567890'}, '1_screencapture_uuid': {'sub_proof_index': 0, 'raw': 'aW1hZ2luZSBhIHNjcmVlbiBjYXB0dXJl', 'encoded': '98765432109876543210'}}, 'self_attested_attrs': {}, 'unrevealed_attrs': {}, 'predicates': {'0_highscore_GE_uuid': {'sub_proof_index': 0}}}, 'identifiers': [{'schema_id': S_ID, 'cred_def_id': CD_ID, 'rev_reg_id': None, 'timestamp': None}]}
    pres_proposal = V20PresProposal(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20_PROPOSAL][V20PresFormat.Format.INDY.api])], proposals_attach=[AttachDecorator.data_base64(INDY_PROOF_REQ_NAME, ident='indy')])
    pres_request = V20PresRequest(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20_REQUEST][V20PresFormat.Format.INDY.api])], request_presentations_attach=[AttachDecorator.data_base64(INDY_PROOF_REQ_NAME, ident='indy')])
    pres = V20Pres(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20][V20PresFormat.Format.INDY.api])], presentations_attach=[AttachDecorator.data_base64(indy_proof, ident='indy')])
    px_rec_dummy = V20PresExRecord(pres_proposal=pres_proposal.serialize(), pres_request=pres_request.serialize())
    by_format = px_rec_dummy.by_format
    assert (by_format.get('pres_proposal').get('indy') == INDY_PROOF_REQ_NAME)
    assert (by_format.get('pres_request').get('indy') == INDY_PROOF_REQ_NAME)
    with async_mock.patch.object(V20PresExRecord, 'save', autospec=True) as save_ex, async_mock.patch.object(V20PresExRecord, 'retrieve_by_tag_filter', autospec=True) as retrieve_ex, async_mock.patch.object(self.profile, 'session', async_mock.MagicMock(return_value=self.profile.session())) as session:
        retrieve_ex.side_effect = [StorageNotFoundError('no such record'), px_rec_dummy]
        px_rec_out = (await self.manager.receive_pres(pres, connection_record))
        assert (retrieve_ex.call_count == 2)
        save_ex.assert_called_once()
        assert (px_rec_out.state == V20PresExRecord.STATE_PRESENTATION_RECEIVED)
async def test_receive_pres(self):
    connection_record = async_mock.MagicMock(connection_id=CONN_ID)
    indy_proof = {'proof': {'proofs': [{'primary_proof': {'eq_proof': '...', 'ge_proofs': [{'...': '...', 'predicate': {'attr_name': 'highscore', 'p_type': 'GE', 'value': 1000000}}]}}]}, 'requested_proof': {'revealed_attrs': {'0_player_uuid': {'sub_proof_index': 0, 'raw': 'Richie Knucklez', 'encoded': '12345678901234567890'}, '1_screencapture_uuid': {'sub_proof_index': 0, 'raw': 'aW1hZ2luZSBhIHNjcmVlbiBjYXB0dXJl', 'encoded': '98765432109876543210'}}, 'self_attested_attrs': {}, 'unrevealed_attrs': {}, 'predicates': {'0_highscore_GE_uuid': {'sub_proof_index': 0}}}, 'identifiers': [{'schema_id': S_ID, 'cred_def_id': CD_ID, 'rev_reg_id': None, 'timestamp': None}]}
    pres_proposal = V20PresProposal(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20_PROPOSAL][V20PresFormat.Format.INDY.api])], proposals_attach=[AttachDecorator.data_base64(INDY_PROOF_REQ_NAME, ident='indy')])
    pres_request = V20PresRequest(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20_REQUEST][V20PresFormat.Format.INDY.api])], request_presentations_attach=[AttachDecorator.data_base64(INDY_PROOF_REQ_NAME, ident='indy')])
    pres = V20Pres(formats=[V20PresFormat(attach_id='indy', format_=ATTACHMENT_FORMAT[PRES_20][V20PresFormat.Format.INDY.api])], presentations_attach=[AttachDecorator.data_base64(indy_proof, ident='indy')])
    px_rec_dummy = V20PresExRecord(pres_proposal=pres_proposal.serialize(), pres_request=pres_request.serialize())
    by_format = px_rec_dummy.by_format
    assert (by_format.get('pres_proposal').get('indy') == INDY_PROOF_REQ_NAME)
    assert (by_format.get('pres_request').get('indy') == INDY_PROOF_REQ_NAME)
    with async_mock.patch.object(V20PresExRecord, 'save', autospec=True) as save_ex, async_mock.patch.object(V20PresExRecord, 'retrieve_by_tag_filter', autospec=True) as retrieve_ex, async_mock.patch.object(self.profile, 'session', async_mock.MagicMock(return_value=self.profile.session())) as session:
        retrieve_ex.side_effect = [StorageNotFoundError('no such record'), px_rec_dummy]
        px_rec_out = (await self.manager.receive_pres(pres, connection_record))
        assert (retrieve_ex.call_count == 2)
        save_ex.assert_called_once()
        assert (px_rec_out.state == V20PresExRecord.STATE_PRESENTATION_RECEIVED)