summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/attach.test6
-rw-r--r--test/chatroom.test201
-rw-r--r--test/contact.test10
-rw-r--r--test/discovery.test75
-rw-r--r--test/message.test16
-rw-r--r--test/network.test31
-rw-r--r--test/storage.test6
-rw-r--r--test/sync.test8
8 files changed, 315 insertions, 38 deletions
diff --git a/test/attach.test b/test/attach.test
index 33a1483..afbdd0e 100644
--- a/test/attach.test
+++ b/test/attach.test
@@ -1,12 +1,14 @@
test:
+ let services = "attach,sync"
+
spawn as p1
spawn as p2
send "create-identity Device1 Owner" to p1
send "create-identity Device2" to p2
send "watch-local-identity" to p1
send "watch-local-identity" to p2
- send "start-server" to p1
- send "start-server" to p2
+ send "start-server services $services" to p1
+ send "start-server services $services" to p2
expect from p1:
/local-identity Device1 Owner/
/peer 1 addr ${p2.node.ip} 29665/
diff --git a/test/chatroom.test b/test/chatroom.test
index 4dda21e..54f9b2a 100644
--- a/test/chatroom.test
+++ b/test/chatroom.test
@@ -1,4 +1,8 @@
+def refpat = /blake2#[0-9a-f]+/
+
test ChatroomSetup:
+ let services = "chatroom"
+
# Local chatrooms
spawn as p1
@@ -30,7 +34,7 @@ test ChatroomSetup:
for p in [ p1, p2, p3 ]:
with p:
send "chatroom-watch-local"
- send "start-server"
+ send "start-server services $services"
for p in [ p2, p3 ]:
with p:
@@ -97,6 +101,8 @@ test ChatroomSetup:
test ChatroomMessages:
+ let services = "chatroom"
+
spawn as p1
spawn as p2
@@ -106,7 +112,7 @@ test ChatroomMessages:
for p in [ p1, p2 ]:
with p:
send "chatroom-watch-local"
- send "start-server"
+ send "start-server services $services"
send "chatroom-create first_room" to p1
expect /chatroom-create-done ([a-z0-9#]+) first_room.*/ from p1 capture room1_p1
@@ -159,7 +165,7 @@ test ChatroomMessages:
spawn as p3
send "create-identity Device3 Owner3" to p3
send "chatroom-watch-local" to p3
- send "start-server" to p3
+ send "start-server services $services" to p3
expect /chatroom-watched-added ([a-z0-9#]+) first_room sub false/ from p3 capture room1_p3
expect /chatroom-watched-added ([a-z0-9#]+) second_room sub false/ from p3 capture room2_p3
expect /chatroom-watched-added ([a-z0-9#]+) third_room sub false/ from p3 capture room3_p3
@@ -242,6 +248,8 @@ test ChatroomMessages:
test ChatroomSubscribedBeforeStart:
+ let services = "chatroom"
+
spawn as p1
spawn as p2
@@ -251,7 +259,7 @@ test ChatroomSubscribedBeforeStart:
for p in [ p1, p2 ]:
with p:
send "chatroom-watch-local"
- send "start-server"
+ send "start-server services $services"
send "chatroom-create first_room" to p1
expect /chatroom-create-done ([a-z0-9#]+) first_room.*/ from p1 capture room1_p1
@@ -271,7 +279,7 @@ test ChatroomSubscribedBeforeStart:
expect /stop-server-done/
for p in [p1, p2]:
with p:
- send "start-server"
+ send "start-server services $services"
send "chatroom-message-send $room1_p1 message1" to p1
expect /chatroom-message-new $room1_p1 room first_room from Owner1 text message1/ from p1
@@ -283,6 +291,8 @@ test ChatroomSubscribedBeforeStart:
test ParallelThreads:
+ let services = "chatroom"
+
spawn as p1
spawn as p2
@@ -292,7 +302,7 @@ test ParallelThreads:
for p in [ p1, p2 ]:
with p:
send "chatroom-watch-local"
- send "start-server"
+ send "start-server services $services"
send "chatroom-create first_room" to p1
expect /chatroom-create-done ([a-z0-9#]+) first_room.*/ from p1 capture room1_p1
@@ -330,7 +340,7 @@ test ParallelThreads:
for p in [p1, p2]:
with p:
- send "start-server"
+ send "start-server services $services"
with p1:
expect /chatroom-message-new $room1_p1 room first_room from Owner. text message(..)/ capture msg
@@ -347,6 +357,8 @@ test ParallelThreads:
test ChatroomMembers:
+ let services = "chatroom"
+
spawn as p1
spawn as p2
spawn as p3
@@ -358,7 +370,7 @@ test ChatroomMembers:
for p in [ p1, p2, p3 ]:
with p:
send "chatroom-watch-local"
- send "start-server"
+ send "start-server services $services"
send "chatroom-create first_room" to p1
expect /chatroom-create-done ([a-z0-9#]+) first_room.*/ from p1 capture room1_p1
@@ -432,6 +444,8 @@ test ChatroomMembers:
test ChatroomIdentity:
+ let services = "chatroom"
+
spawn as p1
spawn as p2
@@ -441,7 +455,7 @@ test ChatroomIdentity:
for p in [ p1, p2 ]:
with p:
send "chatroom-watch-local"
- send "start-server"
+ send "start-server services $services"
send "chatroom-create first_room" to p1
expect /chatroom-create-done ([a-z0-9#]+) first_room.*/ from p1 capture room1_p1
@@ -477,3 +491,172 @@ test ChatroomIdentity:
guard (name1 == "Custom1")
expect /chatroom-message-new [a-z0-9#]+ room first_room from ([^ ]+) text message4/ capture name2
guard (name2 == "Custom2")
+
+
+test ChatroomDelete:
+ let services = "chatroom"
+
+ node n1
+ node n2
+ node n3
+
+ # Create and sync chatrooms on n1 and sync to n2
+ local:
+ spawn as p1 on n1
+ with p1:
+ send "create-identity Device1 Owner1"
+ expect /create-identity-done .*/
+
+ send "chatroom-watch-local"
+ send "start-server services $services"
+
+ send "chatroom-create first"
+ send "chatroom-create second"
+ expect /chatroom-create-done $refpat first.*/
+ expect /chatroom-create-done $refpat second.*/
+
+
+ spawn as p2 on n2
+ with p2:
+ send "create-identity Device2 Owner2"
+ expect /create-identity-done .*/
+
+ send "chatroom-watch-local"
+ send "start-server services $services"
+
+ expect /chatroom-watched-added ($refpat) first sub false/ capture first
+ expect /chatroom-watched-added ($refpat) second sub false/ capture second
+
+ send "chatroom-subscribe $first"
+ send "chatroom-subscribe $second"
+ expect /chatroom-watched-updated $first first sub true .*/
+ expect /chatroom-watched-updated $second second sub true .*/
+
+ local:
+ spawn as p3 on n3
+ with p3:
+ send "create-identity Device3 Owner3"
+ expect /create-identity-done .*/
+
+ local:
+ spawn as p1 on n1
+ spawn as p2 on n2
+ spawn as p3 on n3
+
+ # Delete first chatroom from n1
+ with p1:
+ send "chatroom-watch-local"
+ send "start-server services $services"
+
+ send "chatroom-list-local"
+ expect /chatroom-list-item ($refpat) first sub true/ capture first
+ expect /chatroom-list-item $refpat second sub true/
+ local:
+ expect /chatroom-list-(.*)/ capture done
+ guard (done == "done")
+
+ send "chatroom-delete $first"
+ expect /chatroom-delete-done .*/
+
+ # Setup n3
+ with p3:
+ send "chatroom-watch-local"
+ send "start-server services $services"
+
+ expect /chatroom-watched-added $refpat second sub false/
+
+ # Check that both n1 and n3 see only the second chatroom
+ for p in [ p1, p3 ]:
+ with p:
+ send "chatroom-list-local"
+ expect /chatroom-list-item $refpat second .*/
+ local:
+ expect /chatroom-list-(.*)/ capture done
+ guard (done == "done")
+
+ # Reactive server on n2 and create third chatroom
+ with p2:
+ send "chatroom-watch-local"
+ send "start-server services $services"
+
+ send "chatroom-create third"
+ expect /chatroom-create-done $refpat third.*/
+
+ # Verify that first chatroom appears only on n3 ...
+ with p3:
+ expect /chatroom-watched-added $refpat first sub false/
+ expect /chatroom-watched-added $refpat third sub false/
+
+ send "chatroom-list-local"
+ expect /chatroom-list-item $refpat first .*/
+ expect /chatroom-list-item $refpat second .*/
+ expect /chatroom-list-item $refpat third .*/
+ local:
+ expect /chatroom-list-(.*)/ capture done
+ guard (done == "done")
+
+ # ... and not on n1
+ with p1:
+ expect /chatroom-watched-added ($refpat) third sub false/ capture third
+ send "chatroom-subscribe $third"
+ expect /chatroom-watched-updated $third third sub true .*/
+
+ send "chatroom-list-local"
+ expect /chatroom-list-item $refpat second .*/
+ expect /chatroom-list-item $refpat third .*/
+ local:
+ expect /chatroom-list-(.*)/ capture done
+ guard (done == "done")
+
+ # Delete second chatroom on n2
+ with p2:
+ send "chatroom-list-local"
+ expect /chatroom-list-item $refpat first .*/
+ expect /chatroom-list-item ($refpat) second .*/ capture second
+ expect /chatroom-list-item $refpat third .*/
+ local:
+ expect /chatroom-list-(.*)/ capture done
+ guard (done == "done")
+
+ send "chatroom-delete $second"
+ expect /chatroom-delete-done .*/
+
+ # Send messages
+ with p3:
+ send "chatroom-list-local"
+ expect /chatroom-list-item ($refpat) first .*/ capture first
+ expect /chatroom-list-item ($refpat) second .*/ capture second
+ expect /chatroom-list-item ($refpat) third .*/ capture third
+ local:
+ expect /chatroom-list-(.*)/ capture done
+ guard (done == "done")
+
+ send "chatroom-message-send $first message_first"
+ send "chatroom-message-send $second message_second"
+ send "chatroom-message-send $third message_third"
+
+ # Receive only to non-deleted ones
+ with p1:
+ expect /chatroom-message-new $refpat room second from Owner3 text message_second/
+ expect /chatroom-message-new $refpat room ([a-z]+) from Owner3 text ([a-z_]+)/ capture room, msg
+ guard (room == "third")
+ guard (msg == "message_third")
+
+ send "chatroom-list-local"
+ expect /chatroom-list-item $refpat second .*/
+ expect /chatroom-list-item $refpat third .*/
+ local:
+ expect /chatroom-list-(.*)/ capture done
+ guard (done == "done")
+ with p2:
+ expect /chatroom-message-new $refpat room first from Owner3 text message_first/
+ expect /chatroom-message-new $refpat room ([a-z]+) from Owner3 text ([a-z_]+)/ capture room, msg
+ guard (room == "third")
+ guard (msg == "message_third")
+
+ send "chatroom-list-local"
+ expect /chatroom-list-item $refpat first .*/
+ expect /chatroom-list-item $refpat third .*/
+ local:
+ expect /chatroom-list-(.*)/ capture done
+ guard (done == "done")
diff --git a/test/contact.test b/test/contact.test
index 438aa1f..978f8a6 100644
--- a/test/contact.test
+++ b/test/contact.test
@@ -1,4 +1,6 @@
test Contact:
+ let services = "attach,contact,sync"
+
spawn as p1
spawn as p2
spawn as p3
@@ -9,10 +11,10 @@ test Contact:
send "create-identity Device3 Owner3" to p3
send "create-identity Device4" to p4
- send "start-server" to p1
- send "start-server" to p2
- send "start-server" to p3
- send "start-server" to p4
+ send "start-server services $services" to p1
+ send "start-server services $services" to p2
+ send "start-server services $services" to p3
+ send "start-server services $services" to p4
expect from p1:
/peer ([0-9]+) addr ${p2.node.ip} 29665/ capture peer1_2
diff --git a/test/discovery.test b/test/discovery.test
new file mode 100644
index 0000000..f2dddb7
--- /dev/null
+++ b/test/discovery.test
@@ -0,0 +1,75 @@
+module discovery
+
+test ManualDiscovery:
+ let services = "discovery,test"
+ let refpat = /blake2#[0-9a-f]*/
+
+ subnet sd
+ subnet s1
+ subnet s2
+
+ spawn as pd on sd
+ spawn as p1 on s1
+ spawn as p2 on s2
+ send "create-identity Discovery" to pd
+ send "create-identity Device1 Owner1" to p1
+ send "create-identity Device2 Owner2" to p2
+
+ expect /create-identity-done ref ($refpat).*/ from p1 capture p1id
+ send "identity-info $p1id" to p1
+ expect /identity-info ref $p1id base ($refpat) owner ($refpat).*/ from p1 capture p1base, p1owner
+ send "identity-info $p1owner" to p1
+ expect /identity-info ref $p1owner base ($refpat).*/ from p1 capture p1obase
+
+ expect /create-identity-done ref $refpat.*/ from p2
+ expect /create-identity-done ref $refpat.*/ from pd
+
+ # TODO: avoid the need to send identity objects with weak refs
+ for p in [ p1, p2 ]:
+ with p:
+ send "start-server services $services"
+ send "peer-add ${p2.node.ip}" to p1
+ expect from p1:
+ /peer 1 addr ${p2.node.ip} 29665/
+ /peer 1 id Device2 Owner2/
+ expect from p2:
+ /peer 1 addr ${p1.node.ip} 29665/
+ /peer 1 id Device1 Owner1/
+ for r in [ p1base, p1obase ]:
+ with p1:
+ send "test-message-send 1 $r"
+ expect /test-message-send done/
+ with p2:
+ expect /test-message-received rec [0-9]+ $r/
+ for p in [ p1, p2 ]:
+ send "stop-server" to p
+ expect /stop-server-done/ from p
+
+ # Test discovery using owner and device identities:
+ for id in [ p1obase, p1base ]:
+ for p in [ pd, p1, p2 ]:
+ send "start-server services $services" to p
+
+ for p in [ p1, p2 ]:
+ with p:
+ send "peer-add ${pd.node.ip}"
+ expect:
+ /peer 1 addr ${pd.node.ip} 29665/
+ /peer 1 id Discovery/
+ expect from pd:
+ /peer [12] addr ${p.node.ip} 29665/
+ /peer [12] id .*/
+
+ send "discovery-connect $id" to p2
+
+ expect from p1:
+ /peer [0-9]+ addr ${p2.node.ip} 29665/
+ /peer [0-9]+ id Device2 Owner2/
+ expect from p2:
+ /peer [0-9]+ addr ${p1.node.ip} 29665/
+ /peer [0-9]+ id Device1 Owner1/
+
+ for p in [ pd, p1, p2 ]:
+ send "stop-server" to p
+ for p in [ pd, p1, p2 ]:
+ expect /stop-server-done/ from p
diff --git a/test/message.test b/test/message.test
index 307f11a..c0e251b 100644
--- a/test/message.test
+++ b/test/message.test
@@ -1,10 +1,12 @@
test DirectMessage:
+ let services = "contact,dm"
+
spawn as p1
spawn as p2
send "create-identity Device1 Owner1" to p1
send "create-identity Device2 Owner2" to p2
- send "start-server" to p1
- send "start-server" to p2
+ send "start-server services $services" to p1
+ send "start-server services $services" to p2
expect from p1:
/peer ([0-9]+) addr ${p2.node.ip} 29665/ capture peer1_2
@@ -96,7 +98,7 @@ test DirectMessage:
expect /stop-server-done/
for p in [p1, p2]:
with p:
- send "start-server"
+ send "start-server services $services"
with p1:
send "contact-list"
@@ -126,10 +128,10 @@ test DirectMessage:
for p in [p1, p2]:
with p:
expect /stop-server-done/
- send "start-server" to p2
+ send "start-server services $services" to p2
send "dm-send-contact $c1_2 while_offline" to p1
- send "start-server" to p1
+ send "start-server services $services" to p1
expect /dm-received from Owner1 text while_offline/ from p2
@@ -139,11 +141,11 @@ test DirectMessage:
for p in [p1, p2]:
with p:
expect /stop-server-done/
- send "start-server" to p1
+ send "start-server services $services" to p1
send "dm-send-contact $c1_2 while_peer_offline" to p1
# TODO: sync from p1 on peer p2 discovery not ensured without addition wait
#wait
- send "start-server" to p2
+ send "start-server services $services" to p2
expect /dm-received from Owner1 text while_peer_offline/ from p2
diff --git a/test/network.test b/test/network.test
index 40190f4..52fcbee 100644
--- a/test/network.test
+++ b/test/network.test
@@ -120,12 +120,14 @@ test Discovery:
test LargeData:
+ let services = "test"
+
spawn as p1
spawn as p2
send "create-identity Device1" to p1
send "create-identity Device2" to p2
- send "start-server" to p1
- send "start-server" to p2
+ send "start-server services $services" to p1
+ send "start-server services $services" to p2
expect from p1:
/peer 1 addr ${p2.node.ip} 29665/
/peer 1 id Device2/
@@ -149,12 +151,14 @@ test LargeData:
test ManyStreams:
+ let services = "test"
+
spawn as p1
spawn as p2
send "create-identity Device1" to p1
send "create-identity Device2" to p2
- send "start-server" to p1
- send "start-server" to p2
+ send "start-server services $services" to p1
+ send "start-server services $services" to p2
expect from p1:
/peer 1 addr ${p2.node.ip} 29665/
/peer 1 id Device2/
@@ -179,12 +183,14 @@ test ManyStreams:
test MultipleServiceRefs:
+ let services = "test"
+
spawn as p1
spawn as p2
send "create-identity Device1" to p1
send "create-identity Device2" to p2
- send "start-server" to p1
- send "start-server" to p2
+ send "start-server services $services" to p1
+ send "start-server services $services" to p2
expect from p1:
/peer 1 addr ${p2.node.ip} 29665/
/peer 1 id Device2/
@@ -235,16 +241,18 @@ test MultipleServiceRefs:
test Reconnection:
+ let services = "test"
+
spawn as p1
with p1:
send "create-identity Device1"
- send "start-server"
+ send "start-server services $services"
node n
local:
spawn as p2 on n
send "create-identity Device2" to p2
- send "start-server" to p2
+ send "start-server services $services" to p2
expect from p1:
/peer 1 addr ${p2.node.ip} 29665/
@@ -272,7 +280,7 @@ test Reconnection:
# Restart process on node 'n'
local:
spawn as p2 on n
- send "start-server" to p2
+ send "start-server services $services" to p2
send "peer-add ${p1.node.ip}" to p2
expect from p2:
@@ -383,6 +391,7 @@ test Reconnection:
test SendUnknownObjectType:
+ let services = "test"
let refpat = /blake2#[0-9a-f]*/
spawn as p1
@@ -390,10 +399,10 @@ test SendUnknownObjectType:
with p1:
send "create-identity Device1"
- send "start-server"
+ send "start-server services $services"
with p2:
send "create-identity Device2"
- send "start-server"
+ send "start-server services $services"
expect from p1:
/peer 1 addr ${p2.node.ip} 29665/
diff --git a/test/storage.test b/test/storage.test
index db9e0a1..a5cca7f 100644
--- a/test/storage.test
+++ b/test/storage.test
@@ -381,14 +381,16 @@ test StorageWatcher:
test SharedStateWatcher:
+ let services = "attach,sync"
+
spawn as p1
spawn as p2
send "create-identity Device1 Owner" to p1
send "create-identity Device2" to p2
send "watch-local-identity" to p1
send "watch-local-identity" to p2
- send "start-server" to p1
- send "start-server" to p2
+ send "start-server services $services" to p1
+ send "start-server services $services" to p2
expect from p1:
/local-identity Device1 Owner/
/peer 1 addr ${p2.node.ip} 29665/
diff --git a/test/sync.test b/test/sync.test
index ea9595d..d465b11 100644
--- a/test/sync.test
+++ b/test/sync.test
@@ -1,4 +1,6 @@
test:
+ let services = "attach,sync"
+
spawn as p1
spawn as p2
send "create-identity Device1 Owner" to p1
@@ -7,8 +9,8 @@ test:
send "watch-local-identity" to p2
send "watch-shared-identity" to p1
send "watch-shared-identity" to p2
- send "start-server" to p1
- send "start-server" to p2
+ send "start-server services $services" to p1
+ send "start-server services $services" to p2
expect from p1:
/local-identity Device1 Owner/
/shared-identity Owner/
@@ -57,7 +59,7 @@ test:
send "create-identity Device3"
send "watch-local-identity"
send "watch-shared-identity"
- send "start-server"
+ send "start-server services $services"
send "peer-add ${p1.node.ip}"