Skip to content

Commit d4b2ba6

Browse files
mertcanaltinaduh95
authored andcommitted
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 9b08726 commit d4b2ba6

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
@@ -87,33 +87,6 @@ TEST(NodeCrypto, NewRootCertStore) {
8787
X509_STORE_free(store);
8888
}
8989

90-
/*
91-
* This test verifies that OpenSSL memory tracking constants are properly
92-
* defined.
93-
*/
94-
TEST(NodeCrypto, MemoryTrackingConstants) {
95-
// Verify that our memory tracking constants are defined and reasonable
96-
EXPECT_GT(node::crypto::kSizeOf_SSL_CTX, static_cast<size_t>(0))
97-
<< "SSL_CTX size constant should be positive";
98-
EXPECT_GT(node::crypto::kSizeOf_X509, static_cast<size_t>(0))
99-
<< "X509 size constant should be positive";
100-
EXPECT_GT(node::crypto::kSizeOf_EVP_MD_CTX, static_cast<size_t>(0))
101-
<< "EVP_MD_CTX size constant should be positive";
102-
103-
// Verify reasonable size ranges (basic sanity check)
104-
EXPECT_LT(node::crypto::kSizeOf_SSL_CTX, static_cast<size_t>(10000))
105-
<< "SSL_CTX size should be reasonable";
106-
EXPECT_LT(node::crypto::kSizeOf_X509, static_cast<size_t>(10000))
107-
<< "X509 size should be reasonable";
108-
EXPECT_LT(node::crypto::kSizeOf_EVP_MD_CTX, static_cast<size_t>(1000))
109-
<< "EVP_MD_CTX size should be reasonable";
110-
111-
// Specific values we expect based on our implementation
112-
EXPECT_EQ(node::crypto::kSizeOf_SSL_CTX, static_cast<size_t>(240));
113-
EXPECT_EQ(node::crypto::kSizeOf_X509, static_cast<size_t>(128));
114-
EXPECT_EQ(node::crypto::kSizeOf_EVP_MD_CTX, static_cast<size_t>(48));
115-
}
116-
11790
TEST(NodeCrypto, TryGetIntCipherOutputLength) {
11891
int output_len = 0;
11992

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)