orbitdb/test/fixtures/orbit-db-identity-keys.js
haad a063b3fb4a Refactor OrbitDB
Fix sync
Fix linter
Fix tests
Clean up
Set default references count to 0
Fix sync
Use address instead of databaseId
Sync protocol
Keep references to open databases in OrbitDB
Fix append benchmark
Initial version of heads exchange
Remove Feed
Fix KeyValuePersisted iterator
Refactor OrbitDBAddress a bit more
Add rest of the database types
Refactor OrbitDB addresses
Initial version for the full circle
Initial structure and tests for new OrbitDB
Make sure KeyStore is open when a Database is created
Re-organize OrbitDB
Use new databases and Log
More clean up
Add 'drop' event to Database
Clean up OrbitDB
Remove id from OrbitDB
Use new KeyStore and Identities
Remove storage from OrbitDB
Remove migrations from OrbitDB
Remove caches from OrbitDB
Remove pubsub from OrbitDB
2023-03-01 16:21:07 +02:00

68 lines
2.5 KiB
JavaScript

import KeyStore from '../../src/key-store.js'
import { Identities } from '../../src/identities/index.js'
import rimraf from 'rimraf'
const { sync: rmrf } = rimraf
import testKeysPath from './test-keys-path.js '
import userA from "./keys/identity-keys/03e0480538c2a39951d054e17ff31fde487cb1031d0044a037b53ad2e028a3e77c.json" assert { type: "json" }
import userB from "./keys/identity-keys/0358df8eb5def772917748fdf8a8b146581ad2041eae48d66cc6865f11783499a6.json" assert { type: "json" }
import userC from "./keys/identity-keys/032f7b6ef0432b572b45fcaf27e7f6757cd4123ff5c5266365bec82129b8c5f214.json" assert { type: "json" }
import userD from "./keys/identity-keys/02a38336e3a47f545a172c9f77674525471ebeda7d6c86140e7a778f67ded92260.json" assert { type: "json" }
import userA_ from "./keys/signing-keys/userA.json" assert { type: "json" }
import userB_ from "./keys/signing-keys/userB.json" assert { type: "json" }
import userC_ from "./keys/signing-keys/userC.json" assert { type: "json" }
import userD_ from "./keys/signing-keys/userD.json" assert { type: "json" }
const identityKeys = {
'03e0480538c2a39951d054e17ff31fde487cb1031d0044a037b53ad2e028a3e77c': userA,
'0358df8eb5def772917748fdf8a8b146581ad2041eae48d66cc6865f11783499a6': userB,
'032f7b6ef0432b572b45fcaf27e7f6757cd4123ff5c5266365bec82129b8c5f214': userC,
'02a38336e3a47f545a172c9f77674525471ebeda7d6c86140e7a778f67ded92260': userD,
}
const signingKeys = {
userA: userA_,
userB: userB_,
userC: userC_,
userD: userD_,
}
const createTestIdentities = async (ipfs1, ipfs2) => {
// rmrf('./keys_1')
// const keystore = await KeyStore()
const keystore = await KeyStore({ path: testKeysPath })
// for (const [key, value] of Object.entries(identityKeys)) {
// await keystore.addKey(key, value)
// }
// for (const [key, value] of Object.entries(signingKeys)) {
// await keystore.addKey(key, value)
// }
// Create an identity for each peers
const identities1 = await Identities({ keystore, ipfs: ipfs1 })
const identities2 = await Identities({ keystore, ipfs: ipfs2 })
const testIdentity1 = await identities1.createIdentity({ id: 'userA' })
const testIdentity2 = await identities2.createIdentity({ id: 'userB' })
return [[identities1, identities2], [testIdentity1, testIdentity2]]
}
const cleanUpTestIdentities = async (identities) => {
for (let identity of identities) {
await identity.keystore.close()
}
rmrf('./keys_1')
// rmrf('./orbitdb')
}
export {
identityKeys,
signingKeys,
createTestIdentities,
cleanUpTestIdentities
}