@@ -25,7 +25,6 @@ const os = require('os')
2525const { vcxFlowUpdateMsgsFromAgent } = require ( '../../../src' )
2626const { vcxFlowGetMsgsFromAgentConn } = require ( '../../../src' )
2727const { vcxFlowSendAriesMessage } = require ( '../../../src' )
28- const { vcxFlowGetMsgsFromAgent } = require ( '../../../src' )
2928const { buildAgencyClientNetwork } = require ( '../../common' )
3029const { vcxFlowCreateAgentConnection } = require ( 'vcxagency-client/src' )
3130const { vcxFlowFullOnboarding } = require ( 'vcxagency-client/src' )
@@ -102,51 +101,56 @@ afterEach(async () => {
102101describe ( 'onboarding' , ( ) => {
103102 it ( 'should exchange messages between alice and bob via agency' , async ( ) => {
104103 // arrange
105- const { agentDid : aliceAgentDid , agentVerkey : aliceAgentVerkey } = await vcxFlowFullOnboarding ( aliceWh , sendToAgency , agencyDid , agencyVerkey , aliceDid , aliceVerkey )
104+ const {
105+ agentDid : aliceAgentDid ,
106+ agentVerkey : aliceAgentVerkey
107+ } = await vcxFlowFullOnboarding ( aliceWh , sendToAgency , agencyDid , agencyVerkey , aliceDid , aliceVerkey )
106108 const { did : aliceUserPairwiseDid , vkey : aliceUserPairwiseVerkey } = await indyCreateAndStoreMyDid ( aliceWh )
107109 console . log ( 'Alice was onboarded.' )
108110
109- const { agentDid : bobAgentDid , agentVerkey : bobAgentVerkey } = await vcxFlowFullOnboarding ( bobWh , sendToAgency , agencyDid , agencyVerkey , bobDid , bobVerkey )
111+ const {
112+ agentDid : bobAgentDid ,
113+ agentVerkey : bobAgentVerkey
114+ } = await vcxFlowFullOnboarding ( bobWh , sendToAgency , agencyDid , agencyVerkey , bobDid , bobVerkey )
110115 const { did : bobUserPairwiseDid , vkey : bobUserPairwiseVerkey } = await indyCreateAndStoreMyDid ( bobWh )
111116 console . log ( 'Bob was onboarded.' )
112117
113118 // create agent connection, both alice and bob
114119 console . log ( `Alice is going to create agent connection. aliceAgentDid=${ aliceAgentDid } aliceVerkey=${ aliceVerkey } aliceUserPairwiseDid=${ aliceUserPairwiseDid } aliceUserPairwiseVerkey=${ aliceUserPairwiseVerkey } ` )
115120 const alicesAconn = await vcxFlowCreateAgentConnection ( aliceWh , sendToAgency , aliceAgentDid , aliceAgentVerkey , aliceVerkey , aliceUserPairwiseDid , aliceUserPairwiseVerkey )
116- const alicesRoutingAgentDid = alicesAconn . withPairwiseDID
117- const alicesRoutingAgentVerkey = alicesAconn . withPairwiseDIDVerKey
121+ const aconnAlice2BobDid = alicesAconn . withPairwiseDID
122+ const aconnAlice2BobVk = alicesAconn . withPairwiseDIDVerKey
118123 console . log ( 'Alice created agent connection!' )
119124 await vcxFlowCreateAgentConnection ( bobWh , sendToAgency , bobAgentDid , bobAgentVerkey , bobVerkey , bobUserPairwiseDid , bobUserPairwiseVerkey )
120125
121- const aliceAllMsgs1 = await vcxFlowGetMsgsFromAgent ( aliceWh , sendToAgency , aliceAgentDid , aliceAgentVerkey , aliceVerkey , [ ] , [ ] , [ ] )
126+ const aliceAllMsgs1 = await vcxFlowGetMsgsFromAgentConn ( aliceWh , sendToAgency , aconnAlice2BobDid , aconnAlice2BobVk , aliceUserPairwiseVerkey , [ ] , [ ] , [ ] )
127+ expect ( aliceAllMsgs1 [ '@type' ] ) . toBe ( 'did:sov:123456789abcdefghi1234;spec/pairwise/1.0/MSGS' )
128+ expect ( aliceAllMsgs1 . msgs . length ) . toBe ( 0 )
122129 console . log ( `Alice queries agency for all messages, she should have none. Response = ${ JSON . stringify ( aliceAllMsgs1 ) } ` )
123130
124131 // bobs sends message to alices routing agent
125- const bobSendMsgRes1 = await vcxFlowSendAriesMessage ( bobWh , sendToAgency , aliceUserPairwiseVerkey , alicesRoutingAgentVerkey , bobUserPairwiseVerkey , 'This is Bob!' )
132+ const bobSendMsgRes1 = await vcxFlowSendAriesMessage ( bobWh , sendToAgency , aliceUserPairwiseVerkey , aconnAlice2BobVk , bobUserPairwiseVerkey , 'This is Bob!' )
126133 console . log ( `Bob sends aries message to Alice's agent. Response = ${ JSON . stringify ( bobSendMsgRes1 ) } ` )
127134
128135 // alice fetches messages
129- const aliceAllMsgs2 = await vcxFlowGetMsgsFromAgent ( aliceWh , sendToAgency , aliceAgentDid , aliceAgentVerkey , aliceVerkey , [ ] , [ ] , [ ] )
136+ const aliceAllMsgs2 = await vcxFlowGetMsgsFromAgentConn ( aliceWh , sendToAgency , aconnAlice2BobDid , aconnAlice2BobVk , aliceUserPairwiseVerkey , [ ] , [ ] , [ ] )
130137 console . log ( `Alice queries agency for all messages, she should have one. Response = ${ JSON . stringify ( aliceAllMsgs2 ) } ` )
131-
132- const aliceToBoMsgs = await vcxFlowGetMsgsFromAgentConn ( aliceWh , sendToAgency , alicesRoutingAgentDid , alicesRoutingAgentVerkey , aliceUserPairwiseVerkey , [ ] , [ ] )
133- console . log ( `Alice queries agency for alice2bob messages, she should have one. Response = ${ JSON . stringify ( aliceToBoMsgs ) } ` )
138+ expect ( aliceAllMsgs2 . msgs . length ) . toBe ( 1 )
139+ expect ( aliceAllMsgs2 . msgs [ 0 ] . statusCode ) . toBe ( 'MS-103' )
134140
135141 // alice updates message status
136142 const aliceMsgsByConns = [
137- { pairwiseDID : aliceUserPairwiseDid , uids : [ aliceToBoMsgs . msgs [ 0 ] . uid ] }
143+ { pairwiseDID : 'unused-attribute' , uids : [ aliceAllMsgs2 . msgs [ 0 ] . uid ] }
138144 ]
139- const aliceNewMsgStatus = 'MS-104 '
145+ const aliceNewMsgStatus = 'MS-106 '
140146 const updateResponse = await vcxFlowUpdateMsgsFromAgent ( aliceWh , sendToAgency , aliceAgentDid , aliceAgentVerkey , aliceVerkey , aliceMsgsByConns , aliceNewMsgStatus )
141147 console . log ( `Alice run msg status update for msgs ${ JSON . stringify ( aliceMsgsByConns ) } to status ${ aliceNewMsgStatus } . Response = ${ JSON . stringify ( updateResponse ) } ` )
142148
143- // alice tries to update msg status on connection she doesn't have
144- const updateMsgForNonExistingUserPwDid = [
145- { pairwiseDID : '4aA6TyH2Cgq7gg2wGFiRXS' , uids : [ aliceToBoMsgs . msgs [ 0 ] . uid ] }
146- ]
147- const aliceNewMsgStatus2 = 'MS-105'
148- const updateResponse2 = await vcxFlowUpdateMsgsFromAgent ( aliceWh , sendToAgency , aliceAgentDid , aliceAgentVerkey , aliceVerkey , updateMsgForNonExistingUserPwDid , aliceNewMsgStatus2 )
149- console . log ( `Alice run msg status update for agent connection which does not exists on her agent. Response = ${ JSON . stringify ( updateResponse2 ) } ` )
149+ // alice fetches messages
150+ const aliceAllMsgs3 = await vcxFlowGetMsgsFromAgentConn ( aliceWh , sendToAgency , aconnAlice2BobDid , aconnAlice2BobVk , aliceUserPairwiseVerkey , [ ] , [ ] , [ ] )
151+ console . log ( `Alice queries agency for all messages, she should have one. Response = ${ JSON . stringify ( aliceAllMsgs3 ) } ` )
152+ expect ( aliceAllMsgs3 . msgs . length ) . toBe ( 1 )
153+ expect ( aliceAllMsgs3 . msgs [ 0 ] . statusCode ) . toBe ( 'MS-106' )
150154 } )
151155} )
152156
0 commit comments