Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/auth/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
const resp2 = await fetch(request)

if (!resp2.ok) {
throw new BadResponseError(`Unexpected status code ${resp.status}`)
throw new BadResponseError(`Unexpected status code ${resp2.status}`)

Check warning on line 192 in src/auth/client.ts

View check run for this annotation

Codecov / codecov/patch

src/auth/client.ts#L192

Added line #L192 was not covered by tests
}

const serverAuthHeader = resp2.headers.get('Authentication-Info')
Expand Down
12 changes: 8 additions & 4 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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'
Expand Down Expand Up @@ -45,20 +45,24 @@

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<Connection>()
conn.newStream.callsFake(async (protos: Protocol[], options?: any) => {
conn.newStream.callsFake(async (protos: string | string[], options?: any) => {
const duplexes = duplexPair<any>()
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]
}

Check warning on line 64 in test/index.spec.ts

View check run for this annotation

Codecov / codecov/patch

test/index.spec.ts#L63-L64

Added lines #L63 - L64 were not covered by tests

if (isPeerId(peer) ? peer.equals(serverPeerID) : peer.getPeerId() === serverMultiaddr.getPeerId()) {
await serverCBRegistered.promise
return conn
Expand Down
Loading