@@ -110,7 +110,7 @@ async def connect_agents_and_issue_credentials(
110110 )
111111 print (">>> Done!" )
112112
113- return (inviter_conn , invitee_conn )
113+ return (inviter_conn , invitee_conn , inviter_cred_ex )
114114
115115
116116async def verify_schema_cred_def (issuer , schema_count , cred_def_count ):
@@ -219,7 +219,7 @@ async def upgrade_wallet_and_shutdown_container(
219219 agent_command = agent_container .attrs ["Config" ]["Cmd" ]
220220
221221 # command is a List, find the wallet type and replace "askar" with "askar-anoncreds"
222- correct_wallet_type = update_wallet_type (agent_command , "askar-anoncreds" )
222+ update_wallet_type (agent_command , "askar-anoncreds" )
223223 wallet_name = get_wallet_name (agent_command )
224224
225225 # call the wallet upgrade endpoint to upgrade to askar-anoncreds
@@ -299,7 +299,7 @@ async def main():
299299 Controller (base_url = BOB_ASKAR ) as bob ,
300300 ):
301301 # connect to Bob (Askar wallet) and issue (and revoke) some credentials
302- (alice_conn , bob_conn ) = await connect_agents_and_issue_credentials (
302+ (alice_conn , bob_conn , _ ) = await connect_agents_and_issue_credentials (
303303 alice ,
304304 bob ,
305305 cred_def ,
@@ -315,7 +315,7 @@ async def main():
315315 Controller (base_url = BOB_ANONCREDS ) as bob ,
316316 ):
317317 # connect to Bob (AnonCreds wallet) and issue (and revoke) some credentials
318- (alice_conn , bob_conn ) = await connect_agents_and_issue_credentials (
318+ (alice_conn , bob_conn , _ ) = await connect_agents_and_issue_credentials (
319319 alice ,
320320 bob ,
321321 cred_def ,
@@ -331,7 +331,11 @@ async def main():
331331 Controller (base_url = BOB_ASKAR_ANON ) as bob ,
332332 ):
333333 # connect to Bob (Askar wallet which will be upgraded) and issue (and revoke) some credentials
334- (alice_conn , bob_conn ) = await connect_agents_and_issue_credentials (
334+ (
335+ alice_conn ,
336+ bob_conn ,
337+ pre_upgraded_cred_ex ,
338+ ) = await connect_agents_and_issue_credentials (
335339 alice ,
336340 bob ,
337341 cred_def ,
@@ -386,113 +390,124 @@ async def main():
386390 alice_id = None
387391 new_bob_container = None
388392 bob_id = None
389- try :
390- (new_alice_container , alice_id ) = start_new_container (
391- client ,
392- alice_command ,
393- alice_container ,
394- "alice" ,
393+
394+ (new_alice_container , alice_id ) = start_new_container (
395+ client ,
396+ alice_command ,
397+ alice_container ,
398+ "alice" ,
399+ )
400+
401+ (new_bob_container , bob_id ) = start_new_container (
402+ client ,
403+ bob_command ,
404+ bob_container ,
405+ "bob-askar-anon" ,
406+ )
407+
408+ # TODO verify counts of credentials, revocations etc for each upgraded agent
409+ async with (
410+ Controller (base_url = ALICE ) as alice ,
411+ Controller (base_url = BOB_ASKAR_ANON ) as bob ,
412+ ):
413+ await verify_schema_cred_def (alice , 1 , 1 )
414+
415+ # run some more tests ... alice should still be connected to bob for example ...
416+ async with (
417+ Controller (base_url = ALICE ) as alice ,
418+ Controller (base_url = BOB_ANONCREDS ) as bob ,
419+ ):
420+ # Present the the credential's attributes
421+ print (">>> present proof ... again ..." )
422+ await anoncreds_present_proof_v2 (
423+ bob ,
424+ alice ,
425+ bob_conns ["anoncreds" ].connection_id ,
426+ alice_conns ["anoncreds" ].connection_id ,
427+ requested_attributes = [{"name" : "firstname" }],
395428 )
429+ await connect_agents_and_issue_credentials (
430+ alice ,
431+ bob ,
432+ cred_def ,
433+ "Bob" ,
434+ "AnonCreds" ,
435+ inviter_conn = alice_conns ["anoncreds" ],
436+ invitee_conn = bob_conns ["anoncreds" ],
437+ )
438+ await verify_recd_credentials (bob , 2 , 2 )
439+ print (">>> Done! (again)" )
396440
397- (new_bob_container , bob_id ) = start_new_container (
398- client ,
399- bob_command ,
400- bob_container ,
401- "bob-askar-anon" ,
441+ async with (
442+ Controller (base_url = ALICE ) as alice ,
443+ Controller (base_url = BOB_ASKAR_ANON ) as bob ,
444+ ):
445+ # Present the the credential's attributes
446+ print (">>> present proof ... again ..." )
447+ await anoncreds_present_proof_v2 (
448+ bob ,
449+ alice ,
450+ bob_conns ["askar-anon" ].connection_id ,
451+ alice_conns ["askar-anon" ].connection_id ,
452+ requested_attributes = [{"name" : "firstname" }],
453+ )
454+ await connect_agents_and_issue_credentials (
455+ alice ,
456+ bob ,
457+ cred_def ,
458+ "Bob" ,
459+ "Askar_Anon" ,
460+ inviter_conn = alice_conns ["askar-anon" ],
461+ invitee_conn = bob_conns ["askar-anon" ],
462+ )
463+ await verify_recd_credentials (bob , 2 , 2 )
464+ print (">>> Done! (again)" )
465+
466+ async with (
467+ Controller (base_url = ALICE ) as alice ,
468+ Controller (base_url = BOB_ASKAR ) as bob ,
469+ ):
470+ # Present the the credential's attributes
471+ print (">>> present proof ... again ..." )
472+ await anoncreds_present_proof_v2 (
473+ bob ,
474+ alice ,
475+ bob_conns ["askar" ].connection_id ,
476+ alice_conns ["askar" ].connection_id ,
477+ requested_attributes = [{"name" : "firstname" }],
478+ )
479+ await connect_agents_and_issue_credentials (
480+ alice ,
481+ bob ,
482+ cred_def ,
483+ "Bob" ,
484+ "Askar" ,
485+ inviter_conn = alice_conns ["askar" ],
486+ invitee_conn = bob_conns ["askar" ],
487+ )
488+ await verify_recd_credentials (bob , 2 , 2 )
489+ await verify_issued_credentials (alice , 12 , 6 )
490+ await verify_recd_presentations (alice , 9 )
491+ print (">>> Done! (again)" )
492+
493+ # Revoke one more credential to test revocation post-upgrade
494+ print (
495+ ">>> revoke one more credential created before the upgrade and with cred_ex_id..."
496+ )
497+ await alice .post (
498+ url = "/anoncreds/revocation/revoke" ,
499+ json = {
500+ "connection_id" : alice_conns ["askar" ].connection_id ,
501+ "cred_ex_id" : pre_upgraded_cred_ex .details .cred_ex_id ,
502+ "publish" : True ,
503+ "notify" : True ,
504+ "notify_version" : "v1_0" ,
505+ },
402506 )
403507
404- # TODO verify counts of credentials, revocations etc for each upgraded agent
405- async with (
406- Controller (base_url = ALICE ) as alice ,
407- Controller (base_url = BOB_ASKAR_ANON ) as bob ,
408- ):
409- await verify_schema_cred_def (alice , 1 , 1 )
410-
411- # run some more tests ... alice should still be connected to bob for example ...
412- async with (
413- Controller (base_url = ALICE ) as alice ,
414- Controller (base_url = BOB_ANONCREDS ) as bob ,
415- ):
416- # Present the the credential's attributes
417- print (">>> present proof ... again ..." )
418- await anoncreds_present_proof_v2 (
419- bob ,
420- alice ,
421- bob_conns ["anoncreds" ].connection_id ,
422- alice_conns ["anoncreds" ].connection_id ,
423- requested_attributes = [{"name" : "firstname" }],
424- )
425- await connect_agents_and_issue_credentials (
426- alice ,
427- bob ,
428- cred_def ,
429- "Bob" ,
430- "AnonCreds" ,
431- inviter_conn = alice_conns ["anoncreds" ],
432- invitee_conn = bob_conns ["anoncreds" ],
433- )
434- await verify_recd_credentials (bob , 2 , 2 )
435- print (">>> Done! (again)" )
436-
437- async with (
438- Controller (base_url = ALICE ) as alice ,
439- Controller (base_url = BOB_ASKAR_ANON ) as bob ,
440- ):
441- # Present the the credential's attributes
442- print (">>> present proof ... again ..." )
443- await anoncreds_present_proof_v2 (
444- bob ,
445- alice ,
446- bob_conns ["askar-anon" ].connection_id ,
447- alice_conns ["askar-anon" ].connection_id ,
448- requested_attributes = [{"name" : "firstname" }],
449- )
450- await connect_agents_and_issue_credentials (
451- alice ,
452- bob ,
453- cred_def ,
454- "Bob" ,
455- "Askar_Anon" ,
456- inviter_conn = alice_conns ["askar-anon" ],
457- invitee_conn = bob_conns ["askar-anon" ],
458- )
459- await verify_recd_credentials (bob , 2 , 2 )
460- print (">>> Done! (again)" )
461-
462- async with (
463- Controller (base_url = ALICE ) as alice ,
464- Controller (base_url = BOB_ASKAR ) as bob ,
465- ):
466- # Present the the credential's attributes
467- print (">>> present proof ... again ..." )
468- await anoncreds_present_proof_v2 (
469- bob ,
470- alice ,
471- bob_conns ["askar" ].connection_id ,
472- alice_conns ["askar" ].connection_id ,
473- requested_attributes = [{"name" : "firstname" }],
474- )
475- await connect_agents_and_issue_credentials (
476- alice ,
477- bob ,
478- cred_def ,
479- "Bob" ,
480- "Askar" ,
481- inviter_conn = alice_conns ["askar" ],
482- invitee_conn = bob_conns ["askar" ],
483- )
484- await verify_recd_credentials (bob , 2 , 2 )
485- await verify_issued_credentials (alice , 12 , 6 )
486- await verify_recd_presentations (alice , 9 )
487- print (">>> Done! (again)" )
488-
489- finally :
490- if alice_id and new_alice_container :
491- # cleanup - shut down alice agent (not part of docker compose)
492- stop_and_remove_container (client , alice_id )
493- if bob_id and new_bob_container :
494- # cleanup - shut down bob agent (not part of docker compose)
495- stop_and_remove_container (client , bob_id )
508+ # cleanup - shut down alice agent (not part of docker compose)
509+ stop_and_remove_container (client , alice_id )
510+ stop_and_remove_container (client , bob_id )
496511
497512
498513if __name__ == "__main__" :
0 commit comments