Amend Primitives/Tooling
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
|
||||
import { Encryption } from '~/src/utils/encryption';
|
||||
import { Encrypter } from '~/src/utils/encrypter';
|
||||
import { binToUtf8, utf8ToBin } from '@bitauth/libauth';
|
||||
|
||||
describe('Encryption', () => {
|
||||
let encryption: Encryption;
|
||||
describe('Encrypter', () => {
|
||||
let encryption: Encrypter;
|
||||
const testKey = 'test-secret-key-123';
|
||||
|
||||
beforeEach(async () => {
|
||||
encryption = await Encryption.fromPassphrase(testKey);
|
||||
encryption = await Encrypter.fromPassphrase(testKey);
|
||||
});
|
||||
|
||||
describe('constructor', () => {
|
||||
it('should create instance with string key', async () => {
|
||||
const enc = await Encryption.fromPassphrase('test-key');
|
||||
expect(enc).toBeInstanceOf(Encryption);
|
||||
const enc = await Encrypter.fromPassphrase('test-key');
|
||||
expect(enc).toBeInstanceOf(Encrypter);
|
||||
});
|
||||
|
||||
it('should create instance with Uint8Array key', async () => {
|
||||
const enc = await Encryption.fromBytes(utf8ToBin('test-key'));
|
||||
expect(enc).toBeInstanceOf(Encryption);
|
||||
const enc = await Encrypter.fromBytes(utf8ToBin('test-key'));
|
||||
expect(enc).toBeInstanceOf(Encrypter);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -77,8 +77,8 @@ describe('Encryption', () => {
|
||||
|
||||
describe('cross-instance encryption', () => {
|
||||
it('should decrypt data encrypted with different instance using same key', async () => {
|
||||
const enc1 = await Encryption.fromPassphrase(testKey);
|
||||
const enc2 = await Encryption.fromPassphrase(testKey);
|
||||
const enc1 = await Encrypter.fromPassphrase(testKey);
|
||||
const enc2 = await Encrypter.fromPassphrase(testKey);
|
||||
|
||||
const originalData = 'Hello, World!';
|
||||
const encrypted = await enc1.encrypt(originalData);
|
||||
|
||||
Reference in New Issue
Block a user