romulus-js/tests/encrypt.test.ts
Jack Hadrill 5a042757dd
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Improve code quality and add decrypt status return value
2022-02-05 22:55:31 +00:00

18 lines
624 B
TypeScript

import { decrypt } from '../src/decrypt'
import { encrypt } from '../src/encrypt'
test('Test nonce generation by public encrypt function.', () => {
// Given
const message = Buffer.from('Hello, World! This is a test message.')
const associatedData = Buffer.from('Some associated data.')
const key = Buffer.from('\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f')
// When
const ciphertext = encrypt(message, associatedData, key)
const plaintext = decrypt(ciphertext, associatedData, key)
// Then
expect(plaintext.success).toBe(true)
expect(plaintext.plaintext).toMatchObject(message)
})