Skip to content

Commit 2cdf157

Browse files
committed
s/expectAsync/expect/
1 parent 6e60859 commit 2cdf157

File tree

19 files changed

+86
-93
lines changed

19 files changed

+86
-93
lines changed

packages/cosmwasm-stargate/src/cosmwasmclient.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ interface HackatomInstance {
109109
it("rejects for missing accounts", async () => {
110110
const client = await CosmWasmClient.connect(wasmd.endpoint);
111111
const missing = makeRandomAddress();
112-
await expectAsync(client.getSequence(missing)).toBeRejectedWithError(
112+
await expect(client.getSequence(missing)).rejects.toThrowError(
113113
/account '([a-z0-9]{10,90})' does not exist on chain/i,
114114
);
115115
});
@@ -375,7 +375,7 @@ interface HackatomInstance {
375375

376376
const nonExistentAddress = makeRandomAddress();
377377
const client = await CosmWasmClient.connect(wasmd.endpoint);
378-
await expectAsync(client.queryContractRaw(nonExistentAddress, configKey)).toBeRejectedWithError(
378+
await expect(client.queryContractRaw(nonExistentAddress, configKey)).rejects.toThrowError(
379379
/no such contract/i,
380380
);
381381
});
@@ -422,17 +422,17 @@ interface HackatomInstance {
422422
assert(contract);
423423

424424
const client = await CosmWasmClient.connect(wasmd.endpoint);
425-
await expectAsync(client.queryContractSmart(contract.address, { broken: {} })).toBeRejectedWithError(
425+
await expect(client.queryContractSmart(contract.address, { broken: {} })).rejects.toThrowError(
426426
/Error parsing into type hackatom::msg::QueryMsg: unknown variant/i,
427427
);
428428
});
429429

430430
it("errors for non-existent contract", async () => {
431431
const nonExistentAddress = makeRandomAddress();
432432
const client = await CosmWasmClient.connect(wasmd.endpoint);
433-
await expectAsync(
434-
client.queryContractSmart(nonExistentAddress, { verifier: {} }),
435-
).toBeRejectedWithError(/no such contract/i);
433+
await expect(client.queryContractSmart(nonExistentAddress, { verifier: {} })).rejects.toThrowError(
434+
/no such contract/i,
435+
);
436436
});
437437
});
438438
});

packages/cosmwasm-stargate/src/modules/wasm/queries.spec.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,7 @@ async function executeContract(
226226
assert(hackatomCodeId);
227227
const client = await makeWasmClient(wasmd.endpoint);
228228
const nonExistentAddress = makeRandomAddress();
229-
await expectAsync(client.wasm.getContractInfo(nonExistentAddress)).toBeRejectedWithError(
230-
/no such contract/i,
231-
);
229+
await expect(client.wasm.getContractInfo(nonExistentAddress)).rejects.toThrowError(/no such contract/i);
232230
});
233231
});
234232

@@ -291,7 +289,7 @@ async function executeContract(
291289
it("rejects for non-existent address", async () => {
292290
const client = await makeWasmClient(wasmd.endpoint);
293291
const nonExistentAddress = makeRandomAddress();
294-
await expectAsync(client.wasm.getAllContractState(nonExistentAddress)).toBeRejectedWithError(
292+
await expect(client.wasm.getAllContractState(nonExistentAddress)).rejects.toThrowError(
295293
/no such contract/i,
296294
);
297295
});
@@ -318,9 +316,9 @@ async function executeContract(
318316
it("returns null for non-existent address", async () => {
319317
const client = await makeWasmClient(wasmd.endpoint);
320318
const nonExistentAddress = makeRandomAddress();
321-
await expectAsync(
322-
client.wasm.queryContractRaw(nonExistentAddress, hackatomConfigKey),
323-
).toBeRejectedWithError(/no such contract/i);
319+
await expect(client.wasm.queryContractRaw(nonExistentAddress, hackatomConfigKey)).rejects.toThrowError(
320+
/no such contract/i,
321+
);
324322
});
325323
});
326324

@@ -337,16 +335,16 @@ async function executeContract(
337335
assert(hackatomContractAddress);
338336
const client = await makeWasmClient(wasmd.endpoint);
339337
const request = { nosuchkey: {} };
340-
await expectAsync(
341-
client.wasm.queryContractSmart(hackatomContractAddress, request),
342-
).toBeRejectedWithError(/Error parsing into type hackatom::msg::QueryMsg: unknown variant/i);
338+
await expect(client.wasm.queryContractSmart(hackatomContractAddress, request)).rejects.toThrowError(
339+
/Error parsing into type hackatom::msg::QueryMsg: unknown variant/i,
340+
);
343341
});
344342

