diff --git a/test/cctest/test_node_crypto.cc b/test/cctest/test_node_crypto.cc index 94940e3c55f939..04b6bee9e1e5fa 100644 --- a/test/cctest/test_node_crypto.cc +++ b/test/cctest/test_node_crypto.cc @@ -24,44 +24,3 @@ TEST(NodeCrypto, NewRootCertStore) { "any errors on the OpenSSL error stack\n"; 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; - - EXPECT_TRUE( - node::crypto::TryGetIntCipherOutputLength(INT_MAX - 16, 16, &output_len)); - EXPECT_EQ(output_len, INT_MAX); - - EXPECT_FALSE( - node::crypto::TryGetIntCipherOutputLength(INT_MAX - 15, 16, &output_len)); - - EXPECT_FALSE(node::crypto::TryGetIntCipherOutputLength( - 0, static_cast(INT_MAX) + 1, &output_len)); -} diff --git a/test/pummel/test-heapdump-secure-context.js b/test/pummel/test-heapdump-secure-context.js new file mode 100644 index 00000000000000..bc39a2a001de2c --- /dev/null +++ b/test/pummel/test-heapdump-secure-context.js @@ -0,0 +1,31 @@ +'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 { + createJSHeapSnapshot, + validateByRetainingPathFromNodes, +} = require('../common/heap'); +const tls = require('tls'); + + +// 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' }, + ]); +}