Skip to content

Commit

Permalink
refactor: switch to createController
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Jan 6, 2020
1 parent 58c90af commit bac8428
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
5 changes: 2 additions & 3 deletions test/e2e/peers.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/* global webuiUrl, jest, ipfs page, describe, it, expect, beforeAll, afterAll */

const Ctl = require('ipfsd-ctl')
const { createController } = require('ipfsd-ctl')

describe('Peers screen', () => {
let ipfsd
let peeraddr
beforeAll(async () => {
// spawn an ephemeral local node for manual swarm connect test
const factory = Ctl.createFactory({ type: 'proc', test: true, disposable: true })
ipfsd = await factory.spawn()
ipfsd = await createController({ type: 'proc', test: true, disposable: true })
const { addresses } = await ipfsd.api.id()
peeraddr = addresses.find((addr) => addr.startsWith('/ip4/127.0.0.1'))
// connect to peer to have something in the peer table
Expand Down
13 changes: 6 additions & 7 deletions test/e2e/setup/global-init.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { setup: setupPuppeteer } = require('jest-environment-puppeteer')
const { setup: setupDevServer } = require('jest-dev-server')
const ipfsClient = require('ipfs-http-client')
const Ctl = require('ipfsd-ctl')
const { createController } = require('ipfsd-ctl')
const { findBin } = require('ipfsd-ctl/src/utils')

// port on which static HTTP server exposes the webui from build/ directory
Expand All @@ -27,15 +27,14 @@ module.exports = async function globalSetup (globalConfig) {
} else {
// use ipfds-ctl to spawn daemon to expose http api used for e2e tests
const type = process.env.E2E_IPFSD_TYPE || 'go'
const factory = Ctl.createFactory({
ipfsd = await createController({
type,
test: true, // sets up all CORS headers required for accessing HTTP API port of ipfsd node
overrides: { // call findBin here to ensure we use version from devDependencies, and not from ipfsd-ctl
js: { ipfsBin: findBin('js') },
go: { ipfsBin: findBin('go') }
}
}, {
// overrides: call findBin here to ensure we use version from devDependencies, and not from ipfsd-ctl
js: { ipfsBin: findBin('js') },
go: { ipfsBin: findBin('go') }
})
ipfsd = await factory.spawn()
ipfs = ipfsd.api
}
const { id, agentVersion } = await ipfs.id()
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/setup/test-environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class WebuiTestEnvironment extends PuppeteerEnvironment {
// open Status page, confirm working connection to API
await page.goto(webuiUrl + '#/')
const { id } = await ipfs.id()
await expect(page).toMatch(id)
await expect(page).toMatch(id, { timeout: 15000 })
}
}

Expand Down

0 comments on commit bac8428

Please sign in to comment.