Skip to content

Commit

Permalink
src: test and code review updates [squash]
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed Jul 10, 2024
1 parent afdabb7 commit 4e9f18d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions deps/ncrypto/ncrypto.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "ncrypto.h"
#include <algorithm>
#include <cstring>
#include "openssl/bn.h"
#if OPENSSL_VERSION_MAJOR >= 3
#include "openssl/provider.h"
Expand Down
16 changes: 6 additions & 10 deletions src/crypto/crypto_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ bool CryptoErrorStore::Empty() const {
return errors_.empty();
}

v8::MaybeLocal<v8::Value> cryptoErrorListToException(
MaybeLocal<Value> cryptoErrorListToException(
Environment* env, const ncrypto::CryptoErrorList& errors) {
// The CryptoErrorList contains a listing of zero or more errors.
// If there are no errors, it is likely a bug but we will return
Expand All @@ -261,7 +261,7 @@ v8::MaybeLocal<v8::Value> cryptoErrorListToException(
if (!String::NewFromUtf8(
env->isolate(), last.data(), NewStringType::kNormal, last.size())
.ToLocal(&message)) {
return MaybeLocal<Value>();
return {};
}

Local<Value> exception = Exception::Error(message);
Expand All @@ -277,13 +277,9 @@ v8::MaybeLocal<v8::Value> cryptoErrorListToException(
auto last = errors.end();
last--;
while (current != last) {
Local<String> error;
if (!String::NewFromUtf8(env->isolate(),
current->data(),
NewStringType::kNormal,
current->size())
.ToLocal(&error)) {
return MaybeLocal<Value>();
Local<Value> error;
if (!ToV8Value(env->context(), *current).ToLocal(&error)) {
return {};
}
stack.push_back(error);
++current;
Expand All @@ -295,7 +291,7 @@ v8::MaybeLocal<v8::Value> cryptoErrorListToException(
if (!exception_obj
->Set(env->context(), env->openssl_error_stack(), stackArray)
.IsNothing()) {
return MaybeLocal<Value>();
return {};
}
}
return exception;
Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-process-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const expected_keys = [
'ada',
'cjs_module_lexer',
'nbytes',
'ncrypto',
];

const hasUndici = process.config.variables.node_builtin_shareable_builtins.includes('deps/undici/undici.js');
Expand Down Expand Up @@ -64,6 +65,7 @@ assert.match(process.versions.llhttp, commonTemplate);
assert.match(process.versions.node, commonTemplate);
assert.match(process.versions.uv, commonTemplate);
assert.match(process.versions.nbytes, commonTemplate);
assert.match(process.versions.ncrypto, commonTemplate);
assert.match(process.versions.zlib, /^\d+(?:\.\d+){1,3}(?:-.*)?$/);

if (hasUndici) {
Expand Down

0 comments on commit 4e9f18d

Please sign in to comment.