Skip to content

Commit

Permalink
tests(integration/identity): Using a custom resolver
Browse files Browse the repository at this point in the history
Tests currently fail because of a breaking change in #399.
Furthermore, a better API for passing in a custom resolover is needed
  • Loading branch information
Exulansis committed Jun 9, 2020
1 parent 0c30d18 commit 2a413e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
15 changes: 11 additions & 4 deletions tests/integration/identity.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { testSeed } from '../data/keys.data'
import { ContractsGateway } from '../../ts/contracts/contractsGateway'
import { ContractsAdapter } from '../../ts/contracts/contractsAdapter'
import { Resolver } from 'did-resolver'
import { ErrorCodes } from '../../ts/errors'

chai.use(sinonChai)
const expect = chai.expect
Expand All @@ -35,6 +36,7 @@ export let userIdentityWallet: IdentityWallet
export let serviceIdentityWallet: IdentityWallet
export let testContractsGateway: ContractsGateway
export let testContractsAdapter: ContractsAdapter
export let testResolver: Resolver

before(async () => {
const {
Expand All @@ -51,14 +53,18 @@ before(async () => {
contracts: { gateway, adapter },
})

jolocomRegistry.resolver = new Resolver(
const {host, protocol, port} = testIpfsConfig

testResolver = new Resolver(
getResolver(
testEthereumConfig.providerUrl,
testEthereumConfig.contractAddress,
testIpfsConfig.host
`${protocol}://${host}:${port}`
)
)

jolocomRegistry.resolver = testResolver

userIdentityWallet = await jolocomRegistry.create(userVault, userPass)
serviceIdentityWallet = await jolocomRegistry.create(
serviceVault,
Expand All @@ -75,6 +81,7 @@ describe('Integration Test - Create, Resolve, Public Profile', () => {
const remoteUserIdentity = await jolocomRegistry.resolve(
userIdentityWallet.did,
)

const remoteServiceIdentity = await jolocomRegistry.resolve(
serviceIdentityWallet.did,
)
Expand Down Expand Up @@ -151,8 +158,8 @@ describe('Integration Test - Create, Resolve, Public Profile', () => {
encryptionPass: 'pass',
})
} catch (err) {
expect(err.message).to.eq(
'Could not retrieve DID Document. No record for DID found.',
expect(err.message).to.contain(
ErrorCodes.RegistryDIDNotAnchored
)
}
})
Expand Down
10 changes: 5 additions & 5 deletions ts/registries/jolocomRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ export class JolocomRegistry implements IRegistry {
*/

public async resolve(did: string): Promise<Identity> {
try {
const jsonDidDoc = await this.resolver.resolve(did)
const jsonDidDoc = await this.resolver.resolve(did)

if (!jsonDidDoc) {
throw new Error(ErrorCodes.RegistryDIDNotAnchored)
}
if (!jsonDidDoc) {
throw new Error(ErrorCodes.RegistryDIDNotAnchored)
}

try {
//@ts-ignore TODO IDidDoc vs IDidDocumentAttrs
const didDocument = DidDocument.fromJSON(jsonDidDoc)
const publicProfileJson = await getPublicProfile(jsonDidDoc)
Expand Down

0 comments on commit 2a413e1

Please sign in to comment.