style: Linting.

This commit is contained in:
Hayden Young 2024-10-15 18:38:53 +01:00
parent 2aee8e408c
commit 58769c4d15
5 changed files with 69 additions and 13 deletions

View File

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

View File

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

View 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)
})
})

View File

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

View File

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