|
| 1 | +/* eslint-disable @typescript-eslint/await-thenable */ // secp is sync in node, async in browsers |
1 | 2 | /* eslint-env mocha */
|
2 | 3 | import { expect } from 'aegir/chai'
|
3 | 4 | import { Uint8ArrayList } from 'uint8arraylist'
|
@@ -48,13 +49,13 @@ describe('secp256k1 keys', () => {
|
48 | 49 | )
|
49 | 50 | const sig = await key.sign(text)
|
50 | 51 |
|
51 |
| - await expect(key.sign(text.subarray())) |
52 |
| - .to.eventually.deep.equal(sig, 'list did not have same signature as a single buffer') |
| 52 | + expect(await key.sign(text.subarray())) |
| 53 | + .to.deep.equal(sig, 'list did not have same signature as a single buffer') |
53 | 54 |
|
54 |
| - await expect(key.public.verify(text, sig)) |
55 |
| - .to.eventually.be.true('did not verify message as list') |
56 |
| - await expect(key.public.verify(text.subarray(), sig)) |
57 |
| - .to.eventually.be.true('did not verify message as single buffer') |
| 55 | + expect(await key.public.verify(text, sig)) |
| 56 | + .to.be.true('did not verify message as list') |
| 57 | + expect(await key.public.verify(text.subarray(), sig)) |
| 58 | + .to.be.true('did not verify message as single buffer') |
58 | 59 | })
|
59 | 60 |
|
60 | 61 | it('encoding', () => {
|
@@ -169,19 +170,25 @@ describe('crypto functions', () => {
|
169 | 170 | })
|
170 | 171 |
|
171 | 172 | it('errors if given a null Uint8Array to sign', async () => {
|
172 |
| - // @ts-expect-error incorrect args |
173 |
| - await expect(secp256k1Crypto.hashAndSign(privKey, null)).to.eventually.be.rejected() |
| 173 | + await expect((async () => { |
| 174 | + // @ts-expect-error incorrect args |
| 175 | + await secp256k1Crypto.hashAndSign(privKey, null) |
| 176 | + })()).to.eventually.be.rejected() |
174 | 177 | })
|
175 | 178 |
|
176 | 179 | it('errors when signing with an invalid key', async () => {
|
177 |
| - await expect(secp256k1Crypto.hashAndSign(uint8ArrayFromString('42'), uint8ArrayFromString('Hello'))).to.eventually.be.rejected.with.property('code', 'ERR_INVALID_INPUT') |
| 180 | + await expect((async () => { |
| 181 | + await secp256k1Crypto.hashAndSign(uint8ArrayFromString('42'), uint8ArrayFromString('Hello')) |
| 182 | + })()).to.eventually.be.rejected.with.property('code', 'ERR_INVALID_INPUT') |
178 | 183 | })
|
179 | 184 |
|
180 | 185 | it('errors if given a null Uint8Array to validate', async () => {
|
181 | 186 | const sig = await secp256k1Crypto.hashAndSign(privKey, uint8ArrayFromString('hello'))
|
182 | 187 |
|
183 |
| - // @ts-expect-error incorrect args |
184 |
| - await expect(secp256k1Crypto.hashAndVerify(privKey, sig, null)).to.eventually.be.rejected() |
| 188 | + await expect((async () => { |
| 189 | + // @ts-expect-error incorrect args |
| 190 | + await secp256k1Crypto.hashAndVerify(privKey, sig, null) |
| 191 | + })()).to.eventually.be.rejected() |
185 | 192 | })
|
186 | 193 |
|
187 | 194 | it('throws when compressing an invalid public key', () => {
|
|
0 commit comments