commit 74f8cc3d85a202111c47a5c3b1fb6486ea4decd7
parent 8c5e0d534e6a5eed8a7958953c17da6d6f5e9a21
Author: kyle <kyle@0x30.net>
Date: Sat, 2 Jan 2016 14:10:15 -0700
tests: switch another test over to create_devices()
Diffstat:
1 file changed, 17 insertions(+), 29 deletions(-)
diff --git a/server/tests/multiple_friends_same_other_list/test.pl b/server/tests/multiple_friends_same_other_list/test.pl
@@ -7,47 +7,35 @@ use test;
# your not in, that the list doesn't show up twice in your list_get_other
# request.
-my @phnums = ("4038675309", "4037082094", "4036080226");
-my @sockets;
-my @device_ids;
-
-# create new devices for 0, 1 and 2
-for (0..2) {
- $sockets[$_] = new_socket();
-
- send_msg($sockets[$_], 'new_device', "$phnums[$_]\0unix");
- my ($msg) = recv_msg($sockets[$_], 'new_device');
-
- $device_ids[$_] = check_status($msg, 'ok');
-}
+my ($sockets, $phnums, $device_ids) = create_devices(3);
# 0 and 1 need to be mutual friends
-send_msg($sockets[0], 'add_friend', "$device_ids[0]\0$phnums[1]");
-recv_msg($sockets[0], 'add_friend');
-send_msg($sockets[1], 'add_friend', "$device_ids[1]\0$phnums[0]");
-recv_msg($sockets[1], 'add_friend');
+send_msg($$sockets[0], 'add_friend', "$$device_ids[0]\0$$phnums[1]");
+recv_msg($$sockets[0], 'add_friend');
+send_msg($$sockets[1], 'add_friend', "$$device_ids[1]\0$$phnums[0]");
+recv_msg($$sockets[1], 'add_friend');
# 0 and 2 need to be mutual friends too
-send_msg($sockets[0], 'add_friend', "$device_ids[0]\0$phnums[2]");
-recv_msg($sockets[0], 'add_friend');
-send_msg($sockets[2], 'add_friend', "$device_ids[2]\0$phnums[0]");
-recv_msg($sockets[2], 'add_friend');
+send_msg($$sockets[0], 'add_friend', "$$device_ids[0]\0$$phnums[2]");
+recv_msg($$sockets[0], 'add_friend');
+send_msg($$sockets[2], 'add_friend', "$$device_ids[2]\0$$phnums[0]");
+recv_msg($$sockets[2], 'add_friend');
# 1 and 2 need to be in the same list
-send_msg($sockets[1], 'new_list', "$device_ids[1]\0this is a new list");
-my ($msg_data) = recv_msg($sockets[1], 'new_list');
+send_msg($$sockets[1], 'new_list', "$$device_ids[1]\0this is a new list");
+my ($msg_data) = recv_msg($$sockets[1], 'new_list');
my $list_data = check_status($msg_data, 'ok');
my ($list_id) = split("\0", $list_data);
-send_msg($sockets[2], 'join_list', "$device_ids[2]\0$list_id");
-($msg_data) = recv_msg($sockets[2], 'join_list');
+send_msg($$sockets[2], 'join_list', "$$device_ids[2]\0$list_id");
+($msg_data) = recv_msg($$sockets[2], 'join_list');
check_status($msg_data, 'ok');
# 0 requests his other lists
-send_msg($sockets[0], 'list_get_other', "$device_ids[0]");
-($msg_data) = recv_msg($sockets[0], 'list_get_other');
+send_msg($$sockets[0], 'list_get_other', "$$device_ids[0]");
+($msg_data) = recv_msg($$sockets[0], 'list_get_other');
my $raw_lists = check_status($msg_data, 'ok');
my @lists = split("\n", $raw_lists);
@@ -57,5 +45,5 @@ fail "expected 1 list, got " . @lists if (@lists != 1);
my ($id, $name, @members) = split("\0", $lists[0]);
fail "expected 2 list members, got " . @members if (@members != 2);
fail "bad list id '$id', expected '$list_id'" if ($id ne $list_id);
-fail "expected member '$phnums[1]'" unless (grep {$_ eq $phnums[1]} @phnums);
-fail "expected member '$phnums[2]'" unless (grep {$_ eq $phnums[2]} @phnums);
+fail "expected member '$$phnums[1]'" unless (grep {$_ eq $$phnums[1]} @$phnums);
+fail "expected member '$$phnums[2]'" unless (grep {$_ eq $$phnums[2]} @$phnums);