mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
Remove ipfsDaemon dep from Client. Remove orbit-common dependency.
This commit is contained in:
parent
59c8f8d5b7
commit
2c6d9d7101
@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const ipfsDaemon = require('orbit-common/lib/ipfs-daemon');
|
||||
const logger = require('logplease').create("orbit-db.Client");
|
||||
const PubSub = require('./PubSub');
|
||||
const OrbitDB = require('./OrbitDB');
|
||||
@ -139,11 +138,11 @@ class OrbitClientFactory {
|
||||
options = options ? options : {};
|
||||
|
||||
if(!ipfs) {
|
||||
logger.debug("IPFS instance not provided, starting one");
|
||||
return ipfsDaemon().then((ipfsd) => createClient(ipfsd.ipfs));
|
||||
} else {
|
||||
return createClient(ipfs);
|
||||
logger.error("IPFS instance not provided");
|
||||
throw new Error("IPFS instance not provided");
|
||||
}
|
||||
|
||||
return createClient(ipfs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ const path = require('path');
|
||||
const assert = require('assert');
|
||||
const async = require('asyncawait/async');
|
||||
const await = require('asyncawait/await');
|
||||
const ipfsd = require('ipfsd-ctl');
|
||||
const OrbitClient = require('../src/Client');
|
||||
|
||||
// Mute logging
|
||||
@ -14,18 +15,35 @@ require('logplease').setLogLevel('ERROR');
|
||||
const username = 'testrunner';
|
||||
const password = '';
|
||||
|
||||
const startIpfs = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
ipfsd.disposableApi((err, ipfs) => {
|
||||
if(err) console.error(err);
|
||||
resolve(ipfs);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
describe('Orbit Client', function() {
|
||||
this.timeout(3000);
|
||||
|
||||
let client, db;
|
||||
let ipfs, client, db;
|
||||
let channel = 'abcdefgh';
|
||||
const cacheFile = path.join(process.cwd(), '/test', 'orbit-db-test-cache.json');
|
||||
|
||||
before(async(function (done) {
|
||||
this.timeout(20000);
|
||||
client = await(OrbitClient.connect('localhost', 3333, username, password, null, { allowOffline: true }));
|
||||
db = await(client.channel(channel, '', false));
|
||||
db.delete();
|
||||
|
||||
try {
|
||||
ipfs = await(startIpfs());
|
||||
client = await(OrbitClient.connect('localhost', 3333, username, password, ipfs, { allowOffline: true }));
|
||||
db = await(client.channel(channel, '', false));
|
||||
db.delete();
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
assert.equal(e, null);
|
||||
}
|
||||
|
||||
done();
|
||||
}));
|
||||
|
||||
|
@ -6,9 +6,9 @@ const path = require('path');
|
||||
const assert = require('assert');
|
||||
const async = require('asyncawait/async');
|
||||
const await = require('asyncawait/await');
|
||||
const ipfsDaemon = require('orbit-common/lib/ipfs-daemon');
|
||||
const OrbitDB = require('../src/OrbitDB');
|
||||
const ipfsd = require('ipfsd-ctl');
|
||||
const Log = require('ipfs-log');
|
||||
const OrbitDB = require('../src/OrbitDB');
|
||||
|
||||
// Mute logging
|
||||
require('logplease').setLogLevel('ERROR');
|
||||
@ -18,17 +18,25 @@ const username = 'testrunner';
|
||||
const password = '';
|
||||
const user = { username: username };
|
||||
|
||||
const startIpfs = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
ipfsd.disposableApi((err, ipfs) => {
|
||||
if(err) console.error(err);
|
||||
resolve(ipfs);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
describe('OrbitDB', function() {
|
||||
this.timeout(3000);
|
||||
|
||||
let db, ipfs;
|
||||
let ipfs, db;
|
||||
let channel = 'orbit-db.test';
|
||||
|
||||
before(async(function(done) {
|
||||
this.timeout(20000);
|
||||
try {
|
||||
const daemon = await(ipfsDaemon());
|
||||
ipfs = daemon.ipfs;
|
||||
ipfs = await(startIpfs());
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
assert.equal(e, null);
|
||||
@ -36,6 +44,10 @@ describe('OrbitDB', function() {
|
||||
done();
|
||||
}));
|
||||
|
||||
after(() => {
|
||||
if(db) db.delete();
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
it('sets defaults', async((done) => {
|
||||
db = new OrbitDB(ipfs);
|
||||
|
Loading…
x
Reference in New Issue
Block a user