Skip to content

Commit

Permalink
Merge pull request #1241 from XYOracleNetwork/feature/index-diviner-t…
Browse files Browse the repository at this point in the history
…ests

Index Diviner Tests
  • Loading branch information
JoelBCarter authored Dec 30, 2024
2 parents 885b61a + 379104b commit 3631d4c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"--inspect-brk",
"--no-file-parallelism",
"--testTimeout=120000",
"packages/modules/packages/bridge/packages/pub-sub/src/spec/PubSubBridge.adhoc.spec.ts"
"packages/modules/packages/diviner/packages/indexing/packages/temporal/packages/memory/src/spec/Diviner.spec.ts"
],
"sourceMaps": true,
"resolveSourceMapLocations": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type Query = PayloadDivinerQueryPayload & { status?: number; success?: boolean;
/**
* @group slow
*/
describe.skip('TemporalIndexingDiviner - Multiple', () => {
describe('TemporalIndexingDiviner - Multiple', () => {
const sourceUrl = 'https://placekitten.com/200/300'
const thumbnailHttpSuccess: ImageThumbnail = {
http: { status: 200 },
Expand Down Expand Up @@ -100,11 +100,6 @@ describe.skip('TemporalIndexingDiviner - Multiple', () => {
node = await manifestWrapper.loadNodeFromIndex(0)
await node.start()

const privateModules = manifest.nodes[0].modules?.private ?? []
const publicModules = manifest.nodes[0].modules?.public ?? []
const mods = await node.resolve('*')
expect(mods.length).toBe(privateModules.length + publicModules.length)

// Insert previously witnessed payloads into thumbnail archivist
const timestamp: TimeStamp = { schema: TimestampSchema, timestamp: Date.now() }
const [boundWitness, payloads] = await new BoundWitnessBuilder().payloads([timestamp, ...witnessedThumbnails]).build()
Expand All @@ -126,7 +121,7 @@ describe.skip('TemporalIndexingDiviner - Multiple', () => {
it('has expected bound witnesses', async () => {
const payloads = await stateArchivist.all()
const stateBoundWitnesses = filterAs(payloads, asBoundWitness)
expect(stateBoundWitnesses).toBeArrayOfSize(2)
expect(stateBoundWitnesses).toBeArrayOfSize(1)
for (const stateBoundWitness of stateBoundWitnesses) {
expect(stateBoundWitness).toBeObject()
expect(stateBoundWitness.addresses).toBeArrayOfSize(1)
Expand All @@ -136,11 +131,11 @@ describe.skip('TemporalIndexingDiviner - Multiple', () => {
it('has expected state', async () => {
const payloads = await stateArchivist.all()
const statePayloads = filterAs(payloads, asModuleState)
expect(statePayloads).toBeArrayOfSize(2)
expect(statePayloads).toBeArrayOfSize(1)
expect(statePayloads.at(-1)).toBeObject()
const statePayload = assertEx(statePayloads.at(-1))
expect(statePayload.state).toBeObject()
expect(statePayload.state?.offset).toBe(1)
expect(statePayload.state?.cursor).toBeDefined()
})
})
describe('diviner index', () => {
Expand Down Expand Up @@ -185,7 +180,7 @@ describe.skip('TemporalIndexingDiviner - Multiple', () => {
expect(result).toBeDefined()
const payload = assertEx((witnessedThumbnails).at(-1))
const expected = await PayloadBuilder.dataHash(payload)
expect(result?.sources).toContain(expected)
expect(result?.$sources).toContain(expected)
})
})
describe('with filter criteria', () => {
Expand All @@ -200,7 +195,7 @@ describe.skip('TemporalIndexingDiviner - Multiple', () => {
const result = results.find(isTemporalIndexingDivinerResultIndex)
expect(result).toBeDefined()
const expected = await PayloadBuilder.dataHash(payload)
expect(result?.sources).toContain(expected)
expect(result?.$sources).toContain(expected)
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type Query = PayloadDivinerQueryPayload & { status?: number; success?: boolean;
/**
* @group slow
*/
describe.skip('TemporalIndexingDiviner', () => {
describe('TemporalIndexingDiviner', () => {
const sourceUrl = 'https://placekitten.com/200/300'
const thumbnailHttpSuccess: ImageThumbnail = {
http: { status: 200 },
Expand Down Expand Up @@ -100,11 +100,6 @@ describe.skip('TemporalIndexingDiviner', () => {
node = await manifestWrapper.loadNodeFromIndex(0)
await node.start()

const privateModules = manifest.nodes[0].modules?.private ?? []
const publicModules = manifest.nodes[0].modules?.public ?? []
const mods = await node.resolve('*')
expect(mods.length).toBe(privateModules.length + publicModules.length)

// Insert previously witnessed payloads into thumbnail archivist
const httpSuccessTimestamp: TimeStamp = { schema: TimestampSchema, timestamp: Date.now() }
const [httpSuccessBoundWitness, httpSuccessPayloads] = await new BoundWitnessBuilder()
Expand Down Expand Up @@ -147,7 +142,7 @@ describe.skip('TemporalIndexingDiviner', () => {
it('has expected bound witnesses', async () => {
const payloads = await stateArchivist.all()
const stateBoundWitnesses = filterAs(payloads, asBoundWitness)
expect(stateBoundWitnesses).toBeArrayOfSize(2)
expect(stateBoundWitnesses).toBeArrayOfSize(1)
for (const stateBoundWitness of stateBoundWitnesses) {
expect(stateBoundWitness).toBeObject()
expect(stateBoundWitness.addresses).toBeArrayOfSize(1)
Expand All @@ -157,11 +152,11 @@ describe.skip('TemporalIndexingDiviner', () => {
it('has expected state', async () => {
const payloads = await stateArchivist.all()
const statePayloads = filterAs(payloads, asModuleState)
expect(statePayloads).toBeArrayOfSize(2)
expect(statePayloads).toBeArrayOfSize(1)
expect(statePayloads.at(-1)).toBeObject()
const statePayload = assertEx(statePayloads.at(-1))
expect(statePayload.state).toBeObject()
expect(statePayload.state?.offset).toBe(witnessedThumbnails.length)
expect(statePayload.state?.cursor).toBeDefined()
})
})
describe('diviner index', () => {
Expand Down Expand Up @@ -205,7 +200,7 @@ describe.skip('TemporalIndexingDiviner', () => {
const result = results.find(isTemporalIndexingDivinerResultIndex)
expect(result).toBeDefined()
const expected = await PayloadBuilder.dataHash(thumbnailCodeFail)
expect(result?.sources).toContain(expected)
expect(result?.$sources).toContain(expected)
})
})
describe('with filter criteria', () => {
Expand All @@ -220,35 +215,7 @@ describe.skip('TemporalIndexingDiviner', () => {
const result = results.find(isTemporalIndexingDivinerResultIndex)
expect(result).toBeDefined()
const expected = await PayloadBuilder.dataHash(payload)
expect(result?.sources).toContain(expected)
})
})
describe.skip('for success (most recent)', () => {
const cases: ImageThumbnail[] = [thumbnailHttpSuccess]
it.each(cases)('returns the most recent instance of that success state', async (payload) => {
const success = !!(payload.url ?? false)
const query: Query = {
schema, success, url,
}
const results = await sut.divine([query])
const result = results.find(isTemporalIndexingDivinerResultIndex)
expect(result).toBeDefined()
const expected = await PayloadBuilder.dataHash(payload)
expect(result?.sources).toContain(expected)
})
})
describe.skip('for failure (most recent)', () => {
const cases: ImageThumbnail[] = [thumbnailCodeFail]
it.each(cases)('returns the most recent instance of that success state', async (payload) => {
const success = !!(payload.url ?? false)
const query: Query = {
schema, success, url,
}
const results = await sut.divine([query])
const result = results.find(isTemporalIndexingDivinerResultIndex)
expect(result).toBeDefined()
const expected = await PayloadBuilder.dataHash(payload)
expect(result?.sources).toContain(expected)
expect(result?.$sources).toContain(expected)
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@
"destinationField": "limit",
"sourcePathExpression": "$.limit"
},
{
"defaultValue": 0,
"destinationField": "offset",
"sourcePathExpression": "$.offset"
},
{
"defaultValue": "desc",
"destinationField": "order",
Expand All @@ -162,10 +157,6 @@
{
"destinationField": "status",
"sourcePathExpression": "$.status"
},
{
"destinationField": "success",
"sourcePathExpression": "$.success"
}
]
}
Expand Down

0 comments on commit 3631d4c

Please sign in to comment.