Skip to content

Commit

Permalink
chore: fix assertions make crypto configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Jun 13, 2024
1 parent 7ee0391 commit 2431e57
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/benchmarks/bench.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const ERROR = 0;

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

const { CRYPT_SHARED_LIB_PATH: cryptSharedLibPath = '' } = process.env;
const { CRYPT_SHARED_LIB_PATH: cryptSharedLibPath = '', BENCH_WITH_NATIVE_CRYPTO = '' } =
process.env;

const warmupSecs = 2;
const testInSecs = 57;
Expand Down Expand Up @@ -57,9 +58,9 @@ function createEncryptedDocument(mongoCrypt) {
ctx.finishMongoOperation();
}

console.assert(ctx.state === READY);
if (ctx.state !== READY) throw new Error(`not ready: [${ctx.state}] ${ctx.status.message}`);
const result = ctx.finalize();
console.assert(ctx.state !== ERROR);
if (ctx.state === ERROR) throw new Error(`error: [${ctx.state}] ${ctx.status.message}`);
const { v: encryptedValue } = BSON.deserialize(result);
encrypted[key] = encryptedValue;
}
Expand Down Expand Up @@ -120,7 +121,8 @@ function main() {
`testInSecs=${testInSecs}`
);

const mongoCryptOptions = { kmsProviders: BSON.serialize(kmsProviders), cryptoCallbacks };
const mongoCryptOptions = { kmsProviders: BSON.serialize(kmsProviders) };
if (!BENCH_WITH_NATIVE_CRYPTO) mongoCryptOptions.cryptoCallbacks = cryptoCallbacks;
if (cryptSharedLibPath) mongoCryptOptions.cryptSharedLibPath = cryptSharedLibPath;

const mongoCrypt = new MongoCrypt(mongoCryptOptions);
Expand Down

0 comments on commit 2431e57

Please sign in to comment.