Skip to content

Commit

Permalink
fix: fixed more proof tests
Browse files Browse the repository at this point in the history
Signed-off-by: blu3beri <berend@animo.id>
  • Loading branch information
berendsliedrecht committed Nov 25, 2022
1 parent 3841a15 commit af00bb0
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions packages/core/tests/v1-proofs-auto-accept.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ describe('Auto accept present proof', () => {
test('Alice starts with proof proposal to Faber, both with autoacceptproof on `contentApproved`', async () => {
testLogger.test('Alice sends presentation proposal to Faber')

let faberProofExchangeRecordPromise = waitForProofExchangeRecord(faberAgent, {
state: ProofState.ProposalReceived,
})

const aliceProofExchangeRecord = await aliceAgent.proofs.proposeProof({
connectionId: aliceConnection.id,
protocolVersion: 'v1',
Expand All @@ -165,26 +161,23 @@ describe('Auto accept present proof', () => {
})

testLogger.test('Faber waits for presentation proposal from Alice')

await faberProofExchangeRecordPromise
const faberProofExchangeRecord = await waitForProofExchangeRecord(faberAgent, {
threadId: aliceProofExchangeRecord.threadId,
state: ProofState.ProposalReceived,
})

testLogger.test('Faber accepts presentation proposal from Alice')
await faberAgent.proofs.acceptProposal({ proofRecordId: faberProofExchangeRecord.id })

faberProofExchangeRecordPromise = waitForProofExchangeRecord(faberAgent, {
await waitForProofExchangeRecord(aliceAgent, {
threadId: aliceProofExchangeRecord.threadId,
state: ProofState.Done,
})

const aliceProofExchangeRecordPromise = waitForProofExchangeRecord(aliceAgent, {
threadId: aliceProofExchangeRecord.threadId,
await waitForProofExchangeRecord(faberAgent, {
threadId: faberProofExchangeRecord.threadId,
state: ProofState.Done,
})

testLogger.test('Faber waits for presentation from Alice')

await faberProofExchangeRecordPromise
// Alice waits till it receives presentation ack
await aliceProofExchangeRecordPromise
})

test('Faber starts with proof requests to Alice, both with autoacceptproof on `contentApproved`', async () => {
Expand Down Expand Up @@ -212,14 +205,6 @@ describe('Auto accept present proof', () => {
}),
}

const faberProofExchangeRecordPromise = waitForProofExchangeRecord(faberAgent, {
state: ProofState.Done,
})

const aliceProofExchangeRecordPromise = waitForProofExchangeRecord(aliceAgent, {
state: ProofState.Done,
})

await faberAgent.proofs.requestProof({
protocolVersion: 'v1',
connectionId: faberConnection.id,
Expand All @@ -234,11 +219,22 @@ describe('Auto accept present proof', () => {
},
})

testLogger.test('Faber waits for presentation from Alice')
await faberProofExchangeRecordPromise
testLogger.test('Alice waits for request from Faber')
const { id: proofRecordId } = await waitForProofExchangeRecord(aliceAgent, {
state: ProofState.RequestReceived,
})

const { proofFormats } = await aliceAgent.proofs.autoSelectCredentialsForProofRequest({ proofRecordId })
await aliceAgent.proofs.acceptRequest({ proofRecordId, proofFormats })

// Alice waits till it receives presentation ack
await aliceProofExchangeRecordPromise
await waitForProofExchangeRecord(aliceAgent, {
state: ProofState.Done,
})
// Faber waits till it receives presentation ack
await waitForProofExchangeRecord(faberAgent, {
state: ProofState.Done,
})
})
})
})

0 comments on commit af00bb0

Please sign in to comment.