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

chore: update deps and remove protons #153

Merged
merged 10 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
}
}
}
}
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ts/message/rpc*
26 changes: 14 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn lint
- run: yarn prebuild
- run: yarn aegir dep-check
- run: npm install
- run: npm run lint
- run: npm run prebuild
- run: npx aegir dep-check
test-node:
needs: check
runs-on: ${{ matrix.os }}
vasco-santos marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -29,23 +29,25 @@ jobs:
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: yarn
- run: yarn prebuild
- run: npm install
- run: npm run prebuild
- run: npx nyc --reporter=lcov aegir test -t node -- --bail
- uses: codecov/codecov-action@v1
test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn prebuild
- run: npx aegir test -t browser -t webworker --bail
- run: npm install
- run: npm run prebuild
- run: npx aegir test -t browser --bail
- run: npx aegir test -t webworker --bail
test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn prebuild
- run: npx aegir test -t browser -t webworker --bail -- --browsers FirefoxHeadless
- run: npm install
- run: npm run prebuild
- run: npx aegir test -t browser --bail -- --browsers FirefoxHeadless
- run: npx aegir test -t webworker --bail -- --browsers FirefoxHeadless
28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
"types": "src/index.d.ts",
"scripts": {
"lint": "eslint --ext .ts ts",
"release": "aegir release",
"prebuild": "tsc",
"build": "aegir build",
"release": "aegir release --no-types",
"prebuild": "tsc && cp -R ts/message src",
"build": "npm run build:proto && npm run build:proto-types && npm run build:types",
"build:proto": "pbjs -t static-module --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o ts/message/rpc.js ./ts/message/rpc.proto",
"build:proto-types": "pbts -o ts/message/rpc.d.ts ts/message/rpc.js",
"build:types": "aegir build --no-types",
"pretest": "tsc",
"test": "aegir test",
"test:node": "aegir test --target node",
Expand All @@ -40,22 +43,22 @@
"denque": "^1.4.1",
"err-code": "^2.0.0",
"it-pipe": "^1.0.1",
"libp2p-interfaces": "^0.8.0",
"libp2p-interfaces": "libp2p/js-libp2p-interfaces#chore/update-pubsub-interface",
"peer-id": "^0.14.0",
"protons": "^2.0.0",
"protobufjs": "^6.10.2",
"time-cache": "^0.3.0",
"uint8arrays": "^1.1.0"
"uint8arrays": "^2.1.4"
},
"devDependencies": {
"@types/chai": "^4.2.3",
"@types/mocha": "^7.0.2",
"@types/mocha": "^8.2.2",
"@typescript-eslint/eslint-plugin": "^3.0.2",
"@typescript-eslint/parser": "^3.0.2",
"aegir": "^28.0.0",
"aegir": "^33.0.0",
"benchmark": "^2.1.4",
"chai": "^4.2.0",
"chai-spies": "^1.0.0",
"delay": "^4.3.0",
"delay": "^5.0.0",
"detect-node": "^2.0.4",
"dirty-chai": "^2.0.1",
"eslint": "^7.1.0",
Expand All @@ -65,20 +68,19 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"it-pair": "^1.0.0",
"karma-mocha-webworker": "^1.3.0",
"libp2p": "^0.30.0",
"libp2p-floodsub": "^0.24.1",
"libp2p-mplex": "^0.10.0",
"libp2p-noise": "^2.0.0",
"libp2p-websockets": "^0.14.0",
"libp2p-websockets": "^0.15.4",
"lodash": "^4.17.15",
"mocha": "^7.1.1",
"multiaddr": "^8.0.0",
"os": "^0.1.1",
"p-retry": "^4.2.0",
"p-times": "^2.1.0",
"p-wait-for": "^3.1.0",
"promisify-es6": "^1.0.3",
"sinon": "^9.0.2",
"sinon": "^10.0.1",
"typescript": "4.0.x"
},
"peerDependencies": {
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')
vasco-santos marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 6 additions & 2 deletions test/2-nodes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ describe('2 nodes', () => {
expectSet(nodes[1].topics.get(topic), [nodes[0].peerId.toB58String()])

expect(changedPeerId.toB58String()).to.equal(first(nodes[0].peers).id.toB58String())
expect(changedSubs).to.be.eql([{ topicID: topic, subscribe: true }])
expect(changedSubs).to.have.lengthOf(1)
expect(changedSubs[0].topicID).to.equal(topic)
expect(changedSubs[0].subscribe).to.equal(true)

// await heartbeats
await Promise.all([
Expand Down Expand Up @@ -204,7 +206,9 @@ describe('2 nodes', () => {
expect(nodes[1].peers.size).to.equal(1)
expectSet(nodes[1].topics.get(topic), [])
expect(changedPeerId.toB58String()).to.equal(first(nodes[1].peers).id.toB58String())
expect(changedSubs).to.be.eql([{ topicID: topic, subscribe: false }])
expect(changedSubs).to.have.lengthOf(1)
expect(changedSubs[0].topicID).to.equal(topic)
expect(changedSubs[0].subscribe).to.equal(false)
})

it('Publish to a topic after unsubscribe', async () => {
Expand Down
4 changes: 3 additions & 1 deletion test/floodsub.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ describe('gossipsub fallbacks to floodsub', () => {
expectSet(nodeFs.topics.get(topic), [nodeGs.peerId.toB58String()])

expect(changedPeerId.toB58String()).to.equal(first(nodeGs.peers).id.toB58String())
expect(changedSubs).to.be.eql([{ topicID: topic, subscribe: true }])
expect(changedSubs).to.have.lengthOf(1)
expect(changedSubs[0].topicID).to.equal(topic)
expect(changedSubs[0].subscribe).to.equal(true)
})
})

Expand Down
2 changes: 0 additions & 2 deletions test/go-gossipsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
const { expect } = require('chai')
const delay = require('delay')
const PeerId = require('peer-id')
const errcode = require('err-code')
const sinon = require('sinon')
const pRetry = require('p-retry')
Expand All @@ -19,7 +18,6 @@ const {
sparseConnect,
denseConnect,
stopNode,
startNode,
createPeers,
expectSet,
connectSome,
Expand Down
3 changes: 0 additions & 3 deletions test/peer-score-params.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ describe('TopicScoreParams validation', () => {
createTopicScoreParams({
timeInMeshQuantum: 1000,
meshMessageDeliveriesWeight: -1,
meshMessageDeliveriesDecay: 0.5,
meshMessageDeliveriesDecay: 5,
meshMessageDeliveriesThreshold: -3
})
Expand All @@ -103,7 +102,6 @@ describe('TopicScoreParams validation', () => {
createTopicScoreParams({
timeInMeshQuantum: 1000,
meshMessageDeliveriesWeight: -1,
meshMessageDeliveriesDecay: 0.5,
meshMessageDeliveriesDecay: 5,
meshMessageDeliveriesThreshold: 3,
meshMessageDeliveriesWindow: -1
Expand All @@ -113,7 +111,6 @@ describe('TopicScoreParams validation', () => {
createTopicScoreParams({
timeInMeshQuantum: 1000,
meshMessageDeliveriesWeight: -1,
meshMessageDeliveriesDecay: 0.5,
meshMessageDeliveriesDecay: 5,
meshMessageDeliveriesThreshold: 3,
meshMessageDeliveriesWindow: 1,
Expand Down
8 changes: 8 additions & 0 deletions test/utils/create-peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ 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')

const Peers = require('../fixtures/peers')
const RelayPeer = require('../fixtures/relay')

const transportKey = WS.prototype[Symbol.toStringTag]

const defaultConfig = {
modules: {
transport: [WS],
Expand All @@ -31,6 +34,11 @@ const defaultConfig = {
},
peerDiscovery: {
autoDial: false
},
transport: {
[transportKey]: {
filter: filters.all
}
}
}
}
Expand Down
Loading