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 3 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
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:
# To run CI against unrelased go-ipfs or js-ipfs-* code (eg. wip PR),
# 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
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

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ dist
test/test-data/go-ipfs-repo/LOCK
test/test-data/go-ipfs-repo/LOG
test/test-data/go-ipfs-repo/LOG.old
types
types
2 changes: 1 addition & 1 deletion package-lock.json

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

10 changes: 5 additions & 5 deletions scripts/custom-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ WORKDIR=$(pwd)
if [ "$IPFS_GO_EXEC" == /tmp/go-ipfs/cmd/ipfs/ipfs ]; then
if [ ! -d /tmp/go-ipfs ]; then
cd /tmp
git clone https://github.com/ipfs/go-ipfs.git
git clone https://github.com/coryschwartz/go-ipfs.git
cd go-ipfs
# set implementation to specific commit
git checkout CHANGEME_GO
# implementation from https://github.com/ipfs/go-ipfs/pull/8183
git checkout 153697d524f449ee9bec97245b0fcd7ebc2e8170
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
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()
])
})
})
})
})