create own identity sync
authorVolker Birk <vb@pep.foundation>
Wed, 22 Aug 2018 20:51:23 +0200
branchsync
changeset 287445531079b073
parent 2873 ceaa29b309ef
child 2875 8e3169c2952a
create own identity
src/message_api.h
test/include/pEpEngine_test.h
test/src/engine_tests/SyncTests.cc
     1.1 --- a/src/message_api.h	Wed Aug 22 20:01:29 2018 +0200
     1.2 +++ b/src/message_api.h	Wed Aug 22 20:51:23 2018 +0200
     1.3 @@ -13,7 +13,6 @@
     1.4  #endif
     1.5  
     1.6  bool import_attached_keys(
     1.7 -    
     1.8          PEP_SESSION session, 
     1.9          const message *msg,
    1.10          identity_list **private_idents
     2.1 --- a/test/include/pEpEngine_test.h	Wed Aug 22 20:01:29 2018 +0200
     2.2 +++ b/test/include/pEpEngine_test.h	Wed Aug 22 20:51:23 2018 +0200
     2.3 @@ -1,3 +1,4 @@
     2.4  #include <iomanip>
     2.5  
     2.6 -#define ASSERT_STATUS(status) { cout << setfill('0') << "status: 0x" << hex << setw(4) << status << "\n"; assert(status == PEP_STATUS_OK); cout << std::dec }
     2.7 +#define ASSERT_STATUS(status) { cout << setfill('0') << "status: 0x" << hex << setw(4) << status << "\n"; assert(status == PEP_STATUS_OK); cout << std::dec; }
     2.8 +
     3.1 --- a/test/src/engine_tests/SyncTests.cc	Wed Aug 22 20:01:29 2018 +0200
     3.2 +++ b/test/src/engine_tests/SyncTests.cc	Wed Aug 22 20:51:23 2018 +0200
     3.3 @@ -10,6 +10,7 @@
     3.4  
     3.5  #include "pEp_internal.h"
     3.6  #include "KeySync_fsm.h"
     3.7 +#include "Sync_codec.h"
     3.8  
     3.9  #include "EngineTestSessionSuite.h"
    3.10  #include "SyncTests.h"
    3.11 @@ -55,8 +56,17 @@
    3.12  
    3.13      static PEP_STATUS messageToSend(void *obj, struct _message *msg)
    3.14      {
    3.15 -        assert(msg);
    3.16 -        cout << "messageToSend\n";
    3.17 +        assert(msg && msg->attachments && msg->attachments->value && msg->attachments->size);
    3.18 +        
    3.19 +        cout << "sending message:\n";
    3.20 +
    3.21 +        char *text = NULL;
    3.22 +        PEP_STATUS status = PER_to_XER_Sync_msg(msg->attachments->value, msg->attachments->size, &text);
    3.23 +        assert(status == PEP_STATUS_OK);
    3.24 +        cout << text << "\n";
    3.25 +
    3.26 +        free(text);
    3.27 +        free_message(msg);
    3.28          return PEP_STATUS_OK;
    3.29      }
    3.30  
    3.31 @@ -83,6 +93,15 @@
    3.32      PEP_STATUS status = init(&sync, Sync_Adapter::messageToSend);
    3.33      TEST_ASSERT(status == PEP_STATUS_OK);
    3.34  
    3.35 +    pEp_identity *self = new_identity("alice@synctests.pep", nullptr, "23", "Alice Miller");
    3.36 +    assert(self);
    3.37 +    cout << "setting own identity for " << self->address << "\n";
    3.38 +    status = myself(session, self);
    3.39 +    assert(self->me);
    3.40 +    assert(self->fpr);
    3.41 +    cout << "fpr: " << self->fpr << "\n";
    3.42 +    free_identity(self);
    3.43 +
    3.44      status = register_sync_callbacks(
    3.45              sync,
    3.46              &adapter.q,