Skip to content

Commit 7325e10

Browse files
committed
Use sleep for scream test
1 parent 39e712a commit 7325e10

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/amino/src/wallet.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Xchacha20poly1305Ietf,
77
} from "@cosmjs/crypto";
88
import { toAscii } from "@cosmjs/encoding";
9+
import { sleep } from "@cosmjs/utils";
910

1011
/**
1112
* A fixed salt is chosen to archive a deterministic password to key derivation.
@@ -34,7 +35,7 @@ export async function executeKdf(password: string, configuration: KdfConfigurati
3435

3536
// Emulate a slower implementation. The fast WASM code may get removed.
3637
// This approximates the speed of using a pure JS implementation (@noble/hashes) in Node 22.
37-
const screamTest = new Promise((resolve) => setTimeout(resolve, options.opsLimit * 250));
38+
const screamTest = sleep(options.opsLimit * 250);
3839
const result = await Argon2id.execute(password, cosmjsSalt, options);
3940
await screamTest;
4041
return result;

packages/proto-signing/src/wallet.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Xchacha20poly1305Ietf,
77
} from "@cosmjs/crypto";
88
import { toAscii } from "@cosmjs/encoding";
9+
import { sleep } from "@cosmjs/utils";
910

1011
/**
1112
* A fixed salt is chosen to archive a deterministic password to key derivation.
@@ -31,7 +32,7 @@ export async function executeKdf(password: string, configuration: KdfConfigurati
3132

3233
// Emulate a slower implementation. The fast WASM code may get removed.
3334
// This approximates the speed of using a pure JS implementation (@noble/hashes) in Node 22.
34-
const screamTest = new Promise((resolve) => setTimeout(resolve, options.opsLimit * 250));
35+
const screamTest = sleep(options.opsLimit * 250);
3536
const result = await Argon2id.execute(password, cosmjsSalt, options);
3637
await screamTest;
3738
return result;

0 commit comments

Comments
 (0)