-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: run transport compliance tests on WebRTC and Circuit Relay (#2816
- Loading branch information
1 parent
18e8e1c
commit 02f285f
Showing
37 changed files
with
589 additions
and
673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/integration-tests/test/compliance/transport/circuit-relay.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* eslint-env mocha */ | ||
|
||
import { noise } from '@chainsafe/libp2p-noise' | ||
import { yamux } from '@chainsafe/libp2p-yamux' | ||
import { circuitRelayTransport } from '@libp2p/circuit-relay-v2' | ||
import { identify } from '@libp2p/identify' | ||
import tests from '@libp2p/interface-compliance-tests/transport' | ||
import { webSockets } from '@libp2p/websockets' | ||
import { all } from '@libp2p/websockets/filters' | ||
import { Circuit, P2P } from '@multiformats/multiaddr-matcher' | ||
import { and, fmt, literal } from '@multiformats/multiaddr-matcher/utils' | ||
|
||
export const CircuitListen = fmt( | ||
and(P2P.matchers[0], literal('p2p-circuit')) | ||
) | ||
|
||
describe('Circuit relay transport interface compliance', () => { | ||
tests({ | ||
async setup () { | ||
const dialer = { | ||
transports: [ | ||
circuitRelayTransport(), | ||
webSockets({ | ||
filter: all | ||
}) | ||
], | ||
connectionEncrypters: [ | ||
noise() | ||
], | ||
streamMuxers: [ | ||
yamux() | ||
], | ||
services: { | ||
identify: identify() | ||
}, | ||
connectionGater: { | ||
denyDialMultiaddr: () => false | ||
} | ||
} | ||
|
||
return { | ||
dialer, | ||
listener: { | ||
addresses: { | ||
listen: [ | ||
`${process.env.RELAY_WS_MULTIADDR_0}/p2p-circuit`, | ||
`${process.env.RELAY_WS_MULTIADDR_1}/p2p-circuit` | ||
] | ||
}, | ||
...dialer | ||
}, | ||
dialMultiaddrMatcher: Circuit, | ||
listenMultiaddrMatcher: CircuitListen | ||
} | ||
}, | ||
async teardown () {} | ||
}) | ||
}) |
36 changes: 28 additions & 8 deletions
36
packages/integration-tests/test/compliance/transport/memory.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
packages/integration-tests/test/compliance/transport/webrtc.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* eslint-env mocha */ | ||
|
||
import { noise } from '@chainsafe/libp2p-noise' | ||
import { yamux } from '@chainsafe/libp2p-yamux' | ||
import { circuitRelayTransport } from '@libp2p/circuit-relay-v2' | ||
import { identify } from '@libp2p/identify' | ||
import tests from '@libp2p/interface-compliance-tests/transport' | ||
import { webRTC } from '@libp2p/webrtc' | ||
import { webSockets } from '@libp2p/websockets' | ||
import { all } from '@libp2p/websockets/filters' | ||
import { WebRTC } from '@multiformats/multiaddr-matcher' | ||
import { isWebWorker } from 'wherearewe' | ||
|
||
describe('WebRTC transport interface compliance', () => { | ||
if (isWebWorker) { | ||
return | ||
} | ||
|
||
tests({ | ||
async setup () { | ||
const dialer = { | ||
transports: [ | ||
circuitRelayTransport(), | ||
webSockets({ | ||
filter: all | ||
}), | ||
webRTC() | ||
], | ||
connectionEncrypters: [ | ||
noise() | ||
], | ||
streamMuxers: [ | ||
yamux() | ||
], | ||
services: { | ||
identify: identify() | ||
}, | ||
connectionGater: { | ||
denyDialMultiaddr: () => false | ||
} | ||
} | ||
|
||
return { | ||
dialer, | ||
listener: { | ||
addresses: { | ||
listen: [ | ||
`${process.env.RELAY_WS_MULTIADDR_0}/p2p-circuit`, | ||
`${process.env.RELAY_WS_MULTIADDR_1}/p2p-circuit`, | ||
'/webrtc' | ||
] | ||
}, | ||
...dialer | ||
}, | ||
dialMultiaddrMatcher: WebRTC, | ||
listenMultiaddrMatcher: WebRTC | ||
} | ||
}, | ||
async teardown () {} | ||
}) | ||
}) |
58 changes: 40 additions & 18 deletions
58
packages/integration-tests/test/compliance/transport/websockets.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.