Skip to content

Commit

Permalink
fix: Correct creatPins params.
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenyoung committed May 26, 2024
1 parent 43b1a39 commit 91f4027
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
10 changes: 7 additions & 3 deletions src/lib/libp2p/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import { createFromPrivKey } from '@libp2p/peer-id-factory'
import { unmarshalPrivateKey } from '@libp2p/crypto/keys'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'

const encoded = uint8ArrayFromString(process.env.PRIVATE_KEY, 'hex')
const privateKey = await unmarshalPrivateKey(encoded)
const peerId = await createFromPrivKey(privateKey)
let peerId

if (process.env.PRIVATE_KEY) {
const encoded = uint8ArrayFromString(process.env.PRIVATE_KEY, 'hex')
const privateKey = await unmarshalPrivateKey(encoded)
peerId = await createFromPrivKey(privateKey)
}

export default {
peerId,
Expand Down
2 changes: 1 addition & 1 deletion test/authorization.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Authorization', function () {

after(async function () {
await orbiter.stop()
await rimraf('./orbiter')
await rimraf('./voyager')
})

it('defaults access to deny all', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/messages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Messages', function () {
await lander.orbitdb.stop()
await lander.orbitdb.ipfs.stop()
await rimraf('./lander')
await rimraf('./orbiter')
await rimraf('./voyager')
})

it('pins a database with OK response', async function () {
Expand Down
10 changes: 5 additions & 5 deletions test/pin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Pin', function () {

afterEach(async function () {
await orbiter.stop()
await rimraf('./orbiter')
await rimraf('./voyager')
})

describe('Single Transient Peer', function () {
Expand All @@ -37,14 +37,14 @@ describe('Pin', function () {
})

it('pins a database', async function () {
const { pinned, dbs } = await createPins(1, lander, orbiter)
const { pinned, dbs } = await createPins(1, lander)

strictEqual(pinned, true)
strictEqual(Object.values(orbiter.dbs).pop().address, dbs.pop().address)
})

it('pins multiple databases', async function () {
const { pinned, dbs } = await createPins(2, lander, orbiter)
const { pinned, dbs } = await createPins(2, lander)

strictEqual(pinned, true)
strictEqual(Object.values(orbiter.dbs)[0].address, dbs[0].address)
Expand Down Expand Up @@ -84,8 +84,8 @@ describe('Pin', function () {
})

it('pins a database', async function () {
const { dbs: dbs1 } = await createPins(1, lander1, orbiter)
const { dbs: dbs2 } = await createPins(1, lander2, orbiter)
const { dbs: dbs1 } = await createPins(1, lander1)
const { dbs: dbs2 } = await createPins(1, lander2)

strictEqual(Object.values(orbiter.dbs)[0].address, dbs1.pop().address)
strictEqual(Object.values(orbiter.dbs)[1].address, dbs2.pop().address)
Expand Down
8 changes: 4 additions & 4 deletions test/unpin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Unpin', function () {

afterEach(async function () {
await orbiter.stop()
await rimraf('./orbiter')
await rimraf('./voyager')
})

describe('Single Transient Peer', function () {
Expand All @@ -37,7 +37,7 @@ describe('Unpin', function () {
})

it('unpins a database', async function () {
const { dbs } = await createPins(1, lander, orbiter)
const { dbs } = await createPins(1, lander)

const unpinned = await lander.unpin(dbs)

Expand All @@ -47,7 +47,7 @@ describe('Unpin', function () {
})

it('unpins multiple databases', async function () {
const { dbs } = await createPins(2, lander, orbiter)
const { dbs } = await createPins(2, lander)

const unpinned = await lander.unpin(dbs)

Expand All @@ -57,7 +57,7 @@ describe('Unpin', function () {
})

it('unpins a database when multiple databases have been pinned', async function () {
const { dbs } = await createPins(2, lander, orbiter)
const { dbs } = await createPins(2, lander)

const unpinned = await lander.unpin(dbs.slice(0, 1))

Expand Down

0 comments on commit 91f4027

Please sign in to comment.