Skip to content

Commit 2431e57

Browse files
committed
chore: fix assertions make crypto configurable
1 parent 7ee0391 commit 2431e57

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/benchmarks/bench.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const ERROR = 0;
1515

1616
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
1717

18-
const { CRYPT_SHARED_LIB_PATH: cryptSharedLibPath = '' } = process.env;
18+
const { CRYPT_SHARED_LIB_PATH: cryptSharedLibPath = '', BENCH_WITH_NATIVE_CRYPTO = '' } =
19+
process.env;
1920

2021
const warmupSecs = 2;
2122
const testInSecs = 57;
@@ -57,9 +58,9 @@ function createEncryptedDocument(mongoCrypt) {
5758
ctx.finishMongoOperation();
5859
}
5960

60-
console.assert(ctx.state === READY);
61+
if (ctx.state !== READY) throw new Error(`not ready: [${ctx.state}] ${ctx.status.message}`);
6162
const result = ctx.finalize();
62-
console.assert(ctx.state !== ERROR);
63+
if (ctx.state === ERROR) throw new Error(`error: [${ctx.state}] ${ctx.status.message}`);
6364
const { v: encryptedValue } = BSON.deserialize(result);
6465
encrypted[key] = encryptedValue;
6566
}
@@ -120,7 +121,8 @@ function main() {
120121
`testInSecs=${testInSecs}`
121122
);
122123

123-
const mongoCryptOptions = { kmsProviders: BSON.serialize(kmsProviders), cryptoCallbacks };
124+
const mongoCryptOptions = { kmsProviders: BSON.serialize(kmsProviders) };
125+
if (!BENCH_WITH_NATIVE_CRYPTO) mongoCryptOptions.cryptoCallbacks = cryptoCallbacks;
124126
if (cryptSharedLibPath) mongoCryptOptions.cryptSharedLibPath = cryptSharedLibPath;
125127

126128
const mongoCrypt = new MongoCrypt(mongoCryptOptions);

0 commit comments

Comments
 (0)