From c7dd79bda8978c771e7158b326628eac9b82c317 Mon Sep 17 00:00:00 2001 From: haad Date: Thu, 28 Apr 2016 21:41:14 +0200 Subject: [PATCH] Cleanup --- src/oplog/OperationsLog.js | 1 + src/stores/counters/CounterIndex.js | 3 +-- test/client.test.js | 20 ++++++++++---------- test/counterdb.test.js | 1 - 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/oplog/OperationsLog.js b/src/oplog/OperationsLog.js index ba0d5ce..7b4d3c8 100644 --- a/src/oplog/OperationsLog.js +++ b/src/oplog/OperationsLog.js @@ -28,6 +28,7 @@ class OperationsLog { return this._log.add(entry) .then((op) => node = op) .then(() => { + // Add the hash of the log entry to the payload Object.assign(node.payload, { hash: node.hash }); if(node.payload.key === null) Object.assign(node.payload, { key: node.hash }); diff --git a/src/stores/counters/CounterIndex.js b/src/stores/counters/CounterIndex.js index 87f70ff..05ca89a 100644 --- a/src/stores/counters/CounterIndex.js +++ b/src/stores/counters/CounterIndex.js @@ -18,8 +18,7 @@ class CounterIndex { updateIndex(oplog, updated) { const counter = this._index[oplog.dbname]; if(counter) { - updated - .filter((f) => f && f.op === 'COUNTER') + updated.filter((f) => f && f.op === 'COUNTER') .map((f) => Counter.from(f.value)) .forEach((f) => counter.merge(f)) diff --git a/test/client.test.js b/test/client.test.js index d4b9c74..28b62b5 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -540,16 +540,6 @@ describe('Orbit Client', function() { done(); }); - it('put', async((done) => { - const db2 = await(client2.kvstore(channel, false)); - await(db.put('key1', 'hello1')); - await(db2.put('key1', 'hello2')); - await(db.sync('QmNtELU2N3heY9cFgRuLWavgov7NTXibNyZCxcTCYjw1TM')) - const value = db.get('key1'); - assert.equal(value, 'hello2'); - done(); - })); - it('put', async((done) => { await(db.put('key1', 'hello!')); const value = db.get('key1'); @@ -625,5 +615,15 @@ describe('Orbit Client', function() { assert.equal(_.isEqual(v1, val), true); done(); })); + + it('syncs databases', async((done) => { + const db2 = await(client2.kvstore(channel, false)); + await(db.put('key1', 'hello1')); + await(db2.put('key1', 'hello2')); + await(db.sync('QmNtELU2N3heY9cFgRuLWavgov7NTXibNyZCxcTCYjw1TM')) + const value = db.get('key1'); + assert.equal(value, 'hello2'); + done(); + })); }); }); diff --git a/test/counterdb.test.js b/test/counterdb.test.js index 791f713..d24ac14 100644 --- a/test/counterdb.test.js +++ b/test/counterdb.test.js @@ -92,7 +92,6 @@ describe('CounterStore', function() { it('syncs counters', (done) => { const name = new Date().getTime(); Promise.all([client1.counter(name), client2.counter(name)]).then((counters) => { - // Promise.all([client1.counter(name)]).then((counters) => { const res1 = Promise.map([13, 10], (f) => counters[0].inc(f), { concurrency: 1 }); const res2 = Promise.map([2, 5], (f) => counters[1].inc(f), { concurrency: 1 }) Promise.all([res1, res2]).then((res) => {