Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: tests/standalone/io/socket_ipv6_test.dart

Issue 13918013: Disable IPv6 lookup by default. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/socket.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:io'; 5 import 'dart:io';
6 import 'dart:isolate'; 6 import 'dart:isolate';
7 7
8 const ANY = InternetAddressType.ANY;
9
8 void testIPv6toIPv6() { 10 void testIPv6toIPv6() {
9 ServerSocket.bind("::0").then((server) { 11 InternetAddress.lookup("::0", type: ANY).then((serverAddr) {
10 server.listen((socket) { 12 InternetAddress.lookup("::1", type: ANY).then((clientAddr) {
11 socket.destroy(); 13 ServerSocket.bind(serverAddr.first).then((server) {
12 server.close(); 14 server.listen((socket) {
13 }); 15 socket.destroy();
14 Socket.connect("::1", server.port).then((socket) { 16 server.close();
15 socket.destroy(); 17 });
18 Socket.connect(clientAddr.first, server.port).then((socket) {
19 socket.destroy();
20 });
21 });
16 }); 22 });
17 }); 23 });
18 } 24 }
19 25
20 void testIPv4toIPv6() { 26 void testIPv4toIPv6() {
21 ServerSocket.bind("::0").then((server) { 27 InternetAddress.lookup("::0", type: ANY).then((serverAddr) {
22 server.listen((socket) { 28 ServerSocket.bind(serverAddr.first).then((server) {
23 socket.destroy(); 29 server.listen((socket) {
24 server.close(); 30 socket.destroy();
25 }); 31 server.close();
26 Socket.connect("127.0.0.1", server.port).then((socket) { 32 });
27 socket.destroy(); 33 Socket.connect("127.0.0.1", server.port).then((socket) {
34 socket.destroy();
35 });
28 }); 36 });
29 }); 37 });
30 } 38 }
31 39
32 void testIPv6toIPv4() { 40 void testIPv6toIPv4() {
33 ServerSocket.bind("127.0.0.1").then((server) { 41 InternetAddress.lookup("::1", type: ANY).then((clientAddr) {
34 server.listen((socket) { 42 ServerSocket.bind("127.0.0.1").then((server) {
35 throw "Unexpected socket"; 43 server.listen((socket) {
36 }); 44 throw "Unexpected socket";
37 Socket.connect("::1", server.port).catchError((e) { 45 });
38 server.close(); 46 Socket.connect(clientAddr.first, server.port).catchError((e) {
47 server.close();
48 });
39 }); 49 });
40 }); 50 });
41 } 51 }
42 52
43 void testIPv4toIPv4() { 53 void testIPv4toIPv4() {
44 ServerSocket.bind("127.0.0.1").then((server) { 54 ServerSocket.bind("127.0.0.1").then((server) {
45 server.listen((socket) { 55 server.listen((socket) {
46 socket.destroy(); 56 socket.destroy();
47 server.close(); 57 server.close();
48 }); 58 });
49 Socket.connect("127.0.0.1", server.port).then((socket) { 59 Socket.connect("127.0.0.1", server.port).then((socket) {
50 socket.destroy(); 60 socket.destroy();
51 }); 61 });
52 }); 62 });
53 } 63 }
54 64
55 void testIPv6Lookup() { 65 void testIPv6Lookup() {
56 var port = new ReceivePort(); 66 var port = new ReceivePort();
57 InternetAddress.lookup("::0").then((list) { 67 InternetAddress.lookup("::0", type: ANY).then((list) {
58 if (list.length < 0) throw "no address"; 68 if (list.length < 0) throw "no address";
59 for (var entry in list) { 69 for (var entry in list) {
60 if (entry.type != InternetAddressType.IPv6) { 70 if (entry.type != InternetAddressType.IPv6) {
61 throw "Wrong IP type"; 71 throw "Wrong IP type";
62 } 72 }
63 } 73 }
64 port.close(); 74 port.close();
65 }); 75 });
66 } 76 }
67 77
(...skipping 11 matching lines...) Expand all
79 } 89 }
80 90
81 void main() { 91 void main() {
82 testIPv6toIPv6(); 92 testIPv6toIPv6();
83 testIPv4toIPv6(); 93 testIPv4toIPv6();
84 testIPv6toIPv4(); 94 testIPv6toIPv4();
85 testIPv4toIPv4(); 95 testIPv4toIPv4();
86 testIPv6Lookup(); 96 testIPv6Lookup();
87 testIPv4Lookup(); 97 testIPv4Lookup();
88 } 98 }
OLDNEW
« no previous file with comments | « sdk/lib/io/socket.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698