nodejs/test/parallel/test-crypto-ecdh-setpublickey-deprecation.js
James M Snell 66632648ba
crypto: runtime deprecate ECDH.setPublicKey()
It's been "pending" deprecation since 6.12.0.
I think that's long enough.

PR-URL: https://github.com/nodejs/node/pull/58620
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2025-06-09 15:53:10 +00:00

25 lines
538 B
JavaScript

// Flags: --no-warnings
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
}
const crypto = require('crypto');
common.expectWarning(
'DeprecationWarning',
'ecdh.setPublicKey() is deprecated.', 'DEP0031');
const ec = crypto.createECDH('secp256k1');
try {
// This will throw but we don't care about the error,
// we just want to verify that the deprecation warning
// is emitted.
ec.setPublicKey(Buffer.from([123]));
} catch {
// Intentionally ignore the error
}