-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: convert node-specific tests to run in browsers (#2803)
Converts tests to use the memory transport to allow running all tests in browsers. Removes dependencies on WebSockets, TCP, circuit relay etc so changes in these modules don't cause additional releases here.
- Loading branch information
1 parent
adc7678
commit 58ca044
Showing
31 changed files
with
981 additions
and
3,552 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,6 @@ | ||
/** @type {import('aegir').PartialOptions} */ | ||
export default { | ||
build: { | ||
bundlesizeMax: '147kB' | ||
}, | ||
test: { | ||
before: async () => { | ||
// use dynamic import because we only want to reference these files during the test run, e.g. after building | ||
const { webSockets } = await import('@libp2p/websockets') | ||
const { mplex } = await import('@libp2p/mplex') | ||
const { yamux } = await import('@chainsafe/libp2p-yamux') | ||
const { WebSockets } = await import('@multiformats/mafmt') | ||
const { createLibp2p } = await import('./dist/src/index.js') | ||
const { plaintext } = await import('@libp2p/plaintext') | ||
const { circuitRelayServer, circuitRelayTransport } = await import('@libp2p/circuit-relay-v2') | ||
const { identify } = await import('@libp2p/identify') | ||
const { echo } = await import('./dist/test/fixtures/echo-service.js') | ||
|
||
const libp2p = await createLibp2p({ | ||
connectionManager: { | ||
inboundConnectionThreshold: Infinity | ||
}, | ||
addresses: { | ||
listen: [ | ||
'/ip4/127.0.0.1/tcp/0/ws' | ||
] | ||
}, | ||
transports: [ | ||
circuitRelayTransport(), | ||
webSockets() | ||
], | ||
streamMuxers: [ | ||
yamux(), | ||
mplex() | ||
], | ||
connectionEncrypters: [ | ||
plaintext() | ||
], | ||
services: { | ||
identify: identify(), | ||
relay: circuitRelayServer({ | ||
reservations: { | ||
maxReservations: Infinity | ||
} | ||
}), | ||
echo: echo() | ||
} | ||
}) | ||
|
||
return { | ||
libp2p, | ||
env: { | ||
RELAY_MULTIADDR: libp2p.getMultiaddrs().filter(ma => WebSockets.matches(ma)).pop() | ||
} | ||
} | ||
}, | ||
after: async (_, before) => { | ||
await before.libp2p.stop() | ||
} | ||
bundlesizeMax: '95KB' | ||
} | ||
} |
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.