diff --git a/.github/workflows/test-examples.yml b/.github/workflows/test-examples.yml index 6b25e67..807ecf4 100644 --- a/.github/workflows/test-examples.yml +++ b/.github/workflows/test-examples.yml @@ -17,7 +17,7 @@ jobs: node-version: lts/* - run: npm i working-directory: ./examples - - uses: ipfs/aegir/actions/cache-node-modules@master + - uses: ipfs/aegir/actions/cache-node-modules@main with: directories: | ./examples/node_modules @@ -30,7 +30,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: lts/* - - uses: ipfs/aegir/actions/cache-node-modules@master + - uses: ipfs/aegir/actions/cache-node-modules@main with: directories: | ./examples/node_modules diff --git a/src/auth/client.ts b/src/auth/client.ts index 45b5218..de890a6 100644 --- a/src/auth/client.ts +++ b/src/auth/client.ts @@ -189,7 +189,7 @@ export class ClientAuth { const resp2 = await fetch(request) if (!resp2.ok) { - throw new BadResponseError(`Unexpected status code ${resp.status}`) + throw new BadResponseError(`Unexpected status code ${resp2.status}`) } const serverAuthHeader = resp2.headers.get('Authentication-Info') diff --git a/test/index.spec.ts b/test/index.spec.ts index 11027a8..9951a32 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -4,7 +4,7 @@ import { isPeerId, start, stop } from '@libp2p/interface' import { streamPair } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { peerIdFromString } from '@libp2p/peer-id' -import { multiaddr, type Multiaddr, type Protocol } from '@multiformats/multiaddr' +import { multiaddr, type Multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import { duplexPair } from 'it-pair/duplex' import { type Libp2p } from 'libp2p' @@ -45,20 +45,24 @@ describe('whatwg-fetch', () => { let serverCB: StreamHandler const serverCBRegistered = pDefer() - serverComponents.registrar.handle.callsFake(async (protocol: Protocol, cb: StreamHandler) => { + serverComponents.registrar.handle.callsFake(async (protocol: string, cb: StreamHandler) => { serverCB = cb serverCBRegistered.resolve() }) const conn = stubInterface() - conn.newStream.callsFake(async (protos: Protocol[], options?: any) => { + conn.newStream.callsFake(async (protos: string | string[], options?: any) => { const duplexes = duplexPair() const streams = streamPair({ duplex: duplexes[0] }, { duplex: duplexes[1] }) serverCB({ stream: streams[0], connection: conn }) return streams[1] }) - clientComponents.connectionManager.openConnection.callsFake(async (peer: PeerId | Multiaddr, options?: any) => { + clientComponents.connectionManager.openConnection.callsFake(async (peer: PeerId | Multiaddr | Multiaddr[], options?: any) => { + if (Array.isArray(peer)) { + peer = peer[0] + } + if (isPeerId(peer) ? peer.equals(serverPeerID) : peer.getPeerId() === serverMultiaddr.getPeerId()) { await serverCBRegistered.promise return conn