Skip to content

Commit

Permalink
fix: linting and deps
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed May 2, 2023
1 parent 3d4573d commit 22d3900
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"release": "npm run docs:no-publish && aegir run release && npm run docs"
},
"devDependencies": {
"aegir": "^38.1.0"
"aegir": "^39.0.3"
},
"type": "module",
"workspaces": [
Expand Down
6 changes: 2 additions & 4 deletions packages/interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,17 @@
"@helia/strings": "~0.0.0",
"@libp2p/tcp": "^6.1.2",
"@libp2p/websockets": "^5.0.3",
"aegir": "^38.1.0",
"aegir": "^39.0.3",
"blockstore-core": "^4.0.1",
"datastore-core": "^9.0.3",
"go-ipfs": "^0.19.0",
"helia": "^1.0.0",
"ipfs-core-types": "^0.14.0",
"ipfs-unixfs-importer": "^15.1.0",
"ipfsd-ctl": "^13.0.0",
"it-to-buffer": "^4.0.1",
"kubo-rpc-client": "^3.0.0",
"libp2p": "^0.43.2",
"merge-options": "^3.0.4",
"multiformats": "^11.0.1",
"uint8arrays": "^4.0.3",
"wherearewe": "^2.0.1"
},
"browser": {
Expand Down
8 changes: 4 additions & 4 deletions packages/interop/test/fixtures/create-helia.browser.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createHelia } from 'helia'
import { createLibp2p } from 'libp2p'
import { webSockets } from '@libp2p/websockets'
import { all } from '@libp2p/websockets/filters'
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { webSockets } from '@libp2p/websockets'
import { all } from '@libp2p/websockets/filters'
import { MemoryBlockstore } from 'blockstore-core'
import { MemoryDatastore } from 'datastore-core'
import { createHelia } from 'helia'
import { createLibp2p } from 'libp2p'
import type { Helia } from '@helia/interface'

export async function createHeliaNode (): Promise<Helia> {
Expand Down
6 changes: 3 additions & 3 deletions packages/interop/test/fixtures/create-helia.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createHelia } from 'helia'
import { createLibp2p, Libp2pOptions } from 'libp2p'
import { tcp } from '@libp2p/tcp'
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { tcp } from '@libp2p/tcp'
import { MemoryBlockstore } from 'blockstore-core'
import { MemoryDatastore } from 'datastore-core'
import { createHelia } from 'helia'
import { createLibp2p, type Libp2pOptions } from 'libp2p'
import type { Helia } from '@helia/interface'

export async function createHeliaNode (config: Libp2pOptions = {}): Promise<Helia> {
Expand Down
6 changes: 3 additions & 3 deletions packages/interop/test/fixtures/create-kubo.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

// @ts-expect-error no types
import * as goIpfs from 'go-ipfs'
import { Controller, ControllerOptions, createController } from 'ipfsd-ctl'
import { type Controller, type ControllerOptions, createController } from 'ipfsd-ctl'
import * as kuboRpcClient from 'kubo-rpc-client'
import { isElectronMain, isNode } from 'wherearewe'
import mergeOptions from 'merge-options'
import { isElectronMain, isNode } from 'wherearewe'

export async function createKuboNode (options: ControllerOptions<'go'> = {}): Promise<Controller> {
const opts = mergeOptions({
Expand All @@ -24,5 +24,5 @@ export async function createKuboNode (options: ControllerOptions<'go'> = {}): Pr
}
}, options)

return await createController(opts)
return createController(opts)
}
8 changes: 4 additions & 4 deletions packages/interop/test/strings.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* eslint-env mocha */

import { strings, type Strings, type AddOptions } from '@helia/strings'
import { expect } from 'aegir/chai'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { createHeliaNode } from './fixtures/create-helia.js'
import { createKuboNode } from './fixtures/create-kubo.js'
import type { Helia } from '@helia/interface'
import type { Controller } from 'ipfsd-ctl'
import { strings, Strings, AddOptions } from '@helia/strings'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import type { PutOptions as KuboAddOptions } from 'ipfs-core-types/src/block/index.js'
import type { Controller } from 'ipfsd-ctl'

