diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2022-12-18 18:56:19 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2022-12-18 21:37:11 +0100 |
commit | 86293ff20d9f8625615e855d98249175e8cd5cd3 (patch) | |
tree | 7eb1fe3a34ce1d6a24a9338f3dd3008b500fffe0 /test/contact.test | |
parent | 77fc16d21158c6542addcbaaff47b801d3b5f5c7 (diff) |
Contact service and contacts using stored set
Diffstat (limited to 'test/contact.test')
-rw-r--r-- | test/contact.test | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/test/contact.test b/test/contact.test new file mode 100644 index 0000000..b0005fd --- /dev/null +++ b/test/contact.test @@ -0,0 +1,149 @@ +test Contact: + spawn as p1 + spawn as p2 + spawn as p3 + spawn as p4 + + send "create-identity Device1 Owner1" to p1 + send "create-identity Device2 Owner2" to p2 + 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 + + expect from p1: + /peer ([0-9]+) addr ${p2.node.ip} 29665/ capture peer1_2 + /peer $peer1_2 id Device2 Owner2/ + /peer ([0-9]+) addr ${p3.node.ip} 29665/ capture peer1_3 + /peer $peer1_3 id Device3 Owner3/ + /peer ([0-9]+) addr ${p4.node.ip} 29665/ capture peer1_4 + /peer $peer1_4 id Device4/ + + expect from p2: + /peer ([0-9]+) addr ${p1.node.ip} 29665/ capture peer2_1 + /peer $peer2_1 id Device1 Owner1/ + /peer ([0-9]+) addr ${p3.node.ip} 29665/ capture peer2_3 + /peer $peer2_3 id Device3 Owner3/ + /peer ([0-9]+) addr ${p4.node.ip} 29665/ capture peer2_4 + /peer $peer2_4 id Device4/ + + expect from p3: + /peer ([0-9]+) addr ${p1.node.ip} 29665/ capture peer3_1 + /peer $peer3_1 id Device1 Owner1/ + /peer ([0-9]+) addr ${p2.node.ip} 29665/ capture peer3_2 + /peer $peer3_2 id Device2 Owner2/ + /peer ([0-9]+) addr ${p4.node.ip} 29665/ capture peer3_4 + /peer $peer3_4 id Device4/ + + expect from p4: + /peer ([0-9]+) addr ${p1.node.ip} 29665/ capture peer4_1 + /peer $peer4_1 id Device1 Owner1/ + /peer ([0-9]+) addr ${p2.node.ip} 29665/ capture peer4_2 + /peer $peer4_2 id Device2 Owner2/ + /peer ([0-9]+) addr ${p3.node.ip} 29665/ capture peer4_3 + /peer $peer4_3 id Device3 Owner3/ + + # Rejected contacts + + send "contact-request $peer1_2" to p1 + expect /contact-request $peer2_1 [0-9]*/ from p2 + expect /contact-response $peer1_2 [0-9]*/ from p1 + send "contact-reject $peer1_2" to p1 + expect /contact-request-failed $peer2_1 rejected/ from p2 + expect /contact-response-failed $peer1_2 user/ from p1 + + send "contact-request $peer1_2" to p1 + expect /contact-request $peer2_1 [0-9]*/ from p2 + expect /contact-response $peer1_2 [0-9]*/ from p1 + send "contact-reject $peer2_1" to p2 + expect /contact-request-failed $peer2_1 user/ from p2 + expect /contact-response-failed $peer1_2 rejected/ from p1 + + # Contact between 1 and 2 + + send "contact-request $peer1_2" to p1 + expect /contact-request $peer2_1 ([0-9]*)/ from p2 capture code1_2 + expect /contact-response $peer1_2 ([0-9]*)/ from p1 capture code1_1 + guard code1_1 == code1_2 + + send "contact-accept $peer1_2" to p1 + send "contact-accept $peer2_1" to p2 + expect /contact-request-done $peer2_1/ from p2 + expect /contact-response-done $peer1_2/ from p1 + + send "contact-list" to p1 + expect from p1: + /contact-list-item Owner2 Owner2/ + /contact-list-(.*)/ capture done1_1 + guard done1_1 == "done" + send "contact-list" to p2 + expect from p2: + /contact-list-item Owner1 Owner1/ + /contact-list-(.*)/ capture done1_2 + guard done1_2 == "done" + + # Attach peer 4 to Owner1 + + send "watch-local-identity" to p4 + expect /local-identity Device4/ from p4 + + send "attach-to $peer4_1" to p4 + expect /attach-request $peer1_4 ([0-9]*)/ from p1 capture code2_1 + expect /attach-response $peer4_1 ([0-9]*)/ from p4 capture code2_4 + guard code2_1 == code2_4 + + send "attach-accept $peer1_4" to p1 + send "attach-accept $peer4_1" to p4 + expect /attach-request-done $peer1_4/ from p1 + expect /attach-response-done $peer4_1/ from p4 + expect /local-identity Device4 Owner1/ from p4 + expect /peer $peer1_4 id Device4 Owner1/ from p1 + expect /peer $peer2_4 id Device4 Owner1/ from p2 + expect /peer $peer3_4 id Device4 Owner1/ from p3 + + # Contact between 3 and 4 + + send "contact-request $peer3_4" to p3 + expect /contact-request $peer4_3 ([0-9]*)/ from p4 capture code3_4 + expect /contact-response $peer3_4 ([0-9]*)/ from p3 capture code3_3 + guard code3_3 == code3_4 + + send "contact-accept $peer3_4" to p3 + send "contact-accept $peer4_3" to p4 + expect /contact-request-done $peer4_3/ from p4 + expect /contact-response-done $peer3_4/ from p3 + + send "contact-list" to p3 + expect from p3: + /contact-list-item Owner1 Owner1/ + /contact-list-(.*)/ capture done2_3 + guard done2_3 == "done" + + send "shared-state-get" to p1 + expect /shared-state-get (.*)/ from p1 capture s1 + send "shared-state-wait $s1" to p4 + expect /shared-state-wait $s1/ from p4 + + send "contact-list" to p4 + expect from p4: + /contact-list-item Owner2 Owner2/ + /contact-list-item Owner3 Owner3/ + /contact-list-(.*)/ capture done2_4 + guard done2_4 == "done" + + # Check sync between 1 and 4 + + send "shared-state-get" to p4 + expect /shared-state-get (.*)/ from p4 capture s4 + send "shared-state-wait $s4" to p1 + expect /shared-state-wait $s4/ from p1 + + send "contact-list" to p1 + expect from p1: + /contact-list-item Owner2 Owner2/ + /contact-list-item Owner3 Owner3/ + /contact-list-(.*)/ capture done2_1 + guard done2_1 == "done" |