Skip to content

Commit

Permalink
test(swingset): use tmp directories for snapStore in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Jul 22, 2021
1 parent c046124 commit 813f43c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
9 changes: 2 additions & 7 deletions packages/SwingSet/test/vat-warehouse/test-reload-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// eslint-disable-next-line import/order
import { test } from '../../tools/prepare-test-env-ava.js';

import fs from 'fs';
import path from 'path';
import tmp from 'tmp';
import { makeSnapStore } from '@agoric/xsnap';
import { provideHostStorage, makeSnapStoreIO } from '../../src/hostStorage.js';
import { initializeSwingset, makeSwingsetController } from '../../src/index.js';
Expand All @@ -19,12 +19,7 @@ test('vat reload from snapshot', async t => {
},
};

const snapstorePath = path.resolve(
__dirname,
'./fixture-test-reload-snapshot/',
);
fs.mkdirSync(snapstorePath, { recursive: true });
t.teardown(() => fs.rmdirSync(snapstorePath, { recursive: true }));
const snapstorePath = tmp.dirSync({ unsafeCleanup: true }).name;

const snapStore = makeSnapStore(snapstorePath, makeSnapStoreIO());
const hostStorage = { snapStore, ...provideHostStorage() };
Expand Down
5 changes: 2 additions & 3 deletions packages/SwingSet/test/vat-warehouse/test-warehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { test } from '../../tools/prepare-test-env-ava';
import path from 'path';
import fs from 'fs';
import tmp from 'tmp';
import { makeSnapStore } from '@agoric/xsnap';
import { loadBasedir, buildVatController } from '../../src/index.js';
import { provideHostStorage, makeSnapStoreIO } from '../../src/hostStorage.js';
Expand Down Expand Up @@ -124,9 +125,7 @@ function unusedSnapshotsOnDisk(kvStore, snapstorePath) {
}

test('snapshot after deliveries', async t => {
const snapstorePath = path.resolve(__dirname, './fixture-test-warehouse/');
fs.mkdirSync(snapstorePath, { recursive: true });
t.teardown(() => fs.rmdirSync(snapstorePath, { recursive: true }));
const snapstorePath = tmp.dirSync({ unsafeCleanup: true }).name;

const snapStore = makeSnapStore(snapstorePath, makeSnapStoreIO());
const hostStorage = { snapStore, ...provideHostStorage() };
Expand Down

0 comments on commit 813f43c

Please sign in to comment.