345343
it("throws for non-existent address", async () => {
346344
const client = await makeWasmClient(wasmd.endpoint);
347345
const nonExistentAddress = makeRandomAddress();
348346
const request = { verifier: {} };
349-
await expectAsync(client.wasm.queryContractSmart(nonExistentAddress, request)).toBeRejectedWithError(
347+
await expect(client.wasm.queryContractSmart(nonExistentAddress, request)).rejects.toThrowError(
350348
/no such contract/i,
351349
);
352350
});

packages/cosmwasm-stargate/src/signingcosmwasmclient.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,9 +1339,7 @@ import {
13391339
const height = await client.getHeight();
13401340
const signed = await client.sign(alice.address0, [msgAny], fee, memo, undefined, BigInt(height - 1));
13411341

1342-
await expectAsync(
1343-
client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())),
1344-
).toBeRejectedWith(
1342+
await expect(client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish()))).rejects.toThrowError(
13451343
jasmine.objectContaining({
13461344
code: 30,
13471345
}),
@@ -1615,9 +1613,7 @@ import {
16151613
const height = await client.getHeight();
16161614
const signed = await client.sign(alice.address0, [msgAny], fee, memo, undefined, BigInt(height - 1));
16171615

1618-
await expectAsync(
1619-
client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())),
1620-
).toBeRejectedWith(
1616+
await expect(client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish()))).rejects.toThrowError(
16211617
jasmine.objectContaining({
16221618
code: 30,
16231619
}),

packages/crypto/src/libsodium.spec.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -127,25 +127,25 @@ describe("Libsodium", () => {
127127
};
128128

129129
// 8 bytes
130-
await expectAsync(
131-
Argon2id.execute(password, fromHex("aabbccddeeff0011"), options),
132-
).toBeRejectedWithError(/invalid salt length/);
130+
await expect(Argon2id.execute(password, fromHex("aabbccddeeff0011"), options)).rejects.toThrowError(
131+
/invalid salt length/,
132+
);
133133
// 15 bytes
134-
await expectAsync(
134+
await expect(
135135
Argon2id.execute(password, fromHex("aabbccddeeff001122334455667788"), options),
136-
).toBeRejectedWithError(/invalid salt length/);
136+
).rejects.toThrowError(/invalid salt length/);
137137
// 17 bytes
138-
await expectAsync(
138+
await expect(
139139
Argon2id.execute(password, fromHex("aabbccddeeff00112233445566778899aa"), options),
140-
).toBeRejectedWithError(/invalid salt length/);
140+
).rejects.toThrowError(/invalid salt length/);
141141
// 32 bytes
142-
await expectAsync(
142+
await expect(
143143
Argon2id.execute(
144144
password,
145145
fromHex("aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899"),
146146
options,
147147
),
148-
).toBeRejectedWithError(/invalid salt length/);
148+
).rejects.toThrowError(/invalid salt length/);
149149
});
150150
});
151151

@@ -217,13 +217,13 @@ describe("Libsodium", () => {
217217
{
218218
// seed too short
219219
const seed = fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0");
220-
await expectAsync(Ed25519.makeKeypair(seed)).toBeRejectedWithError(/key of length 32 expected/);
220+
await expect(Ed25519.makeKeypair(seed)).rejects.toThrowError(/key of length 32 expected/);
221221
}
222222

223223
{
224224
// seed too long
225225
const seed = fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9aa");
226-
await expectAsync(Ed25519.makeKeypair(seed)).toBeRejectedWithError(/key of length 32 expected/);
226+
await expect(Ed25519.makeKeypair(seed)).rejects.toThrowError(/key of length 32 expected/);
227227
}
228228
});
229229

