Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Sep 12, 2024
1 parent 2cdb3a7 commit 62a7583
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/pubsub/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ async function readMessages (response: ExtendedResponse, { onMessage, onEnd, onE
data: rpcToBytes(msg.data),
sequenceNumber: rpcToBigInt(msg.seqno),
topic: rpcToText(msg.topicIDs[0]),
key: publicKeyFromProtobuf(rpcToBytes(msg.key ?? 'u')),
// @ts-expect-error kubo does not supply the key
key: msg.key != null ? publicKeyFromProtobuf(rpcToBytes(msg.key ?? 'u')) : undefined,
signature: rpcToBytes(msg.signature ?? 'u')
})
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/interface-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ describe('kubo-rpc-client tests against kubo', function () {
*/
const commonFactory = factory({
type: 'kubo',
bin: path(),
bin: typeof path === 'function' ? path() : undefined,
test: true
})
describe('kubo RPC client interface tests', function () {
Expand Down
10 changes: 6 additions & 4 deletions test/interface-tests/src/name/publish.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-env mocha */

import { peerIdFromString } from '@libp2p/peer-id'
import { peerIdFromCID, peerIdFromString } from '@libp2p/peer-id'
import { expect } from 'aegir/chai'
import last from 'it-last'
import { nanoid } from 'nanoid'
Expand All @@ -10,6 +10,8 @@ import { fixture } from './utils.js'
import type { KuboRPCClient } from '../../../../src/index.js'
import type { PeerId } from '@libp2p/interface'
import type { Factory, KuboNode } from 'ipfsd-ctl'
import { CID } from 'multiformats/cid'
import { base36 } from 'multiformats/bases/base36'

export function testPublish (factory: Factory<KuboNode>, options: MochaConfig): void {
const describe = getDescribe(options)
Expand Down Expand Up @@ -53,7 +55,7 @@ export function testPublish (factory: Factory<KuboNode>, options: MochaConfig):
const res = await ipfs.name.publish(value, { allowOffline: true })
expect(res).to.exist()

expect(peerIdFromString(res.name).toString()).to.equal(peerIdFromString(self.id).toString())
expect(peerIdFromCID(CID.parse(res.name, base36)).toString()).to.equal(peerIdFromCID(CID.parse(self.id, base36)).toString())
expect(res.value).to.equal(`/ipfs/${value}`)
})

Expand Down Expand Up @@ -84,7 +86,7 @@ export function testPublish (factory: Factory<KuboNode>, options: MochaConfig):

const res = await ipfs.name.publish(value, options)
expect(res).to.exist()
expect(peerIdFromString(res.name).toString()).to.equal(peerIdFromString(self.id).toString())
expect(peerIdFromCID(CID.parse(res.name, base36)).toString()).to.equal(peerIdFromCID(CID.parse(self.id, base36)).toString())
expect(res.value).to.equal(`/ipfs/${value}`)
})

Expand All @@ -104,7 +106,7 @@ export function testPublish (factory: Factory<KuboNode>, options: MochaConfig):
const res = await ipfs.name.publish(value, options)

expect(res).to.exist()
expect(peerIdFromString(res.name).toString()).to.equal(peerIdFromString(key.id).toString())
expect(peerIdFromCID(CID.parse(res.name, base36)).toString()).to.equal(peerIdFromCID(CID.parse(key.id, base36)).toString())
expect(res.value).to.equal(`/ipfs/${value}`)
})
})
Expand Down

0 comments on commit 62a7583

Please sign in to comment.