Skip to content

Commit 1cbcb29

Browse files
authored
Merge pull request #1809 from dynst/jasmine-removal-prep
remove some Jasmine specific code from tests
2 parents 56045e7 + 08ba1d6 commit 1cbcb29

29 files changed

+464
-250
lines changed

packages/amino/src/encoding.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ describe("encoding", () => {
8181
});
8282
});
8383

84-
it("works for sr25519", () => {
85-
pending("No test data available");
84+
xit("works for sr25519", () => {
85+
// No test data available
8686
});
8787

8888
it("works for multisig", () => {

packages/crypto/src/libsodium.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,23 @@ describe("Libsodium", () => {
129129
// 8 bytes
130130
await Argon2id.execute(password, fromHex("aabbccddeeff0011"), options)
131131
.then(() => {
132-
fail("Argon2id with invalid salt length must not resolve");
132+
throw new Error("Argon2id with invalid salt length must not resolve");
133133
})
134134
.catch((e) => {
135135
expect(e).toMatch(/invalid salt length/);
136136
});
137137
// 15 bytes
138138
await Argon2id.execute(password, fromHex("aabbccddeeff001122334455667788"), options)
139139
.then(() => {
140-
fail("Argon2id with invalid salt length must not resolve");
140+
throw new Error("Argon2id with invalid salt length must not resolve");
141141
})
142142
.catch((e) => {
143143
expect(e).toMatch(/invalid salt length/);
144144
});
145145
// 17 bytes
146146
await Argon2id.execute(password, fromHex("aabbccddeeff00112233445566778899aa"), options)
147147
.then(() => {
148-
fail("Argon2id with invalid salt length must not resolve");
148+
throw new Error("Argon2id with invalid salt length must not resolve");
149149
})
150150
.catch((e) => {
151151
expect(e).toMatch(/invalid salt length/);
@@ -157,7 +157,7 @@ describe("Libsodium", () => {
157157
options,
158158
)
159159
.then(() => {
160-
fail("Argon2id with invalid salt length must not resolve");
160+
throw new Error("Argon2id with invalid salt length must not resolve");
161161
})
162162
.catch((e) => {
163163
expect(e).toMatch(/invalid salt length/);
@@ -235,7 +235,7 @@ describe("Libsodium", () => {
235235
const seed = fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0");
236236
await Ed25519.makeKeypair(seed)
237237
.then(() => {
238-
fail("promise must not resolve");
238+
throw new Error("promise must not resolve");
239239
})
240240
.catch((error) => {
241241
expect(error.message).toContain("key of length 32 expected");
@@ -247,7 +247,7 @@ describe("Libsodium", () => {
247247
const seed = fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9aa");
248248
await Ed25519.makeKeypair(seed)
249249
.then(() => {
250-
fail("promise must not resolve");
250+
throw new Error("promise must not resolve");
251251
})
252252
.catch((error) => {
253253
expect(error.message).toContain("key of length 32 expected");
@@ -423,7 +423,7 @@ describe("Libsodium", () => {
423423
const key = fromHex("");
424424
await Xchacha20poly1305Ietf.encrypt(message, key, nonce)
425425
.then(() => {
426-
fail("encryption must not succeed");
426+
throw new Error("encryption must not succeed");
427427
})
428428
.catch((error) => {
429429
expect(error).toMatch(/key, got length=0/);
@@ -434,7 +434,7 @@ describe("Libsodium", () => {
434434
const key = fromHex("1324cdddc4b94e625bbabcac862c9429ba011e2184a1ccad60e7c3f6ff4916");
435435
await Xchacha20poly1305Ietf.encrypt(message, key, nonce)
436436
.then(() => {
437-
fail("encryption must not succeed");
437+
throw new Error("encryption must not succeed");
438438
})
439439
.catch((error) => {
440440
expect(error).toMatch(/key, got length=31/);
@@ -445,7 +445,7 @@ describe("Libsodium", () => {
445445
const key = fromHex("1324cdddc4b94e625bbabcac862c9429ba011e2184a1ccad60e7c3f6ff4916d8aa");
446446
await Xchacha20poly1305Ietf.encrypt(message, key, nonce)
447447
.then(() => {
448-
fail("encryption must not succeed");
448+
throw new Error("encryption must not succeed");
449449
})
450450
.catch((error) => {
451451
expect(error).toMatch(/key, got length=33/);
@@ -458,7 +458,7 @@ describe("Libsodium", () => {
458458
);
459459
await Xchacha20poly1305Ietf.encrypt(message, key, nonce)
460460
.then(() => {
461-
fail("encryption must not succeed");
461+
throw new Error("encryption must not succeed");
462462
})
463463
.catch((error) => {
464464
expect(error).toMatch(/key, got length=64/);
@@ -484,7 +484,7 @@ describe("Libsodium", () => {
484484
const corruptedCiphertext = ciphertext.map((x, i) => (i === 0 ? x ^ 0x01 : x));
485485
await Xchacha20poly1305Ietf.decrypt(corruptedCiphertext, key, nonce).then(
486486
() => {
487-
fail("promise must not resolve");
487+
throw new Error("promise must not resolve");
488488
},
489489
(error) => {
490490
expect(error.message).toMatch(/invalid tag/i);
@@ -496,7 +496,7 @@ describe("Libsodium", () => {
496496
const corruptedKey = key.map((x, i) => (i === 0 ? x ^ 0x01 : x));
497497
await Xchacha20poly1305Ietf.decrypt(ciphertext, corruptedKey, nonce).then(
498498
() => {
499-
fail("promise must not resolve");
499+
throw new Error("promise must not resolve");
500500
},
501501
(error) => {
502502
expect(error.message).toMatch(/invalid tag/i);
@@ -508,7 +508,7 @@ describe("Libsodium", () => {
508508
const corruptedNonce = nonce.map((x, i) => (i === 0 ? x ^ 0x01 : x));
509509
await Xchacha20poly1305Ietf.decrypt(ciphertext, key, corruptedNonce).then(
510510
() => {
511-
fail("promise must not resolve");
511+
throw new Error("promise must not resolve");
512512
},
513513
(error) => {
514514
expect(error.message).toMatch(/invalid tag/i);

packages/crypto/src/pbkdf2.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ describe("pbkdf2", () => {
123123
describe("pbkdf2Sha512Subtle", () => {
124124
it("works", async () => {
125125
const subtle = await getSubtle();
126-
if (!subtle) {
127-
pending("Subtle is not available in this environment");
128-
return;
126+
if (subtle === undefined) {
127+
throw new Error("Subtle is not available in this environment");
129128
}
130129

131130
{

packages/crypto/src/secp256k1.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,37 +70,37 @@ describe("Secp256k1", () => {
7070
// too short and too long
7171
await Secp256k1.makeKeypair(fromHex("e4ade2a5232a7c6f37e7b854a774e25e6047ee7c6d63e8304ae04fa190bc17"))
7272
.then(() => {
73-
fail("promise must be rejected");
73+
throw new Error("promise must be rejected");
7474
})
7575
.catch((error) => {
7676
expect(error.message).toContain("not a valid secp256k1 private key");
7777
});
7878
await Secp256k1.makeKeypair(fromHex("e4ade2a5232a7c6f37e7b854a774e25e6047ee7c6d63e8304ae04fa190bc1732aa"))
7979
.then(() => {
80-
fail("promise must be rejected");
80+
throw new Error("promise must be rejected");
8181
})
8282
.catch((error) => {
8383
expect(error.message).toContain("not a valid secp256k1 private key");
8484
});
8585
// value out of range (too small)
8686
await Secp256k1.makeKeypair(fromHex("0000000000000000000000000000000000000000000000000000000000000000"))
8787
.then(() => {
88-
fail("promise must be rejected");
88+
throw new Error("promise must be rejected");
8989
})
9090
.catch((error) => {
9191
expect(error.message).toContain("not a valid secp256k1 private key");
9292
});
9393
// value out of range (>= n)
9494
await Secp256k1.makeKeypair(fromHex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"))
9595
.then(() => {
96-
fail("promise must be rejected");
96+
throw new Error("promise must be rejected");
9797
})
9898
.catch((error) => {
9999
expect(error.message).toContain("not a valid secp256k1 private key");
100100
});
101101
await Secp256k1.makeKeypair(fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"))
102102
.then(() => {
103-
fail("promise must be rejected");
103+
throw new Error("promise must be rejected");
104104
})
105105
.catch((error) => {
106106
expect(error.message).toContain("not a valid secp256k1 private key");
@@ -133,7 +133,7 @@ describe("Secp256k1", () => {
133133
const messageHash = new Uint8Array([]);
134134
await Secp256k1.createSignature(messageHash, keypair.privkey)
135135
.then(() => {
136-
fail("must not resolve");
136+
throw new Error("must not resolve");
137137
})
138138
.catch((error) => {
139139
expect(error).toMatch(/message hash must not be empty/i);
@@ -146,7 +146,7 @@ describe("Secp256k1", () => {
146146
const messageHash = fromHex("11223344556677889900aabbccddeeff11223344556677889900aabbccddeeff11");
147147
await Secp256k1.createSignature(messageHash, keypair.privkey)
148148
.then(() => {
149-
fail("must not resolve");
149+
throw new Error("must not resolve");
150150
})
151151
.catch((error) => {
152152
expect(error).toMatch(/message hash length must not exceed 32 bytes/i);
@@ -202,7 +202,7 @@ describe("Secp256k1", () => {
202202
const messageHash = new Uint8Array([]);
203203
await Secp256k1.verifySignature(dummySignature, messageHash, keypair.pubkey)
204204
.then(() => {
205-
fail("must not resolve");
205+
throw new Error("must not resolve");
206206
})
207207
.catch((error) => {
208208
expect(error).toMatch(/message hash must not be empty/i);
@@ -221,7 +221,7 @@ describe("Secp256k1", () => {
221221
const messageHash = fromHex("11223344556677889900aabbccddeeff11223344556677889900aabbccddeeff11");
222222
await Secp256k1.verifySignature(dummySignature, messageHash, keypair.privkey)
223223
.then(() => {
224-
fail("must not resolve");
224+
throw new Error("must not resolve");
225225
})
226226
.catch((error) => {
227227
expect(error).toMatch(/message hash length must not exceed 32 bytes/i);

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { FaucetClient } from "./faucetclient";
22

3-
function pendingWithoutFaucet(): void {
4-
if (!process.env.FAUCET_ENABLED) {
5-
pending("Set FAUCET_ENABLED to enable tests that need a faucet");
6-
}
7-
}
3+
const enabled = !!globalThis.process?.env.FAUCET_ENABLED;
84

95
describe("FaucetClient", () => {
106
const faucetUrl = "http://localhost:8000";
@@ -25,39 +21,35 @@ describe("FaucetClient", () => {
2521
expect(new FaucetClient("https://localhost/")).toBeTruthy();
2622
});
2723

28-
it("can be used to credit a wallet", async () => {
29-
pendingWithoutFaucet();
24+
(enabled ? it : xit)("can be used to credit a wallet", async () => {
3025
const faucet = new FaucetClient(faucetUrl);
3126
await faucet.credit(defaultAddress, primaryToken);
3227
});
3328

34-
it("can be used to credit a wallet with a different token", async () => {
35-
pendingWithoutFaucet();
29+
(enabled ? it : xit)("can be used to credit a wallet with a different token", async () => {
3630
const faucet = new FaucetClient(faucetUrl);
3731
await faucet.credit(defaultAddress, secondaryToken);
3832
});
3933

40-
it("throws for invalid ticker", async () => {
41-
pendingWithoutFaucet();
34+
(enabled ? it : xit)("throws for invalid ticker", async () => {
4235
const faucet = new FaucetClient(faucetUrl);
4336
await faucet.credit(defaultAddress, "ETH").then(
4437
() => {
45-
fail("must not resolve");
38+
throw new Error("must not resolve");
4639
},
4740
(error) => {
4841
expect(error).toMatch(/token is not available/i);
4942
},
5043
);
5144
});
5245

53-
it("throws for invalid address", async () => {
54-
pendingWithoutFaucet();
46+
(enabled ? it : xit)("throws for invalid address", async () => {
5547
const faucet = new FaucetClient(faucetUrl);
5648

5749
for (const address of ["be5cc2cc05db2cdb4313c18306a5157291cfdcd1", "1234L"]) {
5850
await faucet.credit(address, primaryToken).then(
5951
() => {
60-
fail("must not resolve");
52+
throw new Error("must not resolve");
6153
},
6254
(error) => {
6355
expect(error).toMatch(/address is not in the expected format for this chain/i);

packages/faucet/src/faucet.spec.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ import { assert } from "@cosmjs/utils";
66
import { Faucet } from "./faucet";
77
import { TokenConfiguration } from "./tokenmanager";
88

9-
function pendingWithoutSimapp(): void {
10-
if (!process.env.SIMAPP47_ENABLED && !process.env.SIMAPP50_ENABLED) {
11-
pending("Set SIMAPP{47,50}_ENABLED to enabled Stargate node-based tests");
12-
return;
13-
}
14-
}
9+
const enabled = !!(globalThis.process?.env.SIMAPP47_ENABLED || globalThis.process?.env.SIMAPP50_ENABLED);
1510

1611
const defaultTokenConfig: TokenConfiguration = {
1712
bankTokens: ["ucosm", "ustake"],
@@ -25,7 +20,7 @@ function makeRandomAddress(): string {
2520
const faucetMnemonic =
2621
"economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone";
2722

28-
describe("Faucet", () => {
23+
(enabled ? describe : xdescribe)("Faucet", () => {
2924
const pathBuilder = makeCosmoshubPath;
3025

3126
const apiUrl = "http://localhost:26658";
@@ -44,7 +39,6 @@ describe("Faucet", () => {
4439
describe("stargate", () => {
4540
describe("constructor", () => {
4641
it("can be constructed", async () => {
47-
pendingWithoutSimapp();
4842
const faucet = await Faucet.make(
4943
apiUrl,
5044
defaultAddressPrefix,
@@ -60,7 +54,6 @@ describe("Faucet", () => {
6054

6155
describe("availableTokens", () => {
6256
it("is empty when no tokens are configured", async () => {
63-
pendingWithoutSimapp();
6457
const faucet = await Faucet.make(
6558
apiUrl,
6659
defaultAddressPrefix,
@@ -75,7 +68,6 @@ describe("Faucet", () => {
7568
});
7669

7770
it("is not empty with default token config", async () => {
78-
pendingWithoutSimapp();
7971
const faucet = await Faucet.make(
8072
apiUrl,
8173
defaultAddressPrefix,
@@ -92,7 +84,6 @@ describe("Faucet", () => {
9284

9385
describe("send", () => {
9486
it("can send bank token", async () => {
95-
pendingWithoutSimapp();
9687
const faucet = await Faucet.make(
9788
apiUrl,
9889
defaultAddressPrefix,
@@ -126,7 +117,6 @@ describe("Faucet", () => {
126117

127118
describe("refill", () => {
128119
it("works", async () => {
129-
pendingWithoutSimapp();
130120
const faucet = await Faucet.make(
131121
apiUrl,
132122
defaultAddressPrefix,
@@ -155,7 +145,6 @@ describe("Faucet", () => {
155145

156146
describe("credit", () => {
157147
it("works for fee token", async () => {
158-
pendingWithoutSimapp();
159148
const faucet = await Faucet.make(
160149
apiUrl,
161150
defaultAddressPrefix,
@@ -180,7 +169,6 @@ describe("Faucet", () => {
180169
});
181170

182171
it("works for stake token", async () => {
183-
pendingWithoutSimapp();
184172
const faucet = await Faucet.make(
185173
apiUrl,
186174
defaultAddressPrefix,
@@ -207,7 +195,6 @@ describe("Faucet", () => {
207195

208196
describe("configuredTokens", () => {
209197
it("works", async () => {
210-
pendingWithoutSimapp();
211198
const faucet = await Faucet.make(
212199
apiUrl,
213200
defaultAddressPrefix,
@@ -224,7 +211,6 @@ describe("Faucet", () => {
224211

225212
describe("loadAccounts", () => {
226213
it("works", async () => {
227-
pendingWithoutSimapp();
228214
const faucet = await Faucet.make(
229215
apiUrl,
230216
defaultAddressPrefix,

0 commit comments

Comments
 (0)