0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-blocklist-clone.js
James M Snell fb9257f659
net: make net.BlockList cloneable
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/37917
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2021-04-02 06:16:38 -07:00

32 lines
602 B
JavaScript

'use strict';
const common = require('../common');
const {
BlockList,
} = require('net');
const {
ok,
notStrictEqual,
} = require('assert');
const blocklist = new BlockList();
blocklist.addAddress('123.123.123.123');
const mc = new MessageChannel();
mc.port1.onmessage = common.mustCall(({ data }) => {
notStrictEqual(data, blocklist);
ok(data.check('123.123.123.123'));
ok(!data.check('123.123.123.124'));
data.addAddress('123.123.123.124');
ok(blocklist.check('123.123.123.124'));
ok(data.check('123.123.123.124'));
mc.port1.close();
});
mc.port2.postMessage(blocklist);