Skip to content

Commit

Permalink
deps!: bump @libp2p/interface from 1.7.0 to 2.2.0 (#34)
Browse files Browse the repository at this point in the history
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
dependabot[bot] and achingbrain authored Oct 29, 2024
1 parent 96453b3 commit 2945813
Show file tree
Hide file tree
Showing 22 changed files with 295 additions and 397 deletions.
162 changes: 0 additions & 162 deletions .github/workflows/main.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/test-examples.yml
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
58 changes: 58 additions & 0 deletions examples/go-libp2p-http-proxy/client.js
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()
}
57 changes: 0 additions & 57 deletions examples/go-libp2p-http-proxy/client.mjs

This file was deleted.

18 changes: 18 additions & 0 deletions examples/go-libp2p-http-proxy/server.js
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)
})
16 changes: 0 additions & 16 deletions examples/go-libp2p-http-proxy/server.mjs

This file was deleted.

Loading

0 comments on commit 2945813

Please sign in to comment.