Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 committed Feb 1, 2024
1 parent 3d5334d commit 62865ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/__tests__/ceramic_state_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
* @jest-environment ./build/index.js
*/

import { StreamReaderWriter } from '@ceramicnetwork/common'
import { Ceramic } from '@ceramicnetwork/core'
import { StreamID } from '@ceramicnetwork/streamid'
import { TileDocument } from '@ceramicnetwork/stream-tile'
import { delay, restartCeramic } from '../utils.js'
import { config } from 'node-config-ts'
import { jest } from '@jest/globals'

declare global {
let ceramic: StreamReaderWriter
let ceramic: Ceramic
}

const isPinned = async (ceramic: StreamReaderWriter, streamId: StreamID): Promise<boolean> => {
const isPinned = async (ceramic: Ceramic, streamId: StreamID): Promise<boolean> => {
const pinnedStreamsIterator = await ceramic.admin.pin.ls(streamId)
const pinnedStreamIds = []
for await (const id of pinnedStreamsIterator) {
Expand Down
19 changes: 10 additions & 9 deletions src/__tests__/indexing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* @jest-environment ./build/index.js
*/
import { jest } from '@jest/globals'
import { StreamReaderWriter, Page, StreamState, StreamUtils } from '@ceramicnetwork/common'
import { Page, StreamState, StreamUtils } from '@ceramicnetwork/common'
import { Ceramic } from '@ceramicnetwork/core'
import { CommonTestUtils as TestUtils } from '@ceramicnetwork/common-test-utils'
import { ModelInstanceDocument } from '@ceramicnetwork/stream-model-instance'
import { StreamID } from '@ceramicnetwork/streamid'
Expand All @@ -17,8 +18,8 @@ const DATA2 = { data: 444 }
const DATA3 = { data: 555 }

declare global {
const ceramic: StreamReaderWriter
const ceramicClient: StreamReaderWriter
const ceramic: Ceramic
const ceramicClient: Ceramic
}

const extractStreamStates = (page: Page<StreamState | null>): Array<StreamState> => {
Expand All @@ -32,7 +33,7 @@ const extractStreamStates = (page: Page<StreamState | null>): Array<StreamState>
}

const extractDocuments = (
ceramic: StreamReaderWriter,
ceramic: Ceramic,
page: Page<StreamState | null>
): Array<ModelInstanceDocument> => {
return extractStreamStates(page).map(state =>
Expand All @@ -41,7 +42,7 @@ const extractDocuments = (
}

const waitForMidsToBeIndexed = async (
ceramic: StreamReaderWriter,
ceramic: Ceramic,
docs: ModelInstanceDocument[]
): Promise<void> => {
await firstValueFrom(
Expand Down Expand Up @@ -108,7 +109,7 @@ describe('indexing', () => {
if (singleNodeTestCases.length > 0) {
test.each(singleNodeTestCases)(
'Can create and query on same node -- %s',
async (_, ceramicInstance: StreamReaderWriter) => {
async (_, ceramicInstance: Ceramic) => {
console.info('running test: Can create and query on same node')

const doc1 = await ModelInstanceDocument.create(
Expand Down Expand Up @@ -176,7 +177,7 @@ describe('indexing', () => {

test.each(singleNodeTestCases)(
'Can filter by DID -- %s',
async (_, ceramicInstance: StreamReaderWriter) => {
async (_, ceramicInstance: Ceramic) => {
console.info('running test: Can filter by DID')

const did1 = originalDid
Expand Down Expand Up @@ -239,7 +240,7 @@ describe('indexing', () => {
if (twoNodesTestCases.length > 0) {
test.each(twoNodesTestCases)(
'Can create and query across nodes -- %s',
async (_, ceramic1: CeramicApi, ceramic2: StreamReaderWriter) => {
async (_, ceramic1: Ceramic, ceramic2: Ceramic) => {
console.info('running test: Can create and query across nodes')

const doc = await ModelInstanceDocument.create(
Expand Down Expand Up @@ -268,7 +269,7 @@ describe('indexing', () => {
expect(loadedDoc.content).toEqual(doc.content)

// Indexed streams should always get pinned, regardless of the 'pin' flag
await expect(TestUtils.isPinned(ceramic2, doc.id)).toBeTruthy()
await expect(TestUtils.isPinned(ceramic2.admin, doc.id)).toBeTruthy()

await expect(
ceramic2.index.count({ model: TEST_MODEL.toString() })
Expand Down

0 comments on commit 62865ea

Please sign in to comment.