@agoric/swing-store 0.9.2-dev-75e8d38.0 → 0.9.2-dev-0e6a9f4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/swing-store",
3
- "version": "0.9.2-dev-75e8d38.0+75e8d38",
3
+ "version": "0.9.2-dev-0e6a9f4.0+0e6a9f4",
4
4
  "description": "Persistent storage for SwingSet",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -21,7 +21,7 @@
21
21
  "lint:eslint": "eslint ."
22
22
  },
23
23
  "dependencies": {
24
- "@agoric/internal": "0.3.3-dev-75e8d38.0+75e8d38",
24
+ "@agoric/internal": "0.3.3-dev-0e6a9f4.0+0e6a9f4",
25
25
  "@endo/base64": "^1.0.9",
26
26
  "@endo/bundle-source": "^3.5.1",
27
27
  "@endo/check-bundle": "^1.0.13",
@@ -51,5 +51,5 @@
51
51
  "typeCoverage": {
52
52
  "atLeast": 79.43
53
53
  },
54
- "gitHead": "75e8d388b2e48420f325aae6978d047cf7fe4d33"
54
+ "gitHead": "0e6a9f409040c4805179f0f8adee40cd1bd22ae2"
55
55
  }
@@ -1,13 +1,16 @@
1
1
  // @ts-check
2
2
  import test from 'ava';
3
- import tmp from 'tmp';
4
3
  import { Buffer } from 'buffer';
4
+ import tmp from 'tmp';
5
+ import { makeTempDirFactory } from '@agoric/internal/src/tmpDir.js';
5
6
  import { createSHA256 } from '../src/hasher.js';
6
7
  import { initSwingStore } from '../src/swingStore.js';
7
8
  import { makeSwingStoreExporter } from '../src/exporter.js';
8
9
  import { importSwingStore } from '../src/importer.js';
9
10
  import { buffer } from '../src/util.js';
10
11
 
12
+ const tmpDir = makeTempDirFactory(tmp);
13
+
11
14
  function makeB0ID(bundle) {
12
15
  return `b0-${createSHA256(JSON.stringify(bundle)).finish()}`;
13
16
  }
@@ -53,17 +56,6 @@ function makeExportCallback() {
53
56
  };
54
57
  }
55
58
 
