Skip to content

Commit a43e506

Browse files
Cory Schwartzlidelaschmahmann
authored
fix: multibase in pubsub http rpc (#8183)
* multibase encoding on pubsub * emit multibase for json clients * refactor(pubsub): base64url for all URL args This makes it easier to reason about. Also added better helptext to each command explaining how the binary data is encoded on the wire, and how to process it in userland. * refactor: remove ndpayload and lenpayload Those output formats are undocumented and seem to be only used in tests. This change removes their implementation and replaces it with error message to use JSON instead. I also refactored tests to test the --enc=json response format instead of imaginary one, making tests more useful as they also act as regression tests for HTTP RPC. * test(pubsub): go-ipfs-api Testing against compatible version from ipfs/go-ipfs-api#255 * refactor: safeTextListEncoder Making it clear what it does and why * refactor(pubsub): unify peerids This ensures `ipfs pubsub sub` returns the same peerids in the `From` field as `ipfs pubsub peers`. libp2p already uses base encoding, no need to double wrap or use custom multibase. * test(pubsub): go-ipfs-http-client * refactor(pubsub): make pub command read from a file We want to send payload in the body as multipart so users can use existing tools like curl for publishing arbitrary bytes to a topic. StringArg was created for "one message per line" use case, and if data has `\n` or `\r\n` byte sequences, it will cause payload to be split. It is not possible to undo this, because mentioned sequences are lost, so we are not able to tell if it was `\n` or `\r\n` We already avoid this problem in `block put` and `dht put` by reading payload via FileArg which does not mangle binary data and send it as-is. It feel like `pubsub pub` should be using it in the first place anyway, so this commit replaces StringArg with FileArg. This also closes #8454 and makes rpc in go-ipfs easier to code against. * test(pubsub): publishing with line breaks Making sure we don't see regressions in the future. Ref. #7939 * chore: disable pubsub interop for now See ipfs/interop@344f692 * test: t0322-pubsub-http-rpc.sh - Adds HTTP RPC regression test that ensures topic is encoded as URL-safe multibase. - Moves pubsub tests to live in unique range ./t032x * fix(ci): js-ipfs with fixed pubsub wire format uses js-ipfs from ipfs/js-ipfs#3922 until js-ipfs release can ship with dependency on go-ipfs 0.11.0-rc1 Co-authored-by: Marcin Rataj <[email protected]> Co-authored-by: Adin Schmahmann <[email protected]>
1 parent 72656ea commit a43e506

File tree

6 files changed

+254
-109
lines changed

6 files changed

+254
-109
lines changed

.circleci/main.yml

+12
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,15 @@ jobs:
234234
- run:
235235
name: Running tests
236236
command: |
237+
WORKDIR=$(pwd)
238+
cd /tmp
239+
git clone https://github.com/ipfs/js-ipfs.git
240+
cd js-ipfs
241+
git checkout 1dcac76f56972fc3519526e93567e39d685033dd
242+
npm install
243+
npm run build
244+
npm run link
245+
cd $WORKDIR
237246
mkdir -p /tmp/test-results/interop/
238247
export MOCHA_FILE="$(mktemp /tmp/test-results/interop/unit.XXXXXX.xml)"
239248
npx ipfs-interop -- -t node -f $(sed -n -e "s|^require('\(.*\)')$|test/\1|p" node_modules/ipfs-interop/test/node.js | circleci tests split) -- --reporter mocha-circleci-reporter
@@ -242,6 +251,9 @@ jobs:
242251
LIBP2P_TCP_REUSEPORT: false
243252
LIBP2P_ALLOW_WEAK_RSA_KEYS: 1
244253
IPFS_GO_EXEC: /tmp/circleci-workspace/bin/ipfs
254+
IPFS_JS_EXEC: /tmp/js-ipfs/packages/ipfs/src/cli.js
255+
IPFS_JS_MODULE: /tmp/js-ipfs/packages/ipfs/dist/cjs/src/index.js
256+
IPFS_JS_HTTP_MODULE: /tmp/js-ipfs/packages/ipfs-http-client/dist/cjs/src/index.js
245257
- store_test_results:
246258
path: /tmp/test-results
247259
go-ipfs-api:

0 commit comments

Comments
 (0)