Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

chore: update deps #114

Merged
merged 4 commits into from
Apr 13, 2021
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
22 changes: 14 additions & 8 deletions .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* set up a libp2p instance for browser nodes to relay through
* before tests start
*/
const path = require('path')

const Libp2p = require('libp2p')
const PeerId = require('peer-id')
Expand Down Expand Up @@ -52,15 +53,20 @@ const after = async () => {
await libp2p.stop()
}

/** @type {import('aegir').Options["build"]["config"]} */
const esbuild = {
inject: [path.join(__dirname, './scripts/node-globals.js')]
}

/** @type {import('aegir').PartialOptions} */
module.exports = {
hooks: {
pre: before,
post: after
},
webpack: {
node: {
// this is needed until bcrypto stops using node buffers in browser code
Buffer: true
test: {
before,
after,
browser: {
config: {
buildConfig: esbuild
}
}
}
}
70 changes: 70 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir lint
- run: npx aegir dep-check
- run: npx aegir build
test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [14, 15]
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npx aegir test -t node --cov --bail
- uses: codecov/codecov-action@v1
test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir test -t browser -t webworker --bail
test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir test -t browser -t webworker --bail -- --browser firefox
test-webkit:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- run: npm install
- run: npx aegir test -t browser -t webworker --bail -- --browser webkit
test-electron-main:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx xvfb-maybe aegir test -t electron-main --bail
test-electron-renderer:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx xvfb-maybe aegir test -t electron-renderer --bail
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion benchmarks/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (typeof self !== 'undefined') {
self.Benchmark = Benchmark
}

const utils = require('../src/utils')
const { utils } = require('libp2p-interfaces/src/pubsub')

const suite = new Benchmark.Suite('utils')

Expand Down
21 changes: 13 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "libp2p-floodsub, also known as pubsub-flood or just dumbsub, this implementation of pubsub focused on delivering an API for Publish/Subscribe, but with no CastTree Forming (it just floods the network).",
"leadMaintainer": "Vasco Santos <vasco.santos@moxy.studio>",
"main": "src/index.js",
"types": "dist/src/index.d.ts",
"scripts": {
"lint": "aegir lint",
"test": "aegir test",
Expand Down Expand Up @@ -42,24 +43,28 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-floodsub#readme",
"devDependencies": {
"aegir": "^28.1.0",
"@types/debug": "^4.1.5",
"aegir": "^33.0.0",
"benchmark": "^2.1.4",
"chai": "^4.2.0",
"ipfs-utils": "^4.0.1",
"buffer": "^6.0.3",
"chai": "^4.3.4",
"ipfs-utils": "^6.0.6",
"it-pair": "^1.0.0",
"libp2p": "^0.30.0",
"libp2p-mplex": "^0.10.1",
"libp2p-noise": "^2.0.1",
"libp2p-websockets": "^0.14.0",
"multiaddr": "^8.1.1",
"libp2p-websockets": "^0.15.5",
"multiaddr": "^9.0.1",
"os": "^0.1.1",
"p-wait-for": "^3.1.0",
"peer-id": "^0.14.2",
"sinon": "^9.2.1"
"sinon": "^10.0.0"
},
"dependencies": {
"debug": "^4.2.0",
"libp2p-interfaces": "^0.8.1",
"libp2p-interfaces": "^0.10.0",
"time-cache": "^0.3.0",
"uint8arrays": "^1.1.0"
"uint8arrays": "^2.1.4"
},
"peerDependencies": {
"libp2p": "^0.30.0"
Expand Down
1 change: 1 addition & 0 deletions scripts/node-globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const { Buffer } = require('buffer')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably should include the "buffer" dependency too I guess

6 changes: 3 additions & 3 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict'

const debug = require('debug')

const log = debug('libp2p:floodsub')
log.err = debug('libp2p:floodsub:error')
const log = Object.assign(debug('libp2p:floodsub'), {
error: debug('libp2p:floodsub:err')
})

module.exports = {
log: log,
Expand Down
12 changes: 9 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@

const debugName = 'libp2p:floodsub'

// @ts-ignore time-cache does not export types
const TimeCache = require('time-cache')
const toString = require('uint8arrays/to-string')
const BaseProtocol = require('libp2p-interfaces/src/pubsub')
const { utils } = require('libp2p-interfaces/src/pubsub')

const { multicodec } = require('./config')

/**
* @typedef {import('libp2p-interfaces/src/pubsub').InMessage} InMessage
*/

/**
* FloodSub (aka dumbsub is an implementation of pubsub focused on
* delivering an API for Publish/Subscribe, but with no CastTree Forming
* (it just floods the network).
*/
class FloodSub extends BaseProtocol {
/**
* @param {Libp2p} libp2p - instance of libp2p
* @param {import('libp2p')} libp2p - instance of libp2p
* @param {Object} [options]
* @param {boolean} options.emitSelf - if publish should emit to self, if subscribed, defaults to false
* @param {boolean} [options.emitSelf] - if publish should emit to self, if subscribed, defaults to false
* @class
*/
constructor (libp2p, options = {}) {
Expand Down Expand Up @@ -64,10 +69,11 @@ class FloodSub extends BaseProtocol {
*
* @override
* @param {InMessage} message
* @returns {void}
* @returns {Promise<void>}
*/
_publish (message) {
this._forwardMessage(message)
return Promise.resolve()
}

/**
Expand Down
14 changes: 11 additions & 3 deletions test/utils/create-peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
*/

const Libp2p = require('libp2p')
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')
const PeerId = require('peer-id')

const WS = require('libp2p-websockets')
const filters = require('libp2p-websockets/src/filters')
const MPLEX = require('libp2p-mplex')
const { NOISE } = require('libp2p-noise')

Expand All @@ -21,6 +22,8 @@ const { isNode } = require('ipfs-utils/src/env')
const Peers = require('../fixtures/peers')
const RelayPeer = require('../fixtures/relay')

const transportKey = WS.prototype[Symbol.toStringTag]

const defaultConfig = {
modules: {
transport: [WS],
Expand All @@ -33,6 +36,11 @@ const defaultConfig = {
},
peerDiscovery: {
autoDial: false
},
transport: {
[transportKey]: {
filter: filters.all
}
}
}
}
Expand Down Expand Up @@ -109,10 +117,10 @@ async function createPeers ({ number = 1, started = true, seedAddressBook = true
function getListenAddress (peerId) {
if (isNode) {
// node
return multiaddr('/ip4/127.0.0.1/tcp/0/ws')
return new Multiaddr('/ip4/127.0.0.1/tcp/0/ws')
} else {
// browser
return multiaddr(`${RelayPeer.multiaddr}/p2p-circuit/p2p/${peerId.toB58String()}`)
return new Multiaddr(`${RelayPeer.multiaddr}/p2p-circuit/p2p/${peerId.toB58String()}`)
}
}

Expand Down
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "aegir/src/config/tsconfig.aegir.json",
"compilerOptions": {
"outDir": "dist"
},
"include": [
"src",
"test"
]
}