Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before(async () => {
rmrf.sync(ipfsConfig1.repo)
rmrf.sync(ipfsConfig2.repo)
rmrf.sync(identityKeysPath)
rmrf.sync(signingKeysPath)
await fs.copy(identityKeyFixtures, identityKeysPath)
await fs.copy(signingKeyFixtures, signingKeysPath)
// Start two IPFS instances
ipfs1 = await startIpfs(IPFS, ipfsConfig1)
ipfs2 = await startIpfs(IPFS, ipfsConfig2)
await connectPeers(ipfs1, ipfs2)
// Get the peer IDs
id1 = await getIpfsPeerId(ipfs1)
id2 = await getIpfsPeerId(ipfs2)
// Use mem-store for faster testing (no disk IO)
const memstore = new MemStore()
ipfs1.dag.put = memstore.put.bind(memstore)
ipfs1.dag.get = memstore.get.bind(memstore)
ipfs2.dag.put = memstore.put.bind(memstore)
ipfs2.dag.get = memstore.get.bind(memstore)
keystore = new Keystore(identityKeysPath)
signingKeystore = new Keystore(signingKeysPath)
before(async () => {
rmrf.sync(ipfsConfig1.repo)
rmrf.sync(ipfsConfig2.repo)
rmrf.sync(identityKeysPath)
rmrf.sync(signingKeysPath)
await fs.copy(identityKeyFixtures, identityKeysPath)
await fs.copy(signingKeyFixtures, signingKeysPath)
// Start two IPFS instances
ipfs1 = await startIpfs(IPFS, ipfsConfig1)
ipfs2 = await startIpfs(IPFS, ipfsConfig2)
await connectPeers(ipfs1, ipfs2)
// Get the peer IDs
id1 = await getIpfsPeerId(ipfs1)
id2 = await getIpfsPeerId(ipfs2)
// Use mem-store for faster testing (no disk IO)
const memstore = new MemStore()
ipfs1.dag.put = memstore.put.bind(memstore)
ipfs1.dag.get = memstore.get.bind(memstore)
ipfs2.dag.put = memstore.put.bind(memstore)
ipfs2.dag.get = memstore.get.bind(memstore)
keystore = new Keystore(identityKeysPath)
const Cache = require('orbit-db-cache')
const Keystore = require('orbit-db-keystore')
const IdentityProvider = require('orbit-db-identity-provider')
const DefaultOptions = Store.DefaultOptions
// Test utils
const {
config,
testAPIs,
startIpfs,
stopIpfs,
implementations
} = require('orbit-db-test-utils')
const properLevelModule = implementations.filter(i => i.key.indexOf('memdown') > -1).map(i => i.module)[0]
const storage = require('orbit-db-storage-adapter')(properLevelModule)
Object.keys(testAPIs).forEach((IPFS) => {
describe(`Constructor ${IPFS}`, function () {
let ipfs, identityProvider, testIdentity, identityStore, store, storeWithCache, cacheStore
this.timeout(config.timeout)
const ipfsConfig = Object.assign({}, config.defaultIpfsConfig, {
repo: config.defaultIpfsConfig.repo + '-entry' + new Date().getTime()
})
before(async () => {
identityStore = await storage.createStore('identity')
const keystore = new Keystore(identityStore)
const Cache = require('orbit-db-cache')
const Keystore = require('orbit-db-keystore')
const IdentityProvider = require('orbit-db-identity-provider')
const DefaultOptions = Store.DefaultOptions
// Test utils
const {
config,
testAPIs,
startIpfs,
stopIpfs,
implementations
} = require('orbit-db-test-utils')
const properLevelModule = implementations.filter(i => i.key.indexOf('memdown') > -1).map(i => i.module)[0]
const storage = require('orbit-db-storage-adapter')(properLevelModule)
Object.keys(testAPIs).forEach((IPFS) => {
describe(`Snapshots ${IPFS}`, function () {
let ipfs, testIdentity, identityStore, store, cacheStore
this.timeout(config.timeout)
const ipfsConfig = Object.assign({}, config.defaultIpfsConfig, {
repo: config.defaultIpfsConfig.repo + '-entry' + new Date().getTime()
})
before(async () => {
identityStore = await storage.createStore('identity')
const keystore = new Keystore(identityStore)
const Cache = require('orbit-db-cache')
const Keystore = require('orbit-db-keystore')
const IdentityProvider = require('orbit-db-identity-provider')
const DefaultOptions = Store.DefaultOptions
// Test utils
const {
config,
testAPIs,
startIpfs,
stopIpfs,
implementations
} = require('orbit-db-test-utils')
const properLevelModule = implementations.filter(i => i.key.indexOf('memdown') > -1).map(i => i.module)[0]
const storage = require('orbit-db-storage-adapter')(properLevelModule)
Object.keys(testAPIs).forEach((IPFS) => {
describe(`addOperation ${IPFS}`, function () {
let ipfs, testIdentity, identityStore, store, cacheStore
this.timeout(config.timeout)
const ipfsConfig = Object.assign({}, config.defaultIpfsConfig, {
repo: config.defaultIpfsConfig.repo + '-entry' + new Date().getTime()
})
before(async () => {
identityStore = await storage.createStore('identity')
const keystore = new Keystore(identityStore)
rmrf.sync(signingKeysPath)
await fs.copy(identityKeyFixtures, identityKeysPath)
await fs.copy(signingKeyFixtures, signingKeysPath)
// Start two IPFS instances
ipfs1 = await startIpfs(IPFS, ipfsConfig1)
ipfs2 = await startIpfs(IPFS, ipfsConfig2)
await connectPeers(ipfs1, ipfs2)
// Get the peer IDs
id1 = await getIpfsPeerId(ipfs1)
id2 = await getIpfsPeerId(ipfs2)
// Use mem-store for faster testing (no disk IO)
const memstore = new MemStore()
ipfs1.dag.put = memstore.put.bind(memstore)
ipfs1.dag.get = memstore.get.bind(memstore)
ipfs2.dag.put = memstore.put.bind(memstore)
ipfs2.dag.get = memstore.get.bind(memstore)
keystore = new Keystore(identityKeysPath)
signingKeystore = new Keystore(signingKeysPath)
// Create an identity for each peers
testIdentity = await IdentityProvider.createIdentity({ id: 'userB', keystore, signingKeystore })
testIdentity2 = await IdentityProvider.createIdentity({ id: 'userA', keystore, signingKeystore })
})
describe('ipfs-log - Replication (' + IPFS + ')', function () {
this.timeout(config.timeout)
let ipfs1, ipfs2, id1, id2, testIdentity, testIdentity2
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath, signingKeysPath } = config
const ipfsConfig1 = Object.assign({}, config.daemon1, {
repo: config.daemon1.repo + new Date().getTime()
})
const ipfsConfig2 = Object.assign({}, config.daemon2, {
repo: config.daemon2.repo + new Date().getTime()
})
let keystore, signingKeystore
before(async () => {
rmrf.sync(ipfsConfig1.repo)
rmrf.sync(ipfsConfig2.repo)
rmrf.sync(identityKeysPath)
rmrf.sync(signingKeysPath)
await fs.copy(identityKeyFixtures, identityKeysPath)
await fs.copy(signingKeyFixtures, signingKeysPath)
// Start two IPFS instances
ipfs1 = await startIpfs(IPFS, ipfsConfig1)
ipfs2 = await startIpfs(IPFS, ipfsConfig2)
describe('ipfs-log - Replication (' + IPFS + ')', function () {
this.timeout(config.timeout)
let ipfs1, ipfs2, id1, id2, testIdentity, testIdentity2
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath, signingKeysPath } = config
const ipfsConfig1 = Object.assign({}, config.daemon1, {
repo: config.daemon1.repo + new Date().getTime()
})
const ipfsConfig2 = Object.assign({}, config.daemon2, {
repo: config.daemon2.repo + new Date().getTime()
})
let keystore, signingKeystore
before(async () => {
rmrf.sync(ipfsConfig1.repo)
rmrf.sync(ipfsConfig2.repo)
rmrf.sync(identityKeysPath)
rmrf.sync(signingKeysPath)
await fs.copy(identityKeyFixtures, identityKeysPath)
await fs.copy(signingKeyFixtures, signingKeysPath)
// Start two IPFS instances
ipfs1 = await startIpfs(IPFS, ipfsConfig1)
rmrf.sync(ipfsConfig2.repo)
rmrf.sync(identityKeysPath)
rmrf.sync(signingKeysPath)
await fs.copy(identityKeyFixtures, identityKeysPath)
await fs.copy(signingKeyFixtures, signingKeysPath)
// Start two IPFS instances
ipfs1 = await startIpfs(IPFS, ipfsConfig1)
ipfs2 = await startIpfs(IPFS, ipfsConfig2)
await connectPeers(ipfs1, ipfs2)
// Get the peer IDs
id1 = await getIpfsPeerId(ipfs1)
id2 = await getIpfsPeerId(ipfs2)
// Use mem-store for faster testing (no disk IO)
const memstore = new MemStore()
ipfs1.dag.put = memstore.put.bind(memstore)
ipfs1.dag.get = memstore.get.bind(memstore)
ipfs2.dag.put = memstore.put.bind(memstore)
ipfs2.dag.get = memstore.get.bind(memstore)
keystore = new Keystore(identityKeysPath)
signingKeystore = new Keystore(signingKeysPath)
// Create an identity for each peers
testIdentity = await IdentityProvider.createIdentity({ id: 'userB', keystore, signingKeystore })
testIdentity2 = await IdentityProvider.createIdentity({ id: 'userA', keystore, signingKeystore })
})
rmrf.sync(ipfsConfig1.repo)
rmrf.sync(ipfsConfig2.repo)
rmrf.sync(identityKeysPath)
rmrf.sync(signingKeysPath)
await fs.copy(identityKeyFixtures, identityKeysPath)
await fs.copy(signingKeyFixtures, signingKeysPath)
// Start two IPFS instances
ipfs1 = await startIpfs(IPFS, ipfsConfig1)
ipfs2 = await startIpfs(IPFS, ipfsConfig2)
await connectPeers(ipfs1, ipfs2)
// Get the peer IDs
id1 = await getIpfsPeerId(ipfs1)
id2 = await getIpfsPeerId(ipfs2)
// Use mem-store for faster testing (no disk IO)
const memstore = new MemStore()
ipfs1.dag.put = memstore.put.bind(memstore)
ipfs1.dag.get = memstore.get.bind(memstore)
ipfs2.dag.put = memstore.put.bind(memstore)
ipfs2.dag.get = memstore.get.bind(memstore)
keystore = new Keystore(identityKeysPath)
signingKeystore = new Keystore(signingKeysPath)
// Create an identity for each peers
testIdentity = await IdentityProvider.createIdentity({ id: 'userB', keystore, signingKeystore })
testIdentity2 = await IdentityProvider.createIdentity({ id: 'userA', keystore, signingKeystore })
})