describe('strings interop', () => {
let helia: Helia
Expand Down
4 changes: 3 additions & 1 deletion packages/strings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,15 @@
"release": "aegir release"
},
"dependencies": {
"@helia/interface": "^1.0.0",
"@libp2p/interfaces": "^3.3.1",
"interface-blockstore": "^5.0.0",
"multiformats": "^11.0.1",
"progress-events": "^1.0.0",
"uint8arrays": "^4.0.3"
},
"devDependencies": {
"aegir": "^38.1.0",
"aegir": "^39.0.3",
"blockstore-core": "^4.0.1"
},
"typedoc": {
Expand Down
12 changes: 6 additions & 6 deletions packages/strings/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
*/

import { CID } from 'multiformats/cid'
import type { Blocks, GetBlockProgressEvents, PutBlockProgressEvents } from '@helia/interface/blocks'
import type { AbortOptions } from '@libp2p/interfaces'
import type { ProgressOptions } from 'progress-events'
import { sha256 } from 'multiformats/hashes/sha2'
import * as raw from 'multiformats/codecs/raw'
import { sha256 } from 'multiformats/hashes/sha2'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import type { Blocks, GetBlockProgressEvents, PutBlockProgressEvents } from '@helia/interface/blocks'
import type { AbortOptions } from '@libp2p/interfaces'
import type { BlockCodec } from 'multiformats/codecs/interface'
import type { MultihashHasher } from 'multiformats/hashes/interface'
import type { ProgressOptions } from 'progress-events'

export interface StringsComponents {
blockstore: Blocks
Expand All @@ -46,8 +46,8 @@ export interface GetOptions extends AbortOptions, ProgressOptions<GetBlockProgre
}

/**
* The UnixFS interface provides familiar filesystem operations to make working with
* UnixFS DAGs simple and intuitive.
* The Strings interface provides a simple and intuitive way to add/get strings
* with your Helia node and is a great place to start learning about IPFS.
*/
export interface Strings {
/**
Expand Down
22 changes: 20 additions & 2 deletions packages/strings/test/add.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/* eslint-env mocha */

import { expect } from 'aegir/chai'
import type { Blockstore } from 'interface-blockstore'
import { strings, Strings } from '../src/index.js'
import { MemoryBlockstore } from 'blockstore-core'
import * as json from 'multiformats/codecs/json'
import { identity } from 'multiformats/hashes/identity'
import { strings, type Strings } from '../src/index.js'
import type { Blockstore } from 'interface-blockstore'

describe('put', () => {
let blockstore: Blockstore
Expand All @@ -20,4 +22,20 @@ describe('put', () => {

expect(`${cid}`).to.equal('bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e')
})

it('adds a string with a non-default hashing algorithm', async () => {
const cid = await str.add('hello world', {
hasher: identity
})

expect(`${cid}`).to.equal('bafkqac3imvwgy3zao5xxe3de')
})

it('adds a string with a non-default block codec', async () => {
const cid = await str.add('hello world', {
codec: json
})

expect(`${cid}`).to.equal('bagaaieraxfgspomtju7arjjokll5u7nl7lcij37dpjjyb3uqrd32zyxpzxuq')
})
})
26 changes: 23 additions & 3 deletions packages/strings/test/get.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/* eslint-env mocha */

import { expect } from 'aegir/chai'
import type { Blockstore } from 'interface-blockstore'
import { strings, Strings } from '../src/index.js'
import { MemoryBlockstore } from 'blockstore-core'
import * as json from 'multiformats/codecs/json'
import { identity } from 'multiformats/hashes/identity'
import { strings, type Strings } from '../src/index.js'
import type { Blockstore } from 'interface-blockstore'
import type { CID } from 'multiformats/cid'

describe('get', () => {
Expand All @@ -18,9 +20,27 @@ describe('get', () => {
cid = await str.add('hello world')
})

it('adds a string', async () => {
it('gets a string', async () => {
const string = await str.get(cid)

expect(`${string}`).to.equal('hello world')
})

it('gets a string with a non-default hashing algorithm', async () => {
const input = 'hello world'
const cid = await str.add(input, {
hasher: identity
})

await expect(str.get(cid)).to.eventually.equal(input)
})

it('gets a string with a non-default block codec', async () => {
const input = 'hello world'
const cid = await str.add(input, {
codec: json
})

await expect(str.get(cid)).to.eventually.equal(input)
})
})

0 comments on commit 22d3900

Please sign in to comment.