Skip to content

Commit

Permalink
test: update 0.1 migration snapshots for mediation routing record gen…
Browse files Browse the repository at this point in the history
…eration on init

Signed-off-by: Ariel Gentile <[email protected]>
  • Loading branch information
genaris committed Aug 19, 2022
1 parent 9c3c88c commit 551b767
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/core/src/storage/migration/__tests__/0.1.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { DidInfo, DidConfig } from '../../../wallet'
import type { V0_1ToV0_2UpdateConfig } from '../updates/0.1-0.2'

import { unlinkSync, readFileSync } from 'fs'
Expand All @@ -9,6 +10,7 @@ import { Agent } from '../../../../src'
import { agentDependencies } from '../../../../tests/helpers'
import { InjectionSymbols } from '../../../constants'
import * as uuid from '../../../utils/uuid'
import { IndyWallet } from '../../../wallet/IndyWallet'
import { UpdateAssistant } from '../UpdateAssistant'

const backupDate = new Date('2022-01-21T22:50:20.522Z')
Expand All @@ -28,6 +30,19 @@ const mediationRoleUpdateStrategies: V0_1ToV0_2UpdateConfig['mediationRoleUpdate
]

describe('UpdateAssistant | v0.1 - v0.2', () => {
let createDidSpy: jest.SpyInstance<Promise<DidInfo>, [didConfig?: DidConfig | undefined]>

beforeAll(async () => {
// We need to mock did generation to create a consistent mediator routing record across sessions
createDidSpy = jest
.spyOn(IndyWallet.prototype, 'createDid')
.mockImplementation(async () => ({ did: 'mock-did', verkey: 'ocxwFbXouLkzuTCyyjFg1bPGK3nM6aPv1pZ6fn5RNgD' }))
})

afterAll(async () => {
createDidSpy.mockReset()
})

it(`should correctly update the role in the mediation record`, async () => {
const aliceMediationRecordsString = readFileSync(
path.join(__dirname, '__fixtures__/alice-4-mediators-0.1.json'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,20 @@ Object {
"threadId": "0b2f1133-ced9-49f1-83a1-eb6ba1c24cdf",
},
},
"MEDIATOR_ROUTING_RECORD": Object {
"id": "MEDIATOR_ROUTING_RECORD",
"tags": Object {},
"type": "MediatorRoutingRecord",
"value": Object {
"_tags": Object {},
"createdAt": "2022-01-21T22:50:20.522Z",
"id": "MEDIATOR_ROUTING_RECORD",
"metadata": Object {},
"routingKeys": Array [
"ocxwFbXouLkzuTCyyjFg1bPGK3nM6aPv1pZ6fn5RNgD",
],
},
},
"STORAGE_VERSION_RECORD_ID": Object {
"id": "STORAGE_VERSION_RECORD_ID",
"tags": Object {},
Expand Down Expand Up @@ -2961,6 +2975,20 @@ Object {
"role": "receiver",
},
},
"MEDIATOR_ROUTING_RECORD": Object {
"id": "MEDIATOR_ROUTING_RECORD",
"tags": Object {},
"type": "MediatorRoutingRecord",
"value": Object {
"_tags": Object {},
"createdAt": "2022-01-21T22:50:20.522Z",
"id": "MEDIATOR_ROUTING_RECORD",
"metadata": Object {},
"routingKeys": Array [
"ocxwFbXouLkzuTCyyjFg1bPGK3nM6aPv1pZ6fn5RNgD",
],
},
},
"STORAGE_VERSION_RECORD_ID": Object {
"id": "STORAGE_VERSION_RECORD_ID",
"tags": Object {},
Expand Down

0 comments on commit 551b767

Please sign in to comment.