@@ -99,10 +99,12 @@ describe("connection tests", function () {
99
99
var options = {
100
100
host : 'somewhere' ,
101
101
port : 6379 ,
102
+ family : ip ,
102
103
max_attempts : 1
103
104
} ;
104
105
client = redis . createClient ( options ) ;
105
- assert . strictEqual ( Object . keys ( options ) . length , 3 ) ;
106
+ assert . strictEqual ( client . connection_option . family , ip === 'IPv6' ? 6 : 4 ) ;
107
+ assert . strictEqual ( Object . keys ( options ) . length , 4 ) ;
106
108
var end = helper . callFuncAfter ( done , 2 ) ;
107
109
108
110
client . on ( 'error' , function ( err ) {
@@ -133,13 +135,14 @@ describe("connection tests", function () {
133
135
var connect_timeout = 1000 ; // in ms
134
136
client = redis . createClient ( {
135
137
parser : parser ,
136
- host : '192.168.74.167' ,
138
+ host : '192.168.74.167' , // Should be auto detected as ipv4
137
139
connect_timeout : connect_timeout
138
140
} ) ;
139
141
process . nextTick ( function ( ) {
140
142
assert ( client . stream . _events . timeout ) ;
141
143
} ) ;
142
144
assert . strictEqual ( client . address , '192.168.74.167:6379' ) ;
145
+ assert . strictEqual ( client . connection_option . family , 4 ) ;
143
146
var time = Date . now ( ) ;
144
147
145
148
client . on ( "reconnecting" , function ( params ) {
@@ -156,8 +159,10 @@ describe("connection tests", function () {
156
159
it ( "use the system socket timeout if the connect_timeout has not been provided" , function ( ) {
157
160
client = redis . createClient ( {
158
161
parser : parser ,
159
- host : '192.168.74.167'
162
+ host : '2001:db8::ff00:42:8329' // auto detect ip v6
160
163
} ) ;
164
+ assert . strictEqual ( client . address , '2001:db8::ff00:42:8329:6379' ) ;
165
+ assert . strictEqual ( client . connection_option . family , 6 ) ;
161
166
process . nextTick ( function ( ) {
162
167
assert . strictEqual ( client . stream . _events . timeout , undefined ) ;
163
168
} ) ;
@@ -235,6 +240,7 @@ describe("connection tests", function () {
235
240
236
241
it ( "connects with a port only" , function ( done ) {
237
242
client = redis . createClient ( 6379 ) ;
243
+ assert . strictEqual ( client . connection_option . family , 4 ) ;
238
244
client . on ( "error" , done ) ;
239
245
240
246
client . once ( "ready" , function ( ) {
0 commit comments