Test contexts
This commit is contained in:
@@ -36,6 +36,22 @@ test('Key generation', async () => {
|
||||
expect(k2.publicKey.extractable).toBeTrue()
|
||||
})
|
||||
|
||||
test("Encryption works with context", async () => {
|
||||
const context = 'Super context !'
|
||||
const box = await PrivateWrap.wrap(message, k1.publicKey, context)
|
||||
expect(box).not.toBeNull()
|
||||
const unboxed = await box!.unwrap(k1.privateKey, context)
|
||||
expect(unboxed).not.toBeNull()
|
||||
})
|
||||
test("Encryption doesn't work with different context", async () => {
|
||||
const context1 = 'Super context !'
|
||||
const context2 = 'Awesome context !'
|
||||
const box = await PrivateWrap.wrap(message, k1.publicKey, context1)
|
||||
expect(box).not.toBeNull()
|
||||
const unboxed = await box!.unwrap(k1.privateKey, context2)
|
||||
expect(unboxed).toBeNull()
|
||||
})
|
||||
|
||||
test('serialization', async () => {
|
||||
const box = await PrivateWrap.wrap(message, k1.publicKey)
|
||||
expect(box).not.toBeNull()
|
||||
|
||||
Reference in New Issue
Block a user