-
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: move transport interface tests to integration package (#2813)
Breaks sibling dependencies between interface tests and transports which means a fix to the connection encrypter interface tests don't cause a tcp release which causes a libp2p release which causes a webrtc release.
- Loading branch information
1 parent
6657690
commit 32ca76f
Showing
35 changed files
with
803 additions
and
1,030 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { serviceCapabilities } from '@libp2p/interface' | ||
import { PROTOCOL } from './index.js' | ||
import type { MultiaddrConnection, ConnectionEncrypter, SecuredConnection, SecureConnectionOptions } from '@libp2p/interface' | ||
import type { Duplex } from 'it-stream-types' | ||
import type { Uint8ArrayList } from 'uint8arraylist' | ||
|
||
export class TLS implements ConnectionEncrypter { | ||
public protocol: string = PROTOCOL | ||
|
||
constructor () { | ||
throw new Error('TLS encryption is not possible in browsers') | ||
} | ||
|
||
readonly [Symbol.toStringTag] = '@libp2p/tls' | ||
|
||
readonly [serviceCapabilities]: string[] = [ | ||
'@libp2p/connection-encryption' | ||
] | ||
|
||
async secureInbound <Stream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> = MultiaddrConnection> (conn: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream>> { | ||
throw new Error('TLS encryption is not possible in browsers') | ||
} | ||
|
||
async secureOutbound <Stream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> = MultiaddrConnection> (conn: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream>> { | ||
throw new Error('TLS encryption is not possible in browsers') | ||
} | ||
} |
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
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
19 changes: 19 additions & 0 deletions
19
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import tests from '@libp2p/interface-compliance-tests/transport' | ||
import { memory } from '@libp2p/memory' | ||
import { multiaddr } from '@multiformats/multiaddr' | ||
import type { Multiaddr } from '@multiformats/multiaddr' | ||
|
||
describe('memory transport interface compliance tests', () => { | ||
tests({ | ||
async setup () { | ||
const transport = memory() | ||
const dialAddrs: [Multiaddr, Multiaddr] = [ | ||
multiaddr('/memory/addr-1'), | ||
multiaddr('/memory/addr-2') | ||
] | ||
|
||
return { transport, dialAddrs } | ||
}, | ||
async teardown () {} | ||
}) | ||
}) |
43 changes: 43 additions & 0 deletions
43
packages/integration-tests/test/compliance/transport/tcp.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,43 @@ | ||
import tests from '@libp2p/interface-compliance-tests/transport' | ||
import { tcp } from '@libp2p/tcp' | ||
import { multiaddr } from '@multiformats/multiaddr' | ||
import { isBrowser, isWebWorker } from 'wherearewe' | ||
import type { Multiaddr } from '@multiformats/multiaddr' | ||
|
||
describe('tcp transport interface compliance IPv4', () => { | ||
if (isBrowser || isWebWorker) { | ||
return | ||
} | ||
|
||
tests({ | ||
async setup () { | ||
const transport = tcp() | ||
const dialAddrs: [Multiaddr, Multiaddr] = [ | ||
multiaddr('/ip4/127.0.0.1/tcp/9091'), | ||
multiaddr('/ip4/127.0.0.1/tcp/9092') | ||
] | ||
|
||
return { transport, dialAddrs } | ||
}, | ||
async teardown () {} | ||
}) | ||
}) | ||
|
||
describe('tcp transport interface compliance IPv6', () => { | ||
if (isBrowser || isWebWorker) { | ||
return | ||
} | ||
|
||
tests({ | ||
async setup () { | ||
const transport = tcp() | ||
const dialAddrs: [Multiaddr, Multiaddr] = [ | ||
multiaddr('/ip6/::/tcp/9093'), | ||
multiaddr('/ip6/::/tcp/9094') | ||
] | ||
|
||
return { transport, dialAddrs } | ||
}, | ||
async teardown () {} | ||
}) | ||
}) |
37 changes: 37 additions & 0 deletions
37
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* eslint-env mocha */ | ||
|
||
import tests from '@libp2p/interface-compliance-tests/transport' | ||
import { webSockets } from '@libp2p/websockets' | ||
import * as filters from '@libp2p/websockets/filters' | ||
import { multiaddr } from '@multiformats/multiaddr' | ||
import { isElectronMain, isNode } from 'wherearewe' | ||
import type { Multiaddr } from '@multiformats/multiaddr' | ||
|
||
describe('websocket transport interface compliance', () => { | ||
tests({ | ||
async setup () { | ||
const dialOnly = !isNode && !isElectronMain | ||
|
||
const transport = webSockets({ filter: filters.all }) | ||
let dialAddrs: [Multiaddr, Multiaddr] = [ | ||
multiaddr('/ip4/127.0.0.1/tcp/9096/ws'), | ||
multiaddr('/ip4/127.0.0.1/tcp/9097/ws') | ||
] | ||
|
||
if (dialOnly) { | ||
dialAddrs = [ | ||
multiaddr(process.env.RELAY_WS_MULTIADDR_0), | ||
multiaddr(process.env.RELAY_WS_MULTIADDR_1) | ||
] | ||
} | ||
|
||
return { | ||
transport, | ||
listenAddrs: dialOnly ? undefined : dialAddrs, | ||
dialAddrs, | ||
dialOnly | ||
} | ||
}, | ||
async teardown () {} | ||
}) | ||
}) |
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.