From e0fced031ac6243b728339d0df52d8b6ce7c8a99 Mon Sep 17 00:00:00 2001 From: Mert Can Altin Date: Tue, 7 Jul 2026 22:20:57 +0300 Subject: [PATCH 1/2] test: use heapdump test for SecureContext memory tracking Signed-off-by: Mert Can Altin --- test/cctest/test_node_crypto.cc | 27 --------------- test/pummel/test-heapdump-secure-context.js | 37 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 27 deletions(-) create mode 100644 test/pummel/test-heapdump-secure-context.js diff --git a/test/cctest/test_node_crypto.cc b/test/cctest/test_node_crypto.cc index 94940e3c55f939..0f116726fcb64d 100644 --- a/test/cctest/test_node_crypto.cc +++ b/test/cctest/test_node_crypto.cc @@ -25,33 +25,6 @@ TEST(NodeCrypto, NewRootCertStore) { X509_STORE_free(store); } -/* - * This test verifies that OpenSSL memory tracking constants are properly - * defined. - */ -TEST(NodeCrypto, MemoryTrackingConstants) { - // Verify that our memory tracking constants are defined and reasonable - EXPECT_GT(node::crypto::kSizeOf_SSL_CTX, static_cast(0)) - << "SSL_CTX size constant should be positive"; - EXPECT_GT(node::crypto::kSizeOf_X509, static_cast(0)) - << "X509 size constant should be positive"; - EXPECT_GT(node::crypto::kSizeOf_EVP_MD_CTX, static_cast(0)) - << "EVP_MD_CTX size constant should be positive"; - - // Verify reasonable size ranges (basic sanity check) - EXPECT_LT(node::crypto::kSizeOf_SSL_CTX, static_cast(10000)) - << "SSL_CTX size should be reasonable"; - EXPECT_LT(node::crypto::kSizeOf_X509, static_cast(10000)) - << "X509 size should be reasonable"; - EXPECT_LT(node::crypto::kSizeOf_EVP_MD_CTX, static_cast(1000)) - << "EVP_MD_CTX size should be reasonable"; - - // Specific values we expect based on our implementation - EXPECT_EQ(node::crypto::kSizeOf_SSL_CTX, static_cast(240)); - EXPECT_EQ(node::crypto::kSizeOf_X509, static_cast(128)); - EXPECT_EQ(node::crypto::kSizeOf_EVP_MD_CTX, static_cast(48)); -} - TEST(NodeCrypto, TryGetIntCipherOutputLength) { int output_len = 0; diff --git a/test/pummel/test-heapdump-secure-context.js b/test/pummel/test-heapdump-secure-context.js new file mode 100644 index 00000000000000..feb100070e0535 --- /dev/null +++ b/test/pummel/test-heapdump-secure-context.js @@ -0,0 +1,37 @@ +'use strict'; +// This tests heap snapshot integration of SecureContext. + +const common = require('../common'); + +if (!common.hasCrypto) common.skip('missing crypto'); + +const fixtures = require('../common/fixtures'); +const assert = require('assert'); +const { + createJSHeapSnapshot, + validateByRetainingPathFromNodes, +} = require('../common/heap'); +const tls = require('tls'); + +{ + const nodes = createJSHeapSnapshot(); + const matches = nodes.filter( + (n) => n.name === 'Node / SecureContext' && n.type !== 'string'); + assert.strictEqual(matches.length, 0); +} + +// eslint-disable-next-line no-unused-vars +const ctx = tls.createSecureContext({ + cert: fixtures.readKey('agent1-cert.pem'), + key: fixtures.readKey('agent1-key.pem'), +}); + +{ + const nodes = createJSHeapSnapshot(); + validateByRetainingPathFromNodes(nodes, 'Node / SecureContext', [ + { edge_name: 'ctx', node_name: 'Node / ctx' }, + ]); + validateByRetainingPathFromNodes(nodes, 'Node / SecureContext', [ + { edge_name: 'cert', node_name: 'Node / cert' }, + ]); +} From 5438c862e6100ba7f6c8480a650c78cc65a5dbdb Mon Sep 17 00:00:00 2001 From: Mert Can Altin Date: Tue, 7 Jul 2026 22:25:01 +0300 Subject: [PATCH 2/2] delete not necessary test Signed-off-by: Mert Can Altin --- test/pummel/test-heapdump-secure-context.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/pummel/test-heapdump-secure-context.js b/test/pummel/test-heapdump-secure-context.js index feb100070e0535..9024ad456b924a 100644 --- a/test/pummel/test-heapdump-secure-context.js +++ b/test/pummel/test-heapdump-secure-context.js @@ -13,13 +13,6 @@ const { } = require('../common/heap'); const tls = require('tls'); -{ - const nodes = createJSHeapSnapshot(); - const matches = nodes.filter( - (n) => n.name === 'Node / SecureContext' && n.type !== 'string'); - assert.strictEqual(matches.length, 0); -} - // eslint-disable-next-line no-unused-vars const ctx = tls.createSecureContext({ cert: fixtures.readKey('agent1-cert.pem'),