Skip to content

Commit a2c8da5

Browse files
authored
test: use heapdump test for SecureContext memory tracking
Signed-off-by: Mert Can Altin <mertgold60@gmail.com> PR-URL: #64344 Refs: #59051 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
1 parent 342bf6d commit a2c8da5

2 files changed

Lines changed: 29 additions & 27 deletions

File tree

‎test/cctest/test_node_crypto.cc‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,33 +42,6 @@ TEST(NodeCrypto, NewRootCertStore) {
4242
X509_STORE_free(store);
4343
}
4444

45-
/*
46-
* This test verifies that OpenSSL memory tracking constants are properly
47-
* defined.
48-
*/
49-
TEST(NodeCrypto, MemoryTrackingConstants) {
50-
// Verify that our memory tracking constants are defined and reasonable
51-
EXPECT_GT(node::crypto::kSizeOf_SSL_CTX, static_cast<size_t>(0))
52-
<< "SSL_CTX size constant should be positive";
53-
EXPECT_GT(node::crypto::kSizeOf_X509, static_cast<size_t>(0))
54-
<< "X509 size constant should be positive";
55-
EXPECT_GT(node::crypto::kSizeOf_EVP_MD_CTX, static_cast<size_t>(0))
56-
<< "EVP_MD_CTX size constant should be positive";
57-
58-
// Verify reasonable size ranges (basic sanity check)
59-
EXPECT_LT(node::crypto::kSizeOf_SSL_CTX, static_cast<size_t>(10000))
60-
<< "SSL_CTX size should be reasonable";
61-
EXPECT_LT(node::crypto::kSizeOf_X509, static_cast<size_t>(10000))
62-
<< "X509 size should be reasonable";
63-
EXPECT_LT(node::crypto::kSizeOf_EVP_MD_CTX, static_cast<size_t>(1000))
64-
<< "EVP_MD_CTX size should be reasonable";
65-
66-
// Specific values we expect based on our implementation
67-
EXPECT_EQ(node::crypto::kSizeOf_SSL_CTX, static_cast<size_t>(240));
68-
EXPECT_EQ(node::crypto::kSizeOf_X509, static_cast<size_t>(128));
69-
EXPECT_EQ(node::crypto::kSizeOf_EVP_MD_CTX, static_cast<size_t>(48));
70-
}
71-
7245
TEST(NodeCrypto, TryGetIntCipherOutputLength) {
7346
int output_len = 0;
7447

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
// This tests heap snapshot integration of SecureContext.
3+
4+
const common = require('../common');
5+
6+
if (!common.hasCrypto) common.skip('missing crypto');
7+
8+
const fixtures = require('../common/fixtures');
9+
const {
10+
createJSHeapSnapshot,
11+
validateByRetainingPathFromNodes,
12+
} = require('../common/heap');
13+
const tls = require('tls');
14+
15+
// eslint-disable-next-line no-unused-vars
16+
const ctx = tls.createSecureContext({
17+
cert: fixtures.readKey('agent1-cert.pem'),
18+
key: fixtures.readKey('agent1-key.pem'),
19+
});
20+
21+
{
22+
const nodes = createJSHeapSnapshot();
23+
validateByRetainingPathFromNodes(nodes, 'Node / SecureContext', [
24+
{ edge_name: 'ctx', node_name: 'Node / ctx' },
25+
]);
26+
validateByRetainingPathFromNodes(nodes, 'Node / SecureContext', [
27+
{ edge_name: 'cert', node_name: 'Node / cert' },
28+
]);
29+
}

0 commit comments

Comments
 (0)