mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-06 22:26:41 +00:00
Merge identity keys and signing keys keystores
This commit is contained in:
parent
0caa34afcb
commit
f84915fca8
1
Makefile
1
Makefile
@ -18,7 +18,6 @@ build: test
|
|||||||
@echo "Output: 'dist/', 'examples/browser/'"
|
@echo "Output: 'dist/', 'examples/browser/'"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf orbitdb/
|
|
||||||
rm -rf node_modules/
|
rm -rf node_modules/
|
||||||
rm -f test/browser/identities.js
|
rm -f test/browser/identities.js
|
||||||
rm -f test/browser/ipfs.js
|
rm -f test/browser/ipfs.js
|
||||||
|
@ -15,9 +15,8 @@ const supportedTypes = {
|
|||||||
// [EthIdentityProvider.type]: EthIdentityProvider
|
// [EthIdentityProvider.type]: EthIdentityProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
const Identities = async ({ keystore, signingKeyStore, identityKeysPath, signingKeysPath, storage, ipfs } = {}) => {
|
const Identities = async ({ keystore, identityKeysPath, storage, ipfs } = {}) => {
|
||||||
keystore = keystore || new KeyStore(identityKeysPath || DefaultIdentityKeysPath)
|
keystore = keystore || new KeyStore(identityKeysPath || DefaultIdentityKeysPath)
|
||||||
signingKeyStore = signingKeyStore || (signingKeysPath ? new KeyStore(signingKeysPath) : keystore)
|
|
||||||
storage = storage || (ipfs ? await IPFSBlockStorage({ ipfs, pin: true }) : await MemoryStorage())
|
storage = storage || (ipfs ? await IPFSBlockStorage({ ipfs, pin: true }) : await MemoryStorage())
|
||||||
|
|
||||||
const verifiedIdentitiesCache = await LRUStorage({ size: 1000 })
|
const verifiedIdentitiesCache = await LRUStorage({ size: 1000 })
|
||||||
@ -30,7 +29,7 @@ const Identities = async ({ keystore, signingKeyStore, identityKeysPath, signing
|
|||||||
}
|
}
|
||||||
|
|
||||||
const createIdentity = async (options = {}) => {
|
const createIdentity = async (options = {}) => {
|
||||||
options.keystore = signingKeyStore || keystore
|
options.keystore = keystore
|
||||||
|
|
||||||
const type = options.type || DefaultProviderType
|
const type = options.type || DefaultProviderType
|
||||||
const Provider = getProviderFor(type)
|
const Provider = getProviderFor(type)
|
||||||
@ -99,8 +98,7 @@ const Identities = async ({ keystore, signingKeyStore, identityKeysPath, signing
|
|||||||
getIdentity,
|
getIdentity,
|
||||||
sign,
|
sign,
|
||||||
verify,
|
verify,
|
||||||
keystore,
|
keystore
|
||||||
signingKeyStore
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import { IPFSBlockStorage, LevelStorage } from '../src/storage/index.js'
|
|||||||
// import { config, testAPIs, getIpfsPeerId, waitForPeers, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
// import { config, testAPIs, getIpfsPeerId, waitForPeers, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
||||||
import { config, testAPIs, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
import { config, testAPIs, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
||||||
import connectPeers from './utils/connect-nodes.js'
|
import connectPeers from './utils/connect-nodes.js'
|
||||||
import { identityKeys, signingKeys, createTestIdentities, cleanUpTestIdentities } from './fixtures/orbit-db-identity-keys.js'
|
import { createTestIdentities, cleanUpTestIdentities } from './fixtures/orbit-db-identity-keys.js'
|
||||||
|
|
||||||
const { sync: rmrf } = rimraf
|
const { sync: rmrf } = rimraf
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
|
|
||||||
let ipfsd1, ipfsd2
|
let ipfsd1, ipfsd2
|
||||||
let ipfs1, ipfs2
|
let ipfs1, ipfs2
|
||||||
let keystore, signingKeyStore
|
let keystore
|
||||||
// let peerId1, peerId2
|
// let peerId1, peerId2
|
||||||
let identities1, identities2
|
let identities1, identities2
|
||||||
let testIdentity1, testIdentity2
|
let testIdentity1, testIdentity2
|
||||||
@ -86,9 +86,6 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
if (signingKeyStore) {
|
|
||||||
await signingKeyStore.close()
|
|
||||||
}
|
|
||||||
if (testIdentity1) {
|
if (testIdentity1) {
|
||||||
rmrf(testIdentity1.id)
|
rmrf(testIdentity1.id)
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import { IPFSBlockStorage, LevelStorage } from '../src/storage/index.js'
|
|||||||
import { config, testAPIs, startIpfs, stopIpfs, getIpfsPeerId, waitForPeers } from 'orbit-db-test-utils'
|
import { config, testAPIs, startIpfs, stopIpfs, getIpfsPeerId, waitForPeers } 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'
|
||||||
import { identityKeys, signingKeys, createTestIdentities, cleanUpTestIdentities } from './fixtures/orbit-db-identity-keys.js'
|
import { createTestIdentities, cleanUpTestIdentities } from './fixtures/orbit-db-identity-keys.js'
|
||||||
|
|
||||||
const { sync: rmrf } = rimraf
|
const { sync: rmrf } = rimraf
|
||||||
const { createIdentity } = Identities
|
const { createIdentity } = Identities
|
||||||
@ -23,7 +23,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
|
|
||||||
let ipfsd1, ipfsd2
|
let ipfsd1, ipfsd2
|
||||||
let ipfs1, ipfs2
|
let ipfs1, ipfs2
|
||||||
let keystore, signingKeyStore
|
let keystore
|
||||||
let peerId1, peerId2
|
let peerId1, peerId2
|
||||||
let identities1, identities2
|
let identities1, identities2
|
||||||
let testIdentity1, testIdentity2
|
let testIdentity1, testIdentity2
|
||||||
@ -85,9 +85,6 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
if (signingKeyStore) {
|
|
||||||
await signingKeyStore.close()
|
|
||||||
}
|
|
||||||
if (testIdentity1) {
|
if (testIdentity1) {
|
||||||
rmrf(testIdentity1.id)
|
rmrf(testIdentity1.id)
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import { IPFSBlockStorage, LevelStorage } from '../src/storage/index.js'
|
|||||||
import { config, testAPIs, getIpfsPeerId, waitForPeers, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
import { config, testAPIs, getIpfsPeerId, waitForPeers, 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'
|
||||||
import { identityKeys, signingKeys, createTestIdentities, cleanUpTestIdentities } from './fixtures/orbit-db-identity-keys.js'
|
import { createTestIdentities, cleanUpTestIdentities } from './fixtures/orbit-db-identity-keys.js'
|
||||||
|
|
||||||
const { sync: rmrf } = rimraf
|
const { sync: rmrf } = rimraf
|
||||||
const { createIdentity } = Identities
|
const { createIdentity } = Identities
|
||||||
@ -22,7 +22,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
|
|
||||||
let ipfsd1, ipfsd2
|
let ipfsd1, ipfsd2
|
||||||
let ipfs1, ipfs2
|
let ipfs1, ipfs2
|
||||||
let keystore, signingKeyStore
|
let keystore
|
||||||
let peerId1, peerId2
|
let peerId1, peerId2
|
||||||
let identities1, identities2
|
let identities1, identities2
|
||||||
let testIdentity1, testIdentity2
|
let testIdentity1, testIdentity2
|
||||||
@ -84,9 +84,6 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
if (signingKeyStore) {
|
|
||||||
await signingKeyStore.close()
|
|
||||||
}
|
|
||||||
if (testIdentity1) {
|
if (testIdentity1) {
|
||||||
rmrf(testIdentity1.id)
|
rmrf(testIdentity1.id)
|
||||||
}
|
}
|
||||||
|
11
test/fixtures/orbit-db-identity-keys.js
vendored
11
test/fixtures/orbit-db-identity-keys.js
vendored
@ -30,7 +30,6 @@ const signingKeys = {
|
|||||||
|
|
||||||
const createTestIdentities = async (ipfs1, ipfs2) => {
|
const createTestIdentities = async (ipfs1, ipfs2) => {
|
||||||
rmrf('./keys_1')
|
rmrf('./keys_1')
|
||||||
rmrf('./keys_2')
|
|
||||||
|
|
||||||
const keystore = new KeyStore('./keys_1')
|
const keystore = new KeyStore('./keys_1')
|
||||||
await keystore.open()
|
await keystore.open()
|
||||||
@ -38,15 +37,13 @@ const createTestIdentities = async (ipfs1, ipfs2) => {
|
|||||||
await keystore.addKey(key, value)
|
await keystore.addKey(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const signingKeyStore = new KeyStore('./keys_2')
|
|
||||||
await signingKeyStore.open()
|
|
||||||
for (const [key, value] of Object.entries(signingKeys)) {
|
for (const [key, value] of Object.entries(signingKeys)) {
|
||||||
await signingKeyStore.addKey(key, value)
|
await keystore.addKey(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an identity for each peers
|
// Create an identity for each peers
|
||||||
const identities1 = await Identities({ keystore, signingKeyStore, ipfs: ipfs1 })
|
const identities1 = await Identities({ keystore, ipfs: ipfs1 })
|
||||||
const identities2 = await Identities({ keystore, signingKeyStore, ipfs: ipfs2 })
|
const identities2 = await Identities({ keystore, ipfs: ipfs2 })
|
||||||
const testIdentity1 = await identities1.createIdentity({ id: 'userA' })
|
const testIdentity1 = await identities1.createIdentity({ id: 'userA' })
|
||||||
const testIdentity2 = await identities2.createIdentity({ id: 'userB' })
|
const testIdentity2 = await identities2.createIdentity({ id: 'userB' })
|
||||||
|
|
||||||
@ -56,10 +53,8 @@ const createTestIdentities = async (ipfs1, ipfs2) => {
|
|||||||
const cleanUpTestIdentities = async (identities) => {
|
const cleanUpTestIdentities = async (identities) => {
|
||||||
for (let identity of identities) {
|
for (let identity of identities) {
|
||||||
await identity.keystore.close()
|
await identity.keystore.close()
|
||||||
await identity.signingKeyStore.close()
|
|
||||||
}
|
}
|
||||||
rmrf('./keys_1')
|
rmrf('./keys_1')
|
||||||
rmrf('./keys_2')
|
|
||||||
rmrf('./orbitdb')
|
rmrf('./orbitdb')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,18 +6,15 @@ import { Identity, addIdentityProvider } from '../../src/identities/index.js'
|
|||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
const fixturesPath = path.resolve('./test/identities/fixtures/keys')
|
const fixturesPath = path.resolve('./test/identities/fixtures/keys')
|
||||||
const savedKeysPath = path.resolve('./test/identities/fixtures/savedKeys')
|
const savedKeysPath = path.resolve('./test/identities/fixtures/savedKeys')
|
||||||
const signingKeysPath = path.resolve('./test/identities/signingKeys')
|
|
||||||
const identityKeysPath = path.resolve('./test/identities/identityKeys')
|
const identityKeysPath = path.resolve('./test/identities/identityKeys')
|
||||||
const type = 'orbitdb'
|
const type = 'orbitdb'
|
||||||
|
|
||||||
describe('Identities', function () {
|
describe('Identities', function () {
|
||||||
before(async () => {
|
before(async () => {
|
||||||
rmrf.sync(signingKeysPath)
|
|
||||||
rmrf.sync(identityKeysPath)
|
rmrf.sync(identityKeysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
rmrf.sync(signingKeysPath)
|
|
||||||
rmrf.sync(identityKeysPath)
|
rmrf.sync(identityKeysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -31,26 +28,15 @@ describe('Identities', function () {
|
|||||||
if (identities) {
|
if (identities) {
|
||||||
await identities.keystore.close()
|
await identities.keystore.close()
|
||||||
}
|
}
|
||||||
if (identities) {
|
|
||||||
await identities.signingKeyStore.close()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('identityKeysPath only - has the correct id', async () => {
|
it('has the correct id', async () => {
|
||||||
identities = await Identities({ identityKeysPath })
|
identities = await Identities({ identityKeysPath })
|
||||||
identity = await identities.createIdentity({ id })
|
identity = await identities.createIdentity({ id })
|
||||||
const key = await identities.keystore.getKey(id)
|
const key = await identities.keystore.getKey(id)
|
||||||
const externalId = Buffer.from(key.public.marshal()).toString('hex')
|
const externalId = Buffer.from(key.public.marshal()).toString('hex')
|
||||||
assert.strictEqual(identity.id, externalId)
|
assert.strictEqual(identity.id, externalId)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('identityKeysPath and signingKeysPath - has a different id', async () => {
|
|
||||||
identities = await Identities({ identityKeysPath, signingKeysPath })
|
|
||||||
identity = await identities.createIdentity({ id })
|
|
||||||
const key = await identities.keystore.getKey(id)
|
|
||||||
const externalId = Buffer.from(key.public.marshal()).toString('hex')
|
|
||||||
assert.notStrictEqual(identity.id, externalId)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Get Identity', () => {
|
describe('Get Identity', () => {
|
||||||
@ -63,13 +49,10 @@ describe('Identities', function () {
|
|||||||
if (identities) {
|
if (identities) {
|
||||||
await identities.keystore.close()
|
await identities.keystore.close()
|
||||||
}
|
}
|
||||||
if (identities) {
|
|
||||||
await identities.signingKeyStore.close()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('gets the identity from storage', async () => {
|
it('gets the identity from storage', async () => {
|
||||||
identities = await Identities({ identityKeysPath, signingKeysPath })
|
identities = await Identities({ identityKeysPath })
|
||||||
identity = await identities.createIdentity({ id })
|
identity = await identities.createIdentity({ id })
|
||||||
const result = await identities.getIdentity(identity.hash)
|
const result = await identities.getIdentity(identity.hash)
|
||||||
assert.strictEqual(result.id, identity.id)
|
assert.strictEqual(result.id, identity.id)
|
||||||
@ -88,13 +71,10 @@ describe('Identities', function () {
|
|||||||
let identity
|
let identity
|
||||||
let identities
|
let identities
|
||||||
let keystore
|
let keystore
|
||||||
let signingKeyStore
|
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
await keystore.open()
|
await keystore.open()
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
|
||||||
await signingKeyStore.open()
|
|
||||||
identities = await Identities({ keystore })
|
identities = await Identities({ keystore })
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -102,9 +82,6 @@ describe('Identities', function () {
|
|||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
if (signingKeyStore) {
|
|
||||||
await signingKeyStore.close()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has the correct id', async () => {
|
it('has the correct id', async () => {
|
||||||
@ -177,9 +154,6 @@ describe('Identities', function () {
|
|||||||
if (identities) {
|
if (identities) {
|
||||||
await identities.keystore.close()
|
await identities.keystore.close()
|
||||||
}
|
}
|
||||||
if (identities) {
|
|
||||||
await identities.signingKeyStore.close()
|
|
||||||
}
|
|
||||||
rmrf.sync(savedKeysPath)
|
rmrf.sync(savedKeysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -220,33 +194,27 @@ describe('Identities', function () {
|
|||||||
let identities
|
let identities
|
||||||
let identity
|
let identity
|
||||||
let keystore
|
let keystore
|
||||||
let signingKeyStore
|
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
await keystore.open()
|
await keystore.open()
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
|
||||||
await signingKeyStore.open()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
if (signingKeyStore) {
|
|
||||||
await signingKeyStore.close()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('identity pkSignature verifies', async () => {
|
it('identity pkSignature verifies', async () => {
|
||||||
identities = await Identities({ keystore, signingKeyStore })
|
identities = await Identities({ keystore })
|
||||||
identity = await identities.createIdentity({ id, type })
|
identity = await identities.createIdentity({ id, type })
|
||||||
const verified = await KeyStore.verify(identity.signatures.id, identity.publicKey, identity.id)
|
const verified = await KeyStore.verify(identity.signatures.id, identity.publicKey, identity.id)
|
||||||
assert.strictEqual(verified, true)
|
assert.strictEqual(verified, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('identity signature verifies', async () => {
|
it('identity signature verifies', async () => {
|
||||||
identities = await Identities({ keystore, signingKeyStore })
|
identities = await Identities({ keystore })
|
||||||
identity = await identities.createIdentity({ id, type })
|
identity = await identities.createIdentity({ id, type })
|
||||||
const verified = await KeyStore.verify(identity.signatures.publicKey, identity.id, identity.publicKey + identity.signatures.id)
|
const verified = await KeyStore.verify(identity.signatures.publicKey, identity.id, identity.publicKey + identity.signatures.id)
|
||||||
assert.strictEqual(verified, true)
|
assert.strictEqual(verified, true)
|
||||||
@ -276,23 +244,17 @@ describe('Identities', function () {
|
|||||||
let identities
|
let identities
|
||||||
let identity
|
let identity
|
||||||
let keystore
|
let keystore
|
||||||
let signingKeyStore
|
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
await keystore.open()
|
await keystore.open()
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
identities = await Identities({ keystore })
|
||||||
await signingKeyStore.open()
|
|
||||||
identities = await Identities({ keystore, signingKeyStore })
|
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
if (signingKeyStore) {
|
|
||||||
await signingKeyStore.close()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('identity verifies', async () => {
|
it('identity verifies', async () => {
|
||||||
@ -309,14 +271,11 @@ describe('Identities', function () {
|
|||||||
let identities
|
let identities
|
||||||
let identity
|
let identity
|
||||||
let keystore
|
let keystore
|
||||||
let signingKeyStore
|
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
await keystore.open()
|
await keystore.open()
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
identities = await Identities({ keystore })
|
||||||
await signingKeyStore.open()
|
|
||||||
identities = await Identities({ keystore, signingKeyStore })
|
|
||||||
identity = await identities.createIdentity({ id })
|
identity = await identities.createIdentity({ id })
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -324,9 +283,6 @@ describe('Identities', function () {
|
|||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
if (signingKeyStore) {
|
|
||||||
await signingKeyStore.close()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sign data', async () => {
|
it('sign data', async () => {
|
||||||
@ -359,27 +315,21 @@ describe('Identities', function () {
|
|||||||
let identities
|
let identities
|
||||||
let identity
|
let identity
|
||||||
let keystore
|
let keystore
|
||||||
let signingKeyStore
|
|
||||||
let signature
|
let signature
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
await keystore.open()
|
await keystore.open()
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
|
||||||
await signingKeyStore.open()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
if (signingKeyStore) {
|
|
||||||
await signingKeyStore.close()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
identities = await Identities({ keystore, signingKeyStore })
|
identities = await Identities({ keystore })
|
||||||
identity = await identities.createIdentity({ id, type })
|
identity = await identities.createIdentity({ id, type })
|
||||||
signature = await identities.sign(identity, data, keystore)
|
signature = await identities.sign(identity, data, keystore)
|
||||||
})
|
})
|
||||||
|
@ -10,7 +10,7 @@ import { IPFSBlockStorage, LevelStorage } from '../src/storage/index.js'
|
|||||||
import { config, testAPIs, getIpfsPeerId, waitForPeers, startIpfs, stopIpfs } from 'orbit-db-test-utils'
|
import { config, testAPIs, getIpfsPeerId, waitForPeers, 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'
|
||||||
import { identityKeys, signingKeys, createTestIdentities, cleanUpTestIdentities } from './fixtures/orbit-db-identity-keys.js'
|
import { createTestIdentities, cleanUpTestIdentities } from './fixtures/orbit-db-identity-keys.js'
|
||||||
|
|
||||||
const { sync: rmrf } = rimraf
|
const { sync: rmrf } = rimraf
|
||||||
const { createIdentity } = Identities
|
const { createIdentity } = Identities
|
||||||
@ -23,7 +23,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
|
|
||||||
let ipfsd1, ipfsd2
|
let ipfsd1, ipfsd2
|
||||||
let ipfs1, ipfs2
|
let ipfs1, ipfs2
|
||||||
let keystore, signingKeyStore
|
let keystore
|
||||||
let peerId1, peerId2
|
let peerId1, peerId2
|
||||||
let identities1, identities2
|
let identities1, identities2
|
||||||
let testIdentity1, testIdentity2
|
let testIdentity1, testIdentity2
|
||||||
@ -73,9 +73,6 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
if (signingKeyStore) {
|
|
||||||
await signingKeyStore.close()
|
|
||||||
}
|
|
||||||
if (testIdentity1) {
|
if (testIdentity1) {
|
||||||
rmrf(testIdentity1.id)
|
rmrf(testIdentity1.id)
|
||||||
}
|
}
|
||||||
|
@ -18,32 +18,27 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
describe('Log - Append (' + IPFS + ')', function () {
|
describe('Log - Append (' + IPFS + ')', function () {
|
||||||
this.timeout(config.timeout)
|
this.timeout(config.timeout)
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath, signingKeysPath } = config
|
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
||||||
|
|
||||||
let keystore, signingKeyStore
|
let keystore
|
||||||
let identities
|
let identities
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
rmrf(identityKeysPath)
|
rmrf(identityKeysPath)
|
||||||
rmrf(signingKeysPath)
|
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
await copy(identityKeyFixtures, identityKeysPath)
|
||||||
await copy(signingKeyFixtures, signingKeysPath)
|
await copy(signingKeyFixtures, identityKeysPath)
|
||||||
|
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
|
||||||
|
|
||||||
const storage = await MemoryStorage()
|
const storage = await MemoryStorage()
|
||||||
|
|
||||||
identities = await Identities({ keystore, signingKeyStore, storage })
|
identities = await Identities({ keystore, storage })
|
||||||
testIdentity = await identities.createIdentity({ id: 'userA' })
|
testIdentity = await identities.createIdentity({ id: 'userA' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
rmrf(identityKeysPath)
|
|
||||||
rmrf(signingKeysPath)
|
|
||||||
|
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
await signingKeyStore.close()
|
rmrf(identityKeysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('append', async () => {
|
describe('append', async () => {
|
||||||
|
@ -18,35 +18,31 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
describe('Log - CRDT (' + IPFS + ')', function () {
|
describe('Log - CRDT (' + IPFS + ')', function () {
|
||||||
this.timeout(config.timeout)
|
this.timeout(config.timeout)
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath, signingKeysPath } = config
|
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
||||||
|
|
||||||
let keystore, signingKeyStore
|
let keystore
|
||||||
let identities1, identities2, identities3
|
let identities1, identities2, identities3
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
rmrf(identityKeysPath)
|
rmrf(identityKeysPath)
|
||||||
rmrf(signingKeysPath)
|
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
await copy(identityKeyFixtures, identityKeysPath)
|
||||||
await copy(signingKeyFixtures, signingKeysPath)
|
await copy(signingKeyFixtures, identityKeysPath)
|
||||||
|
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
|
||||||
|
|
||||||
const storage = await MemoryStorage()
|
const storage = await MemoryStorage()
|
||||||
|
|
||||||
identities1 = await Identities({ keystore, signingKeyStore, storage })
|
identities1 = await Identities({ keystore, storage })
|
||||||
identities2 = await Identities({ keystore, signingKeyStore, storage })
|
identities2 = await Identities({ keystore, storage })
|
||||||
identities3 = await Identities({ keystore, signingKeyStore, storage })
|
identities3 = await Identities({ keystore, storage })
|
||||||
testIdentity = await identities1.createIdentity({ id: 'userA' })
|
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' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
await signingKeyStore.close()
|
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
rmrf(identityKeysPath)
|
rmrf(identityKeysPath)
|
||||||
rmrf(signingKeysPath)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('is a CRDT', async () => {
|
describe('is a CRDT', async () => {
|
||||||
|
@ -16,9 +16,9 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
describe('Entry (' + IPFS + ')', function () {
|
describe('Entry (' + IPFS + ')', function () {
|
||||||
this.timeout(config.timeout)
|
this.timeout(config.timeout)
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath, signingKeysPath } = config
|
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
||||||
|
|
||||||
let keystore, signingKeyStore, ipfsBlockStore, identityStore
|
let keystore, ipfsBlockStore, identityStore
|
||||||
let identities
|
let identities
|
||||||
let testIdentity
|
let testIdentity
|
||||||
let ipfsd, ipfs
|
let ipfsd, ipfs
|
||||||
@ -28,26 +28,22 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
ipfs = ipfsd.api
|
ipfs = ipfsd.api
|
||||||
|
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
await copy(identityKeyFixtures, identityKeysPath)
|
||||||
await copy(signingKeyFixtures, signingKeysPath)
|
await copy(signingKeyFixtures, identityKeysPath)
|
||||||
|
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
|
||||||
|
|
||||||
identities = await Identities({ keystore, signingKeyStore, ipfs })
|
identities = await Identities({ keystore, ipfs })
|
||||||
testIdentity = await identities.createIdentity({ id: 'userA' })
|
testIdentity = await identities.createIdentity({ id: 'userA' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
|
||||||
await copy(signingKeyFixtures, signingKeysPath)
|
|
||||||
rmrf(identityKeysPath)
|
|
||||||
rmrf(signingKeysPath)
|
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
await signingKeyStore.close()
|
|
||||||
|
|
||||||
if (ipfsd) {
|
if (ipfsd) {
|
||||||
await stopIpfs(ipfsd)
|
await stopIpfs(ipfsd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rmrf(identityKeysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('create', () => {
|
describe('create', () => {
|
||||||
|
@ -22,31 +22,27 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
describe('Log - Heads (' + IPFS + ')', function () {
|
describe('Log - Heads (' + IPFS + ')', function () {
|
||||||
this.timeout(config.timeout)
|
this.timeout(config.timeout)
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath, signingKeysPath } = config
|
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
||||||
|
|
||||||
let keystore, signingKeyStore
|
let keystore
|
||||||
let identities
|
let identities
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
rmrf(identityKeysPath)
|
rmrf(identityKeysPath)
|
||||||
rmrf(signingKeysPath)
|
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
await copy(identityKeyFixtures, identityKeysPath)
|
||||||
await copy(signingKeyFixtures, signingKeysPath)
|
await copy(signingKeyFixtures, identityKeysPath)
|
||||||
|
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
|
||||||
const storage = await MemoryStorage()
|
const storage = await MemoryStorage()
|
||||||
|
|
||||||
identities = await Identities({ keystore, signingKeyStore, storage })
|
identities = await Identities({ keystore, storage })
|
||||||
testIdentity = await identities.createIdentity({ id: 'userA' })
|
testIdentity = await identities.createIdentity({ id: 'userA' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
rmrf(identityKeysPath)
|
|
||||||
rmrf(signingKeysPath)
|
|
||||||
|
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
await signingKeyStore.close()
|
rmrf(identityKeysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finds one head after one entry', async () => {
|
it('finds one head after one entry', async () => {
|
||||||
|
@ -21,7 +21,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
|
|
||||||
let ipfs
|
let ipfs
|
||||||
let ipfsd
|
let ipfsd
|
||||||
let keystore, signingKeyStore
|
let keystore
|
||||||
let identities1, identities2, identities3
|
let identities1, identities2, identities3
|
||||||
let testIdentity, testIdentity2, testIdentity3
|
let testIdentity, testIdentity2, testIdentity3
|
||||||
|
|
||||||
@ -31,18 +31,15 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
for (const [key, value] of Object.entries(identityKeys)) {
|
for (const [key, value] of Object.entries(identityKeys)) {
|
||||||
await keystore.addKey(key, value)
|
await keystore.addKey(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
signingKeyStore = new KeyStore('./keys_2')
|
|
||||||
await signingKeyStore.open()
|
|
||||||
for (const [key, value] of Object.entries(signingKeys)) {
|
for (const [key, value] of Object.entries(signingKeys)) {
|
||||||
await signingKeyStore.addKey(key, value)
|
await keystore.addKey(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const storage = await MemoryStorage()
|
const storage = await MemoryStorage()
|
||||||
|
|
||||||
identities1 = await Identities({ keystore, signingKeyStore, storage })
|
identities1 = await Identities({ keystore, storage })
|
||||||
identities2 = await Identities({ keystore, signingKeyStore, storage })
|
identities2 = await Identities({ keystore, storage })
|
||||||
identities3 = await Identities({ keystore, signingKeyStore, storage })
|
identities3 = await Identities({ keystore, storage })
|
||||||
testIdentity = await identities1.createIdentity({ id: 'userA' })
|
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' })
|
||||||
@ -58,11 +55,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
if (signingKeyStore) {
|
|
||||||
await signingKeyStore.close()
|
|
||||||
}
|
|
||||||
rmrf('./keys_1')
|
rmrf('./keys_1')
|
||||||
rmrf('./keys_2')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Basic iterator functionality', async () => {
|
describe('Basic iterator functionality', async () => {
|
||||||
|
@ -18,33 +18,30 @@ Object.keys(testAPIs).forEach(IPFS => {
|
|||||||
describe('Log - Join Concurrent Entries (' + IPFS + ')', function () {
|
describe('Log - Join Concurrent Entries (' + IPFS + ')', function () {
|
||||||
this.timeout(config.timeout)
|
this.timeout(config.timeout)
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath, signingKeysPath } = config
|
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
||||||
|
|
||||||
let keystore, signingKeyStore
|
let keystore
|
||||||
let identities1, identities2
|
let identities1, identities2
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
rmrf(identityKeysPath)
|
rmrf(identityKeysPath)
|
||||||
rmrf(signingKeysPath)
|
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
await copy(identityKeyFixtures, identityKeysPath)
|
||||||
await copy(signingKeyFixtures, signingKeysPath)
|
await copy(signingKeyFixtures, identityKeysPath)
|
||||||
|
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
|
||||||
|
|
||||||
const storage = await MemoryStorage()
|
const storage = await MemoryStorage()
|
||||||
|
|
||||||
identities1 = await Identities({ keystore, signingKeyStore, storage })
|
identities1 = await Identities({ keystore, storage })
|
||||||
identities2 = await Identities({ keystore, signingKeyStore, storage })
|
identities2 = await Identities({ keystore, storage })
|
||||||
testIdentity = await identities1.createIdentity({ id: 'userA' })
|
testIdentity = await identities1.createIdentity({ id: 'userA' })
|
||||||
testIdentity2 = await identities2.createIdentity({ id: 'userB' })
|
testIdentity2 = await identities2.createIdentity({ id: 'userB' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
await signingKeyStore.close()
|
|
||||||
rmrf(identityKeysPath)
|
rmrf(identityKeysPath)
|
||||||
rmrf(signingKeysPath)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('join ', async () => {
|
describe('join ', async () => {
|
||||||
|
@ -20,7 +20,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
describe('Log - Join (' + IPFS + ')', async function () {
|
describe('Log - Join (' + IPFS + ')', async function () {
|
||||||
this.timeout(config.timeout)
|
this.timeout(config.timeout)
|
||||||
|
|
||||||
let keystore, signingKeyStore
|
let keystore
|
||||||
let log1, log2, log3, log4
|
let log1, log2, log3, log4
|
||||||
let identities1, identities2, identities3, identities4
|
let identities1, identities2, identities3, identities4
|
||||||
let testIdentity, testIdentity2, testIdentity3, testIdentity4
|
let testIdentity, testIdentity2, testIdentity3, testIdentity4
|
||||||
@ -31,19 +31,16 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
for (const [key, value] of Object.entries(identityKeys)) {
|
for (const [key, value] of Object.entries(identityKeys)) {
|
||||||
await keystore.addKey(key, value)
|
await keystore.addKey(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
signingKeyStore = new KeyStore('./keys_2')
|
|
||||||
await signingKeyStore.open()
|
|
||||||
for (const [key, value] of Object.entries(signingKeys)) {
|
for (const [key, value] of Object.entries(signingKeys)) {
|
||||||
await signingKeyStore.addKey(key, value)
|
await keystore.addKey(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const storage = await MemoryStorage()
|
const storage = await MemoryStorage()
|
||||||
|
|
||||||
identities1 = await Identities({ keystore, signingKeyStore, storage })
|
identities1 = await Identities({ keystore, storage })
|
||||||
identities2 = await Identities({ keystore, signingKeyStore, storage })
|
identities2 = await Identities({ keystore, storage })
|
||||||
identities3 = await Identities({ keystore, signingKeyStore, storage })
|
identities3 = await Identities({ keystore, storage })
|
||||||
identities4 = await Identities({ keystore, signingKeyStore, storage })
|
identities4 = await Identities({ keystore, storage })
|
||||||
testIdentity = await identities1.createIdentity({ id: 'userC' })
|
testIdentity = await identities1.createIdentity({ id: 'userC' })
|
||||||
testIdentity2 = await identities2.createIdentity({ id: 'userB' })
|
testIdentity2 = await identities2.createIdentity({ id: 'userB' })
|
||||||
testIdentity3 = await identities3.createIdentity({ id: 'userD' })
|
testIdentity3 = await identities3.createIdentity({ id: 'userD' })
|
||||||
@ -54,11 +51,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
if (signingKeyStore) {
|
|
||||||
await signingKeyStore.close()
|
|
||||||
}
|
|
||||||
rmrf('./keys_1')
|
rmrf('./keys_1')
|
||||||
rmrf('./keys_2')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
@ -32,7 +32,7 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
describe.skip('Log - Load (' + IPFS + ')', function () {
|
describe.skip('Log - Load (' + IPFS + ')', function () {
|
||||||
this.timeout(config.timeout)
|
this.timeout(config.timeout)
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath, signingKeysPath } = config
|
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
||||||
|
|
||||||
const firstWriteExpectedData = [
|
const firstWriteExpectedData = [
|
||||||
'entryA6', 'entryA7', 'entryA8', 'entryA9',
|
'entryA6', 'entryA7', 'entryA8', 'entryA9',
|
||||||
@ -41,21 +41,20 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
'entryA3', 'entryA4', 'entryA5', 'entryC0'
|
'entryA3', 'entryA4', 'entryA5', 'entryC0'
|
||||||
]
|
]
|
||||||
|
|
||||||
let keystore, signingKeyStore
|
let keystore
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
rmrf(identityKeysPath)
|
rmrf(identityKeysPath)
|
||||||
rmrf(signingKeysPath)
|
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
await copy(identityKeyFixtures, identityKeysPath)
|
||||||
await copy(signingKeyFixtures, signingKeysPath)
|
await copy(signingKeyFixtures, identityKeysPath)
|
||||||
|
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
|
||||||
|
|
||||||
testIdentity = await createIdentity({ id: 'userC', keystore, signingKeyStore })
|
testIdentity = await createIdentity({ id: 'userC', keystore })
|
||||||
testIdentity2 = await createIdentity({ id: 'userB', keystore, signingKeyStore })
|
testIdentity2 = await createIdentity({ id: 'userB', keystore })
|
||||||
testIdentity3 = await createIdentity({ id: 'userD', keystore, signingKeyStore })
|
testIdentity3 = await createIdentity({ id: 'userD', keystore })
|
||||||
testIdentity4 = await createIdentity({ id: 'userA', keystore, signingKeyStore })
|
testIdentity4 = await createIdentity({ id: 'userA', keystore })
|
||||||
ipfsd = await startIpfs(IPFS, config.defaultIpfsConfig)
|
ipfsd = await startIpfs(IPFS, config.defaultIpfsConfig)
|
||||||
ipfs = ipfsd.api
|
ipfs = ipfsd.api
|
||||||
|
|
||||||
@ -66,11 +65,8 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
await stopIpfs(ipfsd)
|
await stopIpfs(ipfsd)
|
||||||
rmrf(identityKeysPath)
|
|
||||||
rmrf(signingKeysPath)
|
|
||||||
|
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
await signingKeyStore.close()
|
rmrf(identityKeysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('fromJSON', async () => {
|
describe('fromJSON', async () => {
|
||||||
|
@ -19,30 +19,26 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
describe('Log (' + IPFS + ')', function () {
|
describe('Log (' + IPFS + ')', function () {
|
||||||
this.timeout(config.timeout)
|
this.timeout(config.timeout)
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath, signingKeysPath } = config
|
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
||||||
|
|
||||||
let keystore, signingKeyStore
|
let keystore
|
||||||
let identities
|
let identities
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
await copy(identityKeyFixtures, identityKeysPath)
|
||||||
await copy(signingKeyFixtures, signingKeysPath)
|
await copy(signingKeyFixtures, identityKeysPath)
|
||||||
|
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
|
||||||
|
|
||||||
const storage = await MemoryStorage()
|
const storage = await MemoryStorage()
|
||||||
|
|
||||||
identities = await Identities({ keystore, signingKeyStore, storage })
|
identities = await Identities({ keystore, storage })
|
||||||
testIdentity = await identities.createIdentity({ id: 'userA' })
|
testIdentity = await identities.createIdentity({ id: 'userA' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
rmrf(signingKeysPath)
|
|
||||||
rmrf(identityKeysPath)
|
|
||||||
|
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
await signingKeyStore.close()
|
rmrf(identityKeysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('create', async () => {
|
describe('create', async () => {
|
||||||
|
@ -18,32 +18,28 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
describe('Log - References (' + IPFS + ')', function () {
|
describe('Log - References (' + IPFS + ')', function () {
|
||||||
this.timeout(config.timeout)
|
this.timeout(config.timeout)
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath, signingKeysPath } = config
|
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
||||||
|
|
||||||
let keystore, signingKeyStore
|
let keystore, signingKeyStore
|
||||||
let identities
|
let identities
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
rmrf(identityKeysPath)
|
rmrf(identityKeysPath)
|
||||||
rmrf(signingKeysPath)
|
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
await copy(identityKeyFixtures, identityKeysPath)
|
||||||
await copy(signingKeyFixtures, signingKeysPath)
|
await copy(signingKeyFixtures, identityKeysPath)
|
||||||
|
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
|
||||||
|
|
||||||
const storage = await MemoryStorage()
|
const storage = await MemoryStorage()
|
||||||
|
|
||||||
identities = await Identities({ keystore, signingKeyStore, storage })
|
identities = await Identities({ keystore, storage })
|
||||||
testIdentity = await identities.createIdentity({ id: 'userA' })
|
testIdentity = await identities.createIdentity({ id: 'userA' })
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
rmrf(identityKeysPath)
|
|
||||||
rmrf(signingKeysPath)
|
|
||||||
|
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
await signingKeyStore.close()
|
rmrf(identityKeysPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('References', async () => {
|
describe('References', async () => {
|
||||||
|
@ -16,8 +16,6 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
describe('ipfs-log - Replication (' + IPFS + ')', function () {
|
describe('ipfs-log - Replication (' + IPFS + ')', function () {
|
||||||
this.timeout(config.timeout * 2)
|
this.timeout(config.timeout * 2)
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath, signingKeysPath } = config
|
|
||||||
|
|
||||||
let ipfsd1, ipfsd2
|
let ipfsd1, ipfsd2
|
||||||
let ipfs1, ipfs2
|
let ipfs1, ipfs2
|
||||||
let id1, id2
|
let id1, id2
|
||||||
@ -27,11 +25,6 @@ Object.keys(testAPIs).forEach((IPFS) => {
|
|||||||
let storage1, storage2
|
let storage1, storage2
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
rmrf(identityKeysPath)
|
|
||||||
rmrf(signingKeysPath)
|
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
|
||||||
await copy(signingKeyFixtures, signingKeysPath)
|
|
||||||
|
|
||||||
// Start two IPFS instances
|
// 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)
|
||||||
|
@ -5,7 +5,7 @@ import { Identities } from '../../src/identities/index.js'
|
|||||||
|
|
||||||
// Test utils
|
// Test utils
|
||||||
import { config, testAPIs } from 'orbit-db-test-utils'
|
import { config, testAPIs } from 'orbit-db-test-utils'
|
||||||
import { identityKeys, signingKeys, createTestIdentities, cleanUpTestIdentities } from '../fixtures/orbit-db-identity-keys.js'
|
import { createTestIdentities, cleanUpTestIdentities } from '../fixtures/orbit-db-identity-keys.js'
|
||||||
|
|
||||||
const { sync: rmrf } = rimraf
|
const { sync: rmrf } = rimraf
|
||||||
const { createIdentity } = Identities
|
const { createIdentity } = Identities
|
||||||
|
@ -17,17 +17,16 @@ Object.keys(testAPIs).forEach((_) => {
|
|||||||
describe('Storages (' + _ + ')', function () {
|
describe('Storages (' + _ + ')', function () {
|
||||||
this.timeout(config.timeout)
|
this.timeout(config.timeout)
|
||||||
|
|
||||||
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath, signingKeysPath } = config
|
const { identityKeyFixtures, signingKeyFixtures, identityKeysPath } = config
|
||||||
|
|
||||||
let ipfs1
|
let ipfs1
|
||||||
let keystore, signingKeyStore
|
let keystore
|
||||||
let testIdentity1
|
let testIdentity1
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
rmrf(identityKeysPath)
|
rmrf(identityKeysPath)
|
||||||
rmrf(signingKeysPath)
|
|
||||||
await copy(identityKeyFixtures, identityKeysPath)
|
await copy(identityKeyFixtures, identityKeysPath)
|
||||||
await copy(signingKeyFixtures, signingKeysPath)
|
await copy(signingKeyFixtures, identityKeysPath)
|
||||||
|
|
||||||
rmrf('./ipfs1')
|
rmrf('./ipfs1')
|
||||||
await copy('./test/fixtures/ipfs1', './ipfs1')
|
await copy('./test/fixtures/ipfs1', './ipfs1')
|
||||||
@ -36,10 +35,9 @@ Object.keys(testAPIs).forEach((_) => {
|
|||||||
ipfs1 = await IPFS.create({ ...config.daemon1, repo: './ipfs1' })
|
ipfs1 = await IPFS.create({ ...config.daemon1, repo: './ipfs1' })
|
||||||
|
|
||||||
keystore = new KeyStore(identityKeysPath)
|
keystore = new KeyStore(identityKeysPath)
|
||||||
signingKeyStore = new KeyStore(signingKeysPath)
|
|
||||||
|
|
||||||
const storage = await MemoryStorage()
|
const storage = await MemoryStorage()
|
||||||
const identities = await Identities({ keystore, signingKeyStore, storage })
|
const identities = await Identities({ keystore, storage })
|
||||||
testIdentity1 = await identities.createIdentity({ id: 'userA' })
|
testIdentity1 = await identities.createIdentity({ id: 'userA' })
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -50,13 +48,10 @@ Object.keys(testAPIs).forEach((_) => {
|
|||||||
if (keystore) {
|
if (keystore) {
|
||||||
await keystore.close()
|
await keystore.close()
|
||||||
}
|
}
|
||||||
if (signingKeyStore) {
|
|
||||||
await signingKeyStore.close()
|
|
||||||
}
|
|
||||||
rmrf(identityKeysPath)
|
rmrf(identityKeysPath)
|
||||||
rmrf(signingKeysPath)
|
|
||||||
rmrf(testIdentity1.id)
|
rmrf(testIdentity1.id)
|
||||||
rmrf('./ipfs1')
|
rmrf('./ipfs1')
|
||||||
|
rmrf('./orbitdb')
|
||||||
})
|
})
|
||||||
|
|
||||||
const runTestWithStorage = async (storage) => {
|
const runTestWithStorage = async (storage) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user