56
- const tmpDir = prefix =>
57
- new Promise((resolve, reject) => {
58
- tmp.dir({ unsafeCleanup: true, prefix }, (err, name, removeCallback) => {
59
- if (err) {
60
- reject(err);
61
- } else {
62
- resolve([name, removeCallback]);
63
- }
64
- });
65
- });
66
-
67
59
  const collectArray = async iter => {
68
60
  const items = [];
69
61
  for await (const item of iter) {
@@ -73,7 +65,7 @@ const collectArray = async iter => {
73
65
  };
74
66
 
75
67
  test('b0 export', async t => {
76
- const [dbDir, cleanup] = await tmpDir('testdb');
68
+ const [dbDir, cleanup] = tmpDir('testdb');
77
69
  t.teardown(cleanup);
78
70
  const { exportData, exportCallback } = makeExportCallback();
79
71
  const { kernelStorage, hostStorage } = initSwingStore(dbDir, {
@@ -7,13 +7,15 @@ import fs from 'node:fs';
7
7
  import zlib from 'node:zlib';
8
8
  import sqlite3 from 'better-sqlite3';
9
9
  import tmp from 'tmp';
10
+ import { makeTempDirFactory } from '@agoric/internal/src/tmpDir.js';
10
11
  import { arrayIsLike } from '@agoric/internal/tools/ava-assertions.js';
11
- import { tmpDir } from './util.js';
12
12
  import { initSwingStore } from '../src/swingStore.js';
13
13
  import { makeArchiveSnapshot, makeArchiveTranscript } from '../src/archiver.js';
14
14
  import { makeSwingStoreExporter } from '../src/exporter.js';
15
15
  import { importSwingStore } from '../src/importer.js';
16
16
 
17
+ const tmpDir = makeTempDirFactory(tmp);
18
+
17
19
  async function* getSnapshotStream() {
18
20
  yield Buffer.from('abc');
19
21
  }
@@ -139,7 +141,7 @@ const getExport = async (dbDir, artifactMode) => {
139
141
  };
140
142
 
141
143
  const reImport = async (t, dbDir, artifactMode) => {
142
- const [dbDir2, cleanup] = await tmpDir('testdb2');
144
+ const [dbDir2, cleanup] = tmpDir('testdb2');
143
145
  t.teardown(cleanup);
144
146
  const exporter = makeSwingStoreExporter(dbDir, { artifactMode });
145
147
  const ss2 = await importSwingStore(exporter, dbDir2, { artifactMode });
@@ -170,9 +172,9 @@ const setupTranscript = async (t, keepTranscripts) => {
170
172
  }
171
173
  mergeExportDeltas(currentExportData, exports);
172
174
  };
173
- const [dbDir, cleanup] = await tmpDir('testdb');
175
+ const [dbDir, cleanup] = tmpDir('testdb');
174
176
  t.teardown(cleanup);
175
- const [archiveDir, cleanupArchives] = await tmpDir('archives');
177
+ const [archiveDir, cleanupArchives] = tmpDir('archives');
176
178
  t.teardown(cleanupArchives);
177
179
  const fsPowers = { fs, path, tmp };
178
180
  const archiveSnapshot = makeArchiveSnapshot(archiveDir, fsPowers);
@@ -531,7 +533,7 @@ const setupSnapshots = async t => {
531
533
  }
532
534
  mergeExportDeltas(currentExportData, exports);
533
535
  };
534
- const [dbDir, cleanup] = await tmpDir('testdb');
536
+ const [dbDir, cleanup] = tmpDir('testdb');
535
537
  t.teardown(cleanup);
536
538
  const store = initSwingStore(dbDir, { exportCallback });
537
539
  const { kernelStorage, hostStorage } = store;
@@ -1,9 +1,14 @@
1
1
  import test from 'ava';
2
+ import tmp from 'tmp';
3
+
4
+ import { makeTempDirFactory } from '@agoric/internal/src/tmpDir.js';
2
5
 
3
6
  import { buffer } from '../src/util.js';
4
7
  import { initSwingStore, makeSwingStoreExporter } from '../src/index.js';
5
8
 
6
- import { tmpDir, getSnapshotStream, makeB0ID } from './util.js';
9
+ import { getSnapshotStream, makeB0ID } from './util.js';
10
+
11
+ const tmpDir = makeTempDirFactory(tmp);
7
12
 
8
13
  const rank = {
9
14
  operational: 1,
@@ -23,7 +28,7 @@ const bundle0 = { moduleFormat: 'nestedEvaluate', source: '1+1' };
23
28
  const bundle0ID = makeB0ID(bundle0);
24
29
 
25
30
  const exportTest = test.macro(async (t, mode) => {
26
- const [dbDir, cleanup] = await tmpDir('testdb');
31
+ const [dbDir, cleanup] = tmpDir('testdb');
27
32
  t.teardown(cleanup);
28
33
  // const dbDir = 't-db';
29
34
 
@@ -234,7 +239,7 @@ test('export debug', exportTest, 'debug');
234
239
  test('export debug-on-pruned', exportTest, 'debug-on-pruned');
235
240
 
236
241
  test('export omits pruned span artifacts', async t => {
237
- const [dbDir, cleanup] = await tmpDir('testdb');
242
+ const [dbDir, cleanup] = tmpDir('testdb');
238
243
  t.teardown(cleanup);
239
244
  // const dbDir = 't-db';
240
245
 
@@ -6,10 +6,14 @@ import test from 'ava';
6
6
  import tmp from 'tmp';
7
7
  import bundleSource from '@endo/bundle-source';
8
8
 
9
+ import { makeTempDirFactory } from '@agoric/internal/src/tmpDir.js';
10
+
9
11
  import { initSwingStore } from '../src/swingStore.js';
10
12
  import { makeSwingStoreExporter } from '../src/exporter.js';
11
13
  import { importSwingStore } from '../src/importer.js';
12
14
 
15
+ const tmpDir = makeTempDirFactory(tmp);
16
+
13
17
  function makeExportLog() {
14
18
  const exportLog = [];
15
19
  const shadowStore = new Map();
@@ -33,21 +37,6 @@ function makeExportLog() {
33
37
  };
34
38
  }
35
39
 
36
- /**
37
- * @param {string} [prefix]
38
- * @returns {Promise<[string, () => void]>}
39
- */
40
- const tmpDir = prefix =>
41
- new Promise((resolve, reject) => {
42
- tmp.dir({ unsafeCleanup: true, prefix }, (err, name, removeCallback) => {
43
- if (err) {
44
- reject(err);
45
- } else {
46
- resolve([name, removeCallback]);
47
- }
48
- });
49
- });
50
-
51
40
  async function embundle(filename) {
52
41
  const bundleFile = new URL(filename, import.meta.url).pathname;
53
42
  const bundle = await bundleSource(bundleFile);
@@ -96,7 +85,7 @@ const compareElems = (a, b) => a[0].localeCompare(b[0]);
96
85
 
97
86
  test('crank abort leaves no debris in export log', async t => {
98
87
  const exportLog = makeExportLog();
99
- const [dbDir, cleanup] = await tmpDir('testdb');
88
+ const [dbDir, cleanup] = tmpDir('testdb');
100
89
  t.teardown(cleanup);
101
90
 
102
91
  const ssOut = initSwingStore(dbDir, {
@@ -176,7 +165,7 @@ async function testExportImport(
176
165
  failureMode = 'none',
177
166
  ) {
178
167
  const exportLog = makeExportLog();
179
- const [dbDir, cleanup] = await tmpDir('testdb');
168
+ const [dbDir, cleanup] = tmpDir('testdb');
180
169
  t.teardown(cleanup);
181
170
 
182
171
  const keepTranscripts = runMode !== 'operational';
@@ -7,12 +7,14 @@ import { Buffer } from 'buffer';
7
7
 
8
8
  import sqlite3 from 'better-sqlite3';
9
9
  import test from 'ava';
10
+ import tmp from 'tmp';
10
11
  import { decodeBase64 } from '@endo/base64';
11
12
 
13
+ import { makeTempDirFactory } from '@agoric/internal/src/tmpDir.js';
14
+
12
15
  import { buffer } from '../src/util.js';
13
16
  import { importSwingStore, makeSwingStoreExporter } from '../src/index.js';
14
17
 
15
- import { tmpDir } from './util.js';
16
18
  import {
17
19
  buildData,
18
20
  bundle0,
@@ -29,6 +31,8 @@ const rank = {
29
31
  debug: 4,
30
32
  };
31
33
 
34
+ const tmpDir = makeTempDirFactory(tmp);
35
+
32
36
  function convert(orig) {
33
37
  const bundles = Object.fromEntries(
34
38
  Object.entries(orig.bundles).map(([bundleID, encBundle]) => {
@@ -42,7 +46,7 @@ function convert(orig) {
42
46
  }
43
47
 
44
48
  test('import empty', async t => {
45
- const [dbDir, cleanup] = await tmpDir('testdb');
49
+ const [dbDir, cleanup] = tmpDir('testdb');
46
50
  t.teardown(cleanup);
47
51
  const exporter = makeExporter(new Map(), new Map());
48
52
  const ss = await importSwingStore(exporter, dbDir);
@@ -61,7 +65,7 @@ const importTest = test.macro(async (t, mode) => {
61
65
  /** @import {ArtifactMode} from '../src/internal.js' */
62
66
  const artifactMode = /** @type {ArtifactMode} */ (mode);
63
67
 
64
- const [dbDir, cleanup] = await tmpDir('testdb');
68
+ const [dbDir, cleanup] = tmpDir('testdb');
65
69
  t.teardown(cleanup);
66
70
 
67
71
  const { exportData, artifacts, t0hash, t2hash, t5hash, t8hash } = buildData();
@@ -211,7 +215,7 @@ test('import archival', importTest, 'archival');
211
215
  test('import debug', importTest, 'debug');
212
216
 
213
217
  test('import is missing bundle', async t => {
214
- const [dbDir, cleanup] = await tmpDir('testdb');
218
+ const [dbDir, cleanup] = tmpDir('testdb');
215
219
  t.teardown(cleanup);
216
220
 
217
221
  const exportData = new Map();
@@ -224,7 +228,7 @@ test('import is missing bundle', async t => {
224
228
  });
225
229
 
226
230
  test('import is missing snapshot', async t => {
227
- const [dbDir, cleanup] = await tmpDir('testdb');
231
+ const [dbDir, cleanup] = tmpDir('testdb');
228
232
  t.teardown(cleanup);
229
233
 
230
234
  const exportData = new Map();
@@ -240,7 +244,7 @@ test('import is missing snapshot', async t => {
240
244
  });
241
245
 
242
246
  test('import is missing transcript span', async t => {
243
- const [dbDir, cleanup] = await tmpDir('testdb');
247
+ const [dbDir, cleanup] = tmpDir('testdb');
244
248
  t.teardown(cleanup);
245
249
 
246
250
  const exportData = new Map();
@@ -265,7 +269,7 @@ test('import is missing transcript span', async t => {
265
269
  });
266
270
 
267
271
  test('import has mismatched transcript span', async t => {
268
- const [dbDir, cleanup] = await tmpDir('testdb');
272
+ const [dbDir, cleanup] = tmpDir('testdb');
269
273
  t.teardown(cleanup);
270
274
 
271
275
  const exportData = new Map();
@@ -289,7 +293,7 @@ test('import has mismatched transcript span', async t => {
289
293
  });
290
294
 
291
295
  test('import has incomplete transcript span', async t => {
292
- const [dbDir, cleanup] = await tmpDir('testdb');
296
+ const [dbDir, cleanup] = tmpDir('testdb');
293
297
  t.teardown(cleanup);
294
298
 
295
299
  const exportData = new Map();
@@ -320,7 +324,7 @@ test('import has incomplete transcript span', async t => {
320
324
  });
321
325
 
322
326
  test('import has corrupt transcript span', async t => {
323
- const [dbDir, cleanup] = await tmpDir('testdb');
327
+ const [dbDir, cleanup] = tmpDir('testdb');
324
328
  t.teardown(cleanup);
325
329
 
326
330
  const exportData = new Map();
@@ -350,7 +354,7 @@ test('import has corrupt transcript span', async t => {
350
354
  });
351
355
 
352
356
  test('import has corrupt snapshot', async t => {
353
- const [dbDir, cleanup] = await tmpDir('testdb');
357
+ const [dbDir, cleanup] = tmpDir('testdb');
354
358
  t.teardown(cleanup);
355
359
 
356
360
  const exportData = new Map();
@@ -373,7 +377,7 @@ test('import has corrupt snapshot', async t => {
373
377
  });
374
378
 
375
379
  test('import has corrupt bundle', async t => {
376
- const [dbDir, cleanup] = await tmpDir('testdb');
380
+ const [dbDir, cleanup] = tmpDir('testdb');
377
381
  t.teardown(cleanup);
378
382
 
379
383
  const exportData = new Map();
@@ -389,7 +393,7 @@ test('import has corrupt bundle', async t => {
389
393
  });
390
394
 
391
395
  test('import has unknown metadata tag', async t => {
392
- const [dbDir, cleanup] = await tmpDir('testdb');
396
+ const [dbDir, cleanup] = tmpDir('testdb');
393
397
  t.teardown(cleanup);
394
398
 
395
399
  const exportData = new Map();
@@ -401,7 +405,7 @@ test('import has unknown metadata tag', async t => {
401
405
  });
402
406
 
403
407
  test('import has unknown artifact tag', async t => {
404
- const [dbDir, cleanup] = await tmpDir('testdb');
408
+ const [dbDir, cleanup] = tmpDir('testdb');
405
409
  t.teardown(cleanup);
406
410
 
407
411
  const artifacts = new Map();
@@ -3,14 +3,18 @@
3
3
  import path from 'path';
4
4
  import test from 'ava';
5
5
  import sqlite3 from 'better-sqlite3';
6
+ import tmp from 'tmp';
7
+
8
+ import { makeTempDirFactory } from '@agoric/internal/src/tmpDir.js';
6
9
 
7
10
  import { importSwingStore, openSwingStore } from '../src/index.js';
8
11
 
9
12
  import { makeExporter, buildData } from './exports.js';
10
- import { tmpDir } from './util.js';
13
+
14
+ const tmpDir = makeTempDirFactory(tmp);
11
15
 
12
16
  test('repair metadata', async t => {
13
- const [dbDir, cleanup] = await tmpDir('testdb');
17
+ const [dbDir, cleanup] = tmpDir('testdb');
14
18
  t.teardown(cleanup);
15
19
 
16
20
  const { exportData, artifacts } = buildData();
@@ -74,7 +78,7 @@ test('repair metadata', async t => {
74
78
  });
75
79
 
76
80
  test('repair metadata ignores kvStore entries', async t => {
77
- const [dbDir, cleanup] = await tmpDir('testdb');
81
+ const [dbDir, cleanup] = tmpDir('testdb');
78
82
  t.teardown(cleanup);
79
83
 
80
84
  const { exportData, artifacts } = buildData();
@@ -97,7 +101,7 @@ test('repair metadata ignores kvStore entries', async t => {
97
101
  });
98
102
 
99
103
  test('repair metadata rejects mismatched snapshot entries', async t => {
100
- const [dbDir, cleanup] = await tmpDir('testdb');
104
+ const [dbDir, cleanup] = tmpDir('testdb');
101
105
  t.teardown(cleanup);
102
106
 
103
107
  const { exportData, artifacts } = buildData();
@@ -120,7 +124,7 @@ test('repair metadata rejects mismatched snapshot entries', async t => {
120
124
  });
121
125
 
122
126
  test('repair metadata rejects mismatched transcript span', async t => {
123
- const [dbDir, cleanup] = await tmpDir('testdb');
127
+ const [dbDir, cleanup] = tmpDir('testdb');
124
128
  t.teardown(cleanup);
125
129
 
126
130
  const { exportData, artifacts } = buildData();
@@ -8,10 +8,11 @@ import zlib from 'node:zlib';
8
8
  import sqlite3 from 'better-sqlite3';
9
9
  import tmp from 'tmp';
10
10
 
11
- import { makeMeasureSeconds } from '@agoric/internal';
11
+ import { makeMeasureSeconds, makeTempDirFactory } from '@agoric/internal';
12
12
  import { makeSnapStore } from '../src/snapStore.js';
13
13
  import { makeArchiveSnapshot } from '../src/archiver.js';
14
- import { tmpDir } from './util.js';
14
+
15
+ const tmpDir = makeTempDirFactory(tmp);
15
16
 
16
17
  function makeExportLog() {
17
18
  const exportLog = [];
@@ -36,7 +37,7 @@ harden(getSnapshotStream);
36
37
  test('compress to cache file; closes snapshot stream', async t => {
37
38
  const db = sqlite3(':memory:');
38
39
  const exportLog = makeExportLog();
39
- const [archiveDir, cleanupArchives] = await tmpDir('archives');
40
+ const [archiveDir, cleanupArchives] = tmpDir('archives');
40
41
  t.teardown(cleanupArchives);
41
42
  const fsPowers = { fs, path, tmp };
42
43
  const archiveSnapshot = makeArchiveSnapshot(archiveDir, fsPowers);
@@ -127,7 +128,7 @@ test('snapStore prepare / commit delete is robust', async t => {
127
128
  measureSeconds: makeMeasureSeconds(() => 0),
128
129
  };
129
130
  const db = sqlite3(':memory:');
130
- const [archiveDir, cleanupArchives] = await tmpDir('archives');
131
+ const [archiveDir, cleanupArchives] = tmpDir('archives');
131
132
  t.teardown(cleanupArchives);
132
133
  const fsPowers = { fs, path, tmp };
133
134
  const archiveSnapshot = makeArchiveSnapshot(archiveDir, fsPowers);
@@ -1,30 +1,19 @@
1
1
  // @ts-check
2
2
 
3
- import tmp from 'tmp';
4
3
  import test from 'ava';
4
+ import tmp from 'tmp';
5
5
 
6
6
  import bundleSource from '@endo/bundle-source';
7
7
 
8
+ import { makeTempDirFactory } from '@agoric/internal/src/tmpDir.js';
9
+
8
10
  import {
9
11
  initSwingStore,
10
12
  openSwingStore,
11
13
  isSwingStore,
12
14
  } from '../src/swingStore.js';
13
15
 
14
- /**
15
- * @param {string} [prefix]
16
- * @returns {Promise<[string, () => void]>}
17
- */
18
- const tmpDir = prefix =>
19
- new Promise((resolve, reject) => {
20
- tmp.dir({ unsafeCleanup: true, prefix }, (err, name, removeCallback) => {
21
- if (err) {
22
- reject(err);
23
- } else {
24
- resolve([name, removeCallback]);
25
- }
26
- });
27
- });
16
+ const tmpDir = makeTempDirFactory(tmp);
28
17
 
29
18
  async function embundle(filename) {
30
19
  const bundleFile = new URL(filename, import.meta.url).pathname;
@@ -121,9 +110,9 @@ test('in-memory kvStore read/write', t => {
121
110
  });
122
111
 
123
112
  test('persistent kvStore read/write/re-open', async t => {
124
- const [dbDir, cleanup] = await tmpDir('testdb');
125
- const exportLog = makeExportLog();
113
+ const [dbDir, cleanup] = tmpDir('testdb');
126
114
  t.teardown(cleanup);
115
+ const exportLog = makeExportLog();
127
116
  t.is(isSwingStore(dbDir), false);
128
117
  const ss1 = initSwingStore(dbDir, { exportCallback: exportLog.callback });
129
118
  testKVStore(t, ss1, exportLog);
@@ -146,7 +135,7 @@ test('persistent kvStore maxKeySize write', async t => {
146
135
  // This tests that no matter what, we can write 254 unicode characters in the
147
136
  // 0x0800 - 0xFFFF range (single UTF-16 codepoint, but 3 byte UTF-8).
148
137
 
149
- const [dbDir, cleanup] = await tmpDir('testdb');
138
+ const [dbDir, cleanup] = tmpDir('testdb');
150
139
  t.teardown(cleanup);
151
140
  t.is(isSwingStore(dbDir), false);
152
141
  const { kernelStorage, hostStorage } = initSwingStore(dbDir);
@@ -164,7 +153,7 @@ const testTranscriptStore = test.macro({
164
153
  async exec(t, { ephemeral, keepTranscripts }) {
165
154
  let dbDir = null;
166
155
  if (!ephemeral) {
167
- const [tmpPath, cleanup] = await tmpDir('testdb');
156
+ const [tmpPath, cleanup] = tmpDir('testdb');
168
157
  t.teardown(cleanup);
169
158
  t.is(isSwingStore(tmpPath), false);
170
159
  dbDir = tmpPath;
@@ -257,7 +246,7 @@ test(testTranscriptStore, { ephemeral: false, keepTranscripts: true });
257
246
  test(testTranscriptStore, { ephemeral: false, keepTranscripts: false });
258
247
 
259
248
  test('transcriptStore abort', async t => {
260
- const [dbDir, cleanup] = await tmpDir('testdb');
249
+ const [dbDir, cleanup] = tmpDir('testdb');
261
250
  t.teardown(cleanup);
262
251
  const { kernelStorage, hostStorage } = initSwingStore(dbDir);
263
252
  const { transcriptStore } = kernelStorage;
@@ -316,14 +305,14 @@ test('in-memory bundleStore read/write', async t => {
316
305
  });
317
306
 
318
307
  test('persistent bundleStore read/write', async t => {
319
- const [dbDir, cleanup] = await tmpDir('testdb');
308
+ const [dbDir, cleanup] = tmpDir('testdb');
320
309
  t.teardown(cleanup);
321
310
  t.is(isSwingStore(dbDir), false);
322
311
  await testBundleStore(t, dbDir);
323
312
  });
324
313
 
325
314
  test('close will abort transaction', async t => {
326
- const [dbDir, cleanup] = await tmpDir('testdb');
315
+ const [dbDir, cleanup] = tmpDir('testdb');
327
316
  t.teardown(cleanup);
328
317
  const ss1 = initSwingStore(dbDir);
329
318
  ss1.kernelStorage.kvStore.set('key1', 'value');
@@ -341,7 +330,7 @@ test('close will abort transaction', async t => {
341
330
  });
342
331
 
343
332
  test('savepoints', async t => {
344
- const [dbDir, cleanup] = await tmpDir('testdb');
333
+ const [dbDir, cleanup] = tmpDir('testdb');
345
334
  t.teardown(cleanup);
346
335
  const ss1 = initSwingStore(dbDir);
347
336
  ss1.kernelStorage.startCrank();
@@ -360,7 +349,7 @@ test('savepoints', async t => {
360
349
  });
361
350
 
362
351
  test('savepoints do not automatically commit', async t => {
363
- const [dbDir, cleanup] = await tmpDir('testdb');
352
+ const [dbDir, cleanup] = tmpDir('testdb');
364
353
  t.teardown(cleanup);
365
354
  const ss1 = initSwingStore(dbDir);
366
355
  ss1.kernelStorage.startCrank();
package/test/util.js CHANGED
@@ -1,22 +1,6 @@
1
1
  import { Buffer } from 'node:buffer';
2
- import tmp from 'tmp';
3
2
  import { createSHA256 } from '../src/hasher.js';
4
3
 
5
- /**
6
- * @param {string} [prefix]
7
- * @returns {Promise<[string, () => void]>}
8
- */
9
- export const tmpDir = prefix =>
10
- new Promise((resolve, reject) => {
11
- tmp.dir({ unsafeCleanup: true, prefix }, (err, name, removeCallback) => {
12
- if (err) {
13
- reject(err);
14
- } else {
15
- resolve([name, removeCallback]);
16
- }
17
- });
18
- });
19
-
20
4
  export async function* getSnapshotStream(contents) {
21
5
  yield Buffer.from(contents);
22
6
  }