Skip to content

Commit 2f7595c

Browse files
committed
test: use heapdump test for SecureContext memory tracking
1 parent 726b220 commit 2f7595c

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

test/cctest/test_node_crypto.cc

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,3 @@ TEST(NodeCrypto, NewRootCertStore) {
2121
"any errors on the OpenSSL error stack\n";
2222
X509_STORE_free(store);
2323
}
24-
25-
/*
26-
* This test verifies that OpenSSL memory tracking constants are properly
27-
* defined.
28-
*/
29-
TEST(NodeCrypto, MemoryTrackingConstants) {
30-
// Verify that our memory tracking constants are defined and reasonable
31-
EXPECT_GT(node::crypto::kSizeOf_SSL_CTX, 0)
32-
<< "SSL_CTX size constant should be positive";
33-
EXPECT_GT(node::crypto::kSizeOf_X509, 0)
34-
<< "X509 size constant should be positive";
35-
EXPECT_GT(node::crypto::kSizeOf_EVP_MD_CTX, 0)
36-
<< "EVP_MD_CTX size constant should be positive";
37-
38-
// Verify reasonable size ranges (basic sanity check)
39-
EXPECT_LT(node::crypto::kSizeOf_SSL_CTX, 10000)
40-
<< "SSL_CTX size should be reasonable";
41-
EXPECT_LT(node::crypto::kSizeOf_X509, 10000)
42-
<< "X509 size should be reasonable";
43-
EXPECT_LT(node::crypto::kSizeOf_EVP_MD_CTX, 1000)
44-
<< "EVP_MD_CTX size should be reasonable";
45-
46-
// Specific values we expect based on our implementation
47-
EXPECT_EQ(node::crypto::kSizeOf_SSL_CTX, 240);
48-
EXPECT_EQ(node::crypto::kSizeOf_X509, 128);
49-
EXPECT_EQ(node::crypto::kSizeOf_EVP_MD_CTX, 48);
50-
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
// This tests heap snapshot integration of SecureContext.
3+
4+
const common = require('../common');
5+
6+
if (!common.hasCrypto)
7+
common.skip('missing crypto');
8+
9+
const fixtures = require('../common/fixtures');
10+
const { validateSnapshotNodes } = require('../common/heap');
11+
const tls = require('tls');
12+
13+
// eslint-disable-next-line no-unused-vars
14+
const ctx = tls.createSecureContext({
15+
cert: fixtures.readKey('agent1-cert.pem'),
16+
key: fixtures.readKey('agent1-key.pem'),
17+
});
18+
19+
validateSnapshotNodes('Node / SecureContext', [
20+
{
21+
children: [
22+
{ edge_name: 'ctx', node_name: 'Node / ctx' },
23+
{ edge_name: 'cert', node_name: 'Node / cert' },
24+
],
25+
},
26+
]);

0 commit comments

Comments
 (0)