From 33a85764cfd6fc29b23368042808f94173b346ad Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 4 Mar 2021 14:34:05 -0500 Subject: [PATCH 01/18] upgrade workflow actions --- .github/workflows/benchmark.yml | 8 ++++---- .github/workflows/linting.yml | 8 ++++---- .github/workflows/tests.yml | 8 ++++---- .github/workflows/tests_windows.yml | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 88974e42dac..db7ae668aa2 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -13,17 +13,17 @@ jobs: redis-version: [5] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2.3.4 with: fetch-depth: 1 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2.1.15 with: node-version: ${{ matrix.node-version }} - name: Setup Redis - uses: shogo82148/actions-setup-redis@v1.0.1 + uses: shogo82148/actions-setup-redis@v1.9.7 with: redis-version: ${{ matrix.redis-version }} auto-start: "true" @@ -32,7 +32,7 @@ jobs: - name: Run Benchmark run: npm run benchmark > benchmark-output.txt && cat benchmark-output.txt - name: Upload Benchmark Result - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2.2.2 with: name: benchmark-output.txt path: benchmark-output.txt diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 08a5f1e5ac3..9bf08b5afed 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -7,10 +7,10 @@ jobs: name: ESLint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2.3.4 with: fetch-depth: 1 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2.1.15 with: node-version: 12 - run: npm i --no-audit --prefer-offline @@ -20,12 +20,12 @@ jobs: run: npm run lint:report continue-on-error: true - name: Annotate Code Linting Results - uses: ataylorme/eslint-annotate-action@1.0.4 + uses: ataylorme/eslint-annotate-action@1.1.2 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" report-json: "eslint-report.json" - name: Upload ESLint report - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2.2.2 with: name: eslint-report.json path: eslint-report.json diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a7829a9d1b5..9c0ac18eee5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,17 +13,17 @@ jobs: redis-version: [4.x, 5.x] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2.3.4 with: fetch-depth: 1 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2.1.15 with: node-version: ${{ matrix.node-version }} - name: Setup Redis - uses: shogo82148/actions-setup-redis@v1.0.1 + uses: shogo82148/actions-setup-redis@v1.9.7 with: redis-version: ${{ matrix.redis-version }} auto-start: "false" @@ -46,7 +46,7 @@ jobs: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} - name: Upload Coverage Report - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2.2.2 with: name: coverage path: coverage diff --git a/.github/workflows/tests_windows.yml b/.github/workflows/tests_windows.yml index 504cb6a4f8f..ae60f095406 100644 --- a/.github/workflows/tests_windows.yml +++ b/.github/workflows/tests_windows.yml @@ -11,12 +11,12 @@ jobs: matrix: node-version: [6.x, 8.x, 10.x, 12.x] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2.3.4 with: fetch-depth: 1 - name: Install Redis - uses: crazy-max/ghaction-chocolatey@v1 + uses: crazy-max/ghaction-chocolatey@v1.4.0 with: args: install redis-64 --no-progress @@ -27,7 +27,7 @@ jobs: redis-cli config set stop-writes-on-bgsave-error no - name: Setup Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2.1.15 with: node-version: ${{ matrix.node-version }} @@ -43,7 +43,7 @@ jobs: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} - name: Upload Coverage Report - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2.2.2 with: name: coverage path: coverage From 2119685ebd1115842adb4ee3f35676f82f253930 Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 4 Mar 2021 14:43:51 -0500 Subject: [PATCH 02/18] fix setup-node version --- .github/workflows/benchmark.yml | 2 +- .github/workflows/linting.yml | 2 +- .github/workflows/tests.yml | 2 +- .github/workflows/tests_windows.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index db7ae668aa2..c3db31f3bb1 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -18,7 +18,7 @@ jobs: fetch-depth: 1 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2.1.15 + uses: actions/setup-node@v2.1.5 with: node-version: ${{ matrix.node-version }} diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 9bf08b5afed..d110707ee09 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v2.3.4 with: fetch-depth: 1 - - uses: actions/setup-node@v2.1.15 + - uses: actions/setup-node@v2.1.5 with: node-version: 12 - run: npm i --no-audit --prefer-offline diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9c0ac18eee5..b3a608ac77f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,7 @@ jobs: fetch-depth: 1 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2.1.15 + uses: actions/setup-node@v2.1.5 with: node-version: ${{ matrix.node-version }} diff --git a/.github/workflows/tests_windows.yml b/.github/workflows/tests_windows.yml index ae60f095406..469b8306a93 100644 --- a/.github/workflows/tests_windows.yml +++ b/.github/workflows/tests_windows.yml @@ -27,7 +27,7 @@ jobs: redis-cli config set stop-writes-on-bgsave-error no - name: Setup Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2.1.15 + uses: actions/setup-node@v2.1.5 with: node-version: ${{ matrix.node-version }} From 76b5066eb37c633aa7700418d452a1890bc46173 Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 4 Mar 2021 14:54:44 -0500 Subject: [PATCH 03/18] change redis-64 version to 3.0.503 --- .github/workflows/tests_windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests_windows.yml b/.github/workflows/tests_windows.yml index 469b8306a93..2f5e7e441ab 100644 --- a/.github/workflows/tests_windows.yml +++ b/.github/workflows/tests_windows.yml @@ -18,7 +18,7 @@ jobs: - name: Install Redis uses: crazy-max/ghaction-chocolatey@v1.4.0 with: - args: install redis-64 --no-progress + args: install redis-64 --version=3.0.503 --no-progress - name: Start Redis run: | From 4172a3d134b55320e5e12b78d9cf237443134141 Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 4 Mar 2021 18:45:37 -0500 Subject: [PATCH 04/18] fix "no password is set" for redis6, fix tests to work with redis6, add redis6 to workflows --- .github/workflows/benchmark.yml | 2 +- .github/workflows/tests.yml | 2 +- lib/individualCommands.js | 2 +- test/auth.spec.js | 17 +++++++++-------- test/errors.js | 6 ++++++ test/pubsub.spec.js | 5 +++-- 6 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 test/errors.js diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index c3db31f3bb1..05c86d52c19 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: node-version: [8.x, 10.x, 12.x] - redis-version: [5] + redis-version: [5.x, 6.x] steps: - uses: actions/checkout@v2.3.4 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b3a608ac77f..9b1d92494ea 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: node-version: [6.x, 8.x, 10.x, 12.x] - redis-version: [4.x, 5.x] + redis-version: [4.x, 5.x, 6.x] steps: - uses: actions/checkout@v2.3.4 diff --git a/lib/individualCommands.js b/lib/individualCommands.js index d366b642502..44973324993 100644 --- a/lib/individualCommands.js +++ b/lib/individualCommands.js @@ -4,7 +4,7 @@ var utils = require('./utils'); var debug = require('./debug'); var Multi = require('./multi'); var Command = require('./command'); -var no_password_is_set = /no password is set/; +var no_password_is_set = /no password is set|called without any password configured/; var loading = /LOADING/; var RedisClient = require('../').RedisClient; diff --git a/test/auth.spec.js b/test/auth.spec.js index d88ac6304e3..7d289f9945f 100644 --- a/test/auth.spec.js +++ b/test/auth.spec.js @@ -3,6 +3,7 @@ var assert = require('assert'); var config = require('./lib/config'); var helper = require('./helper'); +var errors = require('./errors'); var redis = config.redis; if (process.platform === 'win32') { @@ -74,7 +75,7 @@ describe('client authentication', function () { client.once('error', function (err) { assert.strictEqual(err.command, 'AUTH'); - assert.ok(/ERR invalid password/.test(err.message)); + assert.match(err.message, errors.invalidPassword); return done(); }); @@ -88,7 +89,7 @@ describe('client authentication', function () { client.auth('', function (err, res) { assert.strictEqual(err.command, 'AUTH'); - assert.ok(/ERR invalid password/.test(err.message)); + assert.match(err.message, errors.invalidPassword); done(); }); }); @@ -193,7 +194,7 @@ describe('client authentication', function () { client = redis.createClient.apply(null, args); var async = true; client.auth('undefined', function (err, res) { - assert.strictEqual(err.message, 'ERR invalid password'); + assert.match(err.message, errors.invalidPassword); assert.strictEqual(err.command, 'AUTH'); assert.strictEqual(res, undefined); async = false; @@ -207,7 +208,7 @@ describe('client authentication', function () { client = redis.createClient.apply(null, args); client.on('error', function (err) { - assert.strictEqual(err.message, 'ERR invalid password'); + assert.match(err.message, errors.invalidPassword); assert.strictEqual(err.command, 'AUTH'); done(); }); @@ -235,7 +236,7 @@ describe('client authentication', function () { client = redis.createClient.apply(null, args); client.on('ready', function () { client.set('foo', 'bar', function (err, res) { - assert.equal(err.message, 'NOAUTH Authentication required.'); + assert.match(err.message, /^NOAUTH Authentication required\.(\r\n)?$/); assert.equal(err.code, 'NOAUTH'); assert.equal(err.command, 'SET'); done(); @@ -248,7 +249,7 @@ describe('client authentication', function () { client = redis.createClient.apply(null, args); client.on('error', function (err) { assert.equal(err.code, 'NOAUTH'); - assert.equal(err.message, 'Ready check failed: NOAUTH Authentication required.'); + assert.match(err.message, /^Ready check failed: NOAUTH Authentication required\.(\r\n)?$/); assert.equal(err.command, 'INFO'); done(); }); @@ -260,7 +261,7 @@ describe('client authentication', function () { password: 'wrong_password', }); client.once('error', function (err) { - assert.strictEqual(err.message, 'ERR invalid password'); + assert.match(err.message, errors.invalidPassword); done(); }); }); @@ -277,7 +278,7 @@ describe('client authentication', function () { client.once('ready', function () { assert.strictEqual(client.pub_sub_mode, 1); client.get('foo', function (err, res) { - assert(/ERR only \(P\)SUBSCRIBE \/ \(P\)UNSUBSCRIBE/.test(err.message)); + assert.match(err.message, errors.subscribeUnsubscribeOnly); done(); }); }); diff --git a/test/errors.js b/test/errors.js new file mode 100644 index 00000000000..318d50022c4 --- /dev/null +++ b/test/errors.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = { + invalidPassword: /^(ERR invalid password|WRONGPASS invalid username-password pair)/, + subscribeUnsubscribeOnly: /^ERR( Can't execute 'get':) only \(P\)SUBSCRIBE \/ \(P\)UNSUBSCRIBE/ +}; diff --git a/test/pubsub.spec.js b/test/pubsub.spec.js index e0c71adf91d..959a1173bcb 100644 --- a/test/pubsub.spec.js +++ b/test/pubsub.spec.js @@ -3,6 +3,7 @@ var assert = require('assert'); var config = require('./lib/config'); var helper = require('./helper'); +var errors = require('./errors'); var redis = config.redis; describe('publish/subscribe', function () { @@ -587,7 +588,7 @@ describe('publish/subscribe', function () { }); // Get is forbidden sub.get('foo', function (err, res) { - assert(/^ERR only \(P\)SUBSCRIBE \/ \(P\)UNSUBSCRIBE/.test(err.message)); + assert.match(err.message, errors.subscribeUnsubscribeOnly); assert.strictEqual(err.command, 'GET'); }); // Quit is allowed @@ -597,7 +598,7 @@ describe('publish/subscribe', function () { it('emit error if only pub sub commands are allowed without callback', function (done) { sub.subscribe('channel'); sub.on('error', function (err) { - assert(/^ERR only \(P\)SUBSCRIBE \/ \(P\)UNSUBSCRIBE/.test(err.message)); + assert.match(err.message, errors.subscribeUnsubscribeOnly); assert.strictEqual(err.command, 'GET'); done(); }); From 41f088656497f3133cce442f9f70f8d4fe360f85 Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 4 Mar 2021 18:54:29 -0500 Subject: [PATCH 05/18] do not use assert.match (was added only at v13.6.0 & v12.16.0) --- test/auth.spec.js | 16 ++++++++-------- test/pubsub.spec.js | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/auth.spec.js b/test/auth.spec.js index 7d289f9945f..ba978710795 100644 --- a/test/auth.spec.js +++ b/test/auth.spec.js @@ -75,7 +75,7 @@ describe('client authentication', function () { client.once('error', function (err) { assert.strictEqual(err.command, 'AUTH'); - assert.match(err.message, errors.invalidPassword); + assert.ok(errors.invalidPassword.test(err.message)); return done(); }); @@ -89,7 +89,7 @@ describe('client authentication', function () { client.auth('', function (err, res) { assert.strictEqual(err.command, 'AUTH'); - assert.match(err.message, errors.invalidPassword); + assert.ok(errors.invalidPassword.test(err.message)); done(); }); }); @@ -194,7 +194,7 @@ describe('client authentication', function () { client = redis.createClient.apply(null, args); var async = true; client.auth('undefined', function (err, res) { - assert.match(err.message, errors.invalidPassword); + assert.ok(errors.invaliodPassword.test(err.message)); assert.strictEqual(err.command, 'AUTH'); assert.strictEqual(res, undefined); async = false; @@ -208,7 +208,7 @@ describe('client authentication', function () { client = redis.createClient.apply(null, args); client.on('error', function (err) { - assert.match(err.message, errors.invalidPassword); + assert.ok(errors.invalidPassword.test(err.message)); assert.strictEqual(err.command, 'AUTH'); done(); }); @@ -236,7 +236,7 @@ describe('client authentication', function () { client = redis.createClient.apply(null, args); client.on('ready', function () { client.set('foo', 'bar', function (err, res) { - assert.match(err.message, /^NOAUTH Authentication required\.(\r\n)?$/); + assert.ok(/^NOAUTH Authentication required\.(\r\n)?$/.test(err.message)); assert.equal(err.code, 'NOAUTH'); assert.equal(err.command, 'SET'); done(); @@ -249,7 +249,7 @@ describe('client authentication', function () { client = redis.createClient.apply(null, args); client.on('error', function (err) { assert.equal(err.code, 'NOAUTH'); - assert.match(err.message, /^Ready check failed: NOAUTH Authentication required\.(\r\n)?$/); + assert.ok(/^Ready check failed: NOAUTH Authentication required\.(\r\n)?$/.test(err.message)); assert.equal(err.command, 'INFO'); done(); }); @@ -261,7 +261,7 @@ describe('client authentication', function () { password: 'wrong_password', }); client.once('error', function (err) { - assert.match(err.message, errors.invalidPassword); + assert.ok(errors.invalidPassword.test(err.message)); done(); }); }); @@ -278,7 +278,7 @@ describe('client authentication', function () { client.once('ready', function () { assert.strictEqual(client.pub_sub_mode, 1); client.get('foo', function (err, res) { - assert.match(err.message, errors.subscribeUnsubscribeOnly); + assert.ok(errors.subscribeUnsubscribeOnly.test(err.message)); done(); }); }); diff --git a/test/pubsub.spec.js b/test/pubsub.spec.js index 959a1173bcb..e0447046253 100644 --- a/test/pubsub.spec.js +++ b/test/pubsub.spec.js @@ -588,7 +588,7 @@ describe('publish/subscribe', function () { }); // Get is forbidden sub.get('foo', function (err, res) { - assert.match(err.message, errors.subscribeUnsubscribeOnly); + assert.ok(errors.subscribeUnsubscribeOnly.test(err.message)); assert.strictEqual(err.command, 'GET'); }); // Quit is allowed @@ -598,7 +598,7 @@ describe('publish/subscribe', function () { it('emit error if only pub sub commands are allowed without callback', function (done) { sub.subscribe('channel'); sub.on('error', function (err) { - assert.match(err.message, errors.subscribeUnsubscribeOnly); + assert.ok(errors.subscribeUnsubscribeOnly.test(err.message)); assert.strictEqual(err.command, 'GET'); done(); }); From fee79451f3f282033ce315bfd30a69bbcc9785d9 Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 4 Mar 2021 18:57:24 -0500 Subject: [PATCH 06/18] fix errors.subscribeUnsubscribeOnly regex --- test/errors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/errors.js b/test/errors.js index 318d50022c4..060afab585a 100644 --- a/test/errors.js +++ b/test/errors.js @@ -2,5 +2,5 @@ module.exports = { invalidPassword: /^(ERR invalid password|WRONGPASS invalid username-password pair)/, - subscribeUnsubscribeOnly: /^ERR( Can't execute 'get':) only \(P\)SUBSCRIBE \/ \(P\)UNSUBSCRIBE/ + subscribeUnsubscribeOnly: /^ERR( Can't execute 'get':)? only \(P\)SUBSCRIBE \/ \(P\)UNSUBSCRIBE/ }; From 81ed19b89f8174a86d168f10c5311f5fd6fe0c6d Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 4 Mar 2021 18:58:44 -0500 Subject: [PATCH 07/18] fix invaliodPassword typo --- test/auth.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/auth.spec.js b/test/auth.spec.js index ba978710795..679bf4f6ba2 100644 --- a/test/auth.spec.js +++ b/test/auth.spec.js @@ -194,7 +194,7 @@ describe('client authentication', function () { client = redis.createClient.apply(null, args); var async = true; client.auth('undefined', function (err, res) { - assert.ok(errors.invaliodPassword.test(err.message)); + assert.ok(errors.invalidPassword.test(err.message)); assert.strictEqual(err.command, 'AUTH'); assert.strictEqual(res, undefined); async = false; From 955217a35cb58c8b7de4a938561417f20c274e5e Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 4 Mar 2021 20:08:14 -0500 Subject: [PATCH 08/18] send --save "" to redis-server in tests --- test/conf/password.conf | 1 + test/conf/redis.conf | 1 + test/conf/rename.conf | 1 + test/conf/slave.conf | 1 + 4 files changed, 4 insertions(+) diff --git a/test/conf/password.conf b/test/conf/password.conf index c2b8feb4478..3b3c02f346e 100644 --- a/test/conf/password.conf +++ b/test/conf/password.conf @@ -3,3 +3,4 @@ port 6379 bind ::1 127.0.0.1 unixsocket /tmp/redis.sock unixsocketperm 700 +save "" diff --git a/test/conf/redis.conf b/test/conf/redis.conf index fad47a5fc63..9bf706c6543 100644 --- a/test/conf/redis.conf +++ b/test/conf/redis.conf @@ -2,3 +2,4 @@ port 6379 bind ::1 127.0.0.1 unixsocket /tmp/redis.sock unixsocketperm 700 +save "" \ No newline at end of file diff --git a/test/conf/rename.conf b/test/conf/rename.conf index ef839236558..207fe156221 100644 --- a/test/conf/rename.conf +++ b/test/conf/rename.conf @@ -2,6 +2,7 @@ port 6379 bind ::1 127.0.0.1 unixsocket /tmp/redis.sock unixsocketperm 700 +save "" rename-command SET 807081f5afa96845a02816a28b7258c3 rename-command GET f397808a43ceca3963e22b4e13deb672 rename-command GETRANGE 9e3102b15cf231c4e9e940f284744fe0 diff --git a/test/conf/slave.conf b/test/conf/slave.conf index 31cd801c269..f5632bbffcb 100644 --- a/test/conf/slave.conf +++ b/test/conf/slave.conf @@ -4,3 +4,4 @@ unixsocket /tmp/redis6381.sock unixsocketperm 700 slaveof localhost 6379 masterauth porkchopsandwiches +save "" From c5842af497c36d94a914ba9f2a0a287b8397518d Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 4 Mar 2021 20:47:09 -0500 Subject: [PATCH 09/18] upgrade dependencies, set node minimum version to 10, use current LTS versions in tests and benchmark workflows --- .github/workflows/benchmark.yml | 2 +- .github/workflows/tests.yml | 2 +- package.json | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 05c86d52c19..3ec398bb627 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [8.x, 10.x, 12.x] + node-version: [10.x, 12.x, 14.x, 15.x] redis-version: [5.x, 6.x] steps: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9b1d92494ea..06b0e57ec3e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [6.x, 8.x, 10.x, 12.x] + node-version: [10.x, 12.x, 14.x, 15.x] redis-version: [4.x, 5.x, 6.x] steps: diff --git a/package.json b/package.json index 75489c3ec44..6e6ab0cbecd 100644 --- a/package.json +++ b/package.json @@ -43,20 +43,20 @@ "redis-parser": "^3.0.0" }, "engines": { - "node": ">=6" + "node": ">=10" }, "devDependencies": { - "prettier": "^1.19.1", "bluebird": "^3.7.2", - "coveralls": "^2.11.2", - "eslint": "^6.8.0", + "coveralls": "^3.1.0", + "cross-spawn": "^7.0.3", + "eslint": "^7.21.0", "intercept-stdout": "~0.1.2", "metrics": "^0.1.21", - "mocha": "^4.1.0", - "nyc": "^14.1.1", + "mocha": "^8.3.0", + "nyc": "^15.1.0", + "prettier": "^2.2.1", "tcp-port-used": "^1.0.1", - "uuid": "^3.4.0", - "cross-spawn": "^6.0.5" + "uuid": "^8.3.2" }, "repository": { "type": "git", From f188b94dbc63dce6cba3240e892ad87c18532321 Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 4 Mar 2021 20:48:15 -0500 Subject: [PATCH 10/18] change windows tests too --- .github/workflows/tests_windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests_windows.yml b/.github/workflows/tests_windows.yml index 2f5e7e441ab..7a2e00a9c93 100644 --- a/.github/workflows/tests_windows.yml +++ b/.github/workflows/tests_windows.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [6.x, 8.x, 10.x, 12.x] + node-version: [10.x, 12.x, 14.x, 15.x] steps: - uses: actions/checkout@v2.3.4 with: From f5528504a0b69ff7ca836868ead4590e491b8ef4 Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 4 Mar 2021 21:03:48 -0500 Subject: [PATCH 11/18] revert mocha back to ^4.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6e6ab0cbecd..fa230fb63dd 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "eslint": "^7.21.0", "intercept-stdout": "~0.1.2", "metrics": "^0.1.21", - "mocha": "^8.3.0", + "mocha": "5.0.0", "nyc": "^15.1.0", "prettier": "^2.2.1", "tcp-port-used": "^1.0.1", From c09b591d3bc68b35db99afda35d653cc35852401 Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 4 Mar 2021 21:05:04 -0500 Subject: [PATCH 12/18] fix for f5528504a0b69ff7ca836868ead4590e491b8ef4 - revert mocha back to ^4.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fa230fb63dd..37649f75a75 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "eslint": "^7.21.0", "intercept-stdout": "~0.1.2", "metrics": "^0.1.21", - "mocha": "5.0.0", + "mocha": "^4.1.0", "nyc": "^15.1.0", "prettier": "^2.2.1", "tcp-port-used": "^1.0.1", From 379f5f6cfbcfebcb3178298a4b10a584acfb2c62 Mon Sep 17 00:00:00 2001 From: leibale Date: Mon, 8 Mar 2021 09:52:19 -0500 Subject: [PATCH 13/18] fix some tests and upgrade mocha --- package.json | 4 ++-- test/auth.spec.js | 17 +++++++++++++---- test/commands/hgetall.spec.js | 1 - test/connection.spec.js | 11 +++++++---- test/node_redis.spec.js | 1 + test/return_buffers.spec.js | 4 ++++ 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 37649f75a75..a34a288ba4c 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "coveralls": "nyc report --reporter=text-lcov | coveralls", "coverage": "nyc report --reporter=html", "benchmark": "node benchmarks/multi_bench.js", - "test": "nyc --cache mocha ./test/*.js ./test/commands/*.js --timeout=8000 && npm run coverage", + "test": "nyc --cache mocha ./test/*.spec.js ./test/commands/*.spec.js --timeout=8000 && npm run coverage", "lint": "eslint .", "lint:fix": "eslint . --fix", "lint:report": "eslint --output-file=eslint-report.json --format=json .", @@ -52,7 +52,7 @@ "eslint": "^7.21.0", "intercept-stdout": "~0.1.2", "metrics": "^0.1.21", - "mocha": "^4.1.0", + "mocha": "^8.3.0", "nyc": "^15.1.0", "prettier": "^2.2.1", "tcp-port-used": "^1.0.1", diff --git a/test/auth.spec.js b/test/auth.spec.js index 679bf4f6ba2..995d98136b3 100644 --- a/test/auth.spec.js +++ b/test/auth.spec.js @@ -71,7 +71,9 @@ describe('client authentication', function () { it('emits error when auth is bad without callback', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); - client = redis.createClient.apply(null, args); + client = redis.createClient.apply(null, config.configureClient(ip, { + no_ready_check: true + })); client.once('error', function (err) { assert.strictEqual(err.command, 'AUTH'); @@ -85,7 +87,9 @@ describe('client authentication', function () { it('returns an error when auth is bad (empty string) with a callback', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); - client = redis.createClient.apply(null, args); + client = redis.createClient.apply(null, config.configureClient(ip, { + no_ready_check: true + })); client.auth('', function (err, res) { assert.strictEqual(err.command, 'AUTH'); @@ -191,7 +195,9 @@ describe('client authentication', function () { it('should return an error if the password is not correct and a callback has been provided', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); - client = redis.createClient.apply(null, args); + client = redis.createClient.apply(null, config.configureClient(ip, { + no_ready_check: true + })); var async = true; client.auth('undefined', function (err, res) { assert.ok(errors.invalidPassword.test(err.message)); @@ -206,7 +212,9 @@ describe('client authentication', function () { it('should emit an error if the password is not correct and no callback has been provided', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); - client = redis.createClient.apply(null, args); + client = redis.createClient.apply(null, config.configureClient(ip, { + no_ready_check: true + })); client.on('error', function (err) { assert.ok(errors.invalidPassword.test(err.message)); assert.strictEqual(err.command, 'AUTH'); @@ -259,6 +267,7 @@ describe('client authentication', function () { if (helper.redisProcess().spawnFailed()) this.skip(); client = redis.createClient({ password: 'wrong_password', + no_ready_check: true }); client.once('error', function (err) { assert.ok(errors.invalidPassword.test(err.message)); diff --git a/test/commands/hgetall.spec.js b/test/commands/hgetall.spec.js index b74995427a1..a34435692c1 100644 --- a/test/commands/hgetall.spec.js +++ b/test/commands/hgetall.spec.js @@ -50,7 +50,6 @@ describe("The 'hgetall' method", function () { }); describe('binary client', function () { - var client; var args = config.configureClient(ip, { return_buffers: true }); diff --git a/test/connection.spec.js b/test/connection.spec.js index 7c153b3926e..bff6171b81d 100644 --- a/test/connection.spec.js +++ b/test/connection.spec.js @@ -238,7 +238,8 @@ describe('connection tests', function () { client = redis.createClient({ retryStrategy: function (options) { if (options.totalRetryTime > 150) { - client.set('foo', 'bar', function (err, res) { + client.set('foo', 'bar'); + client.once('error', function (err) { assert.strictEqual(err.message, 'Redis connection in broken state: retry aborted.'); assert.strictEqual(err.origin.message, 'Connection timeout'); done(); @@ -256,7 +257,8 @@ describe('connection tests', function () { client = redis.createClient({ retry_strategy: function (options) { if (options.total_retry_time > 150) { - client.set('foo', 'bar', function (err, res) { + client.set('foo', 'bar'); + client.once('error', function (err) { assert.strictEqual(err.message, 'Redis connection in broken state: retry aborted.'); assert.strictEqual(err.code, 'CONNECTION_BROKEN'); assert.strictEqual(err.origin.code, 'ECONNREFUSED'); @@ -334,9 +336,10 @@ describe('connection tests', function () { it('use the system socket timeout if the connect_timeout has not been provided', function (done) { client = redis.createClient({ - host: '2001:db8::ff00:42:8329' // auto detect ip v6 + host: '0:0:0:0:0:0:0:1', // auto detect ip v6 + no_ready_check: true }); - assert.strictEqual(client.address, '2001:db8::ff00:42:8329:6379'); + assert.strictEqual(client.address, '0:0:0:0:0:0:0:1:6379'); assert.strictEqual(client.connection_options.family, 6); process.nextTick(function () { assert.strictEqual(client.stream.listeners('timeout').length, 0); diff --git a/test/node_redis.spec.js b/test/node_redis.spec.js index a2c7fac69e0..38ef0f77093 100644 --- a/test/node_redis.spec.js +++ b/test/node_redis.spec.js @@ -83,6 +83,7 @@ describe('The node_redis client', function () { client.once('reconnecting', function () { process.nextTick(function () { assert.strictEqual(client.reply_parser.buffer, null); + client.end(true); done(); }); }); diff --git a/test/return_buffers.spec.js b/test/return_buffers.spec.js index ba40c26c373..cb58340d969 100644 --- a/test/return_buffers.spec.js +++ b/test/return_buffers.spec.js @@ -40,6 +40,10 @@ describe('return_buffers', function () { }); }); + afterEach(function () { + client.end(true); + }); + describe('get', function () { describe('first argument is a string', function () { it('returns a buffer', function (done) { From b7c8fa2a2ae3b080fe31bbaef1f1dab79508ddb6 Mon Sep 17 00:00:00 2001 From: leibale Date: Mon, 8 Mar 2021 10:40:41 -0500 Subject: [PATCH 14/18] fix two more tests --- test/node_redis.spec.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/node_redis.spec.js b/test/node_redis.spec.js index 38ef0f77093..ac46d1dded7 100644 --- a/test/node_redis.spec.js +++ b/test/node_redis.spec.js @@ -532,11 +532,11 @@ describe('The node_redis client', function () { // TODO: Investigate why this test is failing hard and killing mocha if using '/tmp/redis.sock'. // Seems like something is wrong with nyc while passing a socket connection to create client! - client = redis.createClient(); - client.quit(function () { - client.get('foo', function (err, res) { + var client2 = redis.createClient(); + client2.quit(function () { + client2.get('foo', function (err, res) { assert.strictEqual(err.message, 'Stream connection ended and command aborted. It might have been processed.'); - assert.strictEqual(client.offline_queue.length, 0); + assert.strictEqual(client2.offline_queue.length, 0); done(); }); }); @@ -703,6 +703,7 @@ describe('The node_redis client', function () { // Recreate client in domain so error handlers run this domain // Changed in: "error handler runs outside of its domain" // https://github.com/nodejs/node/pull/26211 + client.end(true); // make sure to close current client client = redis.createClient(); } client.end(true); From 41b9749708b46e2ae9867a9fc94fedcf84b991a6 Mon Sep 17 00:00:00 2001 From: leibale Date: Mon, 8 Mar 2021 10:48:08 -0500 Subject: [PATCH 15/18] try to fix tests in windows --- test/connection.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/connection.spec.js b/test/connection.spec.js index bff6171b81d..26a982a92cc 100644 --- a/test/connection.spec.js +++ b/test/connection.spec.js @@ -14,6 +14,8 @@ describe('connection tests', function () { client = null; }); afterEach(function () { + if (!client) return; + client.end(true); }); From c26901d02187807821785a8284458b1b46ee622b Mon Sep 17 00:00:00 2001 From: leibale Date: Mon, 8 Mar 2021 10:49:03 -0500 Subject: [PATCH 16/18] upgrade denque and redis-commands ref #1575 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a34a288ba4c..a8ae6da26ea 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,8 @@ "compare": "node benchmarks/diff_multi_bench_output.js beforeBench.txt afterBench.txt" }, "dependencies": { - "denque": "^1.4.1", - "redis-commands": "^1.5.0", + "denque": "^1.5.0", + "redis-commands": "^1.7.0", "redis-errors": "^1.2.0", "redis-parser": "^3.0.0" }, From 58f0aedae8908946d8e73e113c1501da6fa19524 Mon Sep 17 00:00:00 2001 From: leibale Date: Mon, 8 Mar 2021 11:57:17 -0500 Subject: [PATCH 17/18] replace `new Buffer` (deprecated) with `Buffer.from` --- test/commands/client.spec.js | 6 +++--- test/commands/hgetall.spec.js | 6 +++--- test/commands/hlen.spec.js | 8 ++++---- test/commands/hset.spec.js | 16 ++++++++-------- test/commands/monitor.spec.js | 4 ++-- test/detect_buffers.spec.js | 24 ++++++++++++------------ test/multi.spec.js | 2 +- test/node_redis.spec.js | 4 ++-- test/pubsub.spec.js | 24 ++++++++++++------------ test/return_buffers.spec.js | 22 +++++++++++----------- 10 files changed, 58 insertions(+), 58 deletions(-) diff --git a/test/commands/client.spec.js b/test/commands/client.spec.js index 51a55e3f16b..3214243107c 100644 --- a/test/commands/client.spec.js +++ b/test/commands/client.spec.js @@ -57,7 +57,7 @@ describe("The 'client' method", function () { it('off', function (done) { helper.serverVersionAtLeast.call(this, client, [3, 2, 0]); assert.strictEqual(client.reply, 'ON'); - client.client(new Buffer('REPLY'), 'OFF', helper.isUndefined()); + client.client(Buffer.from('REPLY'), 'OFF', helper.isUndefined()); assert.strictEqual(client.reply, 'OFF'); client.set('foo', 'bar', helper.isUndefined(done)); }); @@ -65,7 +65,7 @@ describe("The 'client' method", function () { it('skip', function (done) { helper.serverVersionAtLeast.call(this, client, [3, 2, 0]); assert.strictEqual(client.reply, 'ON'); - client.client('REPLY', new Buffer('SKIP'), helper.isUndefined()); + client.client('REPLY', Buffer.from('SKIP'), helper.isUndefined()); assert.strictEqual(client.reply, 'SKIP_ONE_MORE'); client.set('foo', 'bar', helper.isUndefined()); client.get('foo', helper.isString('bar', done)); @@ -91,7 +91,7 @@ describe("The 'client' method", function () { var batch = client.batch(); assert.strictEqual(client.reply, 'ON'); batch.set('hello', 'world'); - batch.client(new Buffer('REPLY'), new Buffer('OFF'), helper.isUndefined()); + batch.client(Buffer.from('REPLY'), Buffer.from('OFF'), helper.isUndefined()); batch.set('foo', 'bar', helper.isUndefined()); batch.exec(function (err, res) { assert.strictEqual(client.reply, 'OFF'); diff --git a/test/commands/hgetall.spec.js b/test/commands/hgetall.spec.js index a34435692c1..5bfa609d0bc 100644 --- a/test/commands/hgetall.spec.js +++ b/test/commands/hgetall.spec.js @@ -62,14 +62,14 @@ describe("The 'hgetall' method", function () { }); it('returns binary results', function (done) { - client.hmset(['bhosts', 'mjr', '1', 'another', '23', 'home', '1234', new Buffer([0xAA, 0xBB, 0x00, 0xF0]), new Buffer([0xCC, 0xDD, 0x00, 0xF0])], helper.isString('OK')); + client.hmset(['bhosts', 'mjr', '1', 'another', '23', 'home', '1234', Buffer.from([0xAA, 0xBB, 0x00, 0xF0]), Buffer.from([0xCC, 0xDD, 0x00, 0xF0])], helper.isString('OK')); client.HGETALL('bhosts', function (err, obj) { assert.strictEqual(4, Object.keys(obj).length); assert.strictEqual('1', obj.mjr.toString()); assert.strictEqual('23', obj.another.toString()); assert.strictEqual('1234', obj.home.toString()); - assert.strictEqual((new Buffer([0xAA, 0xBB, 0x00, 0xF0])).toString('binary'), Object.keys(obj)[3]); - assert.strictEqual((new Buffer([0xCC, 0xDD, 0x00, 0xF0])).toString('binary'), obj[(new Buffer([0xAA, 0xBB, 0x00, 0xF0])).toString('binary')].toString('binary')); + assert.strictEqual((Buffer.from([0xAA, 0xBB, 0x00, 0xF0])).toString('binary'), Object.keys(obj)[3]); + assert.strictEqual((Buffer.from([0xCC, 0xDD, 0x00, 0xF0])).toString('binary'), obj[(Buffer.from([0xAA, 0xBB, 0x00, 0xF0])).toString('binary')].toString('binary')); return done(err); }); }); diff --git a/test/commands/hlen.spec.js b/test/commands/hlen.spec.js index f1f94fec025..a1e3d25a403 100644 --- a/test/commands/hlen.spec.js +++ b/test/commands/hlen.spec.js @@ -20,10 +20,10 @@ describe("The 'hlen' method", function () { it('reports the count of keys', function (done) { var hash = 'test hash'; - var field1 = new Buffer('0123456789'); - var value1 = new Buffer('abcdefghij'); - var field2 = new Buffer(0); - var value2 = new Buffer(0); + var field1 = Buffer.from('0123456789'); + var value1 = Buffer.from('abcdefghij'); + var field2 = Buffer.from(0); + var value2 = Buffer.from(0); client.HSET(hash, field1, value1, helper.isNumber(1)); client.HSET(hash, field2, value2, helper.isNumber(1)); diff --git a/test/commands/hset.spec.js b/test/commands/hset.spec.js index d94a7aa0f2b..50624c13e52 100644 --- a/test/commands/hset.spec.js +++ b/test/commands/hset.spec.js @@ -21,24 +21,24 @@ describe("The 'hset' method", function () { }); it('allows a value to be set in a hash', function (done) { - var field = new Buffer('0123456789'); - var value = new Buffer('abcdefghij'); + var field = Buffer.from('0123456789'); + var value = Buffer.from('abcdefghij'); client.hset(hash, field, value, helper.isNumber(1)); client.HGET(hash, field, helper.isString(value.toString(), done)); }); it('handles an empty value', function (done) { - var field = new Buffer('0123456789'); - var value = new Buffer(0); + var field = Buffer.from('0123456789'); + var value = Buffer.from(0); client.HSET(hash, field, value, helper.isNumber(1)); client.HGET([hash, field], helper.isString('', done)); }); it('handles empty key and value', function (done) { - var field = new Buffer(0); - var value = new Buffer(0); + var field = Buffer.from(0); + var value = Buffer.from(0); client.HSET([hash, field, value], function (err, res) { assert.strictEqual(res, 1); client.HSET(hash, field, value, helper.isNumber(0, done)); @@ -60,7 +60,7 @@ describe("The 'hset' method", function () { it('does not error when a buffer and date are set as values on the same hash', function (done) { var hash = 'test hash'; var field1 = 'buffer'; - var value1 = new Buffer('abcdefghij'); + var value1 = Buffer.from('abcdefghij'); var field2 = 'date'; var value2 = new Date(); @@ -70,7 +70,7 @@ describe("The 'hset' method", function () { it('does not error when a buffer and date are set as fields on the same hash', function (done) { var hash = 'test hash'; var value1 = 'buffer'; - var field1 = new Buffer('abcdefghij'); + var field1 = Buffer.from('abcdefghij'); var value2 = 'date'; var field2 = new Date(); diff --git a/test/commands/monitor.spec.js b/test/commands/monitor.spec.js index 7465ac4eb84..679277ffcac 100644 --- a/test/commands/monitor.spec.js +++ b/test/commands/monitor.spec.js @@ -90,8 +90,8 @@ describe("The 'monitor' method", function () { monitorClient.MONITOR(function (err, res) { assert.strictEqual(monitorClient.monitoring, true); - assert.strictEqual(res.inspect(), new Buffer('OK').inspect()); - monitorClient.mget('hello', new Buffer('world')); + assert.strictEqual(res.inspect(), Buffer.from('OK').inspect()); + monitorClient.mget('hello', Buffer.from('world')); }); monitorClient.on('monitor', function (time, args, rawOutput) { diff --git a/test/detect_buffers.spec.js b/test/detect_buffers.spec.js index a656c549435..faa63efb1f1 100644 --- a/test/detect_buffers.spec.js +++ b/test/detect_buffers.spec.js @@ -43,7 +43,7 @@ describe('detect_buffers', function () { describe('first argument is a buffer', function () { it('returns a buffer', function (done) { - client.get(new Buffer('string key 1'), function (err, reply) { + client.get(Buffer.from('string key 1'), function (err, reply) { assert.strictEqual(true, Buffer.isBuffer(reply)); assert.strictEqual('', reply.inspect()); return done(err); @@ -51,7 +51,7 @@ describe('detect_buffers', function () { }); it('returns a bufffer when executed as part of transaction', function (done) { - client.multi().get(new Buffer('string key 1')).exec(function (err, reply) { + client.multi().get(Buffer.from('string key 1')).exec(function (err, reply) { assert.strictEqual(1, reply.length); assert.strictEqual(true, Buffer.isBuffer(reply[0])); assert.strictEqual('', reply[0].inspect()); @@ -65,8 +65,8 @@ describe('detect_buffers', function () { it('can interleave string and buffer results', function (done) { client.multi() .hget('hash key 2', 'key 1') - .hget(new Buffer('hash key 2'), 'key 1') - .hget('hash key 2', new Buffer('key 2')) + .hget(Buffer.from('hash key 2'), 'key 1') + .hget('hash key 2', Buffer.from('key 2')) .hget('hash key 2', 'key 2') .exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); @@ -86,8 +86,8 @@ describe('detect_buffers', function () { it('can interleave string and buffer results', function (done) { client.batch() .hget('hash key 2', 'key 1') - .hget(new Buffer('hash key 2'), 'key 1') - .hget('hash key 2', new Buffer('key 2')) + .hget(Buffer.from('hash key 2'), 'key 1') + .hget('hash key 2', Buffer.from('key 2')) .hget('hash key 2', 'key 2') .exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); @@ -150,7 +150,7 @@ describe('detect_buffers', function () { describe('first argument is a buffer', function () { it('returns buffers for keys requested', function (done) { - client.hmget(new Buffer('hash key 2'), 'key 1', 'key 2', function (err, reply) { + client.hmget(Buffer.from('hash key 2'), 'key 1', 'key 2', function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(2, reply.length); assert.strictEqual(true, Buffer.isBuffer(reply[0])); @@ -162,7 +162,7 @@ describe('detect_buffers', function () { }); it('returns buffers for keys requested in transaction', function (done) { - client.multi().hmget(new Buffer('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) { + client.multi().hmget(Buffer.from('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(1, reply.length); assert.strictEqual(2, reply[0].length); @@ -175,7 +175,7 @@ describe('detect_buffers', function () { }); it('returns buffers for keys requested in .batch', function (done) { - client.batch().hmget(new Buffer('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) { + client.batch().hmget(Buffer.from('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(1, reply.length); assert.strictEqual(2, reply[0].length); @@ -226,7 +226,7 @@ describe('detect_buffers', function () { describe('first argument is a buffer', function () { it('returns buffer values', function (done) { - client.hgetall(new Buffer('hash key 2'), function (err, reply) { + client.hgetall(Buffer.from('hash key 2'), function (err, reply) { assert.strictEqual(null, err); assert.strictEqual('object', typeof reply); assert.strictEqual(2, Object.keys(reply).length); @@ -239,7 +239,7 @@ describe('detect_buffers', function () { }); it('returns buffer values when executed in transaction', function (done) { - client.multi().hgetall(new Buffer('hash key 2')).exec(function (err, reply) { + client.multi().hgetall(Buffer.from('hash key 2')).exec(function (err, reply) { assert.strictEqual(1, reply.length); assert.strictEqual('object', typeof reply[0]); assert.strictEqual(2, Object.keys(reply[0]).length); @@ -252,7 +252,7 @@ describe('detect_buffers', function () { }); it('returns buffer values when executed in .batch', function (done) { - client.batch().hgetall(new Buffer('hash key 2')).exec(function (err, reply) { + client.batch().hgetall(Buffer.from('hash key 2')).exec(function (err, reply) { assert.strictEqual(1, reply.length); assert.strictEqual('object', typeof reply[0]); assert.strictEqual(2, Object.keys(reply[0]).length); diff --git a/test/multi.spec.js b/test/multi.spec.js index 2465dfc2d0b..5b0e801c875 100644 --- a/test/multi.spec.js +++ b/test/multi.spec.js @@ -46,7 +46,7 @@ describe("The 'multi' method", function () { } var json = JSON.stringify(test_arr); - zlib.deflate(new Buffer(json), function (err, buffer) { + zlib.deflate(Buffer.from(json), function (err, buffer) { if (err) { done(err); return; diff --git a/test/node_redis.spec.js b/test/node_redis.spec.js index ac46d1dded7..12ad70d5ef6 100644 --- a/test/node_redis.spec.js +++ b/test/node_redis.spec.js @@ -87,7 +87,7 @@ describe('The node_redis client', function () { done(); }); }); - var partialInput = new Buffer('$100\r\nabcdef'); + var partialInput = Buffer.from('$100\r\nabcdef'); client.reply_parser.execute(partialInput); assert.strictEqual(client.reply_parser.buffer.inspect(), partialInput.inspect()); client.stream.destroy(); @@ -813,7 +813,7 @@ describe('The node_redis client', function () { // ready is called in a reply process.nextTick(function () { // Fail the set answer. Has no corresponding command obj and will therefore land in the error handler and set - client.reply_parser.execute(new Buffer('a*1\r*1\r$1`zasd\r\na')); + client.reply_parser.execute(Buffer.from('a*1\r*1\r$1`zasd\r\na')); }); }); }); diff --git a/test/pubsub.spec.js b/test/pubsub.spec.js index e0447046253..34e93f37f2c 100644 --- a/test/pubsub.spec.js +++ b/test/pubsub.spec.js @@ -125,7 +125,7 @@ describe('publish/subscribe', function () { detect_buffers: true }); sub.on('subscribe', function (chnl, count) { - if (chnl.inspect() === new Buffer([0xAA, 0xBB, 0x00, 0xF0]).inspect()) { + if (chnl.inspect() === Buffer.from([0xAA, 0xBB, 0x00, 0xF0]).inspect()) { assert.equal(1, count); if (a) { return done(); @@ -138,7 +138,7 @@ describe('publish/subscribe', function () { a = true; }); - sub.subscribe(new Buffer([0xAA, 0xBB, 0x00, 0xF0]), channel2); + sub.subscribe(Buffer.from([0xAA, 0xBB, 0x00, 0xF0]), channel2); }); it('receives messages on subscribed channel', function (done) { @@ -263,13 +263,13 @@ describe('publish/subscribe', function () { }); it('handles multiple channels with the same channel name properly, even with buffers', function (done) { - var channels = ['a', 'b', 'a', new Buffer('a'), 'c', 'b']; + var channels = ['a', 'b', 'a', Buffer.from('a'), 'c', 'b']; var subscribed_channels = [1, 2, 2, 2, 3, 3]; var i = 0; sub.subscribe(channels); sub.on('subscribe', function (channel, count) { if (Buffer.isBuffer(channel)) { - assert.strictEqual(channel.inspect(), new Buffer(channels[i]).inspect()); + assert.strictEqual(channel.inspect(), Buffer.from(channels[i]).inspect()); } else { assert.strictEqual(channel, channels[i].toString()); } @@ -421,7 +421,7 @@ describe('publish/subscribe', function () { }); subscribe(['prefix:*', 'prefix:3'], function () { - pub.publish('prefix:1', new Buffer('test'), function () { + pub.publish('prefix:1', Buffer.from('test'), function () { subscribe(['prefix:2']); subscribe(['5', 'test:a', 'bla'], function () { assert(all); @@ -495,9 +495,9 @@ describe('publish/subscribe', function () { sub2.batch().psubscribe('*', helper.isString('*')).exec(); sub2.subscribe('/foo'); sub2.on('pmessage', function (pattern, channel, message) { - assert.strictEqual(pattern.inspect(), new Buffer('*').inspect()); - assert.strictEqual(channel.inspect(), new Buffer('/foo').inspect()); - assert.strictEqual(message.inspect(), new Buffer('hello world').inspect()); + assert.strictEqual(pattern.inspect(), Buffer.from('*').inspect()); + assert.strictEqual(channel.inspect(), Buffer.from('/foo').inspect()); + assert.strictEqual(message.inspect(), Buffer.from('hello world').inspect()); sub2.quit(done); }); pub.pubsub('numsub', '/foo', function (err, res) { @@ -518,11 +518,11 @@ describe('publish/subscribe', function () { assert.strictEqual(sub.shouldBuffer, false); sub.on('pmessageBuffer', function (pattern, channel) { if (typeof pattern === 'string') { - pattern = new Buffer(pattern); - channel = new Buffer(channel); + pattern = Buffer.from(pattern); + channel = Buffer.from(channel); } - assert.strictEqual(pattern.inspect(), new Buffer('*').inspect()); - assert.strictEqual(channel.inspect(), new Buffer('/foo').inspect()); + assert.strictEqual(pattern.inspect(), Buffer.from('*').inspect()); + assert.strictEqual(channel.inspect(), Buffer.from('/foo').inspect()); sub.quit(end); }); // Either message_buffers or buffers has to be true, but not both at the same time diff --git a/test/return_buffers.spec.js b/test/return_buffers.spec.js index cb58340d969..22efb31a04f 100644 --- a/test/return_buffers.spec.js +++ b/test/return_buffers.spec.js @@ -69,8 +69,8 @@ describe('return_buffers', function () { it('returns buffers', function (done) { client.multi() .hget('hash key 2', 'key 1') - .hget(new Buffer('hash key 2'), 'key 1') - .hget('hash key 2', new Buffer('key 2')) + .hget(Buffer.from('hash key 2'), 'key 1') + .hget('hash key 2', Buffer.from('key 2')) .hget('hash key 2', 'key 2') .exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); @@ -91,8 +91,8 @@ describe('return_buffers', function () { it('returns buffers', function (done) { client.batch() .hget('hash key 2', 'key 1') - .hget(new Buffer('hash key 2'), 'key 1') - .hget('hash key 2', new Buffer('key 2')) + .hget(Buffer.from('hash key 2'), 'key 1') + .hget('hash key 2', Buffer.from('key 2')) .hget('hash key 2', 'key 2') .exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); @@ -125,7 +125,7 @@ describe('return_buffers', function () { describe('first argument is a buffer', function () { it('returns buffers for keys requested', function (done) { - client.hmget(new Buffer('hash key 2'), 'key 1', 'key 2', function (err, reply) { + client.hmget(Buffer.from('hash key 2'), 'key 1', 'key 2', function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(2, reply.length); assert.strictEqual(true, Buffer.isBuffer(reply[0])); @@ -137,7 +137,7 @@ describe('return_buffers', function () { }); it('returns buffers for keys requested in transaction', function (done) { - client.multi().hmget(new Buffer('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) { + client.multi().hmget(Buffer.from('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(1, reply.length); assert.strictEqual(2, reply[0].length); @@ -150,7 +150,7 @@ describe('return_buffers', function () { }); it('returns buffers for keys requested in .batch', function (done) { - client.batch().hmget(new Buffer('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) { + client.batch().hmget(Buffer.from('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(1, reply.length); assert.strictEqual(2, reply[0].length); @@ -201,7 +201,7 @@ describe('return_buffers', function () { describe('first argument is a buffer', function () { it('returns buffer values', function (done) { - client.hgetall(new Buffer('hash key 2'), function (err, reply) { + client.hgetall(Buffer.from('hash key 2'), function (err, reply) { assert.strictEqual(null, err); assert.strictEqual('object', typeof reply); assert.strictEqual(2, Object.keys(reply).length); @@ -214,7 +214,7 @@ describe('return_buffers', function () { }); it('returns buffer values when executed in transaction', function (done) { - client.multi().hgetall(new Buffer('hash key 2')).exec(function (err, reply) { + client.multi().hgetall(Buffer.from('hash key 2')).exec(function (err, reply) { assert.strictEqual(1, reply.length); assert.strictEqual('object', typeof reply[0]); assert.strictEqual(2, Object.keys(reply[0]).length); @@ -227,7 +227,7 @@ describe('return_buffers', function () { }); it('returns buffer values when executed in .batch', function (done) { - client.batch().hgetall(new Buffer('hash key 2')).exec(function (err, reply) { + client.batch().hgetall(Buffer.from('hash key 2')).exec(function (err, reply) { assert.strictEqual(1, reply.length); assert.strictEqual('object', typeof reply[0]); assert.strictEqual(2, Object.keys(reply[0]).length); @@ -245,7 +245,7 @@ describe('return_buffers', function () { var pub; var sub; var channel = 'test channel'; - var message = new Buffer('test message'); + var message = Buffer.from('test message'); var args = config.configureClient(ip, { return_buffers: true From cd9b1ed1bfd95301ffce0fd95d36ec7f22b716fb Mon Sep 17 00:00:00 2001 From: leibale Date: Mon, 8 Mar 2021 12:16:23 -0500 Subject: [PATCH 18/18] Buffer.from(0) should be Buffer.alloc(0) --- test/commands/hlen.spec.js | 4 ++-- test/commands/hset.spec.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/commands/hlen.spec.js b/test/commands/hlen.spec.js index a1e3d25a403..874cb2970a1 100644 --- a/test/commands/hlen.spec.js +++ b/test/commands/hlen.spec.js @@ -22,8 +22,8 @@ describe("The 'hlen' method", function () { var hash = 'test hash'; var field1 = Buffer.from('0123456789'); var value1 = Buffer.from('abcdefghij'); - var field2 = Buffer.from(0); - var value2 = Buffer.from(0); + var field2 = Buffer.alloc(0); + var value2 = Buffer.alloc(0); client.HSET(hash, field1, value1, helper.isNumber(1)); client.HSET(hash, field2, value2, helper.isNumber(1)); diff --git a/test/commands/hset.spec.js b/test/commands/hset.spec.js index 50624c13e52..746176f3d8c 100644 --- a/test/commands/hset.spec.js +++ b/test/commands/hset.spec.js @@ -30,15 +30,15 @@ describe("The 'hset' method", function () { it('handles an empty value', function (done) { var field = Buffer.from('0123456789'); - var value = Buffer.from(0); + var value = Buffer.alloc(0); client.HSET(hash, field, value, helper.isNumber(1)); client.HGET([hash, field], helper.isString('', done)); }); it('handles empty key and value', function (done) { - var field = Buffer.from(0); - var value = Buffer.from(0); + var field = Buffer.alloc(0); + var value = Buffer.alloc(0); client.HSET([hash, field, value], function (err, res) { assert.strictEqual(res, 1); client.HSET(hash, field, value, helper.isNumber(0, done));