@@ -393,21 +393,21 @@ describe("Libsodium", () => {
393393
{
394394
// empty
395395
const key = fromHex("");
396-
await expectAsync(Xchacha20poly1305Ietf.encrypt(message, key, nonce)).toBeRejectedWithError(
396+
await expect(Xchacha20poly1305Ietf.encrypt(message, key, nonce)).rejects.toThrowError(
397397
/key, got length=0/,
398398
);
399399
}
400400
{
401401
// 31 bytes
402402
const key = fromHex("1324cdddc4b94e625bbabcac862c9429ba011e2184a1ccad60e7c3f6ff4916");
403-
await expectAsync(Xchacha20poly1305Ietf.encrypt(message, key, nonce)).toBeRejectedWithError(
403+
await expect(Xchacha20poly1305Ietf.encrypt(message, key, nonce)).rejects.toThrowError(
404404
/key, got length=31/,
405405
);
406406
}
407407
{
408408
// 33 bytes
409409
const key = fromHex("1324cdddc4b94e625bbabcac862c9429ba011e2184a1ccad60e7c3f6ff4916d8aa");
410-
await expectAsync(Xchacha20poly1305Ietf.encrypt(message, key, nonce)).toBeRejectedWithError(
410+
await expect(Xchacha20poly1305Ietf.encrypt(message, key, nonce)).rejects.toThrowError(
411411
/key, got length=33/,
412412
);
413413
}
@@ -416,7 +416,7 @@ describe("Libsodium", () => {
416416
const key = fromHex(
417417
"1324cdddc4b94e625bbabcac862c9429ba011e2184a1ccad60e7c3f6ff4916d81324cdddc4b94e625bbabcac862c9429ba011e2184a1ccad60e7c3f6ff4916d8",
418418
);
419-
await expectAsync(Xchacha20poly1305Ietf.encrypt(message, key, nonce)).toBeRejectedWithError(
419+
await expect(Xchacha20poly1305Ietf.encrypt(message, key, nonce)).rejects.toThrowError(
420420
/key, got length=64/,
421421
);
422422
}
@@ -438,23 +438,23 @@ describe("Libsodium", () => {
438438
{
439439
// corrupted ciphertext
440440
const corruptedCiphertext = ciphertext.map((x, i) => (i === 0 ? x ^ 0x01 : x));
441-
await expectAsync(
442-
Xchacha20poly1305Ietf.decrypt(corruptedCiphertext, key, nonce),
443-
).toBeRejectedWithError(/invalid tag/i);
441+
await expect(Xchacha20poly1305Ietf.decrypt(corruptedCiphertext, key, nonce)).rejects.toThrowError(
442+
/invalid tag/i,
443+
);
444444
}
445445
{
446446
// corrupted key
447447
const corruptedKey = key.map((x, i) => (i === 0 ? x ^ 0x01 : x));
448-
await expectAsync(
449-
Xchacha20poly1305Ietf.decrypt(ciphertext, corruptedKey, nonce),
450-
).toBeRejectedWithError(/invalid tag/i);
448+
await expect(Xchacha20poly1305Ietf.decrypt(ciphertext, corruptedKey, nonce)).rejects.toThrowError(
449+
/invalid tag/i,
450+
);
451451
}
452452
{
453453
// corrupted nonce
454454
const corruptedNonce = nonce.map((x, i) => (i === 0 ? x ^ 0x01 : x));
455-
await expectAsync(
456-
Xchacha20poly1305Ietf.decrypt(ciphertext, key, corruptedNonce),
457-
).toBeRejectedWithError(/invalid tag/i);
455+
await expect(Xchacha20poly1305Ietf.decrypt(ciphertext, key, corruptedNonce)).rejects.toThrowError(
456+
/invalid tag/i,
457+
);
458458
}
459459
});
460460

packages/crypto/src/secp256k1.spec.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,23 @@ describe("Secp256k1", () => {
6868
).toBeTruthy();
6969

7070
// too short and too long
71-
await expectAsync(
71+
await expect(
7272
Secp256k1.makeKeypair(fromHex("e4ade2a5232a7c6f37e7b854a774e25e6047ee7c6d63e8304ae04fa190bc17")),
73-
).toBeRejectedWithError("input data is not a valid secp256k1 private key");
74-
await expectAsync(
73+
).rejects.toThrowError("input data is not a valid secp256k1 private key");
74+
await expect(
7575
Secp256k1.makeKeypair(fromHex("e4ade2a5232a7c6f37e7b854a774e25e6047ee7c6d63e8304ae04fa190bc1732aa")),
76-
).toBeRejectedWithError("input data is not a valid secp256k1 private key");
76+
).rejects.toThrowError("input data is not a valid secp256k1 private key");
7777
// value out of range (too small)
78-
await expectAsync(
78+
await expect(
7979
Secp256k1.makeKeypair(fromHex("0000000000000000000000000000000000000000000000000000000000000000")),
80-
).toBeRejectedWithError("input data is not a valid secp256k1 private key");
80+
).rejects.toThrowError("input data is not a valid secp256k1 private key");
8181
// value out of range (>= n)
82-
await expectAsync(
82+
await expect(
8383
Secp256k1.makeKeypair(fromHex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),
84-
).toBeRejectedWithError("input data is not a valid secp256k1 private key");
85-
await expectAsync(
84+
).rejects.toThrowError("input data is not a valid secp256k1 private key");
85+
await expect(
8686
Secp256k1.makeKeypair(fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141")),
87-
).toBeRejectedWithError("input data is not a valid secp256k1 private key");
87+
).rejects.toThrowError("input data is not a valid secp256k1 private key");
8888
});
8989

9090
it("creates signatures", async () => {
@@ -111,7 +111,7 @@ describe("Secp256k1", () => {
111111
const privkey = fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9");
112112
const keypair = await Secp256k1.makeKeypair(privkey);
113113
const messageHash = new Uint8Array([]);
114-
await expectAsync(Secp256k1.createSignature(messageHash, keypair.privkey)).toBeRejectedWithError(
114+
await expect(Secp256k1.createSignature(messageHash, keypair.privkey)).rejects.toThrowError(
115115
/message hash must not be empty/i,
116116
);
117117
});
@@ -120,7 +120,7 @@ describe("Secp256k1", () => {
120120
const privkey = fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9");
121121
const keypair = await Secp256k1.makeKeypair(privkey);
122122
const messageHash = fromHex("11223344556677889900aabbccddeeff11223344556677889900aabbccddeeff11");
123-
await expectAsync(Secp256k1.createSignature(messageHash, keypair.privkey)).toBeRejectedWithError(
123+
await expect(Secp256k1.createSignature(messageHash, keypair.privkey)).rejects.toThrowError(
124124
/message hash length must not exceed 32 bytes/i,
125125
);
126126
});
@@ -172,9 +172,9 @@ describe("Secp256k1", () => {
172172
fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9"),
173173
);
174174
const messageHash = new Uint8Array([]);
175-
await expectAsync(
176-
Secp256k1.verifySignature(dummySignature, messageHash, keypair.pubkey),
177-
).toBeRejectedWithError(/message hash must not be empty/i);
175+
await expect(Secp256k1.verifySignature(dummySignature, messageHash, keypair.pubkey)).rejects.toThrowError(
176+
/message hash must not be empty/i,
177+
);
178178
});
179179

180180
it("throws for message hash longer than 32 bytes in verification", async () => {
@@ -187,9 +187,9 @@ describe("Secp256k1", () => {
187187
fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9"),
188188
);
189189
const messageHash = fromHex("11223344556677889900aabbccddeeff11223344556677889900aabbccddeeff11");
190-
await expectAsync(
190+
await expect(
191191
Secp256k1.verifySignature(dummySignature, messageHash, keypair.privkey),
192-
).toBeRejectedWithError(/message hash length must not exceed 32 bytes/i);
192+
).rejects.toThrowError(/message hash length must not exceed 32 bytes/i);
193193
});
194194

195195
it("verifies unnormalized pyca/cryptography signatures", async () => {

packages/faucet-client/src/faucetclient.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ describe("FaucetClient", () => {
3939

4040
(enabled ? it : it.skip)("throws for invalid ticker", async () => {
4141
const faucet = new FaucetClient(faucetUrl);
42-
await expectAsync(faucet.credit(defaultAddress, "ETH")).toBeRejectedWithError(/token is not available/i);
42+
await expect(faucet.credit(defaultAddress, "ETH")).rejects.toThrowError(/token is not available/i);
4343
});
4444

4545
(enabled ? it : it.skip)("throws for invalid address", async () => {
4646
const faucet = new FaucetClient(faucetUrl);
4747

4848
for (const address of ["be5cc2cc05db2cdb4313c18306a5157291cfdcd1", "1234L"]) {
49-
await expectAsync(faucet.credit(address, primaryToken)).toBeRejectedWithError(
49+
await expect(faucet.credit(address, primaryToken)).rejects.toThrowError(
5050
/address is not in the expected format for this chain/i,
5151
);
5252
}

packages/socket/src/socketwrapper.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const enabled = !!globalThis.process?.env.SOCKETSERVER_ENABLED;
147147
);
148148
socket.connect();
149149

150-
await expectAsync(socket.connected).toBeRejectedWithError(/connection attempt timed out/i);
150+
await expect(socket.connected).rejects.toThrowError(/connection attempt timed out/i);
151151
});
152152

153153
it("can connect and disconnect", async () => {
@@ -338,7 +338,7 @@ const enabled = !!globalThis.process?.env.SOCKETSERVER_ENABLED;
338338
socket.disconnect();
339339
},
340340
() => {
341-
done(expectAsync(socket.send("la li lu")).toBeRejectedWithError(/socket was closed/i));
341+
done(expect(socket.send("la li lu")).rejects.toThrowError(/socket was closed/i));
342342
},
343343
);
344344
socket.connect();

packages/socket/src/streamingsocket.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const enabled = !!globalThis.process?.env.SOCKETSERVER_ENABLED;
3333
const socket = new StreamingSocket(socketServerUrlSlow, 2_000);
3434
socket.connect();
3535

36-
await expectAsync(socket.connected).toBeRejectedWithError(/connection attempt timed out/i);
36+
await expect(socket.connected).rejects.toThrowError(/connection attempt timed out/i);
3737
});
3838

3939
it("can send events when connected", async () => {

packages/stargate/src/modules/auth/queries.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async function makeClientWithAuth(rpcUrl: string): Promise<[QueryClient & AuthEx
5151
it("rejects for non-existent address", async () => {
5252
const [client, cometClient] = await makeClientWithAuth(simapp.tendermintUrlHttp);
5353

54-
await expectAsync(client.auth.account(nonExistentAddress)).toBeRejectedWithError(
54+
await expect(client.auth.account(nonExistentAddress)).rejects.toThrowError(
5555
/account cosmos1p79apjaufyphcmsn4g07cynqf0wyjuezqu84hd not found/i,
5656
);
5757

packages/stargate/src/modules/bank/queries.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ async function makeClientWithBank(rpcUrl: string): Promise<[QueryClient & BankEx
167167
it("works for non-existent denom", async () => {
168168
const [client, cometClient] = await makeClientWithBank(simapp.tendermintUrlHttp);
169169

170-
await expectAsync(client.bank.denomMetadata("nothere")).toBeRejectedWithError(/code = NotFound/i);
170+
await expect(client.bank.denomMetadata("nothere")).rejects.toThrowError(/code = NotFound/i);
171171

172172
cometClient.disconnect();
173173
});

0 commit comments

Comments
 (0)