Skip to content

Commit

Permalink
chore: deflake unit_node/crypto/crypto_key_test.ts (#21331)
Browse files Browse the repository at this point in the history
Ref #21187

On CI we are going to run only fast tests, with an option to
pass `SLOW_TESTS=1` env var to enable more comprehensive tests.
  • Loading branch information
bartlomieju authored Nov 24, 2023
1 parent 57dc427 commit 998d906
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cli/tests/unit_node/crypto/crypto_key_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
} from "../../../../test_util/std/testing/asserts.ts";
import { createHmac } from "node:crypto";

const RUN_SLOW_TESTS = Deno.env.get("SLOW_TESTS") === "1";

const generateKeyPairAsync = promisify(
(
type: any,
Expand Down Expand Up @@ -77,10 +79,12 @@ Deno.test({
},
});

const modulusLengths = RUN_SLOW_TESTS ? [2048, 3072] : [2048];

for (const type of ["rsa", "rsa-pss", "dsa"]) {
for (const modulusLength of [2048, 3072]) {
for (const modulusLength of modulusLengths) {
Deno.test({
name: `generate ${type} key`,
name: `generate ${type} key ${modulusLength}`,
fn() {
const { publicKey, privateKey } = generateKeyPairSync(type as any, {
modulusLength,
Expand All @@ -92,7 +96,7 @@ for (const type of ["rsa", "rsa-pss", "dsa"]) {
});

Deno.test({
name: `generate ${type} key async`,
name: `generate ${type} key async ${modulusLength}`,
async fn() {
const x = await generateKeyPairAsync(type as any, {
modulusLength,
Expand Down Expand Up @@ -174,7 +178,9 @@ for (
});
}

for (const primeLength of [1024, 2048, 4096]) {
const primeLengths = RUN_SLOW_TESTS ? [1024, 2048, 4096] : [1024];

for (const primeLength of primeLengths) {
Deno.test({
name: `generate dh key ${primeLength}`,
fn() {
Expand Down

0 comments on commit 998d906

Please sign in to comment.