nicer sync
authorVolker Birk <vb@pep.foundation>
Thu, 23 Aug 2018 07:07:31 +0200
branchsync
changeset 28766ad08f60ae1b
parent 2875 8e3169c2952a
child 2877 70189b383730
nicer
sync/sync.fsm
test/src/engine_tests/SyncTests.cc
     1.1 --- a/sync/sync.fsm	Wed Aug 22 21:44:48 2018 +0200
     1.2 +++ b/sync/sync.fsm	Thu Aug 23 07:07:31 2018 +0200
     1.3 @@ -10,13 +10,6 @@
     1.4  protocol Sync 1 {
     1.5      // all messages have a timestamp, time out and are removed after timeout
     1.6  
     1.7 -    unencrypted sendBeacon;
     1.8 -    acceptUnencrypted Beacon;
     1.9 -
    1.10 -    acceptUntrusted HandshakeRequest;
    1.11 -    acceptUntrusted Rollback;
    1.12 -    acceptUntrusted CommitReject;
    1.13 -
    1.14      fsm KeySync 1 {
    1.15          version 1, 2;
    1.16          state InitState {
    1.17 @@ -304,12 +297,12 @@
    1.18  
    1.19          // beacons are always broadcasted
    1.20  
    1.21 -        message Beacon 2, type=broadcast {
    1.22 +        message Beacon 2, type=broadcast, security=unencrypted {
    1.23              field TID challenge;
    1.24              auto Version version;
    1.25          }
    1.26  
    1.27 -        message HandshakeRequest 3 {
    1.28 +        message HandshakeRequest 3, security=untrusted {
    1.29              field TID challenge;
    1.30              auto Version version;
    1.31              field TID transaction;
    1.32 @@ -322,11 +315,11 @@
    1.33              field Hash fpr;
    1.34          }
    1.35  
    1.36 -        message Rollback 5 {
    1.37 +        message Rollback 5, security=untrusted {
    1.38              field TID transaction;
    1.39          }
    1.40  
    1.41 -        message CommitReject 6 {
    1.42 +        message CommitReject 6, security=untrusted {
    1.43              field TID transaction;
    1.44          }
    1.45  
     2.1 --- a/test/src/engine_tests/SyncTests.cc	Wed Aug 22 21:44:48 2018 +0200
     2.2 +++ b/test/src/engine_tests/SyncTests.cc	Thu Aug 23 07:07:31 2018 +0200
     2.3 @@ -56,16 +56,20 @@
     2.4  
     2.5      static PEP_STATUS messageToSend(void *obj, struct _message *msg)
     2.6      {
     2.7 -        assert(msg && msg->attachments && msg->attachments->value && msg->attachments->size);
     2.8 +        assert(msg && msg->attachments);
     2.9          
    2.10          cout << "sending message:\n";
    2.11  
    2.12 -        char *text = NULL;
    2.13 -        PEP_STATUS status = PER_to_XER_Sync_msg(msg->attachments->value, msg->attachments->size, &text);
    2.14 -        assert(status == PEP_STATUS_OK);
    2.15 -        cout << text << "\n";
    2.16 +        for (bloblist_t *b = msg->attachments; b && b->value; b = b->next) {
    2.17 +            if (b->mime_type && strcasecmp(b->mime_type, "application/pEp.sync") == 0) {
    2.18 +                char *text = NULL;
    2.19 +                PEP_STATUS status = PER_to_XER_Sync_msg(msg->attachments->value, msg->attachments->size, &text);
    2.20 +                assert(status == PEP_STATUS_OK);
    2.21 +                cout << text << "\n";
    2.22 +                free(text);
    2.23 +            }
    2.24 +        }
    2.25  
    2.26 -        free(text);
    2.27          free_message(msg);
    2.28          return PEP_STATUS_OK;
    2.29      }
    2.30 @@ -91,7 +95,7 @@
    2.31      thread *sync_thread;
    2.32      PEP_STATUS status = PEP_STATUS_OK;
    2.33  
    2.34 -    pEp_identity *self = new_identity("alice@synctests.pep", nullptr, "23", "Alice Miller");
    2.35 +    pEp_identity *self = new_identity("alice@synctests.pEp", nullptr, "23", "Alice Miller");
    2.36      assert(self);
    2.37      cout << "setting own identity for " << self->address << "\n";
    2.38      status = myself(session, self);
    2.39 @@ -103,6 +107,7 @@
    2.40      status = init(&sync, Sync_Adapter::messageToSend);
    2.41      TEST_ASSERT(status == PEP_STATUS_OK);
    2.42  
    2.43 +    cout << "initialize sync and start first state machine\n";
    2.44      status = register_sync_callbacks(
    2.45              sync,
    2.46              &adapter.q,