Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: update uint8arrays, protons and multiformats #143

Merged
merged 2 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# js-libp2p-daemon <!-- omit in toc -->

[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-daemon.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-daemon)
[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml)
[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-daemon/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml)

> Standalone libp2p executable

## Table of contents <!-- omit in toc -->

- [Structure](#structure)
- [Contribute](#contribute)
- [License](#license)
- [Contribution](#contribution)
- [Contribute](#contribute)

## Structure

Expand All @@ -22,21 +20,13 @@
- [`/packages/libp2p-daemon-protocol`](./packages/libp2p-daemon-protocol) Communication protocol between libp2p daemons and clients
- [`/packages/libp2p-daemon-server`](./packages/libp2p-daemon-server) API server for libp2p-daemon instances

## Contribute

Feel free to join in. All welcome. Open an [issue](https://github.com/libp2p/js-interfaces/issues)!

This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).

[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md)

## License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribution
## Contribute

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
7 changes: 5 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"lerna": "4.0.0",
"lerna": "5.4.0",
"useWorkspaces": true,
"version": "independent",
"command": {
"run": {
"stream": true
}
}
},
"packages": [
"packages/*"
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"release": "lerna run --concurrency 1 release -- --"
},
"dependencies": {
"lerna": "^5.1.2",
"lerna": "^6.0.0",
"rimraf": "^3.0.2"
},
"workspaces": [
Expand Down
12 changes: 3 additions & 9 deletions packages/libp2p-daemon-client/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# @libp2p/daemon-client <!-- omit in toc -->

[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-daemon.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-daemon)
[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml)
[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-daemon/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml)

> libp2p-daemon client implementation

Expand All @@ -16,9 +15,8 @@
- [Run a daemon process](#run-a-daemon-process)
- [Interact with the daemon process using the client](#interact-with-the-daemon-process-using-the-client)
- [API](#api)
- [Contribute](#contribute)
- [License](#license)
- [Contribution](#contribution)
- [Contribute](#contribute)

## Install

Expand Down Expand Up @@ -77,17 +75,13 @@ await client.close()
- [`dht.getClosestPeers`](API.md#dht.getClosestPeers)
- [`dht.getPublicKey`](API.md#dht.getPublicKey)

## Contribute

This module is actively under development. Please check out the issues and submit PRs!

## License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribution
## Contribute

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
13 changes: 7 additions & 6 deletions packages/libp2p-daemon-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,29 +137,30 @@
"@libp2p/daemon-protocol": "^3.0.0",
"@libp2p/interface-peer-id": "^1.0.2",
"@libp2p/interface-peer-info": "^1.0.1",
"@libp2p/interface-transport": "^2.0.0",
"@libp2p/logger": "^2.0.0",
"@libp2p/peer-id": "^1.1.10",
"@libp2p/tcp": "^4.0.1",
"@libp2p/tcp": "^5.0.0",
"@multiformats/multiaddr": "^11.0.0",
"err-code": "^3.0.1",
"it-stream-types": "^1.0.4",
"multiformats": "^9.6.4",
"multiformats": "^10.0.0",
"uint8arraylist": "^2.3.2"
},
"devDependencies": {
"@libp2p/components": "^3.0.1",
"@libp2p/daemon-server": "^3.0.0",
"@libp2p/interface-compliance-tests": "^3.0.1",
"@libp2p/interface-dht": "^1.0.0",
"@libp2p/interface-mocks": "^6.0.0",
"@libp2p/interface-mocks": "^7.0.1",
"@libp2p/interface-peer-store": "^1.0.0",
"@libp2p/interface-pubsub": "^2.0.1",
"@libp2p/interface-pubsub": "^3.0.0",
"@libp2p/peer-id-factory": "^1.0.9",
"aegir": "^37.2.0",
"it-all": "^1.0.6",
"it-pipe": "^2.0.3",
"sinon": "^14.0.0",
"ts-sinon": "^2.0.2",
"uint8arrays": "^3.0.0"
"sinon-ts": "^0.0.2",
"uint8arrays": "^4.0.2"
}
}
7 changes: 4 additions & 3 deletions packages/libp2p-daemon-client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import errcode from 'err-code'
import { TCP } from '@libp2p/tcp'
import { tcp } from '@libp2p/tcp'
import { PSMessage, Request, Response, StreamInfo } from '@libp2p/daemon-protocol'
import { StreamHandler } from '@libp2p/daemon-protocol/stream-handler'
import type { Multiaddr } from '@multiformats/multiaddr'
Expand All @@ -15,18 +15,19 @@ import type { PeerInfo } from '@libp2p/interface-peer-info'
import type { MultiaddrConnection } from '@libp2p/interface-connection'
import type { Uint8ArrayList } from 'uint8arraylist'
import { logger } from '@libp2p/logger'
import type { Transport } from '@libp2p/interface-transport'

const log = logger('libp2p:daemon-client')

class Client implements DaemonClient {
private readonly multiaddr: Multiaddr
public dht: DHT
public pubsub: Pubsub
private readonly tcp: TCP
private readonly tcp: Transport

constructor (addr: Multiaddr) {
this.multiaddr = addr
this.tcp = new TCP()
this.tcp = tcp()()
this.dht = new DHT(this)
this.pubsub = new Pubsub(this)
}
Expand Down
10 changes: 7 additions & 3 deletions packages/libp2p-daemon-client/test/dht.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { createServer, Libp2p, Libp2pServer } from '@libp2p/daemon-server'
import { createClient, DaemonClient } from '../src/index.js'
import { multiaddr } from '@multiformats/multiaddr'
import { StubbedInstance, stubInterface } from 'ts-sinon'
import { StubbedInstance, stubInterface } from 'sinon-ts'
import { DualDHT, ValueEvent, FinalPeerEvent, PeerResponseEvent, MessageType, EventTypes } from '@libp2p/interface-dht'
import { peerIdFromString } from '@libp2p/peer-id'
import { CID } from 'multiformats/cid'
import all from 'it-all'

const defaultMultiaddr = multiaddr('/ip4/0.0.0.0/tcp/12345')

function match (cid: CID) {
return sinon.match((c: CID) => c.toString() === cid.toString(), 'cid')
}

describe('daemon dht client', function () {
this.timeout(30e3)

Expand Down Expand Up @@ -138,7 +142,7 @@ describe('daemon dht client', function () {

await client.dht.provide(cid)

expect(dht.provide.calledWith(cid)).to.be.true()
expect(dht.provide.calledWith(match(cid))).to.be.true()
})

it('should error if receive an error message', async () => {
Expand All @@ -157,7 +161,7 @@ describe('daemon dht client', function () {
const cid = CID.parse('QmVzw6MPsF96TyXBSRs1ptLoVMWRv5FCYJZZGJSVB2Hp38')
const id = peerIdFromString('12D3KooWJKCJW8Y26pRFNv78TCMGLNTfyN8oKaFswMRYXTzSbSsa')

dht.findProviders.withArgs(cid).returns(async function * () {
dht.findProviders.withArgs(match(cid)).returns(async function * () {
const event: PeerResponseEvent = {
name: 'PEER_RESPONSE',
type: EventTypes.PEER_RESPONSE,
Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p-daemon-client/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import sinon from 'sinon'
import { createServer, Libp2p, Libp2pServer } from '@libp2p/daemon-server'
import { createClient, DaemonClient } from '../src/index.js'
import { multiaddr } from '@multiformats/multiaddr'
import { StubbedInstance, stubInterface } from 'ts-sinon'
import { StubbedInstance, stubInterface } from 'sinon-ts'
import { isPeerId } from '@libp2p/interface-peer-id'
import { peerIdFromString } from '@libp2p/peer-id'
import { mockConnection, mockDuplex, mockMultiaddrConnection } from '@libp2p/interface-mocks'
Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p-daemon-client/test/pubsub.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { createServer, Libp2p, Libp2pServer } from '@libp2p/daemon-server'
import { createClient, DaemonClient } from '../src/index.js'
import { multiaddr } from '@multiformats/multiaddr'
import { StubbedInstance, stubInterface } from 'ts-sinon'
import { StubbedInstance, stubInterface } from 'sinon-ts'
import type { PubSub } from '@libp2p/interface-pubsub'

const defaultMultiaddr = multiaddr('/ip4/0.0.0.0/tcp/12345')
Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p-daemon-client/test/stream.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import sinon from 'sinon'
import { createServer, Libp2p, Libp2pServer } from '@libp2p/daemon-server'
import { createClient, DaemonClient } from '../src/index.js'
import { multiaddr } from '@multiformats/multiaddr'
import { StubbedInstance, stubInterface } from 'ts-sinon'
import { StubbedInstance, stubInterface } from 'sinon-ts'
import { peerIdFromString } from '@libp2p/peer-id'
import { mockRegistrar, connectionPair } from '@libp2p/interface-mocks'
import type { PeerStore, AddressBook } from '@libp2p/interface-peer-store'
Expand Down
12 changes: 3 additions & 9 deletions packages/libp2p-daemon-protocol/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
# @libp2p/daemon-protocol <!-- omit in toc -->

[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-daemon.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-daemon)
[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml)
[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-daemon/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml)

> Communication protocol between libp2p daemons and clients

## Table of contents <!-- omit in toc -->

- [Install](#install)
- [Contribute](#contribute)
- [License](#license)
- [Contribution](#contribution)
- [Contribute](#contribute)

## Install

```console
$ npm i @libp2p/daemon-protocol
```

## Contribute

This module is actively under development. Please check out the issues and submit PRs!

## License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribution
## Contribute

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
4 changes: 2 additions & 2 deletions packages/libp2p-daemon-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@
"dependencies": {
"@libp2p/interface-transport": "^2.0.0",
"it-handshake": "^4.0.0",
"protons-runtime": "^3.0.1",
"protons-runtime": "^4.0.1",
"uint8arraylist": "^2.3.2"
},
"devDependencies": {
"aegir": "^37.2.0",
"protons": "^5.0.0"
"protons": "^6.0.0"
}
}
Loading