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
|
||||
- Tests for remove(), put() and get()
|
||||
- Local caching of messages
|
||||
|
@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('asyncawait/async');
|
||||
var OrbitClient = require('../OrbitClient');
|
||||
var Timer = require('../Timer');
|
||||
var OrbitClient = require('../src/OrbitClient');
|
||||
var Timer = require('../src/Timer');
|
||||
|
||||
var host = 'localhost:3006';
|
||||
var username = 'testrunner';
|
||||
|
@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('asyncawait/async');
|
||||
var OrbitClient = require('../OrbitClient');
|
||||
var Timer = require('../Timer');
|
||||
var OrbitClient = require('../src/OrbitClient');
|
||||
var Timer = require('../src/Timer');
|
||||
|
||||
var host = 'localhost:3006';
|
||||
var username = 'testrunner';
|
||||
|
16
package.json
16
package.json
@ -1,16 +1,13 @@
|
||||
{
|
||||
"name": "orbit-client",
|
||||
"version": "1.0.0",
|
||||
"description": "A client module to communicate with an Orbit network",
|
||||
"main": "OrbitClient.js",
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "0.1.0",
|
||||
"description": "Event Log and KeyValue Store on IPFS",
|
||||
"author": "Haad",
|
||||
"license": "ISC",
|
||||
"license": "MIT",
|
||||
"engines" : {
|
||||
"node" : "^4.x.x"
|
||||
},
|
||||
},
|
||||
"main": "src/OrbitClient.js",
|
||||
"dependencies": {
|
||||
"asyncawait": "^1.0.1",
|
||||
"bluebird": "^3.1.1",
|
||||
@ -20,5 +17,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^2.3.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class OrbitClient {
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
},
|
||||
next: () => {
|
||||
next() {
|
||||
let item = { value: null, done: true };
|
||||
if(currentIndex < messages.length) {
|
||||
item = { value: messages[currentIndex], done: false };
|
||||
@ -81,7 +81,7 @@ class OrbitClient {
|
||||
if(lt || lte) {
|
||||
startFromHash = lte ? lte : lt;
|
||||
} 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;
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
var assert = require('assert');
|
||||
var async = require('asyncawait/async');
|
||||
var await = require('asyncawait/await');
|
||||
var encryption = require('../Encryption');
|
||||
var OrbitClient = require('../OrbitClient');
|
||||
var encryption = require('../src/Encryption');
|
||||
var OrbitClient = require('../src/OrbitClient');
|
||||
|
||||
// var mockServerAddresses = [
|
||||
// "localhost",
|
||||
@ -35,7 +35,7 @@ describe('Orbit Client', () => {
|
||||
let head = '';
|
||||
let second = '';
|
||||
let items = [];
|
||||
let channel = 'abcde';
|
||||
let channel = 'abcdefgh';
|
||||
|
||||
before(function(done) {
|
||||
// logger.setLevel('ERROR');
|
||||
@ -58,7 +58,7 @@ describe('Orbit Client', () => {
|
||||
// }
|
||||
var start = () => new Promise(async((resolve, reject) => {
|
||||
orbit = OrbitClient.connect(host, username, password);
|
||||
// orbit.channel(channel, 'hello').setMode({ mode: "-r" })
|
||||
orbit.channel(channel, '').delete();
|
||||
resolve();
|
||||
}));
|
||||
start().then(done);
|
||||
@ -157,6 +157,7 @@ describe('Orbit Client', () => {
|
||||
describe('Insert', function() {
|
||||
it('adds an item to an empty channel', async((done) => {
|
||||
try {
|
||||
orbit.channel(channel, '').delete();
|
||||
head = orbit.channel(channel, '').add('hello');
|
||||
assert.notEqual(head, null);
|
||||
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) => {
|
||||
try {
|
||||
var v = orbit.channel(channel, '').iterator().collect();
|
||||
second = orbit.channel(channel, '').add('hello');
|
||||
assert.notEqual(second, null);
|
||||
assert.notEqual(second, head);
|
||||
@ -526,7 +528,7 @@ describe('Orbit Client', () => {
|
||||
|
||||
it('can\'t read with wrong password', async((done) => {
|
||||
try {
|
||||
var modes = orbit.channel(channel, '').iterator();
|
||||
var modes = orbit.channel(channel, 'invalidpassword').iterator();
|
||||
assert.equal(true, false);
|
||||
} catch(e) {
|
||||
assert.equal(e, 'Unauthorized');
|
||||
|
Loading…
x
Reference in New Issue
Block a user