Adapt tests

This commit is contained in:
2024-09-11 23:13:55 +02:00
parent a0ffa2f682
commit a26dd305f8
8 changed files with 58 additions and 29 deletions
+7 -3
View File
@@ -11,7 +11,8 @@ test('Private box', async () => {
expect(de).not.toBeNull()
const box = await PrivateBox.encrypt(message, de!)
const unbox = await box.decrypt(k.privateKey)
expect(box).not.toBeNull()
const unbox = await box!.decrypt(k.privateKey)
expect(unbox).toEqual(message)
})
test('Private wrap', async () => {
@@ -24,11 +25,14 @@ test('Private wrap', async () => {
const message = crypto.getRandomValues(new Uint8Array(8))
const k_wrapped = await SecretBox.gen(true)
const boxed_message = await SecretBox.encrypt(message, k_wrapped)
expect(boxed_message).not.toBeNull()
const box = await PrivateWrap.wrap(k_wrapped, de!)
const unbox = await box.unwrap(k.privateKey)
expect(box).not.toBeNull()
const unbox = await box!.unwrap(k.privateKey)
expect(unbox).not.toBeNull()
const unboxed_message = await boxed_message.decrypt(unbox!)
const unboxed_message = await boxed_message!.decrypt(unbox!)
expect(unboxed_message).toEqual(message)
})
test('Signature', async () => {