Skip to content

Commit c52c4a3

Browse files
authored
Test fix: Clean up all tmp dirs (#719)
* Test fix: Clean up all tmp dirs * use t.tmp throughout
1 parent bdb4924 commit c52c4a3

File tree

11 files changed

+18
-29
lines changed

11 files changed

+18
-29
lines changed

test/basic.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const test = require('brittle')
22
const b4a = require('b4a')
3-
const createTempDir = require('test-tmp')
43
const HypercoreStorage = require('hypercore-storage')
54

65
const Hypercore = require('../')
@@ -119,7 +118,7 @@ test('createIfMissing', async function (t) {
119118
})
120119

121120
test('reopen writable core', async function (t) {
122-
const dir = await createTempDir(t)
121+
const dir = await t.tmp()
123122

124123
const core = new Hypercore(dir)
125124
await core.ready()
@@ -166,7 +165,7 @@ test('reopen writable core', async function (t) {
166165
})
167166

168167
test('reopen and overwrite', async function (t) {
169-
const dir = await createTempDir()
168+
const dir = await t.tmp()
170169
let storage = null
171170

172171
const core = new Hypercore(await open())

test/batch.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const test = require('brittle')
2-
const createTempDir = require('test-tmp')
32
const b4a = require('b4a')
43

54
const Hypercore = require('../')
@@ -446,7 +445,7 @@ test('encryption and bigger batches', async function (t) {
446445
})
447446

448447
test('persistent batch', async function (t) {
449-
const dir = await createTempDir()
448+
const dir = await t.tmp()
450449
let storage = null
451450

452451
const core = new Hypercore(await open())
@@ -544,7 +543,7 @@ test('batch append with huge batch', { timeout: 120000 }, async function (t) {
544543
})
545544

546545
test('batch does not append but reopens', async function (t) {
547-
const dir = await createTempDir(t)
546+
const dir = await t.tmp()
548547

549548
let core = new Hypercore(dir)
550549

test/bench/open-close.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
const test = require('brittle')
2-
const tmp = require('test-tmp')
32
const b4a = require('b4a')
43
const Hypercore = require('../../index.js')
54

65
test('open and close', async function (t) {
7-
const tmpDir = await tmp(t)
6+
const tmpDir = await t.tmp()
87

98
const core = new Hypercore(tmpDir)
109
for (let i = 0; i < 100; i++) {

test/bench/throughput.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const test = require('brittle')
2-
const tmp = require('test-tmp')
32
const b4a = require('b4a')
43
const { create, replicate } = require('../helpers')
54
const Hypercore = require('../../index.js')
65

76
test('throughput from disk', async function (t) {
8-
const dir = await tmp(t)
7+
const dir = await t.tmp()
98

109
const a = new Hypercore(dir)
1110
await a.append(new Array(20000).fill().map(() => b4a.alloc(1)))

test/bitfield.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const test = require('brittle')
22
const b4a = require('b4a')
3-
const createTempDir = require('test-tmp')
43
const CoreStorage = require('hypercore-storage')
54
const Bitfield = require('../lib/bitfield')
65
const BitInterlude = require('../lib/bit-interlude')
@@ -53,7 +52,7 @@ test('bitfield - random set and gets', async function (t) {
5352
})
5453

5554
test('bitfield - reload', async function (t) {
56-
const dir = await createTempDir(t)
55+
const dir = await t.tmp()
5756

5857
{
5958
const storage = await createStorage(t, dir)
@@ -292,7 +291,7 @@ test('bitfield - setRange over multiple pages', async function (t) {
292291
})
293292

294293
async function createStorage (t, dir) {
295-
if (!dir) dir = await createTempDir(t)
294+
if (!dir) dir = await t.tmp()
296295

297296
const db = new CoreStorage(dir)
298297

test/clear.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const test = require('brittle')
2-
const tmp = require('test-tmp')
32
const b4a = require('b4a')
43
const CoreStorage = require('hypercore-storage')
54
const { create, createStorage, replicate, eventFlush } = require('./helpers')
@@ -108,8 +107,8 @@ test('clear blocks with diff option', async function (t) {
108107
})
109108

110109
test('clear - no side effect from clearing unknown nodes', async function (t) {
111-
const storageWriter = await tmp(t)
112-
const storageReader = await tmp(t)
110+
const storageWriter = await t.tmp()
111+
const storageReader = await t.tmp()
113112

114113
const writer1 = new Hypercore(storageWriter)
115114
await writer1.append(['a', 'b', 'c', 'd']) // => 'Error: Could not load node: 1'

test/core.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const test = require('brittle')
22
const b4a = require('b4a')
3-
const createTempDir = require('test-tmp')
43
const CoreStorage = require('hypercore-storage')
54
const { MerkleTree } = require('../lib/merkle-tree')
65
const Core = require('../lib/core')
@@ -427,7 +426,7 @@ test('core - copyPrologue many', async function (t) {
427426
})
428427

429428
async function create (t, opts = {}) {
430-
const dir = opts.dir || await createTempDir(t)
429+
const dir = opts.dir || await t.tmp()
431430

432431
let db = null
433432

test/helpers/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const Hypercore = require('../../')
2-
const createTempDir = require('test-tmp')
32
const CoreStorage = require('hypercore-storage')
43
const safetyCatch = require('safety-catch')
54
const DebuggingStream = require('debugging-stream')
65

76
exports.create = async function (t, ...args) {
8-
const dir = await createTempDir(t)
7+
const dir = await t.tmp()
98

109
const db = new CoreStorage(dir)
1110

@@ -18,12 +17,12 @@ exports.create = async function (t, ...args) {
1817
}
1918

2019
const createStorage = exports.createStorage = async function (t, dir) {
21-
if (!dir) dir = await createTempDir(t)
20+
if (!dir) dir = await t.tmp()
2221
return new CoreStorage(dir)
2322
}
2423

2524
exports.createStored = async function (t) {
26-
const dir = await createTempDir(t)
25+
const dir = await t.tmp()
2726
let db = null
2827

2928
return async function (...args) {

test/manifest.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const test = require('brittle')
22
const crypto = require('hypercore-crypto')
33
const b4a = require('b4a')
4-
const tmpDir = require('test-tmp')
54
const c = require('compact-encoding')
65

76
const Hypercore = require('../')
@@ -710,7 +709,7 @@ test('multisig - multiple appends', async function (t) {
710709
})
711710

712711
test('multisig - persist to disk', async function (t) {
713-
const dir = await tmpDir(t)
712+
const dir = await t.tmp()
714713
const storage = await createStorage(t, dir)
715714

716715
const signers = []

test/purge.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
const test = require('brittle')
2-
const tmp = require('test-tmp')
32
const fs = require('fs')
43
const Path = require('path')
54

65
const Hypercore = require('..')
76

87
test('basic purge', async function (t) {
9-
const dir = await tmp(t)
8+
const dir = await t.tmp()
109
const core = new Hypercore(dir)
1110
await core.append(['a', 'b', 'c'])
1211

@@ -32,7 +31,7 @@ test('basic purge', async function (t) {
3231
})
3332

3433
test('purge closes all sessions', async function (t) {
35-
const dir = await tmp(t)
34+
const dir = await t.tmp()
3635
const core = new Hypercore(dir)
3736
await core.append(['a', 'b', 'c'])
3837
const otherSession = core.session()

0 commit comments

Comments
 (0)