Use constants.TEST

This commit is contained in:
Girish Ramakrishnan
2023-10-01 13:52:19 +05:30
parent 0e195679bf
commit ceb908bee7
20 changed files with 26 additions and 23 deletions

View File

@@ -9,6 +9,7 @@ exports = module.exports = {
const assert = require('assert'),
BoxError = require('../boxerror.js'),
constants = require('../constants.js'),
debug = require('debug')('box:network/generic'),
safe = require('safetydance'),
superagent = require('superagent');
@@ -18,7 +19,7 @@ const gCache = { ipv4: {}, ipv6: {} }; // each has { timestamp, value, request }
async function getIPv4(config) {
assert.strictEqual(typeof config, 'object');
if (process.env.BOX_ENV === 'test') return '127.0.0.1';
if (constants.TEST) return '127.0.0.1';
if (gCache.ipv4.value && (Date.now() - gCache.ipv4.timestamp <= 5 * 60 * 1000)) return gCache.ipv4.value;
@@ -52,7 +53,7 @@ async function getIPv4(config) {
async function getIPv6(config) {
assert.strictEqual(typeof config, 'object');
if (process.env.BOX_ENV === 'test') return '::1';
if (constants.TEST) return '::1';
if (gCache.ipv6.value && (Date.now() - gCache.ipv6.timestamp <= 5 * 60 * 1000)) return gCache.ipv6.value;