summaryrefslogtreecommitdiff
path: root/test/attach.et
diff options
context:
space:
mode:
Diffstat (limited to 'test/attach.et')
-rw-r--r--test/attach.et128
1 files changed, 128 insertions, 0 deletions
diff --git a/test/attach.et b/test/attach.et
new file mode 100644
index 0000000..ae00048
--- /dev/null
+++ b/test/attach.et
@@ -0,0 +1,128 @@
+module attach
+
+import common
+
+test Attach:
+ 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 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/
+ /peer 1 id Device2/
+ expect from p2:
+ /local-identity Device2/
+ /peer 1 addr ${p1.node.ip} 29665/
+ /peer 1 id Device1 Owner/
+
+ send "attach-to 1" to p2
+ expect /attach-request 1 .*/ from p1
+ expect /attach-response 1 .*/ from p2
+ send "attach-reject 1" to p1
+ expect /attach-request-failed 1 user/ from p1
+ expect /attach-response-failed 1 rejected/ from p2
+
+ send "attach-to 1" to p2
+ expect /attach-request 1 .*/ from p1
+ expect /attach-response 1 .*/ from p2
+ send "attach-reject 1" to p2
+ expect /attach-request-failed 1 rejected/ from p1
+ expect /attach-response-failed 1 user/ from p2
+
+ send "attach-to 1" to p2
+ expect /attach-request 1 ([0-9]*)/ from p1 capture code1
+ expect /attach-response 1 ([0-9]*)/ from p2 capture code2
+ guard (code1 == code2)
+
+ send "attach-accept 1" to p1
+ send "attach-accept 1" to p2
+ expect /attach-request-done 1/ from p1
+ expect /attach-response-done 1/ from p2
+ expect /local-identity Device2 Owner/ from p2
+ expect /peer 1 id Device2 Owner/ from p1
+
+
+test SyncAfterAttach:
+ let services_1 = "attach"
+ let services_2 = "discovery,sync"
+ let services_d = "discovery"
+
+ subnet sd
+ subnet s1
+ subnet s2
+ subnet s3
+
+ node nd on sd
+ node n1 on s1
+ node n2 on s2
+ node n3 on s3
+
+ local:
+ spawn as pd on nd
+ spawn as p1 on n1
+ spawn as p2 on n2
+ spawn as p3 on n3
+
+ send "create-identity Discovery" to pd
+ send "create-identity Device1 Owner" to p1
+ send "create-identity Device2" to p2
+ send "create-identity Device3" to p3
+
+ expect /create-identity-done ref $refpat.*/ from pd
+ expect /create-identity-done ref $refpat.*/ from p1
+ expect /create-identity-done ref $refpat.*/ from p2
+ expect /create-identity-done ref $refpat.*/ from p3
+
+ send "start-server services $services_1" to p1
+ for p in [ p2, p3 ]:
+ with p:
+ send "start-server services $services_1"
+ send "peer-add ${p1.node.ip}"
+ expect /peer 1 addr ${p1.node.ip} 29665/
+ expect /peer 1 id Device1 Owner/
+
+ expect /peer ([0-9]+) addr ${p.node.ip} 29665/ from p1 capture pidx
+ expect /peer $pidx id Device./ from p1
+
+ send "attach-to 1"
+ expect /attach-request $pidx ([0-9]*)/ from p1 capture code1
+ expect /attach-response 1 ([0-9]*)/ capture code2
+ guard (code1 == code2)
+
+ send "attach-accept $pidx" to p1
+ send "attach-accept 1"
+ expect /attach-request-done $pidx/ from p1
+ expect /attach-response-done 1/
+
+ spawn as pd on nd
+ spawn as p1 on n1
+ spawn as p2 on n2
+ spawn as p3 on n3
+
+ send "start-server services $services_d" to pd
+ for p in [ p1, p2, p3 ]:
+ send "start-server services $services_2" to p
+
+ # Shared identity sync after explicit direct connection
+
+ send "peer-add ${p1.node.ip}" to p2
+ expect /peer 1 addr ${p2.node.ip} 29665/ from p1
+ expect /peer 1 id Device. Owner/ from p1
+
+ # Shared identity sync after automatic discovery
+
+ for p in [ p1, p3 ]:
+ send "peer-add ${pd.node.ip}" to p
+
+ expect /peer 2 addr ${pd.node.ip} 29665/ from p1
+ expect /peer 2 id Discovery/ from p1
+
+ expect /peer 3 addr ${p3.node.ip} 29665/ from p1
+ expect /peer 3 id Device. Owner/ from p1