mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
style: Linting.
This commit is contained in:
parent
2aee8e408c
commit
58769c4d15
@ -6,7 +6,6 @@
|
||||
*/
|
||||
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
||||
import { signMessage, verifyMessage } from '../../key-store.js'
|
||||
import { publicKeyFromRaw } from '@libp2p/crypto/keys'
|
||||
|
||||
const type = 'publickey'
|
||||
|
||||
|
@ -31,18 +31,18 @@ describe('Documents Database Replication', function () {
|
||||
|
||||
before(async () => {
|
||||
[ipfs1, ipfs2] = await Promise.all([createHelia(), createHelia()])
|
||||
|
||||
ipfs1.libp2p.addEventListener("peer:connect", (event) => {
|
||||
console.log(event.detail.toString())
|
||||
|
||||
ipfs1.libp2p.addEventListener('peer:connect', (event) => {
|
||||
console.log(event.detail.toString())
|
||||
})
|
||||
|
||||
ipfs2.libp2p.addEventListener("peer:connect", (event) => {
|
||||
console.log(event.detail.toString())
|
||||
|
||||
ipfs2.libp2p.addEventListener('peer:connect', (event) => {
|
||||
console.log(event.detail.toString())
|
||||
})
|
||||
|
||||
|
||||
console.log(ipfs1.libp2p.peerId.toString())
|
||||
console.log(ipfs2.libp2p.peerId.toString())
|
||||
|
||||
|
||||
await connectPeers(ipfs1, ipfs2)
|
||||
|
||||
await copy(testKeysPath, keysPath)
|
||||
|
57
test/orbitdb-replication-pins.test.js
Normal file
57
test/orbitdb-replication-pins.test.js
Normal file
@ -0,0 +1,57 @@
|
||||
import { strictEqual } from 'assert'
|
||||
import { rimraf } from 'rimraf'
|
||||
import { createOrbitDB } from '../src/index.js'
|
||||
import connectPeers from './utils/connect-nodes.js'
|
||||
import waitFor from './utils/wait-for.js'
|
||||
import createHelia from './utils/create-helia.js'
|
||||
import { CID } from 'multiformats/cid'
|
||||
import { base58btc } from 'multiformats/bases/base58'
|
||||
|
||||
describe.skip('Replicating databases', function () {
|
||||
this.timeout(10000)
|
||||
|
||||
let ipfs1, ipfs2
|
||||
let orbitdb1, orbitdb2
|
||||
|
||||
before(async () => {
|
||||
ipfs1 = await createHelia({ directory: './ipfs1' })
|
||||
ipfs2 = await createHelia({ directory: './ipfs2' })
|
||||
await connectPeers(ipfs1, ipfs2)
|
||||
|
||||
orbitdb1 = await createOrbitDB({ ipfs: ipfs1, id: 'user1', directory: './orbitdb1' })
|
||||
orbitdb2 = await createOrbitDB({ ipfs: ipfs2, id: 'user2', directory: './orbitdb2' })
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await orbitdb1.stop()
|
||||
await orbitdb2.stop()
|
||||
await ipfs1.stop()
|
||||
await ipfs2.stop()
|
||||
|
||||
await rimraf('./orbitdb1')
|
||||
await rimraf('./orbitdb2')
|
||||
await rimraf('./ipfs1')
|
||||
await rimraf('./ipfs2')
|
||||
})
|
||||
|
||||
it('pins all entries in the replicated database', async () => {
|
||||
const db1 = await orbitdb1.open('helloworld', { referencesCount: 0 })
|
||||
const hash = await db1.add('hello world')
|
||||
|
||||
let replicated = false
|
||||
|
||||
const onJoin = async (peerId, heads) => {
|
||||
replicated = true
|
||||
}
|
||||
|
||||
const db2 = await orbitdb2.open(db1.address)
|
||||
|
||||
db2.events.on('join', onJoin)
|
||||
|
||||
await waitFor(() => replicated, () => true)
|
||||
|
||||
const cid = CID.parse(hash, base58btc)
|
||||
strictEqual(await ipfs1.pins.isPinned(cid), true)
|
||||
strictEqual(await ipfs2.pins.isPinned(cid), false)
|
||||
})
|
||||
})
|
@ -136,10 +136,10 @@ describe('Replicating databases', function () {
|
||||
|
||||
await orbitdb1.stop()
|
||||
await orbitdb2.stop()
|
||||
// TODO: Strange issue with ClassicLevel. Causes subsequent Helia
|
||||
// TODO: Strange issue with ClassicLevel. Causes subsequent Helia
|
||||
// instantiations to error with db closed. Explicitly closing the
|
||||
// nested ClassicLevel db seems to resolve the issue. Requires further
|
||||
// investigation.
|
||||
// nested ClassicLevel db seems to resolve the issue. Requires further
|
||||
// investigation.
|
||||
await ipfs1.blockstore.child.child.child.close()
|
||||
await ipfs2.blockstore.child.child.child.close()
|
||||
await ipfs1.stop()
|
||||
|
@ -193,7 +193,7 @@ describe('OrbitDB', function () {
|
||||
it('has a peerId', async () => {
|
||||
notStrictEqual(orbitdb1.peerId, undefined)
|
||||
})
|
||||
|
||||
|
||||
it('has a peerId of type Ed25519', async () => {
|
||||
strictEqual(orbitdb1.peerId.type, 'Ed25519')
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user