UNPKG

@web4/bitdrive

Version:

Bitdrive is a secure, real time distributed file system

49 lines (44 loc) 1.32 kB
const test = require('tape') const ram = require('random-access-memory') const Chainstore = require('@web4/chainstore') const Replicator = require('./helpers/replicator') const create = require('./helpers/create') test('single-file download and clear', t => { const r = new Replicator(t) const drive1 = create() var drive2 = null drive1.ready(err => { t.error(err, 'no error') drive2 = create(drive1.key) drive2.ready(err => { t.error(err, 'no error') r.replicate(drive1, drive2) onready() }) }) function onready () { drive1.writeFile('hello', 'world', err => { t.error(err, 'no error') setImmediate(() => { drive2.stats('hello', (err, totals) => { t.error(err, 'no error') t.same(totals.blocks, 1) t.same(totals.downloadedBlocks, 0) drive2.download('hello', err => { t.error(err) drive2.stats('hello', (err, totals) => { t.same(totals.downloadedBlocks, 1) drive2.clear('hello', (err) => { t.error(err) drive2.stats('hello', (err, totals) => { t.same(totals.downloadedBlocks, 0) r.end() }) }) }) }) }) }) }) } })