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

fix: multibase in pubsub http rpc interop tests #387

Closed
wants to merge 6 commits into from
Closed
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
18 changes: 9 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ on:
# uncomment env below and define git revisions in ./scripts/custom-runtime.sh

env:
IPFS_GO_EXEC: /tmp/go-ipfs/cmd/ipfs/ipfs
#IPFS_JS_EXEC: /tmp/js-ipfs/packages/ipfs/src/cli.js
#IPFS_JS_MODULE: /tmp/js-ipfs/packages/ipfs/dist/cjs/src/index.js
#IPFS_JS_HTTP_MODULE: /tmp/js-ipfs/packages/ipfs-http-client/dist/cjs/src/index.js
#IPFS_GO_EXEC: /tmp/go-ipfs/cmd/ipfs/ipfs
IPFS_JS_EXEC: /tmp/js-ipfs/packages/ipfs/src/cli.js
IPFS_JS_MODULE: /tmp/js-ipfs/packages/ipfs/dist/cjs/src/index.js
IPFS_JS_HTTP_MODULE: /tmp/js-ipfs/packages/ipfs-http-client/dist/cjs/src/index.js

jobs:
build:
Expand All @@ -31,7 +31,7 @@ jobs:
with:
path: |
/tmp/*-ipfs/**
./go-libp2p-relay-daemon
./scripts/libp2p-relay-daemon
~/.npm
./node_modules
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
Expand All @@ -57,7 +57,7 @@ jobs:
with:
path: |
/tmp/*-ipfs/**
./go-libp2p-relay-daemon
./scripts/libp2p-relay-daemon
~/.npm
./node_modules
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
with:
path: |
/tmp/*-ipfs/**
./go-libp2p-relay-daemon
./scripts/libp2p-relay-daemon
~/.npm
./node_modules
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
with:
path: |
/tmp/*-ipfs/**
./go-libp2p-relay-daemon
./scripts/libp2p-relay-daemon
~/.npm
./node_modules
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:
with:
path: |
/tmp/*-ipfs/**
./go-libp2p-relay-daemon
./scripts/libp2p-relay-daemon
~/.npm
./node_modules
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ test/test-data/go-ipfs-repo/LOG
test/test-data/go-ipfs-repo/LOG.old
types
go-libp2p-relay-daemon
scripts/libp2p-relay-daemon
*.identity
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"npm": ">6.0.0"
},
"scripts": {
"postinstall": "./scripts/setup-relayd.sh",
"postinstall": "./scripts/setup-libp2p-relay-daemon.sh",
"clean": "rimraf /tmp/js-ipfs /tmp/go-ipfs ./go-libp2p-relay-daemon",
"lint": "aegir lint",
"build": "aegir build",
Expand Down Expand Up @@ -102,7 +102,7 @@
],
"devDependencies": {
"execa": "^5.1.1",
"go-ipfs": "^0.9.1",
"go-ipfs": "0.11.0-rc1",
"ipfs": "^0.59.0",
"ipfs-http-client": "^53.0.0"
}
Expand Down
6 changes: 3 additions & 3 deletions scripts/custom-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if [ ! -d /tmp/go-ipfs ]; then
git clone https://github.com/ipfs/go-ipfs.git
cd go-ipfs
# set implementation to specific commit
git switch master # https://github.com/ipfs/go-ipfs/pull/8563 got merged, lets roll with master until go-ipfs 0.11.0-rc1
git switch master # , lets roll with master until go-ipfs 0.11.0-rc1
make build
fi
fi
Expand All @@ -35,8 +35,8 @@ if [ ! -d /tmp/js-ipfs ]; then
cd /tmp
git clone https://github.com/ipfs/js-ipfs.git
cd js-ipfs
# set implementation to specific commit
git checkout CHANGEME_JS
# implementation from https://github.com/ipfs/js-ipfs/pull/3922
git checkout 1dcac76f56972fc3519526e93567e39d685033dd
npm install
npm run build
npm run link
Expand Down
26 changes: 26 additions & 0 deletions scripts/setup-libp2p-relay-daemon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# This script ensures go-libp2p-relay-daemon is available
# for use in circuit v1 and v2 tests.

set -eo pipefail

download_dist_package () {
local DIST_NAME="$1"
local DIST_VERSION="$2"
local DIST_FILE="${DIST_NAME}_${DIST_VERSION}_linux-amd64.tar.gz"
local DIST_URL="https://dist.ipfs.io/${DIST_NAME}/${DIST_VERSION}/${DIST_FILE}"
wget -nv -c --retry-connrefused --tries=0 --retry-on-host-error --retry-on-http-error=503,504,429 -O "${DIST_FILE}" "${DIST_URL}"
wget -nv -c --retry-connrefused --tries=0 --retry-on-host-error --retry-on-http-error=503,504,429 -O "${DIST_FILE}.sha512" "${DIST_URL}.sha512"
sha512sum -c "${DIST_FILE}.sha512"
}

if ! test -e ./scripts/libp2p-relay-daemon; then
echo "Fetching ./scripts/libp2p-relay-daemon binary.."
#GOBIN=$(realpath ./scripts) go install github.com/libp2p/go-libp2p-relay-daemon/cmd/libp2p-relay-daemon@v0.1.0
VERSION="v0.1.0"
download_dist_package libp2p-relay-daemon $VERSION
tar vzx -f "libp2p-relay-daemon_${VERSION}_linux-amd64.tar.gz" -C ./scripts libp2p-relay-daemon/libp2p-relay-daemon --strip-components=1
rm -f ./*_linux-amd64.tar.gz*
echo "./scripts/libp2p-relay-daemon is ready"
fi
17 changes: 0 additions & 17 deletions scripts/setup-relayd.sh

This file was deleted.

3 changes: 1 addition & 2 deletions test/ipns-pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ const namespace = '/record/'

const ipfsRef = '/ipfs/QmPFVLPmp9zv5Z5KUqLhe2EivAGccQW2r7M7jhVJGLZoZU'

// TODO: unskip after https://github.com/ipfs/js-ipfs/pull/3922 and https://github.com/ipfs/go-ipfs/pull/8183 both ship
describe.skip('ipns-pubsub', function () {
describe('ipns-pubsub', function () {
let nodes = []
let factory

Expand Down
31 changes: 28 additions & 3 deletions test/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ const daemonOptions = {

const timeout = 20e3

// TODO: unskip after https://github.com/ipfs/js-ipfs/pull/3922 and https://github.com/ipfs/go-ipfs/pull/8183 both ship
describe.skip('pubsub', function () {
describe('pubsub', function () {
this.timeout(60 * 1000)

const tests = {
Expand Down Expand Up @@ -100,7 +99,7 @@ describe.skip('pubsub', function () {
})

it('should exchange non ascii data', function () {
lidel marked this conversation as resolved.
Show resolved Hide resolved
const data = uint8ArrayFromString('你好世界')
const data = uint8ArrayFromString('你好世界 zażółć gęślą jaźń')
const topic = 'pubsub-non-ascii'

const subscriber = () => new Promise((resolve) => {
Expand Down Expand Up @@ -150,6 +149,32 @@ describe.skip('pubsub', function () {
publisher()
])
})

it('should exchange data over a topic with unicode and newlines', function () {
const data = uint8ArrayFromString('你好世界\nzażółć\r\ngęślą\njaźń')
const topic = 'pubsub\n你好世界\r\njaźń'

const subscriber = () => new Promise((resolve) => {
daemon2.api.pubsub.subscribe(topic, (msg) => {
expect(uint8ArrayEquals(data, msg.data)).to.be.true()
expect(msg).to.have.property('seqno')
expect(msg.seqno).to.be.an.instanceof(Uint8Array)
expect(msg).to.have.property('topicIDs').and.to.include(topic)
expect(msg).to.have.property('from', daemon1.api.peerId.id)
resolve()
})
})

const publisher = async () => {
await waitForTopicPeer(topic, daemon2.api.peerId, daemon1)
await daemon1.api.pubsub.publish(topic, data)
}

return Promise.all([
subscriber(),
publisher()
])
})
})
})
})
2 changes: 1 addition & 1 deletion test/utils/relayd.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function getRelayV (version, factory) {
if (relays.has(version)) return relays.get(version)
if (process.env.DEBUG) console.log(`Starting relayd_v${version}..`) // eslint-disable-line no-console
if (version < 1 || version > 2) throw new Error('Unsupported circuit relay version')
const relayd = command(`go-libp2p-relay-daemon/relayd -config scripts/relayd_v${version}.config.json -id scripts/relayd_v${version}.identity`)
const relayd = command(`scripts/libp2p-relay-daemon -config scripts/relayd_v${version}.config.json -id scripts/relayd_v${version}.identity`)
let id
for await (const line of relayd.stdout) {
const text = line.toString()
Expand Down