Skip to content

Commit c37ba88

Browse files
authoredMay 25, 2022
chore: update libp2p interfaces (#435)
Updates deps
1 parent 22772ef commit c37ba88

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed
 

‎package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
"generate:proto-types": "pbts -o src/message/message.d.ts src/message/message.js"
162162
},
163163
"dependencies": {
164-
"@libp2p/interfaces": "^1.3.18",
164+
"@libp2p/interfaces": "^2.0.2",
165165
"@libp2p/topology": "^1.1.6",
166166
"@libp2p/tracked-map": "^1.0.4",
167167
"@multiformats/multiaddr": "^10.1.8",
@@ -182,7 +182,7 @@
182182
"varint-decoder": "^1.0.0"
183183
},
184184
"devDependencies": {
185-
"@chainsafe/libp2p-noise": "^6.0.1",
185+
"@chainsafe/libp2p-noise": "^6.2.0",
186186
"@libp2p/kad-dht": "^1.0.3",
187187
"@libp2p/mplex": "^1.0.2",
188188
"@libp2p/peer-id": "^1.1.8",
@@ -214,7 +214,7 @@
214214
"process": "^0.11.10",
215215
"promisify-es6": "^1.0.3",
216216
"rimraf": "^3.0.2",
217-
"sinon": "^13.0.1",
217+
"sinon": "^14.0.0",
218218
"stats-lite": "^2.2.0",
219219
"url": "^0.11.0",
220220
"util": "^0.12.3",

‎test/utils/mocks.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ export const mockLibp2pNode = () => {
3131
const buf = uint8ArrayFromString('122019318b6e5e0cf93a2314bf01269a2cc23cd3dcd452d742cdb9379d8646f6e4a9', 'base16')
3232
const peerId = peerIdFromBytes(buf)
3333

34-
// @ts-ignore - not all libp2p fields are implemented
35-
return Object.assign(new EventEmitter(), {
34+
const libp2p = Object.assign(new EventEmitter(), {
3635
peerId,
3736
multiaddrs: [],
3837
handle () {},
@@ -57,10 +56,15 @@ export const mockLibp2pNode = () => {
5756
swarm: {
5857
setMaxListeners () {}
5958
},
60-
peerStore: new PersistentPeerStore(new Components({ peerId, datastore: new MemoryDatastore() }), {
59+
peerStore: new PersistentPeerStore({
6160
addressFilter: async () => true
6261
})
6362
})
63+
64+
libp2p.peerStore.init(new Components({ peerId, datastore: new MemoryDatastore() }))
65+
66+
// @ts-expect-error not all libp2p fields are implemented
67+
return libp2p
6468
}
6569

6670
/**
@@ -173,7 +177,10 @@ export const genBitswapNetwork = async (n, enableDHT = false) => {
173177
peers.map(async (peerId, i) => {
174178
const libp2p = await createLibp2pNode({
175179
peerId,
176-
DHT: enableDHT
180+
DHT: enableDHT,
181+
nat: {
182+
enabled: false
183+
}
177184
})
178185

179186
await libp2p.start()

0 commit comments

Comments
 (0)
Please sign in to comment.