Skip to content

Commit

Permalink
fix tests expecting hop to be enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ckousik committed Jan 25, 2023
1 parent 97248f7 commit 625753a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/circuit/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { codes } from '../errors.js'
import {
setDelayedInterval,
clearDelayedInterval
// @ts-expect-error set-delayed-interval does not export types
// @ts-expect-error set-delayed-interval does not export types
} from 'set-delayed-interval'
import { namespaceToCid } from './utils.js'
import {
Expand Down Expand Up @@ -62,9 +62,9 @@ export class Relay implements Startable {
* Stop Relay service
*/
async stop () {
if (this.timeout != null) {
try {
clearDelayedInterval(this.timeout)
}
} catch (err) { }

this.started = false
}
Expand Down
10 changes: 7 additions & 3 deletions src/circuit/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,17 @@ export class Circuit implements Transport, Startable {
log.error(err)
})

this.reservationStore.start()
if (this._init.hop.enabled === true) {
this.reservationStore.start()
}
}

async stop () {
this.reservationStore.stop()
if (this._init.hop.enabled === true) {
this.reservationStore.stop()
await this.components.registrar.unhandle(RELAY_V2_HOP_CODEC)
}
await this.components.registrar.unhandle(RELAY_V1_CODEC)
await this.components.registrar.unhandle(RELAY_V2_HOP_CODEC)
await this.components.registrar.unhandle(RELAY_V2_STOP_CODEC)
}

Expand Down
4 changes: 2 additions & 2 deletions test/configuration/protocol-prefix.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Protocol prefix is configurable', () => {
const protocols = await libp2p.peerStore.protoBook.get(libp2p.peerId)
expect(protocols).to.include.members([
`/${testProtocol}/fetch/0.0.1`,
'/libp2p/circuit/relay/0.2.0/hop',
'/libp2p/circuit/relay/0.2.0/stop',
`/${testProtocol}/id/1.0.0`,
`/${testProtocol}/id/push/1.0.0`,
`/${testProtocol}/ping/1.0.0`
Expand All @@ -46,7 +46,7 @@ describe('Protocol prefix is configurable', () => {

const protocols = await libp2p.peerStore.protoBook.get(libp2p.peerId)
expect(protocols).to.include.members([
'/libp2p/circuit/relay/0.2.0/hop',
'/libp2p/circuit/relay/0.2.0/stop',
'/ipfs/id/1.0.0',
'/ipfs/id/push/1.0.0',
'/ipfs/ping/1.0.0',
Expand Down

0 comments on commit 625753a

Please sign in to comment.