Skip to content

Commit

Permalink
test: added test for allowPublishZeroPeers param in publish function
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Jan 9, 2023
1 parent c4b1bea commit ce30c04
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/gossip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ describe('gossip', () => {
scoreParams: {
IPColocationFactorThreshold: GossipsubDhi + 3
},
maxInboundDataLength: 4000000
maxInboundDataLength: 4000000,
allowPublishToZeroPeers: false
}
})
})
Expand Down Expand Up @@ -80,6 +81,22 @@ describe('gossip', () => {
nodeASpy.pushGossip.restore()
})

it('Should allow publishing to zero peers if flag is passed', async function () {
this.timeout(10e4)
const nodeA = nodes[0]
const topic = 'Z'

const publishResult = await nodeA.pubsub.publish(topic, uint8ArrayFromString('hey'), {
allowPublishToZeroPeers: true
})

// gossip happens during the heartbeat
await pEvent(nodeA.pubsub, 'gossipsub:heartbeat')

// should have sent message to peerB
expect(publishResult.recipients).to.deep.equal([])
})

it('should reject incoming messages bigger than maxInboundDataLength limit', async function () {
this.timeout(10e4)
const nodeA = nodes[0]
Expand Down

0 comments on commit ce30c04

Please sign in to comment.