Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('write a file', function (t) {
var lines = ['a\n', 'b\n', 'c\n'].map(Buffer)
var file = '/tmp/test-pfs-write'
pull(
pull.values(lines),
pfs.write(file, function (err) {
if(err) throw err
fs.readFile(file, 'utf-8', function (err, data) {
if(err) throw err
t.equal(data, lines.join(''))
t.end()
})
})
)
})
tape('add, size', function (t) {
pull(
pull.values(random1),
blobs.add(function (err, hash) {
if(err) throw err
t.equal(hash, hash1)
blobs.size(hash, function (_, size) {
t.equal(size, 100*1024)
t.end()
})
})
)
})
function hasher (ary) {
var hasher = util.createHash(alg, true)
pull(pull.values(ary), hasher, pull.drain())
return util.encode(hasher.digest, alg)
}
function upto (opts) {
opts = opts || {}
var ary = Object.keys(toSend).map(function (k) {
return { id: k, sequence: toSend[k] }
})
if (opts.live) {
return Cat([pull.values(ary), pull.once({sync: true}), newPeer.listen()])
}
return pull.values(ary)
}
function upto (opts) {
opts = opts || {}
var ary = Object.keys(replicate).map(function (k) {
return { id: k, sequence: toSend[k]||0 }
})
if(opts.live)
return Cat([
pull.values(ary),
pull.once({sync: true}),
newPeers.listen()
])
return pull.values(ary)
}