Skip to content

Commit 45526dc

Browse files
committed
test: fix test-dgram-udp6-link-local-address on Windows
1 parent c6b0ae8 commit 45526dc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/parallel/test-dgram-udp6-link-local-address.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ const dgram = require('dgram');
88
const os = require('os');
99

1010
function linklocal() {
11-
for (const [ifname, entries] of Object.entries(os.networkInterfaces())) {
11+
for (const entries of Object.values(os.networkInterfaces())) {
1212
for (const { address, family, scopeid } of entries) {
1313
if (family === 'IPv6' && address.startsWith('fe80:')) {
14-
return { address, ifname, scopeid };
14+
return { address, scopeid };
1515
}
1616
}
1717
}
@@ -21,7 +21,6 @@ const iface = linklocal();
2121
if (!iface)
2222
common.skip('cannot find any IPv6 interfaces with a link local address');
2323

24-
const address = `${iface.address}%${iface.ifname}`;
2524
const message = 'Hello, local world!';
2625

2726
// Create a client socket for sending to the link-local address.
@@ -32,7 +31,7 @@ const server = dgram.createSocket('udp6');
3231

3332
server.on('listening', common.mustCall(() => {
3433
const port = server.address().port;
35-
client.send(message, 0, message.length, port, address);
34+
client.send(message, 0, message.length, port, iface.address);
3635
}));
3736

3837
server.on('message', common.mustCall((buf, info) => {
@@ -42,10 +41,10 @@ server.on('message', common.mustCall((buf, info) => {
4241
// including the link local scope identifier.
4342
assert.strictEqual(
4443
info.address,
45-
common.isWindows ? `${iface.address}%${iface.scopeid}` : address
44+
common.isWindows ? `${iface.address}%${iface.scopeid}` : iface.address
4645
);
4746
server.close();
4847
client.close();
4948
}, 1));
5049

51-
server.bind({ address });
50+
server.bind({ address: iface.address });

0 commit comments

Comments
 (0)