From 58e623e30ac72043a4454aedf1277621aaaa93d3 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Thu, 14 Mar 2019 10:41:11 -0700 Subject: [PATCH] test: minor, cleanup and clarity --- test/blockstore-test.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/test/blockstore-test.js b/test/blockstore-test.js index dd84f159..cc7525c7 100644 --- a/test/blockstore-test.js +++ b/test/blockstore-test.js @@ -492,6 +492,10 @@ describe('BlockStore', function() { await store.close(); }); + after(async () => { + await rimraf(location); + }); + it('will write and read a block', async () => { const block1 = random.randomBytes(128); const hash = random.randomBytes(32); @@ -567,7 +571,8 @@ describe('BlockStore', function() { assert.equal(second.size, 952); assert.equal(third.size, 272); - const len = first.size + second.size + third.size - (8 * 16); + const magic = (8 * 16); + const len = first.size + second.size + third.size - magic; assert.equal(len, 128 * 16); for (let i = 0; i < 16; i++) { @@ -596,7 +601,8 @@ describe('BlockStore', function() { assert.equal(second.size, 952); assert.equal(third.size, 272); - const len = first.size + second.size + third.size - (8 * 16); + const magic = (8 * 16); + const len = first.size + second.size + third.size - magic; assert.equal(len, 128 * 16); for (let i = 0; i < 16; i++) { @@ -726,7 +732,8 @@ describe('BlockStore', function() { const second = await fs.stat(store.filepath(types.BLOCK, 1)); const third = await fs.stat(store.filepath(types.BLOCK, 2)); - const len = first.size + second.size + third.size - (8 * 16); + const magic = (8 * 16); + const len = first.size + second.size + third.size - magic; assert.equal(len, 128 * 16); for (let i = 0; i < 16; i++) { @@ -760,7 +767,8 @@ describe('BlockStore', function() { const second = await fs.stat(store.filepath(types.UNDO, 1)); const third = await fs.stat(store.filepath(types.UNDO, 2)); - const len = first.size + second.size + third.size - (8 * 16); + const magic = (8 * 16); + const len = first.size + second.size + third.size - magic; assert.equal(len, 128 * 16); for (let i = 0; i < 16; i++) { @@ -802,6 +810,10 @@ describe('BlockStore', function() { await store.close(); }); + after(async () => { + await rimraf(location); + }); + it('will import from files (e.g. db corruption)', async () => { const blocks = []; @@ -853,6 +865,10 @@ describe('BlockStore', function() { await store.close(); }); + after(async () => { + await rimraf(location); + }); + it('will write and read a block', async () => { const block1 = random.randomBytes(128); const hash = random.randomBytes(32);