diff --git a/src/__tests__/ceramic_integration.test.ts b/src/__tests__/ceramic_integration.test.ts index f3d1f00e3..1ca75342d 100644 --- a/src/__tests__/ceramic_integration.test.ts +++ b/src/__tests__/ceramic_integration.test.ts @@ -334,6 +334,10 @@ describe('Ceramic Integration Test', () => { ceramic1 = await makeCeramicCore(ipfs3, `http://localhost:${casPort1}`, ganacheServer.url) ceramic2 = await makeCeramicCore(ipfs4, `http://localhost:${casPort2}`, ganacheServer.url) + // Speed up polling interval to speed up test + ceramic1.context.anchorService.pollInterval = 100 + ceramic2.context.anchorService.pollInterval = 100 + // The two user-facing ceramic nodes need to have the same DID Provider so that they can modify // each others streams. const did = makeDID() @@ -528,7 +532,7 @@ describe('CAR file', () => { // Poll more often to speed up the test const anchorService = ceramic.context.anchorService as any - anchorService.pollInterval = 200 + anchorService.pollInterval = 100 // CAS: Do not publish to IPFS const carFactory = new CARFactory() diff --git a/src/services/__tests__/anchor-service.test.ts b/src/services/__tests__/anchor-service.test.ts index 027a982bf..ff3c9591e 100644 --- a/src/services/__tests__/anchor-service.test.ts +++ b/src/services/__tests__/anchor-service.test.ts @@ -172,7 +172,6 @@ describe('anchor service', () => { await requestRepository.findAndMarkReady(0) - const publishSpy = jest.spyOn(ipfsService, 'publishAnchorCommit') const [candidates] = await anchorService._findCandidates(requests, 0) const merkleTree = await anchorService._buildMerkleTree(candidates) const ipfsProofCid = await ipfsService.storeRecord({}) @@ -182,8 +181,6 @@ describe('anchor service', () => { expect(candidates.length).toEqual(requests.length) expect(anchors.length).toEqual(candidates.length) - expect(publishSpy).toBeCalledTimes(anchors.length) - // All requests are anchored, in a different order because of IpfsLeafCompare expect(anchors.map((a) => a.requestId).sort()).toEqual(requests.map((r) => r.id).sort()) for (const [index, anchor] of anchors.entries()) { @@ -197,10 +194,6 @@ describe('anchor service', () => { expect(anchorRecord.prev.toString()).toEqual(request.cid) expect(anchorRecord.proof).toEqual(ipfsProofCid) expect(anchorRecord.path).toEqual(anchor.path) - expect(publishSpy.mock.calls[index]).toEqual([ - anchor.cid, - StreamID.fromString(request.streamId), - ]) } expectPresent(anchors[0]) diff --git a/src/services/anchor-service.ts b/src/services/anchor-service.ts index 5f485eaa8..40d68bd90 100644 --- a/src/services/anchor-service.ts +++ b/src/services/anchor-service.ts @@ -503,10 +503,20 @@ export class AnchorService { try { await this.ipfsService.storeRecord(ipfsAnchorCommit) - await this.ipfsService.publishAnchorCommit(anchorCid, candidate.streamId) - logger.debug( - `Created anchor commit with CID ${anchorCid} for commit ${candidate.cid} of stream ${candidate.streamId}` - ) + + // Do not publish to pubsub by default + if (process.env['CAS_PUBSUB_PUBLISH']) { + // TODO: Remove this case entirely after js-ceramic no longer supports pubsub + await this.ipfsService.publishAnchorCommit(anchorCid, candidate.streamId) + logger.debug( + `Created anchor commit with CID ${anchorCid} for commit ${candidate.cid} of stream ${candidate.streamId} and published it to pubsub` + ) + } else { + logger.debug( + `Created anchor commit with CID ${anchorCid} for commit ${candidate.cid} of stream ${candidate.streamId}` + ) + } + return anchor } catch (err) { const msg = `Error publishing anchor commit of commit ${