Skip to content

Commit 17e7928

Browse files
authored
chore: upgrade aegir to 38.1.2 (#109)
1 parent c89a5e1 commit 17e7928

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,14 @@
144144
"@libp2p/peer-id": "^2.0.0",
145145
"any-signal": "^3.0.1",
146146
"err-code": "^3.0.1",
147+
"ipfs-core-types": "^0.14.0",
147148
"multiformats": "^11.0.0",
148149
"p-defer": "^4.0.0",
149150
"p-queue": "^7.2.0"
150151
},
151152
"devDependencies": {
152153
"@libp2p/peer-id-factory": "^2.0.0",
153-
"aegir": "^37.9.1",
154+
"aegir": "^38.1.2",
154155
"go-ipfs": "^0.15.0",
155156
"ipfs-http-client": "^59.0.0",
156157
"ipfsd-ctl": "^12.0.2",

src/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,15 @@ class DelegatedPeerRouting implements PeerRouting, Startable {
148148
log(`enabled DelegatedPeerRouting via ${protocol}://${host}:${port}`)
149149
}
150150

151-
isStarted () {
151+
isStarted (): boolean {
152152
return this.started
153153
}
154154

155-
start () {
155+
start (): void {
156156
this.started = true
157157
}
158158

159-
stop () {
159+
stop (): void {
160160
this.httpQueue.clear()
161161
this.abortController.abort()
162162
this.abortController = new AbortController()
@@ -166,7 +166,7 @@ class DelegatedPeerRouting implements PeerRouting, Startable {
166166
/**
167167
* Attempts to find the given peer
168168
*/
169-
async findPeer (id: PeerId, options: HTTPClientExtraOptions & AbortOptions = {}) {
169+
async findPeer (id: PeerId, options: HTTPClientExtraOptions & AbortOptions = {}): Promise<PeerInfo> {
170170
log('findPeer starts: %p', id)
171171
options.timeout = options.timeout ?? DEFAULT_TIMEOUT
172172
options.signal = anySignal([this.abortController.signal].concat((options.signal != null) ? [options.signal] : []))
@@ -208,7 +208,7 @@ class DelegatedPeerRouting implements PeerRouting, Startable {
208208
/**
209209
* Attempt to find the closest peers on the network to the given key
210210
*/
211-
async * getClosestPeers (key: Uint8Array, options: HTTPClientExtraOptions & AbortOptions = {}) {
211+
async * getClosestPeers (key: Uint8Array, options: HTTPClientExtraOptions & AbortOptions = {}): AsyncGenerator<PeerInfo, void, undefined> {
212212
let cidOrPeerId: CID | PeerId
213213
const cid = CID.asCID(key)
214214

test/index.spec.ts

+10-16
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const factory = createFactory({
2929
endpoint: 'http://localhost:57583'
3030
})
3131

32-
async function spawnNode (bootstrap: any[] = []) {
32+
async function spawnNode (bootstrap: any[] = []): Promise<{ node: Controller, id: IDResult }> {
3333
const node = await factory.spawn({
3434
// Lock down the nodes so testing can be deterministic
3535
ipfsOptions: {
@@ -46,7 +46,7 @@ async function spawnNode (bootstrap: any[] = []) {
4646
}
4747
}
4848

49-
function createIpfsClient (opts: Options) {
49+
function createIpfsClient (opts: Options): any {
5050
const client = create(opts)
5151

5252
return {
@@ -119,7 +119,7 @@ describe('DelegatedPeerRouting', function () {
119119
port: 8000,
120120
host: 'localhost'
121121
})
122-
// @ts-expect-error ipfs-http-client types are out of date
122+
123123
const router = delegatedPeerRouting(client)()
124124

125125
expect(router).to.have.property('client')
@@ -138,33 +138,30 @@ describe('DelegatedPeerRouting', function () {
138138
it('should be able to find peers via the delegate with a peer id string', async () => {
139139
const opts = delegatedNode.apiAddr.toOptions()
140140

141-
// @ts-expect-error ipfs-http-client types are out of date
142141
const router = delegatedPeerRouting(createIpfsClient({
143142
protocol: 'http',
144143
port: opts.port,
145144
host: opts.host
146145
}))()
147146

148-
// @ts-expect-error ipfs-http-client types are out of date
149147
const peer = await router.findPeer(peerIdToFind.id)
150148

151149
const { id, multiaddrs } = peer
152150
expect(id).to.exist()
153151
expect(multiaddrs).to.exist()
154-
// @ts-expect-error ipfs-http-client types are out of date
152+
155153
expect(id.equals(peerIdToFind.id)).to.be.true()
156154
})
157155

158156
it('should be able to find peers via the delegate with a peerid', async () => {
159157
const opts = delegatedNode.apiAddr.toOptions()
160-
// @ts-expect-error ipfs-http-client types are out of date
158+
161159
const router = delegatedPeerRouting(createIpfsClient({
162160
protocol: 'http',
163161
port: opts.port,
164162
host: opts.host
165163
}))()
166164

167-
// @ts-expect-error ipfs-http-client types are out of date
168165
const peer = await router.findPeer(peerIdToFind.id)
169166

170167
const { id, multiaddrs } = peer
@@ -176,15 +173,14 @@ describe('DelegatedPeerRouting', function () {
176173

177174
it('should be able to specify a timeout', async () => {
178175
const opts = delegatedNode.apiAddr.toOptions()
179-
// @ts-expect-error ipfs-http-client types are out of date
176+
180177
const router = delegatedPeerRouting(createIpfsClient({
181178
protocol: 'http',
182179
port: opts.port,
183180
host: opts.host
184181
}))()
185182
const controller = new TimeoutController(5e3)
186183

187-
// @ts-expect-error ipfs-http-client types are out of date
188184
const peer = await router.findPeer(peerIdToFind.id, { signal: controller.signal })
189185

190186
const { id, multiaddrs } = peer
@@ -198,7 +194,7 @@ describe('DelegatedPeerRouting', function () {
198194

199195
it('should not be able to find peers not on the network', async () => {
200196
const opts = delegatedNode.apiAddr.toOptions()
201-
// @ts-expect-error ipfs-http-client types are out of date
197+
202198
const router = delegatedPeerRouting(createIpfsClient({
203199
protocol: 'http',
204200
port: opts.port,
@@ -216,7 +212,6 @@ describe('DelegatedPeerRouting', function () {
216212
it('should be able to query for the closest peers', async () => {
217213
const opts = delegatedNode.apiAddr.toOptions()
218214

219-
// @ts-expect-error ipfs-http-client types are out of date
220215
const router = delegatedPeerRouting(createIpfsClient({
221216
protocol: 'http',
222217
port: opts.port,
@@ -234,7 +229,7 @@ describe('DelegatedPeerRouting', function () {
234229
expect(closerPeers.length).to.equal(2)
235230
closerPeers.forEach(result => {
236231
// shouldn't be the delegate
237-
// @ts-expect-error ipfs-http-client types are out of date
232+
238233
expect(delegatePeerId.equals(result.id)).to.equal(false)
239234
expect(result.multiaddrs).to.be.an('array')
240235
})
@@ -243,7 +238,6 @@ describe('DelegatedPeerRouting', function () {
243238
it('should find closest peers even if the peer does not exist', async () => {
244239
const opts = delegatedNode.apiAddr.toOptions()
245240

246-
// @ts-expect-error ipfs-http-client types are out of date
247241
const router = delegatedPeerRouting(createIpfsClient({
248242
protocol: 'http',
249243
port: opts.port,
@@ -260,7 +254,7 @@ describe('DelegatedPeerRouting', function () {
260254
expect(closerPeers.length).to.equal(2)
261255
closerPeers.forEach(result => {
262256
// shouldnt be the delegate
263-
// @ts-expect-error ipfs-http-client types are out of date
257+
264258
expect(delegatePeerId.equals(result.id)).to.equal(false)
265259
expect(result.multiaddrs).to.be.an('array')
266260
})
@@ -270,7 +264,7 @@ describe('DelegatedPeerRouting', function () {
270264
describe('stop', () => {
271265
it('should cancel in-flight requests when stopping', async () => {
272266
const opts = delegatedNode.apiAddr.toOptions()
273-
// @ts-expect-error ipfs-http-client types are out of date
267+
274268
const router = delegatedPeerRouting(createIpfsClient({
275269
protocol: 'http',
276270
port: opts.port,

0 commit comments

Comments
 (0)