Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('enabled', () => {
let nodeA
const datastore = new MemoryStore()
before(function (done) {
createNode('/ip4/0.0.0.0/tcp/0', {
datastore
}, (err, node) => {
expect(err).to.not.exist()
nodeA = node
// Rewrite validators
nodeA._dht.validators.v = {
func (key, publicKey, callback) {
setImmediate(callback)
},
sign: false
}
it('can be created', async () => {
const ipfs = {
id () {
return {
id: 'replica id'
}
},
_repo: {
datastore: new MemoryDatastore()
}
}
const collaboration = {
name: 'shared test collaboration'
}
const store = new Store(ipfs, collaboration, storeOptions)
await store.start()
const keys = await Keys.generate()
shared = await Shared('name', 'replica id', CRDT('fake'), {}, store, keys)
store.setShared(shared)
})
it('introduces another pusher', async () => {
const ipfs = {
id () {
return { id: 'pusher 2' }
},
_peerInfo: fakePeerInfoFor('pusher 2'),
_repo: {
datastore: new MemoryDatastore()
}
}
const collaboration = { name: 'collaboration protocol test' }
pusher2.store = new Store(ipfs, collaboration, storeOptions)
await pusher2.store.start()
const clocks = new Clocks()
const replication = Replication(ipfs.id().id, clocks)
pusher2.protocol = Protocol(ipfs, collaboration, pusher2.store, null, clocks, replication)
pusher2.shared = await Shared(null, 'pusher 2', Type, collaboration, pusher2.store, keys)
pusher2.store.setShared(pusher2.shared)
})
])
peerIdA = pubsubA.peerInfo.id
peerIdB = pubsubB.peerInfo.id
await connectPubsubNodes(
{
router: pubsubA,
registrar: registrarRecordA
},
{
router: pubsubB,
registrar: registrarRecordB
})
datastoreA = new MemoryDatastore()
datastoreB = new MemoryDatastore()
})
createPubsubNode(registrarRecordB)
])
peerIdA = pubsubA.peerInfo.id
peerIdB = pubsubB.peerInfo.id
await connectPubsubNodes(
{
router: pubsubA,
registrar: registrarRecordA
},
{
router: pubsubB,
registrar: registrarRecordB
})
datastoreA = new MemoryDatastore()
datastoreB = new MemoryDatastore()
})
Discovery: {
MDNS: {
Enabled: false
},
webRTCStar: {
Enabled: false
}
},
EXPERIMENTAL: {
dht: false,
pubsub: false
}
})
}
}
datastore = new MemoryStore()
peerBook = new PeerBook()
PeerInfo.create((err, pi) => {
peerInfo = pi
done(err)
})
})
export async function getCID(files: ContentServiceFile[], shareRoot: boolean): Promise {
const importer = new Importer(new MemoryDatastore(), { onlyHash: true })
return new Promise((resolve, reject) => {
pull(
pull.values(files),
pull.asyncMap((file: ContentServiceFile, cb: any) => {
const data = {
path: shareRoot ? '/tmp/' + file.path : file.path,
content: file.content
}
cb(null, data)
}),
importer,
pull.onEnd(() => {
return importer.flush((err: any, content: any) => {
if (err) {
reject(err)
}