fix: add yamux interop tests (#1290)

Test stream compatibility with https://www.npmjs.com/package/@chainsafe/libp2p-yamux

Co-authored-by: achingbrain <alex@achingbrain.net>
This commit is contained in:
Cayman
2022-09-09 06:27:34 -04:00
committed by achingbrain
parent dd14f82ed5
commit b87632f97f
3 changed files with 17 additions and 5 deletions

View File

@ -12,6 +12,7 @@ import { execa } from 'execa'
import pDefer from 'p-defer'
import { logger } from '@libp2p/logger'
import { Mplex } from '@libp2p/mplex'
import { Yamux } from '@chainsafe/libp2p-yamux'
import fs from 'fs'
import { unmarshalPrivateKey } from '@libp2p/crypto/keys'
import type { PeerId } from '@libp2p/interface-peer-id'
@ -93,10 +94,16 @@ async function createJsPeer (options: SpawnOptions): Promise<Daemon> {
listen: ['/ip4/0.0.0.0/tcp/0']
},
transports: [new TCP()],
streamMuxers: [new Mplex()],
streamMuxers: [],
connectionEncryption: [new Noise()]
}
if (options.muxer === 'mplex') {
opts.streamMuxers?.push(new Mplex())
} else {
opts.streamMuxers?.push(new Yamux())
}
if (options.dht === true) {
// go-libp2p-daemon only has the older single-table DHT instead of the dual
// lan/wan version found in recent go-ipfs versions. unfortunately it's been