Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion yarn-project/kv-store/src/lmdb/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ describe('AztecLmdbStore', () => {
};

it('forks a persistent store', async () => {
const path = join(await mkdtemp(join(tmpdir(), 'aztec-store-test-')), 'main.mdb');
const path = await mkdtemp(join(tmpdir(), 'aztec-store-test-'));
const store = AztecLmdbStore.open(path, false);
await itForks(store);
});

it('forks a persistent store with no path', async () => {
const store = AztecLmdbStore.open(undefined, false);
await itForks(store);
});

it('forks an ephemeral store', async () => {
const store = AztecLmdbStore.open(undefined, true);
await itForks(store);
Expand Down
3 changes: 2 additions & 1 deletion yarn-project/kv-store/src/lmdb/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export class AztecLmdbStore implements AztecKVStore {
async fork() {
const baseDir = this.path ? dirname(this.path) : tmpdir();
this.#log.debug(`Forking store with basedir ${baseDir}`);
const forkPath = join(await mkdtemp(join(baseDir, 'aztec-store-fork-')), 'root.mdb');
const forkPath =
(await mkdtemp(join(baseDir, 'aztec-store-fork-'))) + (this.isEphemeral || !this.path ? '/data.mdb' : '');
this.#log.verbose(`Forking store to ${forkPath}`);
await this.#rootDb.backup(forkPath, false);
const forkDb = open(forkPath, { noSync: this.isEphemeral });
Expand Down