Skip to content

Commit

Permalink
chore: remove node buffers
Browse files Browse the repository at this point in the history
There's no need to use node buffers, everything is `Uint8Array`
compatible now.

Needs the `libp2p-interfaces-compliance-tests` upgrade from
#173 before
CI will pass.
  • Loading branch information
achingbrain committed Dec 2, 2021
1 parent e61668e commit b388009
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 18 deletions.
15 changes: 2 additions & 13 deletions .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 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 @@ -45,28 +44,18 @@ const before = async () => {
}
}
})

await libp2p.start()
}

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 = {
test: {
before,
after,
browser: {
config: {
buildConfig: esbuild
}
}
after
}
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"@typescript-eslint/parser": "^3.0.2",
"aegir": "^36.0.2",
"benchmark": "^2.1.4",
"buffer": "^6.0.3",
"chai": "^4.2.0",
"chai-spies": "^1.0.0",
"delay": "^5.0.0",
Expand Down
1 change: 0 additions & 1 deletion scripts/node-globals.js

This file was deleted.

6 changes: 3 additions & 3 deletions test/gossip.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'
/* eslint-env mocha */

const { Buffer } = require('buffer')
const { expect } = require('chai')
const sinon = require('sinon')
const delay = require('delay')
const { fromString: uint8ArrayFromString } = require('uint8arrays/from-string')

const { GossipsubDhi } = require('../src/constants')
const {
Expand Down Expand Up @@ -42,7 +42,7 @@ describe('gossip', () => {
// set spy
sinon.spy(nodeA, '_pushGossip')

await nodeA.publish(topic, Buffer.from('hey'))
await nodeA.publish(topic, uint8ArrayFromString('hey'))

await new Promise((resolve) => nodeA.once('gossipsub:heartbeat', resolve))

Expand Down Expand Up @@ -84,7 +84,7 @@ describe('gossip', () => {
const graft = { graft: [{ topicID: topic }] }
nodeA.control.set(peerB, graft)

await nodeA.publish(topic, Buffer.from('hey'))
await nodeA.publish(topic, uint8ArrayFromString('hey'))

expect(nodeA._piggybackControl.callCount).to.be.equal(1)
// expect control message to be sent alongside published message
Expand Down

0 comments on commit b388009

Please sign in to comment.