mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-25 07:22:29 +00:00
Merge pull request #18 from orbitdb/dev/fix-oplog-tests
Clean up oplog tests
This commit is contained in:
commit
a4fb12c65b
@ -458,4 +458,4 @@ const Log = async (identity, { logId, logHeads, access, entryStorage, headsStora
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Log as default, DefaultAccessController }
|
export { Log as default, DefaultAccessController, Clock }
|
||||||
|
@ -11,7 +11,6 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
describe('DocumentStore Database (' + IPFS + ')', function () {
|
describe('DocumentStore Database (' + IPFS + ')', function () {
|
||||||
let ipfsd
|
let ipfsd
|
||||||
let ipfs
|
let ipfs
|
||||||
let keystore, signingKeyStore
|
|
||||||
let accessController
|
let accessController
|
||||||
let identities1
|
let identities1
|
||||||
let testIdentity1
|
let testIdentity1
|
||||||
|
@ -13,7 +13,6 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
describe('EventStore Database (' + IPFS + ')', function () {
|
describe('EventStore Database (' + IPFS + ')', function () {
|
||||||
let ipfsd
|
let ipfsd
|
||||||
let ipfs
|
let ipfs
|
||||||
let keystore, signingKeyStore
|
|
||||||
let accessController
|
let accessController
|
||||||
let identities1
|
let identities1
|
||||||
let testIdentity1
|
let testIdentity1
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { deepStrictEqual } from 'assert'
|
import { deepStrictEqual } from 'assert'
|
||||||
import rmrf from 'rimraf'
|
import rmrf from 'rimraf'
|
||||||
import { Log, Entry } from '../../../src/index.js'
|
import { Log, Entry, Database } from '../../../src/index.js'
|
||||||
import { DocumentStore } from '../../../src/db/index.js'
|
import { DocumentStore } from '../../../src/db/index.js'
|
||||||
import { Database } from '../../../src/index.js'
|
|
||||||
import { config, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
import { config, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
||||||
import connectPeers from '../../utils/connect-nodes.js'
|
import connectPeers from '../../utils/connect-nodes.js'
|
||||||
import { createTestIdentities, cleanUpTestIdentities } from '../../fixtures/orbit-db-identity-keys.js'
|
import { createTestIdentities, cleanUpTestIdentities } from '../../fixtures/orbit-db-identity-keys.js'
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { deepStrictEqual } from 'assert'
|
import { deepStrictEqual } from 'assert'
|
||||||
import rmrf from 'rimraf'
|
import rmrf from 'rimraf'
|
||||||
import { Log, Entry } from '../../../src/index.js'
|
import { Log, Entry, Database } from '../../../src/index.js'
|
||||||
import { EventStore } from '../../../src/db/index.js'
|
import { EventStore } from '../../../src/db/index.js'
|
||||||
import { Database } from '../../../src/index.js'
|
|
||||||
import { config, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
import { config, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
||||||
import connectPeers from '../../utils/connect-nodes.js'
|
import connectPeers from '../../utils/connect-nodes.js'
|
||||||
import waitFor from '../../utils/wait-for.js'
|
import waitFor from '../../utils/wait-for.js'
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { deepStrictEqual } from 'assert'
|
import { deepStrictEqual } from 'assert'
|
||||||
import rmrf from 'rimraf'
|
import rmrf from 'rimraf'
|
||||||
import { Log, Entry } from '../../../src/index.js'
|
import { Log, Entry, Database } from '../../../src/index.js'
|
||||||
import { KeyValue, KeyValuePersisted } from '../../../src/db/index.js'
|
import { KeyValue, KeyValuePersisted } from '../../../src/db/index.js'
|
||||||
import { Database } from '../../../src/index.js'
|
|
||||||
import { config, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
import { config, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
||||||
import connectPeers from '../../utils/connect-nodes.js'
|
import connectPeers from '../../utils/connect-nodes.js'
|
||||||
import waitFor from '../../utils/wait-for.js'
|
import waitFor from '../../utils/wait-for.js'
|
||||||
|
@ -1,44 +1,30 @@
|
|||||||
import { strictEqual, deepStrictEqual } from 'assert'
|
import { strictEqual, deepStrictEqual } from 'assert'
|
||||||
import rimraf from 'rimraf'
|
import rmrf from 'rimraf'
|
||||||
import { copy } from 'fs-extra'
|
import { copy } from 'fs-extra'
|
||||||
import { Log } from '../../src/oplog/index.js'
|
import { Log, Identities, KeyStore } from '../../src/index.js'
|
||||||
import MemoryStorage from '../../src/storage/memory.js'
|
import testKeysPath from '../fixtures/test-keys-path.js '
|
||||||
import LevelStorage from '../../src/storage/level.js'
|
|
||||||
import { Identities } from '../../src/identities/index.js'
|
|
||||||
import KeyStore from '../../src/key-store.js'
|
|
||||||
|
|
||||||
// Test utils
|
const keysPath = './testkeys'
|
||||||
import { config, testAPIs } from 'orbit-db-test-utils'
|
|
||||||
|
|
||||||
const { sync: rmrf } = rimraf
|
describe('Log - Append', function () {
|
||||||
|
this.timeout(5000)
|
||||||
let testIdentity
|
|
||||||
|
|
||||||
Object.keys(testAPIs).forEach((IPFS) => {
|
|
||||||
describe('Log - Append (' + IPFS + ')', function () {
|
|
||||||
this.timeout(config.timeout)
|
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
|
||||||
|
|
||||||
let keystore
|
let keystore
|
||||||
let identities
|
let identities
|
||||||
|
let testIdentity
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
rmrf(identityKeysPath)
|
await copy(testKeysPath, keysPath)
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
keystore = await KeyStore({ path: keysPath })
|
||||||
await copy(signingKeyFixtures, identityKeysPath)
|
identities = await Identities({ keystore })
|
||||||
|
|
||||||
keystore = await KeyStore({ storage: await LevelStorage({ path: identityKeysPath }) })
|
|
||||||
|
|
||||||
const storage = await MemoryStorage()
|
|
||||||
|
|
||||||
identities = await Identities({ keystore, storage })
|
|
||||||
testIdentity = await identities.createIdentity({ id: 'userA' })
|
testIdentity = await identities.createIdentity({ id: 'userA' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
rmrf(identityKeysPath)
|
}
|
||||||
|
await rmrf(keysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('append', async () => {
|
describe('append', async () => {
|
||||||
@ -131,4 +117,3 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -1,27 +1,22 @@
|
|||||||
import { strictEqual, deepStrictEqual } from 'assert'
|
import { strictEqual, deepStrictEqual } from 'assert'
|
||||||
import rimraf from 'rimraf'
|
import rmrf from 'rimraf'
|
||||||
import { Log } from '../../src/oplog/index.js'
|
import { copy } from 'fs-extra'
|
||||||
import { Identities } from '../../src/identities/index.js'
|
import { Log, Identities, KeyStore } from '../../src/index.js'
|
||||||
import KeyStore from '../../src/key-store.js'
|
|
||||||
import { config, testAPIs } from 'orbit-db-test-utils'
|
|
||||||
import testKeysPath from '../fixtures/test-keys-path.js '
|
import testKeysPath from '../fixtures/test-keys-path.js '
|
||||||
|
|
||||||
const { sync: rmrf } = rimraf
|
const keysPath = './testkeys'
|
||||||
|
|
||||||
let testIdentity, testIdentity2, testIdentity3
|
let testIdentity, testIdentity2, testIdentity3
|
||||||
|
|
||||||
Object.keys(testAPIs).forEach((IPFS) => {
|
describe('Log - CRDT', function () {
|
||||||
describe('Log - CRDT (' + IPFS + ')', function () {
|
this.timeout(5000)
|
||||||
this.timeout(config.timeout)
|
|
||||||
|
|
||||||
const { identityKeysPath } = config
|
|
||||||
|
|
||||||
let keystore
|
let keystore
|
||||||
let identities1
|
let identities1
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
keystore = await KeyStore({ path: testKeysPath })
|
await copy(testKeysPath, keysPath)
|
||||||
|
keystore = await KeyStore({ path: keysPath })
|
||||||
identities1 = await Identities({ keystore })
|
identities1 = await Identities({ keystore })
|
||||||
testIdentity = await identities1.createIdentity({ id: 'userA' })
|
testIdentity = await identities1.createIdentity({ id: 'userA' })
|
||||||
testIdentity2 = await identities1.createIdentity({ id: 'userB' })
|
testIdentity2 = await identities1.createIdentity({ id: 'userB' })
|
||||||
@ -29,8 +24,10 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
rmrf(identityKeysPath)
|
}
|
||||||
|
await rmrf(keysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('is a CRDT', async () => {
|
describe('is a CRDT', async () => {
|
||||||
@ -243,4 +240,3 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -1,54 +1,38 @@
|
|||||||
import { strictEqual, deepStrictEqual } from 'assert'
|
import { strictEqual, deepStrictEqual } from 'assert'
|
||||||
import rimraf from 'rimraf'
|
import rmrf from 'rimraf'
|
||||||
import { copy } from 'fs-extra'
|
import { copy } from 'fs-extra'
|
||||||
import { Entry } from '../../src/oplog/index.js'
|
import { Entry, Identities, KeyStore } from '../../src/index.js'
|
||||||
import { Identities } from '../../src/identities/index.js'
|
|
||||||
import KeyStore from '../../src/key-store.js'
|
|
||||||
import { config, testAPIs, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
|
||||||
import testKeysPath from '../fixtures/test-keys-path.js '
|
import testKeysPath from '../fixtures/test-keys-path.js '
|
||||||
|
|
||||||
const { sync: rmrf } = rimraf
|
|
||||||
const { create, isEntry } = Entry
|
const { create, isEntry } = Entry
|
||||||
|
const keysPath = './testkeys'
|
||||||
|
|
||||||
Object.keys(testAPIs).forEach((IPFS) => {
|
describe('Entry', function () {
|
||||||
describe('Entry (' + IPFS + ')', function () {
|
this.timeout(5000)
|
||||||
this.timeout(config.timeout)
|
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
|
||||||
|
|
||||||
let keystore
|
let keystore
|
||||||
let identities
|
let identities
|
||||||
let testIdentity
|
let testIdentity
|
||||||
let ipfsd, ipfs
|
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
ipfsd = await startIpfs(IPFS, config.daemon1)
|
await copy(testKeysPath, keysPath)
|
||||||
ipfs = ipfsd.api
|
keystore = await KeyStore({ path: keysPath })
|
||||||
|
identities = await Identities({ keystore })
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
|
||||||
await copy(signingKeyFixtures, identityKeysPath)
|
|
||||||
|
|
||||||
keystore = await KeyStore({ path: testKeysPath })
|
|
||||||
|
|
||||||
identities = await Identities({ keystore, ipfs })
|
|
||||||
testIdentity = await identities.createIdentity({ id: 'userA' })
|
testIdentity = await identities.createIdentity({ id: 'userA' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
|
|
||||||
if (ipfsd) {
|
|
||||||
await stopIpfs(ipfsd)
|
|
||||||
}
|
}
|
||||||
|
await rmrf(keysPath)
|
||||||
rmrf(identityKeysPath)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('create', () => {
|
describe('create', () => {
|
||||||
it('creates a an empty entry', async () => {
|
it('creates a an empty entry', async () => {
|
||||||
// const expectedHash = 'zdpuAsqjGLA4aAGiSNYeTE5zH6e5ayRpgiZrfN2d3UpmzEF76'
|
const expectedHash = 'zdpuApShn2wbu8aDWJhmzBtLWmoVF5VBbVVtuszMpscmiUgrH'
|
||||||
const entry = await create(testIdentity, 'A', 'hello')
|
const entry = await create(testIdentity, 'A', 'hello')
|
||||||
// strictEqual(entry.hash, expectedHash)
|
strictEqual(entry.hash, expectedHash)
|
||||||
strictEqual(entry.id, 'A')
|
strictEqual(entry.id, 'A')
|
||||||
strictEqual(entry.clock.id, testIdentity.publicKey)
|
strictEqual(entry.clock.id, testIdentity.publicKey)
|
||||||
strictEqual(entry.clock.time, 0)
|
strictEqual(entry.clock.time, 0)
|
||||||
@ -59,9 +43,10 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('creates a entry with payload', async () => {
|
it('creates a entry with payload', async () => {
|
||||||
// const expectedHash = 'zdpuB2uuvoKD9cmBV8ET5R9KeytY1Jq72LNQrjEpuEyZURP5Q'
|
const expectedHash = 'zdpuApKrG9gBpxSqNRQ1Zq8zkkVTS1GQxYoCkXKtDvuNKv4WB'
|
||||||
const payload = 'hello world'
|
const payload = 'hello world'
|
||||||
const entry = await create(testIdentity, 'A', payload)
|
const entry = await create(testIdentity, 'A', payload)
|
||||||
|
strictEqual(entry.hash, expectedHash)
|
||||||
strictEqual(entry.payload, payload)
|
strictEqual(entry.payload, payload)
|
||||||
strictEqual(entry.id, 'A')
|
strictEqual(entry.id, 'A')
|
||||||
strictEqual(entry.clock.id, testIdentity.publicKey)
|
strictEqual(entry.clock.id, testIdentity.publicKey)
|
||||||
@ -69,7 +54,6 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
strictEqual(entry.v, 2)
|
strictEqual(entry.v, 2)
|
||||||
strictEqual(entry.next.length, 0)
|
strictEqual(entry.next.length, 0)
|
||||||
strictEqual(entry.refs.length, 0)
|
strictEqual(entry.refs.length, 0)
|
||||||
// strictEqual(entry.hash, expectedHash)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('retrieves the identity from an entry', async () => {
|
it('retrieves the identity from an entry', async () => {
|
||||||
@ -198,4 +182,3 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -1,46 +1,34 @@
|
|||||||
import { strictEqual, deepStrictEqual } from 'assert'
|
import { strictEqual, deepStrictEqual } from 'assert'
|
||||||
import rimraf from 'rimraf'
|
import rmrf from 'rimraf'
|
||||||
import { copy } from 'fs-extra'
|
import { copy } from 'fs-extra'
|
||||||
import { Log } from '../../src/oplog/index.js'
|
import { Log, Identities, KeyStore } from '../../src/index.js'
|
||||||
import { Identities } from '../../src/identities/index.js'
|
|
||||||
import KeyStore from '../../src/key-store.js'
|
|
||||||
import MemoryStorage from '../../src/storage/memory.js'
|
|
||||||
import { config, testAPIs } from 'orbit-db-test-utils'
|
|
||||||
import testKeysPath from '../fixtures/test-keys-path.js '
|
import testKeysPath from '../fixtures/test-keys-path.js '
|
||||||
|
|
||||||
const { sync: rmrf } = rimraf
|
const keysPath = './testkeys'
|
||||||
|
|
||||||
let testIdentity
|
|
||||||
|
|
||||||
const last = (arr) => {
|
const last = (arr) => {
|
||||||
return arr[arr.length - 1]
|
return arr[arr.length - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(testAPIs).forEach((IPFS) => {
|
describe('Log - Heads', function () {
|
||||||
describe('Log - Heads (' + IPFS + ')', function () {
|
this.timeout(5000)
|
||||||
this.timeout(config.timeout)
|
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
|
||||||
|
|
||||||
let keystore
|
let keystore
|
||||||
let identities
|
let identities
|
||||||
|
let testIdentity
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
rmrf(identityKeysPath)
|
await copy(testKeysPath, keysPath)
|
||||||
|
keystore = await KeyStore({ path: keysPath })
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
identities = await Identities({ keystore })
|
||||||
await copy(signingKeyFixtures, identityKeysPath)
|
|
||||||
|
|
||||||
keystore = await KeyStore({ path: testKeysPath })
|
|
||||||
const storage = await MemoryStorage()
|
|
||||||
|
|
||||||
identities = await Identities({ keystore, storage })
|
|
||||||
testIdentity = await identities.createIdentity({ id: 'userA' })
|
testIdentity = await identities.createIdentity({ id: 'userA' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
rmrf(identityKeysPath)
|
}
|
||||||
|
await rmrf(keysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finds one head after one entry', async () => {
|
it('finds one head after one entry', async () => {
|
||||||
@ -181,4 +169,3 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
deepStrictEqual(heads[2].hash, expectedHead3.hash)
|
deepStrictEqual(heads[2].hash, expectedHead3.hash)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -1,61 +1,38 @@
|
|||||||
import { strictEqual, deepStrictEqual } from 'assert'
|
import { strictEqual, deepStrictEqual } from 'assert'
|
||||||
import rimraf from 'rimraf'
|
|
||||||
import { Log } from '../../src/oplog/index.js'
|
|
||||||
import { Identities } from '../../src/identities/index.js'
|
|
||||||
import KeyStore from '../../src/key-store.js'
|
|
||||||
import LogCreator from './utils/log-creator.js'
|
|
||||||
import all from 'it-all'
|
import all from 'it-all'
|
||||||
import MemoryStorage from '../../src/storage/memory.js'
|
import rmrf from 'rimraf'
|
||||||
import LevelStorage from '../../src/storage/level.js'
|
import { copy } from 'fs-extra'
|
||||||
|
import { Log, Identities, KeyStore } from '../../src/index.js'
|
||||||
|
import LogCreator from './utils/log-creator.js'
|
||||||
|
import testKeysPath from '../fixtures/test-keys-path.js '
|
||||||
|
|
||||||
// Test utils
|
|
||||||
import { config, testAPIs, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
|
||||||
import { identityKeys, signingKeys } from '../fixtures/orbit-db-identity-keys.js'
|
|
||||||
|
|
||||||
const { sync: rmrf } = rimraf
|
|
||||||
const { createLogWithSixteenEntries } = LogCreator
|
const { createLogWithSixteenEntries } = LogCreator
|
||||||
|
|
||||||
Object.keys(testAPIs).forEach((IPFS) => {
|
const keysPath = './testkeys'
|
||||||
describe('Log - Iterator (' + IPFS + ')', function () {
|
|
||||||
this.timeout(config.timeout)
|
describe('Log - Iterator', function () {
|
||||||
|
this.timeout(5000)
|
||||||
|
|
||||||
let ipfs
|
|
||||||
let ipfsd
|
|
||||||
let keystore
|
let keystore
|
||||||
let identities1, identities2, identities3
|
let identities1, identities2, identities3
|
||||||
let testIdentity, testIdentity2, testIdentity3
|
let testIdentity, testIdentity2, testIdentity3
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
keystore = await KeyStore({ storage: await LevelStorage({ path: './keys_1', valueEncoding: 'json' }) })
|
await copy(testKeysPath, keysPath)
|
||||||
|
keystore = await KeyStore({ path: keysPath })
|
||||||
for (const [key, value] of Object.entries(identityKeys)) {
|
identities1 = await Identities({ keystore })
|
||||||
await keystore.addKey(key, value)
|
identities2 = await Identities({ keystore })
|
||||||
}
|
identities3 = await Identities({ keystore })
|
||||||
for (const [key, value] of Object.entries(signingKeys)) {
|
testIdentity = await identities1.createIdentity({ id: 'userC' })
|
||||||
await keystore.addKey(key, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
const storage = await MemoryStorage()
|
|
||||||
|
|
||||||
identities1 = await Identities({ keystore, storage })
|
|
||||||
identities2 = await Identities({ keystore, storage })
|
|
||||||
identities3 = await Identities({ keystore, storage })
|
|
||||||
testIdentity = await identities1.createIdentity({ id: 'userA' })
|
|
||||||
testIdentity2 = await identities2.createIdentity({ id: 'userB' })
|
testIdentity2 = await identities2.createIdentity({ id: 'userB' })
|
||||||
testIdentity3 = await identities3.createIdentity({ id: 'userC' })
|
testIdentity3 = await identities3.createIdentity({ id: 'userC' })
|
||||||
|
|
||||||
ipfsd = await startIpfs(IPFS, config.defaultIpfsConfig)
|
|
||||||
ipfs = ipfsd.api
|
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
if (ipfsd) {
|
|
||||||
await stopIpfs(ipfsd)
|
|
||||||
}
|
|
||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
rmrf('./keys_1')
|
await rmrf(keysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Basic iterator functionality', async () => {
|
describe('Basic iterator functionality', async () => {
|
||||||
@ -410,7 +387,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
identities = [testIdentity3, testIdentity2, testIdentity3, testIdentity]
|
identities = [testIdentity3, testIdentity2, testIdentity3, testIdentity]
|
||||||
fixture = await createLogWithSixteenEntries(Log, ipfs, identities)
|
fixture = await createLogWithSixteenEntries(Log, null, identities)
|
||||||
heads = await fixture.log.heads()
|
heads = await fixture.log.heads()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -487,4 +464,3 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -1,29 +1,31 @@
|
|||||||
import { strictEqual, deepStrictEqual } from 'assert'
|
import { strictEqual, deepStrictEqual } from 'assert'
|
||||||
import { Log } from '../../src/oplog/index.js'
|
import rmrf from 'rimraf'
|
||||||
import { Identities } from '../../src/identities/index.js'
|
import { copy } from 'fs-extra'
|
||||||
import KeyStore from '../../src/key-store.js'
|
import { Log, Identities, KeyStore } from '../../src/index.js'
|
||||||
import { config, testAPIs } from 'orbit-db-test-utils'
|
|
||||||
import testKeysPath from '../fixtures/test-keys-path.js '
|
import testKeysPath from '../fixtures/test-keys-path.js '
|
||||||
|
|
||||||
let testIdentity, testIdentity2
|
const keysPath = './testkeys'
|
||||||
|
|
||||||
Object.keys(testAPIs).forEach(IPFS => {
|
describe('Log - Join Concurrent Entries', function () {
|
||||||
describe('Log - Join Concurrent Entries (' + IPFS + ')', function () {
|
this.timeout(5000)
|
||||||
this.timeout(config.timeout)
|
|
||||||
|
|
||||||
let keystore
|
let keystore
|
||||||
let identities1
|
let identities1
|
||||||
|
let testIdentity, testIdentity2
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
keystore = await KeyStore({ path: testKeysPath })
|
await copy(testKeysPath, keysPath)
|
||||||
|
keystore = await KeyStore({ path: keysPath })
|
||||||
identities1 = await Identities({ keystore })
|
identities1 = await Identities({ keystore })
|
||||||
testIdentity = await identities1.createIdentity({ id: 'userA' })
|
testIdentity = await identities1.createIdentity({ id: 'userA' })
|
||||||
testIdentity2 = await identities1.createIdentity({ id: 'userB' })
|
testIdentity2 = await identities1.createIdentity({ id: 'userB' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
|
}
|
||||||
|
await rmrf(keysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('join ', async () => {
|
describe('join ', async () => {
|
||||||
@ -83,4 +85,3 @@ Object.keys(testAPIs).forEach(IPFS => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -1,24 +1,18 @@
|
|||||||
import { strictEqual, notStrictEqual, deepStrictEqual } from 'assert'
|
import { strictEqual, notStrictEqual, deepStrictEqual } from 'assert'
|
||||||
import rimraf from 'rimraf'
|
import rmrf from 'rimraf'
|
||||||
import { Log, Clock } from '../../src/oplog/index.js'
|
import { copy } from 'fs-extra'
|
||||||
import { Identities } from '../../src/identities/index.js'
|
import { Log, Identities, KeyStore } from '../../src/index.js'
|
||||||
import KeyStore from '../../src/key-store.js'
|
import { Clock } from '../../src/oplog/log.js'
|
||||||
import LevelStorage from '../../src/storage/level.js'
|
import testKeysPath from '../fixtures/test-keys-path.js '
|
||||||
import MemoryStorage from '../../src/storage/memory.js'
|
|
||||||
|
|
||||||
// Test utils
|
const keysPath = './testkeys'
|
||||||
import { config, testAPIs } from 'orbit-db-test-utils'
|
|
||||||
import { identityKeys, signingKeys } from '../fixtures/orbit-db-identity-keys.js'
|
|
||||||
|
|
||||||
const { sync: rmrf } = rimraf
|
|
||||||
|
|
||||||
const last = (arr) => {
|
const last = (arr) => {
|
||||||
return arr[arr.length - 1]
|
return arr[arr.length - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(testAPIs).forEach((IPFS) => {
|
describe('Log - Join', async function () {
|
||||||
describe('Log - Join (' + IPFS + ')', async function () {
|
this.timeout(5000)
|
||||||
this.timeout(config.timeout)
|
|
||||||
|
|
||||||
let keystore
|
let keystore
|
||||||
let log1, log2, log3, log4
|
let log1, log2, log3, log4
|
||||||
@ -26,32 +20,23 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
let testIdentity, testIdentity2, testIdentity3, testIdentity4
|
let testIdentity, testIdentity2, testIdentity3, testIdentity4
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
keystore = await KeyStore({ storage: await LevelStorage({ path: './keys_1', valueEncoding: 'json' }) })
|
await copy(testKeysPath, keysPath)
|
||||||
|
keystore = await KeyStore({ path: keysPath })
|
||||||
for (const [key, value] of Object.entries(identityKeys)) {
|
identities1 = await Identities({ keystore })
|
||||||
await keystore.addKey(key, value)
|
identities2 = await Identities({ keystore })
|
||||||
}
|
identities3 = await Identities({ keystore })
|
||||||
for (const [key, value] of Object.entries(signingKeys)) {
|
identities4 = await Identities({ keystore })
|
||||||
await keystore.addKey(key, value)
|
testIdentity = await identities1.createIdentity({ id: 'userX' })
|
||||||
}
|
testIdentity2 = await identities2.createIdentity({ id: 'userA' })
|
||||||
|
testIdentity3 = await identities3.createIdentity({ id: 'userB' })
|
||||||
const storage = await MemoryStorage()
|
testIdentity4 = await identities4.createIdentity({ id: 'userC' })
|
||||||
|
|
||||||
identities1 = await Identities({ keystore, storage })
|
|
||||||
identities2 = await Identities({ keystore, storage })
|
|
||||||
identities3 = await Identities({ keystore, storage })
|
|
||||||
identities4 = await Identities({ keystore, storage })
|
|
||||||
testIdentity = await identities1.createIdentity({ id: 'userC' })
|
|
||||||
testIdentity2 = await identities2.createIdentity({ id: 'userB' })
|
|
||||||
testIdentity3 = await identities3.createIdentity({ id: 'userD' })
|
|
||||||
testIdentity4 = await identities4.createIdentity({ id: 'userA' })
|
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
rmrf('./keys_1')
|
await rmrf(keysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@ -441,4 +426,3 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
deepStrictEqual(values.map((e) => e.payload), expectedData)
|
deepStrictEqual(values.map((e) => e.payload), expectedData)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -2,9 +2,8 @@ import { strictEqual, deepStrictEqual, notStrictEqual, throws } from 'assert'
|
|||||||
import rimraf from 'rimraf'
|
import rimraf from 'rimraf'
|
||||||
import { copy } from 'fs-extra'
|
import { copy } from 'fs-extra'
|
||||||
import { Log, Entry, Sorting } from '../../src/oplog/index.js'
|
import { Log, Entry, Sorting } from '../../src/oplog/index.js'
|
||||||
|
import { Identities, KeyStore } from '../../src/index.js'
|
||||||
import bigLogString from '../fixtures/big-log.fixture.js'
|
import bigLogString from '../fixtures/big-log.fixture.js'
|
||||||
import { Identities } from '../../src/identities/index.js'
|
|
||||||
import KeyStore from '../../src/key-store.js'
|
|
||||||
import LogCreator from './utils/log-creator.js'
|
import LogCreator from './utils/log-creator.js'
|
||||||
import testKeysPath from '../fixtures/test-keys-path.js '
|
import testKeysPath from '../fixtures/test-keys-path.js '
|
||||||
import { config, testAPIs, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
import { config, testAPIs, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
||||||
|
@ -1,42 +1,32 @@
|
|||||||
import { notStrictEqual, deepStrictEqual, strictEqual } from 'assert'
|
import { notStrictEqual, deepStrictEqual, strictEqual } from 'assert'
|
||||||
import rimraf from 'rimraf'
|
import rmrf from 'rimraf'
|
||||||
import { Log, Entry } from '../../src/oplog/index.js'
|
|
||||||
import { Identities } from '../../src/identities/index.js'
|
|
||||||
import KeyStore from '../../src/key-store.js'
|
|
||||||
import { copy } from 'fs-extra'
|
import { copy } from 'fs-extra'
|
||||||
import MemoryStorage from '../../src/storage/memory.js'
|
import { Log, Entry, Identities, KeyStore, MemoryStorage } from '../../src/index.js'
|
||||||
import { config, testAPIs } from 'orbit-db-test-utils'
|
|
||||||
import testKeysPath from '../fixtures/test-keys-path.js '
|
import testKeysPath from '../fixtures/test-keys-path.js '
|
||||||
|
|
||||||
const { sync: rmrf } = rimraf
|
|
||||||
const { create } = Entry
|
const { create } = Entry
|
||||||
|
|
||||||
let testIdentity
|
const keysPath = './testkeys'
|
||||||
|
|
||||||
Object.keys(testAPIs).forEach((IPFS) => {
|
describe('Log', function () {
|
||||||
describe('Log (' + IPFS + ')', function () {
|
this.timeout(5000)
|
||||||
this.timeout(config.timeout)
|
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
|
||||||
|
|
||||||
let keystore
|
let keystore
|
||||||
let identities
|
let identities
|
||||||
|
let testIdentity
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
await copy(testKeysPath, keysPath)
|
||||||
await copy(signingKeyFixtures, identityKeysPath)
|
keystore = await KeyStore({ path: keysPath })
|
||||||
|
identities = await Identities({ keystore })
|
||||||
keystore = await KeyStore({ path: testKeysPath })
|
|
||||||
|
|
||||||
const storage = await MemoryStorage()
|
|
||||||
|
|
||||||
identities = await Identities({ keystore, storage })
|
|
||||||
testIdentity = await identities.createIdentity({ id: 'userA' })
|
testIdentity = await identities.createIdentity({ id: 'userA' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
rmrf(identityKeysPath)
|
}
|
||||||
|
await rmrf(keysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('create', async () => {
|
describe('create', async () => {
|
||||||
@ -154,4 +144,3 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -1,43 +1,31 @@
|
|||||||
import { strictEqual } from 'assert'
|
import { strictEqual } from 'assert'
|
||||||
import rimraf from 'rimraf'
|
import rmrf from 'rimraf'
|
||||||
import { copy } from 'fs-extra'
|
import { copy } from 'fs-extra'
|
||||||
import { Log } from '../../src/oplog/index.js'
|
import { Log } from '../../src/oplog/index.js'
|
||||||
import { Identities } from '../../src/identities/index.js'
|
import { Identities, KeyStore, MemoryStorage } from '../../src/index.js'
|
||||||
import KeyStore from '../../src/key-store.js'
|
|
||||||
import MemoryStorage from '../../src/storage/memory.js'
|
|
||||||
import testKeysPath from '../fixtures/test-keys-path.js '
|
import testKeysPath from '../fixtures/test-keys-path.js '
|
||||||
import { config, testAPIs } from 'orbit-db-test-utils'
|
|
||||||
|
|
||||||
const { sync: rmrf } = rimraf
|
const keysPath = './testkeys'
|
||||||
|
|
||||||
let testIdentity
|
describe('Log - References', function () {
|
||||||
|
this.timeout(60000)
|
||||||
Object.keys(testAPIs).forEach((IPFS) => {
|
|
||||||
describe('Log - References (' + IPFS + ')', function () {
|
|
||||||
this.timeout(config.timeout)
|
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
|
||||||
|
|
||||||
let keystore
|
let keystore
|
||||||
let identities
|
let identities
|
||||||
|
let testIdentity
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
rmrf(identityKeysPath)
|
await copy(testKeysPath, keysPath)
|
||||||
|
keystore = await KeyStore({ path: keysPath })
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
identities = await Identities({ keystore })
|
||||||
await copy(signingKeyFixtures, identityKeysPath)
|
|
||||||
|
|
||||||
keystore = await KeyStore({ path: testKeysPath })
|
|
||||||
|
|
||||||
const storage = await MemoryStorage()
|
|
||||||
|
|
||||||
identities = await Identities({ keystore, storage })
|
|
||||||
testIdentity = await identities.createIdentity({ id: 'userA' })
|
testIdentity = await identities.createIdentity({ id: 'userA' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
rmrf(identityKeysPath)
|
}
|
||||||
|
await rmrf(keysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('References', async () => {
|
describe('References', async () => {
|
||||||
@ -170,4 +158,3 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
import { strictEqual } from 'assert'
|
import { strictEqual } from 'assert'
|
||||||
import { Log, Entry } from '../../src/index.js'
|
import rmrf from 'rimraf'
|
||||||
import { IPFSBlockStorage } from '../../src/storage/index.js'
|
import { copy } from 'fs-extra'
|
||||||
|
import { Log, Entry, Identities, KeyStore, IPFSBlockStorage } from '../../src/index.js'
|
||||||
|
import { config, startIpfs, stopIpfs, getIpfsPeerId, waitForPeers, connectPeers } from 'orbit-db-test-utils'
|
||||||
|
import testKeysPath from '../fixtures/test-keys-path.js '
|
||||||
|
|
||||||
// Test utils
|
const keysPath = './testkeys'
|
||||||
import { config, testAPIs, startIpfs, stopIpfs, getIpfsPeerId, waitForPeers, connectPeers } from 'orbit-db-test-utils'
|
const IPFS = 'js-ipfs'
|
||||||
import { createTestIdentities, cleanUpTestIdentities } from '../fixtures/orbit-db-identity-keys.js'
|
|
||||||
|
|
||||||
Object.keys(testAPIs).forEach((IPFS) => {
|
describe('Log - Replication', function () {
|
||||||
describe('ipfs-log - Replication (' + IPFS + ')', function () {
|
this.timeout(60000)
|
||||||
this.timeout(config.timeout * 2)
|
|
||||||
|
|
||||||
let ipfsd1, ipfsd2
|
let ipfsd1, ipfsd2
|
||||||
let ipfs1, ipfs2
|
let ipfs1, ipfs2
|
||||||
let id1, id2
|
let id1, id2
|
||||||
|
let keystore
|
||||||
let identities1, identities2
|
let identities1, identities2
|
||||||
let testIdentity1, testIdentity2
|
let testIdentity1, testIdentity2
|
||||||
let storage1, storage2
|
let storage1, storage2
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
// Start two IPFS instances
|
|
||||||
ipfsd1 = await startIpfs(IPFS, config.daemon1)
|
ipfsd1 = await startIpfs(IPFS, config.daemon1)
|
||||||
ipfsd2 = await startIpfs(IPFS, config.daemon2)
|
ipfsd2 = await startIpfs(IPFS, config.daemon2)
|
||||||
ipfs1 = ipfsd1.api
|
ipfs1 = ipfsd1.api
|
||||||
@ -27,26 +27,30 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
|
|
||||||
await connectPeers(ipfs1, ipfs2)
|
await connectPeers(ipfs1, ipfs2)
|
||||||
|
|
||||||
// Get the peer IDs
|
|
||||||
id1 = await getIpfsPeerId(ipfs1)
|
id1 = await getIpfsPeerId(ipfs1)
|
||||||
id2 = await getIpfsPeerId(ipfs2)
|
id2 = await getIpfsPeerId(ipfs2)
|
||||||
|
|
||||||
const [identities, testIdentities] = await createTestIdentities(ipfs1, ipfs2)
|
await copy(testKeysPath, keysPath)
|
||||||
identities1 = identities[0]
|
keystore = await KeyStore({ path: keysPath })
|
||||||
identities2 = identities[1]
|
|
||||||
testIdentity2 = testIdentities[0]
|
identities1 = await Identities({ keystore, ipfs: ipfs1 })
|
||||||
testIdentity1 = testIdentities[1]
|
identities2 = await Identities({ keystore, ipfs: ipfs2 })
|
||||||
|
testIdentity1 = await identities1.createIdentity({ id: 'userB' })
|
||||||
|
testIdentity2 = await identities2.createIdentity({ id: 'userA' })
|
||||||
|
|
||||||
storage1 = await IPFSBlockStorage({ ipfs: ipfs1 })
|
storage1 = await IPFSBlockStorage({ ipfs: ipfs1 })
|
||||||
storage2 = await IPFSBlockStorage({ ipfs: ipfs2 })
|
storage2 = await IPFSBlockStorage({ ipfs: ipfs2 })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
await cleanUpTestIdentities([identities1, identities2])
|
|
||||||
await stopIpfs(ipfsd1)
|
await stopIpfs(ipfsd1)
|
||||||
await stopIpfs(ipfsd2)
|
await stopIpfs(ipfsd2)
|
||||||
|
if (keystore) {
|
||||||
|
await keystore.close()
|
||||||
|
}
|
||||||
await storage1.close()
|
await storage1.close()
|
||||||
await storage2.close()
|
await storage2.close()
|
||||||
|
await rmrf(keysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('replicates logs deterministically', async function () {
|
describe('replicates logs deterministically', async function () {
|
||||||
@ -150,4 +154,3 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -1,30 +1,37 @@
|
|||||||
import { notStrictEqual, strictEqual } from 'assert'
|
import { notStrictEqual, strictEqual } from 'assert'
|
||||||
import { Log } from '../../src/oplog/index.js'
|
import rmrf from 'rimraf'
|
||||||
import { config, testAPIs } from 'orbit-db-test-utils'
|
import { copy } from 'fs-extra'
|
||||||
import { createTestIdentities, cleanUpTestIdentities } from '../fixtures/orbit-db-identity-keys.js'
|
import { Log, Identities, KeyStore } from '../../src/index.js'
|
||||||
|
import testKeysPath from '../fixtures/test-keys-path.js '
|
||||||
|
|
||||||
Object.keys(testAPIs).forEach((IPFS) => {
|
const keysPath = './testkeys'
|
||||||
describe('Signed Log (' + IPFS + ')', function () {
|
|
||||||
this.timeout(config.timeout)
|
|
||||||
|
|
||||||
let identities1, identities2
|
describe('Signed Log', function () {
|
||||||
let testIdentity, testIdentity2
|
this.timeout(5000)
|
||||||
|
|
||||||
|
let keystore
|
||||||
|
let identities
|
||||||
|
let testIdentity1, testIdentity2
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
const [identities, testIdentities] = await createTestIdentities()
|
await copy(testKeysPath, keysPath)
|
||||||
identities1 = identities[0]
|
keystore = await KeyStore({ path: keysPath })
|
||||||
identities2 = identities[1]
|
|
||||||
testIdentity = testIdentities[0]
|
identities = await Identities({ keystore })
|
||||||
testIdentity2 = testIdentities[1]
|
testIdentity1 = await identities.createIdentity({ id: 'userB' })
|
||||||
|
testIdentity2 = await identities.createIdentity({ id: 'userA' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
await cleanUpTestIdentities([identities1, identities2])
|
if (keystore) {
|
||||||
|
await keystore.close()
|
||||||
|
}
|
||||||
|
await rmrf(keysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('creates a signed log', async () => {
|
it('creates a signed log', async () => {
|
||||||
const logId = 'A'
|
const logId = 'A'
|
||||||
const log = await Log(testIdentity, { logId })
|
const log = await Log(testIdentity1, { logId })
|
||||||
notStrictEqual(log.id, null)
|
notStrictEqual(log.id, null)
|
||||||
strictEqual(log.id, logId)
|
strictEqual(log.id, logId)
|
||||||
})
|
})
|
||||||
@ -40,18 +47,18 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
// })
|
// })
|
||||||
|
|
||||||
it('has the correct public key', async () => {
|
it('has the correct public key', async () => {
|
||||||
const log = await Log(testIdentity, { logId: 'A' })
|
const log = await Log(testIdentity1, { logId: 'A' })
|
||||||
strictEqual(log.identity.publicKey, testIdentity.publicKey)
|
strictEqual(log.identity.publicKey, testIdentity1.publicKey)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has the correct pkSignature', async () => {
|
it('has the correct pkSignature', async () => {
|
||||||
const log = await Log(testIdentity, { logId: 'A' })
|
const log = await Log(testIdentity1, { logId: 'A' })
|
||||||
strictEqual(log.identity.signatures.id, testIdentity.signatures.id)
|
strictEqual(log.identity.signatures.id, testIdentity1.signatures.id)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has the correct signature', async () => {
|
it('has the correct signature', async () => {
|
||||||
const log = await Log(testIdentity, { logId: 'A' })
|
const log = await Log(testIdentity1, { logId: 'A' })
|
||||||
strictEqual(log.identity.signatures.publicKey, testIdentity.signatures.publicKey)
|
strictEqual(log.identity.signatures.publicKey, testIdentity1.signatures.publicKey)
|
||||||
})
|
})
|
||||||
|
|
||||||
// it('entries contain an identity', async () => {
|
// it('entries contain an identity', async () => {
|
||||||
@ -73,7 +80,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error if log is signed but trying to merge with an entry that doesn\'t have public signing key', async () => {
|
it('throws an error if log is signed but trying to merge with an entry that doesn\'t have public signing key', async () => {
|
||||||
const log1 = await Log(testIdentity, { logId: 'A' })
|
const log1 = await Log(testIdentity1, { logId: 'A' })
|
||||||
const log2 = await Log(testIdentity2, { logId: 'A' })
|
const log2 = await Log(testIdentity2, { logId: 'A' })
|
||||||
|
|
||||||
let err
|
let err
|
||||||
@ -89,7 +96,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error if log is signed but trying to merge an entry that doesn\'t have a signature', async () => {
|
it('throws an error if log is signed but trying to merge an entry that doesn\'t have a signature', async () => {
|
||||||
const log1 = await Log(testIdentity, { logId: 'A' })
|
const log1 = await Log(testIdentity1, { logId: 'A' })
|
||||||
const log2 = await Log(testIdentity2, { logId: 'A' })
|
const log2 = await Log(testIdentity2, { logId: 'A' })
|
||||||
|
|
||||||
let err
|
let err
|
||||||
@ -105,7 +112,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error if log is signed but the signature doesn\'t verify', async () => {
|
it('throws an error if log is signed but the signature doesn\'t verify', async () => {
|
||||||
const log1 = await Log(testIdentity, { logId: 'A' })
|
const log1 = await Log(testIdentity1, { logId: 'A' })
|
||||||
const log2 = await Log(testIdentity2, { logId: 'A' })
|
const log2 = await Log(testIdentity2, { logId: 'A' })
|
||||||
let err
|
let err
|
||||||
|
|
||||||
@ -127,7 +134,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
|
|
||||||
it('throws an error if entry doesn\'t have append access', async () => {
|
it('throws an error if entry doesn\'t have append access', async () => {
|
||||||
const denyAccess = { canAppend: () => false }
|
const denyAccess = { canAppend: () => false }
|
||||||
const log1 = await Log(testIdentity, { logId: 'A' })
|
const log1 = await Log(testIdentity1, { logId: 'A' })
|
||||||
const log2 = await Log(testIdentity2, { logId: 'A', access: denyAccess })
|
const log2 = await Log(testIdentity2, { logId: 'A', access: denyAccess })
|
||||||
|
|
||||||
let err
|
let err
|
||||||
@ -145,11 +152,11 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
it('throws an error upon join if entry doesn\'t have append access', async () => {
|
it('throws an error upon join if entry doesn\'t have append access', async () => {
|
||||||
const testACL = {
|
const testACL = {
|
||||||
canAppend: async (entry) => {
|
canAppend: async (entry) => {
|
||||||
const identity = await identities1.getIdentity(entry.identity)
|
const identity = await identities.getIdentity(entry.identity)
|
||||||
return identity && identity.id !== testIdentity2.id
|
return identity && identity.id !== testIdentity2.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const log1 = await Log(testIdentity, { logId: 'A', access: testACL })
|
const log1 = await Log(testIdentity1, { logId: 'A', access: testACL })
|
||||||
const log2 = await Log(testIdentity2, { logId: 'A' })
|
const log2 = await Log(testIdentity2, { logId: 'A' })
|
||||||
|
|
||||||
let err
|
let err
|
||||||
@ -164,4 +171,3 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
strictEqual(err, `Error: Could not append entry:\nKey "${testIdentity2.hash}" is not allowed to write to the log`)
|
strictEqual(err, `Error: Could not append entry:\nKey "${testIdentity2.hash}" is not allowed to write to the log`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user