This commit is contained in:
haad 2016-04-28 21:41:14 +02:00
parent 06ee3ebf31
commit c7dd79bda8
4 changed files with 12 additions and 13 deletions

View File

@ -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 });

View File

@ -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))

View File

@ -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();
}));
});
});

View File

@ -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) => {