release: v0.5.1 — 存储后端生产级硬化(CRC-32/全库加密/WAL分片/页面化存储/多标签页锁/e2e)+ 深度审查修复(假实现接线/死代码清理)
This commit is contained in:
@@ -5,13 +5,7 @@
|
||||
* v0.2.6 补强:此前仅验证实例化,现在验证真实的加解密往返一致性。
|
||||
*/
|
||||
import 'fake-indexeddb/auto';
|
||||
import {
|
||||
CryptoManager,
|
||||
initCrypto,
|
||||
encryptPage,
|
||||
decryptPage,
|
||||
closeCrypto,
|
||||
} from '../../src/engine/aria/crypto';
|
||||
import { CryptoManager } from '../../src/engine/aria/crypto';
|
||||
|
||||
function toBytes(data: ArrayBuffer): number[] {
|
||||
return Array.from(new Uint8Array(data));
|
||||
@@ -89,15 +83,6 @@ describe('AriaEngine — CryptoManager', () => {
|
||||
cm2.close();
|
||||
});
|
||||
|
||||
test('全局兼容层往返一致', async () => {
|
||||
await initCrypto('global-password');
|
||||
const original = new TextEncoder().encode('global compat layer').buffer;
|
||||
const { iv, data } = await encryptPage(original);
|
||||
const decrypted = await decryptPage(iv, data);
|
||||
expect(toBytes(decrypted)).toEqual(toBytes(original));
|
||||
closeCrypto();
|
||||
});
|
||||
|
||||
test('大块数据(接近页面大小)往返一致', async () => {
|
||||
const cm = new CryptoManager();
|
||||
await cm.init('page-size-test');
|
||||
@@ -111,47 +96,3 @@ describe('AriaEngine — CryptoManager', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// ===================================================================
|
||||
// 真实存储路径:SSTable 加密 → 持久化 → 重载解密(v0.3.2 CI 修复)
|
||||
// ===================================================================
|
||||
|
||||
describe('AriaEngine — SSTable 加密存储真实路径', () => {
|
||||
test('加密落盘后重载可完整解密', async () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const { AriaEngine } = require('../../src/engine/aria/index');
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const { createSchema } = require('../../src/table/schema');
|
||||
const dbName = `enc-store-${Date.now()}`;
|
||||
|
||||
await initCrypto('engine-store-password');
|
||||
|
||||
const engine = new AriaEngine({
|
||||
storageBackend: 'indexeddb',
|
||||
walSyncMode: 'none',
|
||||
} as any);
|
||||
await engine.open(dbName, 1);
|
||||
await engine.createTable(createSchema('t', {
|
||||
id: { type: 'string', primaryKey: true },
|
||||
v: { type: 'number' },
|
||||
}));
|
||||
await engine.insert('t', [{ id: '1', v: 42 }, { id: '2', v: 99 }]);
|
||||
// 强制刷盘:SSTable 经加密保存(encryptPage 真实路径)
|
||||
await (engine as any).lsm.flush();
|
||||
await engine.close();
|
||||
|
||||
// 重载:SSTable 解密恢复
|
||||
const engine2 = new AriaEngine({
|
||||
storageBackend: 'indexeddb',
|
||||
walSyncMode: 'none',
|
||||
} as any);
|
||||
await engine2.open(dbName, 1);
|
||||
const rows = await engine2.find('t', { table: 't' });
|
||||
expect(rows).toHaveLength(2);
|
||||
const byId = Object.fromEntries(rows.map((r: any) => [r.id, r.v]));
|
||||
expect(byId['1']).toBe(42);
|
||||
expect(byId['2']).toBe(99);
|
||||
await engine2.close();
|
||||
|
||||
closeCrypto();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user