Skip to content

Commit

Permalink
Fix IP tests
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Nov 3, 2021
1 parent f6d1fb7 commit 8122d96
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
6 changes: 4 additions & 2 deletions test/http.ts
Expand Up @@ -2,7 +2,7 @@ import process from 'process';
import {Buffer} from 'buffer';
import {STATUS_CODES, Agent} from 'http';
import os from 'os';
import {isIPv4, isIPv6} from 'net';
import {isIPv4, isIPv6, isIP} from 'net';
import test from 'ava';
import {Handler} from 'express';
import nock from 'nock';
Expand Down Expand Up @@ -305,7 +305,9 @@ test('DNS auto', withServer, async (t, server, got) => {
dnsLookupIpVersion: undefined,
});

t.true(isIPv4(response.body));
const version = isIP(response.body);

t.true(version === 4 || version === 6);
});

test('DNS IPv4', withServer, async (t, server, got) => {
Expand Down
5 changes: 2 additions & 3 deletions test/https.ts
Expand Up @@ -414,9 +414,8 @@ test('invalid key passphrase', withHttpsServer(), async (t, server, got) => {
},
});

await t.throwsAsync(request, {
code: 'ERR_OSSL_EVP_BAD_DECRYPT',
});
const {code}: NodeJS.ErrnoException = await t.throwsAsync(request);
t.true(code === 'ERR_OSSL_BAD_DECRYPT' || code === 'ERR_OSSL_EVP_BAD_DECRYPT');
});

test('client certificate PFX', withHttpsServer(), async (t, server, got) => {
Expand Down
2 changes: 1 addition & 1 deletion test/promise.ts
Expand Up @@ -26,7 +26,7 @@ test('emits response event as promise', withServer, async (t, server, got) => {
t.true(response instanceof IncomingMessage);
t.false(response.readable);
t.is(response.statusCode, 200);
t.is(response.ip, '127.0.0.1');
t.true(response.ip === '127.0.0.1' || response.ip === '::1');
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/stream.ts
Expand Up @@ -354,7 +354,7 @@ test('works with pipeline', async t => {
got.stream.put('http://localhost:7777'),
), {
instanceOf: RequestError,
message: 'connect ECONNREFUSED 127.0.0.1:7777',
message: /^connect ECONNREFUSED (127\.0\.0\.1|::1):7777$/,
});
});

Expand Down

0 comments on commit 8122d96

Please sign in to comment.