mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
Move source files to src/. Update package.json.
This commit is contained in:
parent
2bfa82e3e8
commit
3901e15260
13
README.md
13
README.md
@ -99,6 +99,19 @@ async(() => {
|
|||||||
})();
|
})();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Development
|
||||||
|
#### Run Tests
|
||||||
|
*Note! Before running tests, make sure orbit-server is running*
|
||||||
|
|
||||||
|
```
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
Keep tests running while development:
|
||||||
|
```
|
||||||
|
mocha -w
|
||||||
|
```
|
||||||
|
|
||||||
### TODO
|
### TODO
|
||||||
- Tests for remove(), put() and get()
|
- Tests for remove(), put() and get()
|
||||||
- Local caching of messages
|
- Local caching of messages
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('asyncawait/async');
|
var async = require('asyncawait/async');
|
||||||
var OrbitClient = require('../OrbitClient');
|
var OrbitClient = require('../src/OrbitClient');
|
||||||
var Timer = require('../Timer');
|
var Timer = require('../src/Timer');
|
||||||
|
|
||||||
var host = 'localhost:3006';
|
var host = 'localhost:3006';
|
||||||
var username = 'testrunner';
|
var username = 'testrunner';
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('asyncawait/async');
|
var async = require('asyncawait/async');
|
||||||
var OrbitClient = require('../OrbitClient');
|
var OrbitClient = require('../src/OrbitClient');
|
||||||
var Timer = require('../Timer');
|
var Timer = require('../src/Timer');
|
||||||
|
|
||||||
var host = 'localhost:3006';
|
var host = 'localhost:3006';
|
||||||
var username = 'testrunner';
|
var username = 'testrunner';
|
||||||
|
14
package.json
14
package.json
@ -1,16 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "orbit-client",
|
"name": "orbit-client",
|
||||||
"version": "1.0.0",
|
"version": "0.1.0",
|
||||||
"description": "A client module to communicate with an Orbit network",
|
"description": "Event Log and KeyValue Store on IPFS",
|
||||||
"main": "OrbitClient.js",
|
|
||||||
"scripts": {
|
|
||||||
"test": "mocha"
|
|
||||||
},
|
|
||||||
"author": "Haad",
|
"author": "Haad",
|
||||||
"license": "ISC",
|
"license": "MIT",
|
||||||
"engines" : {
|
"engines" : {
|
||||||
"node" : "^4.x.x"
|
"node" : "^4.x.x"
|
||||||
},
|
},
|
||||||
|
"main": "src/OrbitClient.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"asyncawait": "^1.0.1",
|
"asyncawait": "^1.0.1",
|
||||||
"bluebird": "^3.1.1",
|
"bluebird": "^3.1.1",
|
||||||
@ -20,5 +17,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"mocha": "^2.3.4"
|
"mocha": "^2.3.4"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class OrbitClient {
|
|||||||
[Symbol.iterator]() {
|
[Symbol.iterator]() {
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
next: () => {
|
next() {
|
||||||
let item = { value: null, done: true };
|
let item = { value: null, done: true };
|
||||||
if(currentIndex < messages.length) {
|
if(currentIndex < messages.length) {
|
||||||
item = { value: messages[currentIndex], done: false };
|
item = { value: messages[currentIndex], done: false };
|
||||||
@ -81,7 +81,7 @@ class OrbitClient {
|
|||||||
if(lt || lte) {
|
if(lt || lte) {
|
||||||
startFromHash = lte ? lte : lt;
|
startFromHash = lte ? lte : lt;
|
||||||
} else {
|
} else {
|
||||||
var channel = await (this.client.linkedList(channel, password).head())
|
var channel = await (this.client.linkedList(channel, password).head());
|
||||||
startFromHash = channel.head ? channel.head : null;
|
startFromHash = channel.head ? channel.head : null;
|
||||||
}
|
}
|
||||||
|
|
@ -3,8 +3,8 @@
|
|||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var async = require('asyncawait/async');
|
var async = require('asyncawait/async');
|
||||||
var await = require('asyncawait/await');
|
var await = require('asyncawait/await');
|
||||||
var encryption = require('../Encryption');
|
var encryption = require('../src/Encryption');
|
||||||
var OrbitClient = require('../OrbitClient');
|
var OrbitClient = require('../src/OrbitClient');
|
||||||
|
|
||||||
// var mockServerAddresses = [
|
// var mockServerAddresses = [
|
||||||
// "localhost",
|
// "localhost",
|
||||||
@ -35,7 +35,7 @@ describe('Orbit Client', () => {
|
|||||||
let head = '';
|
let head = '';
|
||||||
let second = '';
|
let second = '';
|
||||||
let items = [];
|
let items = [];
|
||||||
let channel = 'abcde';
|
let channel = 'abcdefgh';
|
||||||
|
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
// logger.setLevel('ERROR');
|
// logger.setLevel('ERROR');
|
||||||
@ -58,7 +58,7 @@ describe('Orbit Client', () => {
|
|||||||
// }
|
// }
|
||||||
var start = () => new Promise(async((resolve, reject) => {
|
var start = () => new Promise(async((resolve, reject) => {
|
||||||
orbit = OrbitClient.connect(host, username, password);
|
orbit = OrbitClient.connect(host, username, password);
|
||||||
// orbit.channel(channel, 'hello').setMode({ mode: "-r" })
|
orbit.channel(channel, '').delete();
|
||||||
resolve();
|
resolve();
|
||||||
}));
|
}));
|
||||||
start().then(done);
|
start().then(done);
|
||||||
@ -157,6 +157,7 @@ describe('Orbit Client', () => {
|
|||||||
describe('Insert', function() {
|
describe('Insert', function() {
|
||||||
it('adds an item to an empty channel', async((done) => {
|
it('adds an item to an empty channel', async((done) => {
|
||||||
try {
|
try {
|
||||||
|
orbit.channel(channel, '').delete();
|
||||||
head = orbit.channel(channel, '').add('hello');
|
head = orbit.channel(channel, '').add('hello');
|
||||||
assert.notEqual(head, null);
|
assert.notEqual(head, null);
|
||||||
assert.equal(head.startsWith('Qm'), true);
|
assert.equal(head.startsWith('Qm'), true);
|
||||||
@ -169,6 +170,7 @@ describe('Orbit Client', () => {
|
|||||||
|
|
||||||
it('adds a new item to a channel with one item', async((done) => {
|
it('adds a new item to a channel with one item', async((done) => {
|
||||||
try {
|
try {
|
||||||
|
var v = orbit.channel(channel, '').iterator().collect();
|
||||||
second = orbit.channel(channel, '').add('hello');
|
second = orbit.channel(channel, '').add('hello');
|
||||||
assert.notEqual(second, null);
|
assert.notEqual(second, null);
|
||||||
assert.notEqual(second, head);
|
assert.notEqual(second, head);
|
||||||
@ -526,7 +528,7 @@ describe('Orbit Client', () => {
|
|||||||
|
|
||||||
it('can\'t read with wrong password', async((done) => {
|
it('can\'t read with wrong password', async((done) => {
|
||||||
try {
|
try {
|
||||||
var modes = orbit.channel(channel, '').iterator();
|
var modes = orbit.channel(channel, 'invalidpassword').iterator();
|
||||||
assert.equal(true, false);
|
assert.equal(true, false);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
assert.equal(e, 'Unauthorized');
|
assert.equal(e, 'Unauthorized');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user