Skip to content

Commit

Permalink
fix: disable recon feed in test where it is causing flaky behavior (#…
Browse files Browse the repository at this point in the history
…3206)

* fix: disable recon feed in test where it is causing flaky behavior

* fix: remove console log
  • Loading branch information
stephhuynh18 authored Apr 15, 2024
1 parent fdcc5fd commit 4b15ada
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/core/src/__tests__/ceramic-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe('Ceramic API', () => {
tmpFolder = await tmp.dir({ unsafeCleanup: true })
ceramic = await createCeramic(ipfs, {
stateStoreDirectory: tmpFolder.path,
reconFeedEnabled: false,
})
})

Expand Down Expand Up @@ -373,28 +374,24 @@ describe('Ceramic API', () => {
handleAnchorEventSpy.mockImplementation(() => Promise.resolve(false))

const model = await Model.create(ceramic, MODEL_DEFINITION_BLOB)
await CommonTestUtils.delay(1000)

// In v3 mode we call into update the state store and index twice as part of creating a
// Stream. Once from loading the genesis commit, a second from applying the handling the
// create. In v4 mode and going forward, there is only 1 call into the index since we don't
// update persisted state on stream loads.
const NUM_INDEX_CALLS_PER_STREAM_CREATE = 2
const NUM_INDEX_CALLS_PER_STREAM_CREATE = process.env.CERAMIC_RECON_MODE ? 1 : 2

expect(addIndexSpy).toBeCalledTimes(NUM_INDEX_CALLS_PER_STREAM_CREATE)
const midMetadata = { model: model.id }
const doc = await ModelInstanceDocument.create(ceramic, CONTENT0, midMetadata, {
anchor: false,
pin: false,
})
await CommonTestUtils.delay(1000)
expect(doc.content).toEqual(CONTENT0)
expect(addIndexSpy).toBeCalledTimes(NUM_INDEX_CALLS_PER_STREAM_CREATE * 2)
await doc.patch(CONTENT1, { anchor: false })
await CommonTestUtils.delay(1000)
expect(doc.content).toEqual({ myData: 'abcdefgh' })
const reconCorrection = process.env.CERAMIC_RECON_MODE ? 0 : -1
expect(addIndexSpy).toBeCalledTimes(NUM_INDEX_CALLS_PER_STREAM_CREATE * 3 + reconCorrection)
expect(addIndexSpy).toBeCalledTimes(NUM_INDEX_CALLS_PER_STREAM_CREATE * 2 + 1)
addIndexSpy.mockRestore()
})

Expand Down

0 comments on commit 4b15ada

Please sign in to comment.