11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciif (!common.hasCrypto) 41cb0ef41Sopenharmony_ci common.skip('missing crypto'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads'); 81cb0ef41Sopenharmony_ciconst fixturesPath = require.resolve('../common/fixtures'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci// Test that transferring the result of e.g. crypto.sign() from Worker to parent 111cb0ef41Sopenharmony_ci// thread does not crash 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciconst w = new Worker(` 141cb0ef41Sopenharmony_ciconst { parentPort } = require('worker_threads'); 151cb0ef41Sopenharmony_ciconst crypto = require('crypto'); 161cb0ef41Sopenharmony_ciconst assert = require('assert'); 171cb0ef41Sopenharmony_ciconst fixtures = require(${JSON.stringify(fixturesPath)}); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ciconst keyPem = fixtures.readKey('rsa_private.pem'); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciconst buf = crypto.sign('sha256', Buffer.from('hello'), keyPem); 221cb0ef41Sopenharmony_ciassert.notStrictEqual(buf.byteLength, 0); 231cb0ef41Sopenharmony_ciparentPort.postMessage(buf, [buf.buffer]); 241cb0ef41Sopenharmony_ciassert.strictEqual(buf.byteLength, 0); 251cb0ef41Sopenharmony_ci`, { eval: true }); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ciw.on('message', common.mustCall((buf) => { 281cb0ef41Sopenharmony_ci assert.notStrictEqual(buf.byteLength, 0); 291cb0ef41Sopenharmony_ci})); 301cb0ef41Sopenharmony_ciw.on('exit', common.mustCall()); 31