-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps!: bump @libp2p/interface from 1.7.0 to 2.2.0 (#34)
Bumps [@libp2p/interface](https://github.com/libp2p/js-libp2p) from 1.7.0 to 2.2.0. - [Release notes](https://github.com/libp2p/js-libp2p/releases) - [Changelog](https://github.com/libp2p/js-libp2p/blob/main/.release-please.json) - [Commits](libp2p/js-libp2p@libp2p-v1.7.0...libp2p-v2.2.0) --- updated-dependencies: - dependency-name: "@libp2p/interface" dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> BREAKING CHANGE: requires [email protected] --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: achingbrain <[email protected]>
- Loading branch information
1 parent
96453b3
commit 2945813
Showing
22 changed files
with
295 additions
and
397 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,47 @@ | ||
name: test examples | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- "**" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
- run: npm i | ||
working-directory: ./examples | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
with: | ||
directories: | | ||
./examples/node_modules | ||
test-examples: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
with: | ||
directories: | | ||
./examples/node_modules | ||
- uses: actions/setup-go@v5 | ||
- run: go build -o test-runner main.go | ||
working-directory: ./examples/test-runner | ||
- run: ../test-runner/test-runner -hasProxy | ||
working-directory: ./examples/go-libp2p-http-proxy | ||
- run: ../test-runner/test-runner | ||
working-directory: ./examples/js-libp2p-client-and-node-server/ | ||
- run: ../test-runner/test-runner | ||
working-directory: ./examples/two-js-peers | ||
- run: ./runTest.sh | ||
working-directory: ./examples/peer-id-auth |
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-disable no-console */ | ||
|
||
import { noise } from '@chainsafe/libp2p-noise' | ||
import { yamux } from '@chainsafe/libp2p-yamux' | ||
import { http } from '@libp2p/http-fetch' | ||
import { tcp } from '@libp2p/tcp' | ||
import { multiaddr } from '@multiformats/multiaddr' | ||
import { createLibp2p } from 'libp2p' | ||
|
||
const node = await createLibp2p({ | ||
// libp2p nodes are started by default, pass false to override this | ||
start: false, | ||
addresses: { | ||
listen: [] | ||
}, | ||
transports: [tcp()], | ||
connectionEncrypters: [noise()], | ||
streamMuxers: [yamux()], | ||
services: { http: http() } | ||
}) | ||
|
||
// start libp2p | ||
await node.start() | ||
console.error('libp2p has started') | ||
|
||
// Read server multiaddr from the command line | ||
const serverAddr = process.argv[2] | ||
if (!serverAddr) { | ||
console.error('Please provide the server multiaddr as an argument') | ||
process.exit(1) | ||
} | ||
|
||
let serverMA = multiaddr(serverAddr) | ||
|
||
// check if this is an http transport multiaddr | ||
const isHTTPTransport = serverMA.protos().find(p => p.name === 'http') | ||
if (!isHTTPTransport && serverMA.getPeerId() === null) { | ||
// Learn the peer id of the server. This lets us reuse the connection for all our HTTP requests. | ||
// Otherwise js-libp2p will open a new connection for each request. | ||
const conn = await node.dial(serverMA) | ||
serverMA = serverMA.encapsulate(`/p2p/${conn.remotePeer.toString()}`) | ||
} | ||
|
||
console.error(`Making request to ${serverMA.toString()}`) | ||
try { | ||
const resp = await node.services.http.fetch(new Request(`multiaddr:${serverMA}`)) | ||
const respBody = await resp.text() | ||
if (resp.status !== 200) { | ||
throw new Error(`Unexpected status code: ${resp.status}`) | ||
} | ||
if (respBody !== 'Hello, World!') { | ||
throw new Error(`Unexpected response body: ${respBody}`) | ||
} | ||
console.error('Got response:', respBody) | ||
} finally { | ||
// stop libp2p | ||
await node.stop() | ||
} |
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
/* eslint-disable no-console */ | ||
|
||
import http from 'http' | ||
|
||
const port = 55776 | ||
|
||
const server = http.createServer((req, res) => { | ||
res.writeHead(200, { 'Content-Type': 'text/plain' }) | ||
res.end('Hello, World!') | ||
}) | ||
|
||
server.listen(port, () => { | ||
console.error(`Server running at: http://localhost:${port}/`) | ||
// Print multiaddr on stdout for test | ||
console.error("Server's multiaddr is:") | ||
console.log(`/dns4/localhost/tcp/${port}/http`) | ||
console.log('') // Empty line to signal we have no more addresses (for test runner) | ||
}) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.