From d89172833905b3e57c49ebfcc6dca6a987c125c6 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Mon, 6 Jan 2025 15:53:27 +0100 Subject: [PATCH] test again storage --- package.json | 1 - test/blobs.js | 18 +++++++++--------- test/drives.js | 18 +++++++++--------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index ffa4ba9..2969c11 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "corestore": "^6.18.4", "hyperblobs": "^2.7.4", "hyperdrive": "^11.13.3", - "random-access-memory": "^6.2.1", "standard": "^17.1.2" }, "repository": { diff --git a/test/blobs.js b/test/blobs.js index dfee05b..7502d13 100644 --- a/test/blobs.js +++ b/test/blobs.js @@ -1,11 +1,11 @@ const test = require('brittle') const b4a = require('b4a') -const RAM = require('random-access-memory') +const tmp = require('test-tmp') const Corestore = require('corestore') const { testBlobServer, request, testHyperblobs } = require('./helpers') test('can get blob from hypercore', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const blobs = testHyperblobs(t, store) @@ -21,7 +21,7 @@ test('can get blob from hypercore', async function (t) { }) test('can get encrypted blob from hypercore', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const blobs = testHyperblobs(t, store) @@ -41,7 +41,7 @@ test('can get encrypted blob from hypercore', async function (t) { }) test('can get blob from hypercore - multiple blocks', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const blobs = testHyperblobs(t, store) blobs.blockSize = 4 // force multiple blocks @@ -59,7 +59,7 @@ test('can get blob from hypercore - multiple blocks', async function (t) { }) test('can get a partial blob from hypercore', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const blobs = testHyperblobs(t, store) @@ -74,7 +74,7 @@ test('can get a partial blob from hypercore', async function (t) { }) test('can get a partial blob from hypercore, but request the whole data', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const blobs = testHyperblobs(t, store) @@ -89,7 +89,7 @@ test('can get a partial blob from hypercore, but request the whole data', async }) test('handle out of range header end', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const blobs = testHyperblobs(t, store) @@ -104,7 +104,7 @@ test('handle out of range header end', async function (t) { }) test('handle range header without end', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const blobs = testHyperblobs(t, store) @@ -119,7 +119,7 @@ test('handle range header without end', async function (t) { }) test('handle invalid range header', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const blobs = testHyperblobs(t, store) diff --git a/test/drives.js b/test/drives.js index b0154a8..970abfb 100644 --- a/test/drives.js +++ b/test/drives.js @@ -1,11 +1,11 @@ const test = require('brittle') const b4a = require('b4a') -const RAM = require('random-access-memory') +const tmp = require('test-tmp') const Corestore = require('corestore') const { testHyperdrive, testBlobServer, request, get } = require('./helpers') test('can get file from hyperdrive', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const drive = testHyperdrive(t, store) await drive.put('/file.txt', 'Here') @@ -19,7 +19,7 @@ test('can get file from hyperdrive', async function (t) { }) test('can get versioned file from hyperdrive', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const drive = testHyperdrive(t, store) await drive.put('/file.txt', 'Here') @@ -36,7 +36,7 @@ test('can get versioned file from hyperdrive', async function (t) { }) test('404 if file not found', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const drive = testHyperdrive(t, store) await drive.put('/file.txt', 'Here') @@ -50,7 +50,7 @@ test('404 if file not found', async function (t) { }) test('404 if token is invalid', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const drive = testHyperdrive(t, store) await drive.put('/file.txt', 'Here') @@ -66,7 +66,7 @@ test('404 if token is invalid', async function (t) { }) test('sending request while suspended', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const drive = testHyperdrive(t, store) await drive.put('/file.txt', 'Here') @@ -85,7 +85,7 @@ test('sending request while suspended', async function (t) { }) test('sending request after resume', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const drive = testHyperdrive(t, store) await drive.put('/file.txt', 'Here') @@ -102,7 +102,7 @@ test('sending request after resume', async function (t) { }) test('can get encrypted blob from hyperdrive', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const drive = testHyperdrive(t, store, { encryptionKey: b4a.alloc(32) }) await drive.put('/file.txt', 'Here') @@ -120,7 +120,7 @@ test('can get encrypted blob from hyperdrive', async function (t) { }) test('can select a file for full download', async function (t) { - const store = new Corestore(RAM) + const store = new Corestore(await tmp()) const drive = testHyperdrive(t, store, { encryptionKey: b4a.alloc(32) }) await drive.put('/file.txt', 'Here')