Skip to content

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki authored Nov 22, 2024
1 parent 9d4490f commit 730cd77
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 13 deletions.
3 changes: 0 additions & 3 deletions test/e2e/edge-cases.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { loadBlockFixtures } from './fixtures/load-block-fixtures.js'
import { testExploredCid } from './fixtures/test-explore-cid.js'

test.describe('edge-cases', () => {
/**
* @type {ReturnType<import('kubo-rpc-client')['create']>}
*/
let ipfs: KuboRPCClient
test.beforeEach(async () => {
ipfs = create(process.env.IPFS_RPC_ADDR)
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/setup/global-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const __filename = fileURLToPath(import.meta.url)
// eslint-disable-next-line @typescript-eslint/naming-convention
const __dirname = path.dirname(__filename)

// make sure that ipfs-backend is fully running
interface ApiOpts {
protocol: string
host: string
port: number
}
// make sure that ipfs-backend is fully running
const ensureKuboDaemon = async (apiOpts: ApiOpts): Promise<void> => {
const backendEndpoint = `${apiOpts.protocol}://${apiOpts.host}:${apiOpts.port}`
const body = new FormData()
Expand Down Expand Up @@ -47,8 +47,6 @@ const globalSetup = async (config: PlaywrightTestConfig): Promise<void> => {

await ensureKuboDaemon(apiOpts)

// Set and save RPC API endpoint in storageState, so test start against
// desired endpoint
// @ts-expect-error - broken types for projects from playwright config
const { baseURL, storageState } = config.projects[0].use
const browser = await chromium.launch()
Expand Down
7 changes: 0 additions & 7 deletions test/e2e/setup/ipfs-backend.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-check
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'url'
Expand All @@ -15,7 +14,6 @@ const { console } = globalThis
let ipfsd: KuboNode
let ipfs: KuboRPCClient
async function run (rpcPort?: string): Promise<void> {
// let gatewayPort = 8080
if (ipfsd != null && ipfs != null) {
throw new Error('IPFS backend already running')
}
Expand All @@ -25,7 +23,6 @@ async function run (rpcPort?: string): Promise<void> {
ipfs = create(endpoint)
} else {
// use ipfds-ctl to spawn daemon to expose http api used for e2e tests
// gatewayPort = await getPort(gatewayPort, '0.0.0.0')
const factory = createFactory({
rpc: create,
type: 'kubo',
Expand Down Expand Up @@ -58,17 +55,13 @@ async function run (rpcPort?: string): Promise<void> {
const { address: apiHost, port: apiPort } = rpcApiMaddr.nodeAddress()
const { hostname: gatewayHost, port: gatewayPort } = new URL(gateway)

// some temporary hardcoding until https://github.com/ipfs/js-ipfsd-ctl/issues/831 is resolved.
// const { apiHost, apiPort } = { apiHost: '127.0.0.1', apiPort: rpcPort }

if (String(apiPort) !== rpcPort) {
console.error(`Invalid RPC port returned by IPFS backend: ${apiPort} != ${rpcPort}`)
await ipfsd.stop()
process.exit(1)
}

// const rpcAddr = `/ip4/${apiHost}/tcp/${apiPort}`
// const gatewayAddr = endpoint ?? rpcAddr

// persist details for e2e tests
fs.writeFileSync(path.join(__dirname, 'ipfs-backend.json'), JSON.stringify({
Expand Down

0 comments on commit 730cd77

Please sign in to comment.