Skip to content

Commit

Permalink
fix: add factory opts and use ipfs api (#655)
Browse files Browse the repository at this point in the history
Add `.opts` arg to `Factory` interface as it's used by the `interface-ipfs-core` tests.

Also stop extending IPFS, just use the core api and if you need id/config details call the relevant API methods instead.
  • Loading branch information
achingbrain committed Aug 3, 2021
1 parent 19585f2 commit a09661d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 24 deletions.
14 changes: 2 additions & 12 deletions src/types.d.ts
@@ -1,23 +1,12 @@

import { EventEmitter } from 'events'
import { IPFS } from 'ipfs-core-types'
import { IDResult } from 'ipfs-core-types/src/root'

export interface Subprocess {
stderr: EventEmitter | null
stdout: EventEmitter | null
}

export interface API extends IPFS {
peerId: IDResult
apiHost: string
apiPort: string
gatewayHost: string
gatewayPort: string
grpcHost: string
grpcPort: string
}

export interface Controller {
init: (options?: InitOptions) => Promise<Controller>
start: () => Promise<Controller>
Expand All @@ -29,7 +18,7 @@ export interface Controller {
started: boolean
initialized: boolean
clean: boolean
api: API
api: IPFS
subprocess?: Subprocess | null
opts: ControllerOptions
}
Expand Down Expand Up @@ -207,4 +196,5 @@ export interface Factory {
spawn: (options?: ControllerOptions) => Promise<Controller>
clean: () => Promise<void>
controllers: Controller[]
opts: ControllerOptions
}
2 changes: 0 additions & 2 deletions test/controller.spec.js
Expand Up @@ -203,8 +203,6 @@ describe('Controller API', function () {
await ctl.init()
await ctl.start()
expect(ctl.started).to.be.true()
const id = await ctl.api.id()
expect(factory.controllers[0].api.peerId.id).to.be.eq(id.id)
})
}
})
Expand Down
10 changes: 0 additions & 10 deletions test/create.spec.js
Expand Up @@ -172,16 +172,6 @@ const types = [{
remote: true
}]

describe('`createController` should return daemon with peerId when started', () => {
for (const opts of types) {
it(`type: ${opts.type} remote: ${Boolean(opts.remote)}`, async () => {
const node = await createController(opts)
expect(node.api.peerId).to.exist()
await node.stop()
})
}
})

describe('`createController({test: true})` should return daemon with test profile', () => {
for (const opts of types) {
it(`type: ${opts.type} remote: ${Boolean(opts.remote)}`, async () => {
Expand Down

0 comments on commit a09661d

Please sign in to comment.