var osmdb = require('osm-p2p-db')
var memdb = require('memdb')
var hyperlog = require('hyperlog')
var memstore = require('memory-chunk-store')

var slowdb = require('./slowdb.js')

var DELAY = process.env.OSM_P2P_DB_DELAY

function testDb (cb) {
  return osmdb({
    db: DELAY ? slowdb({delay: DELAY}) : memdb(),
    log: hyperlog(memdb(), { valueEncoding: 'json' }),
    store: memstore(4096)
  })
}

module.exports = testDb

var kosm = require('kappa-osm')
var kcore = require('kappa-core')
var memdb = require('memdb')
var ram = require('random-access-memory')

var slowdb = require('./slowdb.js')

var DELAY = process.env.OSM_P2P_DB_DELAY

function testDb (cb) {
  return kosm({
    index: DELAY ? slowdb({delay: DELAY}) : memdb(),
    core: kcore(ram, { valueEncoding: 'json' }),
    storage: function (name, cb) { cb(null, ram()) }
  })
}

module.exports = testDb

update test_db to use kappa-osm