@@ -29,8 +29,9 @@ public void twoHops() throws IOException, ASAPException, InterruptedException {
2929 ui .doSetSendReceivedMessage ("Clara:twoHops on" );
3030
3131 // add message to alice storage
32- String messageAlice2Clara = "Alice twoHops abcChat HiClara" ;
33- ui .doCreateASAPMessage (messageAlice2Clara );
32+ String messageAlice2Clara = "HiClara" ;
33+ String parameters = "Alice twoHops abcChat " + messageAlice2Clara ;
34+ ui .doCreateASAPMessage (parameters );
3435
3536 System .out .println ("**************************************************************************" );
3637 System .out .println ("** connect Alice with Bob **" );
@@ -44,12 +45,16 @@ public void twoHops() throws IOException, ASAPException, InterruptedException {
4445
4546 ui .doConnect ("7070 Bob" );
4647
48+ // alice should be in era 1 (content has changed before connection) and bob era is 0 - no changes
49+
4750 // wait a moment
4851 Thread .sleep (1000 );
4952
5053 // kill connections
5154 ui .doKill ("all" );
5255
56+ // alice should stay in era 1 (no content change), bob should be in era 1 received something
57+
5358 // wait a moment
5459 Thread .sleep (1000 );
5560
@@ -62,16 +67,27 @@ public void twoHops() throws IOException, ASAPException, InterruptedException {
6267 Thread .sleep (10 );
6368 ui .doConnect ("8080 Bob" );
6469
70+ // bob should remain in era 1 o changes, clara is era 0
71+
6572 // wait a moment
6673 Thread .sleep (1000 );
6774 // kill connections
6875 ui .doKill ("all" );
6976
7077 // get Clara storage
71- ASAPStorage clara = ui .getStorage ("Clara:twoHops" );
78+ String rootFolder = ui .getEngineRootFolderByStorageName ("Clara:twoHops" );
79+ ASAPStorage clara = ASAPEngineFS .getExistingASAPEngineFS (rootFolder );
80+
81+ /* that asap message is from Bob even if it was created by Alice .. !!
82+ apps on top of asap could and should deal differently with ownership of messages.
83+ */
7284 ASAPChunkStorage claraBob = clara .getIncomingChunkStorage ("Bob" );
73- ASAPChunk claraABCChat = claraBob .getChunk ("abcChat" , clara .getEra ());
85+
86+ // clara era was increased after connection terminated - message from bob is in era before current one
87+ int eraToLook = ASAPEngine .previousEra (clara .getEra ());
88+ ASAPChunk claraABCChat = claraBob .getChunk ("abcChat" , eraToLook );
7489 CharSequence message = claraABCChat .getMessages ().next ();
75- Assert .assertTrue (message .toString ().equalsIgnoreCase (messageAlice2Clara ));
90+ boolean same = messageAlice2Clara .equalsIgnoreCase (message .toString ());
91+ Assert .assertTrue (same );
7692 }
7793}
0 commit comments