From dee03d0a2325e0d9b46732270d1264bb178425d7 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Thu, 1 Feb 2024 20:28:47 -0800 Subject: [PATCH] add a test for it --- example/src/tests.ts | 14 ++++++++++++++ src/index.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/example/src/tests.ts b/example/src/tests.ts index 814a091b3..b9412b352 100644 --- a/example/src/tests.ts +++ b/example/src/tests.ts @@ -173,6 +173,20 @@ test('canMessage', async () => { return canMessage }) +test('fetch a public key bundle and sign a digest', async () => { + const bob = await Client.createRandom({ env: 'local' }) + const bytes = new Uint8Array([1, 2, 3]) + const signature = await bob.sign(bytes, { kind: 'identity' }) + if (signature.length === 0) { + throw new Error('signature was not returned') + } + const keyBundle = await bob.exportPublicKeyBundle() + if (keyBundle.length === 0) { + throw new Error('key bundle was not returned') + } + return true +}) + test('createFromKeyBundle throws error for non string value', async () => { try { const bytes = [1, 2, 3] diff --git a/src/index.ts b/src/index.ts index 02214f4f7..a671bfc87 100644 --- a/src/index.ts +++ b/src/index.ts @@ -80,7 +80,7 @@ export async function sign( clientAddress: string, digest: Uint8Array, keyType: string, - preKeyIndex?: number | 0 + preKeyIndex: number = 0 ): Promise { const signatureArray = await XMTPModule.sign( clientAddress,