Skip to content

Commit

Permalink
chore: update deps and remove protons
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Apr 7, 2021
1 parent 12626e8 commit 1b14088
Show file tree
Hide file tree
Showing 13 changed files with 2,487 additions and 215 deletions.
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 }}
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
25 changes: 15 additions & 10 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 @@ -74,12 +77,14 @@
"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",
"typescript": "4.0.x"
"typescript": "4.0.x",
"url": "^0.11.0"
},
"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')
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
Loading

0 comments on commit 1b14088

Please sign in to comment.