@@ -537,8 +537,10 @@ async def test_txn_endorse(
537537 @async_mock .patch ("aries_cloudagent.storage.indy.IndySdkStorage.add_record" )
538538 @async_mock .patch ("indy.ledger.build_schema_request" )
539539 @async_mock .patch ("indy.ledger.append_request_endorser" )
540+ @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger.is_ledger_read_only" )
540541 async def test_send_schema (
541542 self ,
543+ mock_is_ledger_read_only ,
542544 mock_append_request_endorser ,
543545 mock_build_schema_req ,
544546 mock_add_record ,
@@ -550,6 +552,7 @@ async def test_send_schema(
550552 ):
551553 mock_wallet = async_mock .MagicMock ()
552554 self .session .context .injector .bind_provider (BaseWallet , mock_wallet )
555+ mock_is_ledger_read_only .return_value = False
553556
554557 issuer = async_mock .MagicMock (IndyIssuer )
555558 ledger = IndySdkLedger (IndySdkLedgerPool ("name" , checked = True ), self .profile )
@@ -677,8 +680,10 @@ async def test_send_schema_already_exists(
677680 )
678681 @async_mock .patch ("aries_cloudagent.storage.indy.IndySdkStorage.add_record" )
679682 @async_mock .patch ("indy.ledger.build_schema_request" )
683+ @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger.is_ledger_read_only" )
680684 async def test_send_schema_ledger_transaction_error_already_exists (
681685 self ,
686+ mock_is_ledger_read_only ,
682687 mock_build_schema_req ,
683688 mock_add_record ,
684689 mock_check_existing ,
@@ -690,6 +695,7 @@ async def test_send_schema_ledger_transaction_error_already_exists(
690695
691696 mock_wallet = async_mock .MagicMock ()
692697 self .session .context .injector .bind_provider (BaseWallet , mock_wallet )
698+ mock_is_ledger_read_only .return_value = False
693699
694700 issuer = async_mock .MagicMock (IndyIssuer )
695701 issuer .create_schema .return_value = ("1" , "{}" )
@@ -764,8 +770,10 @@ async def test_send_schema_ledger_read_only(
764770 @async_mock .patch (
765771 "aries_cloudagent.ledger.indy.IndySdkLedger.check_existing_schema"
766772 )
773+ @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger.is_ledger_read_only" )
767774 async def test_send_schema_issuer_error (
768775 self ,
776+ mock_is_ledger_read_only ,
769777 mock_check_existing ,
770778 mock_close_pool ,
771779 mock_open_ledger ,
@@ -775,6 +783,7 @@ async def test_send_schema_issuer_error(
775783
776784 mock_wallet = async_mock .MagicMock ()
777785 self .session .context .injector .bind_provider (BaseWallet , mock_wallet )
786+ mock_is_ledger_read_only .return_value = False
778787
779788 issuer = async_mock .MagicMock (IndyIssuer )
780789 issuer .create_schema = async_mock .CoroutineMock (
@@ -850,8 +859,10 @@ async def test_send_schema_ledger_transaction_error(
850859 )
851860 @async_mock .patch ("aries_cloudagent.storage.indy.IndySdkStorage.add_record" )
852861 @async_mock .patch ("indy.ledger.build_schema_request" )
862+ @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger.is_ledger_read_only" )
853863 async def test_send_schema_no_seq_no (
854864 self ,
865+ mock_is_ledger_read_only ,
855866 mock_build_schema_req ,
856867 mock_add_record ,
857868 mock_fetch_schema_by_seq_no ,
@@ -863,6 +874,7 @@ async def test_send_schema_no_seq_no(
863874 mock_wallet = async_mock .MagicMock ()
864875 self .session .context .injector .bind_provider (BaseWallet , mock_wallet )
865876 issuer = async_mock .MagicMock (IndyIssuer )
877+ mock_is_ledger_read_only .return_value = False
866878 ledger = IndySdkLedger (IndySdkLedgerPool ("name" , checked = True ), self .profile )
867879 issuer .create_schema .return_value = ("schema_issuer_did:name:1.0" , "{}" )
868880 mock_fetch_schema_by_id .return_value = None
@@ -1143,8 +1155,10 @@ async def test_get_schema_by_wrong_seq_no(
11431155 @async_mock .patch ("aries_cloudagent.storage.indy.IndySdkStorage.find_all_records" )
11441156 @async_mock .patch ("aries_cloudagent.storage.indy.IndySdkStorage.add_record" )
11451157 @async_mock .patch ("indy.ledger.build_cred_def_request" )
1158+ @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger.is_ledger_read_only" )
11461159 async def test_send_credential_definition (
11471160 self ,
1161+ mock_is_ledger_read_only ,
11481162 mock_build_cred_def ,
11491163 mock_add_record ,
11501164 mock_find_all_records ,
@@ -1157,6 +1171,7 @@ async def test_send_credential_definition(
11571171 mock_wallet = async_mock .MagicMock ()
11581172 self .session .context .injector .bind_provider (BaseWallet , mock_wallet )
11591173 mock_find_all_records .return_value = []
1174+ mock_is_ledger_read_only .return_value = False
11601175
11611176 mock_get_schema .return_value = {"seqNo" : 999 }
11621177 cred_def_id = f"{ self .test_did } :3:CL:999:default"
@@ -1231,8 +1246,10 @@ async def test_send_credential_definition(
12311246 @async_mock .patch ("aries_cloudagent.storage.indy.IndySdkStorage.add_record" )
12321247 @async_mock .patch ("indy.ledger.build_cred_def_request" )
12331248 @async_mock .patch ("indy.ledger.append_request_endorser" )
1249+ @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger.is_ledger_read_only" )
12341250 async def test_send_credential_definition_endorse_only (
12351251 self ,
1252+ mock_is_ledger_read_only ,
12361253 mock_append_request_endorser ,
12371254 mock_build_cred_def ,
12381255 mock_add_record ,
@@ -1246,6 +1263,7 @@ async def test_send_credential_definition_endorse_only(
12461263 mock_wallet = async_mock .MagicMock ()
12471264 self .session .context .injector .bind_provider (BaseWallet , mock_wallet )
12481265 mock_find_all_records .return_value = []
1266+ mock_is_ledger_read_only .return_value = False
12491267
12501268 mock_get_schema .return_value = {"seqNo" : 999 }
12511269 cred_def_id = f"{ self .test_did } :3:CL:999:default"
@@ -2229,8 +2247,10 @@ async def test_get_endpoint_for_did_no_endpoint(
22292247 @async_mock .patch ("indy.ledger.build_get_attrib_request" )
22302248 @async_mock .patch ("indy.ledger.build_attrib_request" )
22312249 @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger._submit" )
2250+ @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger.is_ledger_read_only" )
22322251 async def test_update_endpoint_for_did (
22332252 self ,
2253+ mock_is_ledger_read_only ,
22342254 mock_submit ,
22352255 mock_build_attrib_req ,
22362256 mock_build_get_attrib_req ,
@@ -2240,6 +2260,7 @@ async def test_update_endpoint_for_did(
22402260 mock_wallet = async_mock .MagicMock ()
22412261 self .session .context .injector .bind_provider (BaseWallet , mock_wallet )
22422262 endpoint = ["http://old.aries.ca" , "http://new.aries.ca" ]
2263+ mock_is_ledger_read_only .return_value = False
22432264 mock_submit .side_effect = [
22442265 json .dumps (
22452266 {
@@ -2283,8 +2304,10 @@ async def test_update_endpoint_for_did(
22832304 @async_mock .patch ("indy.ledger.build_get_attrib_request" )
22842305 @async_mock .patch ("indy.ledger.build_attrib_request" )
22852306 @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger._submit" )
2307+ @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger.is_ledger_read_only" )
22862308 async def test_update_endpoint_for_did_no_prior_endpoints (
22872309 self ,
2310+ mock_is_ledger_read_only ,
22882311 mock_submit ,
22892312 mock_build_attrib_req ,
22902313 mock_build_get_attrib_req ,
@@ -2294,6 +2317,7 @@ async def test_update_endpoint_for_did_no_prior_endpoints(
22942317 mock_wallet = async_mock .MagicMock ()
22952318 self .session .context .injector .bind_provider (BaseWallet , mock_wallet )
22962319 endpoint = "http://new.aries.ca"
2320+ mock_is_ledger_read_only .return_value = False
22972321 ledger = IndySdkLedger (IndySdkLedgerPool ("name" , checked = True ), self .profile )
22982322 with async_mock .patch .object (
22992323 IndySdkWallet , "get_public_did"
@@ -2329,8 +2353,10 @@ async def test_update_endpoint_for_did_no_prior_endpoints(
23292353 @async_mock .patch ("indy.ledger.build_get_attrib_request" )
23302354 @async_mock .patch ("indy.ledger.build_attrib_request" )
23312355 @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger._submit" )
2356+ @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger.is_ledger_read_only" )
23322357 async def test_update_endpoint_of_type_profile_for_did (
23332358 self ,
2359+ mock_is_ledger_read_only ,
23342360 mock_submit ,
23352361 mock_build_attrib_req ,
23362362 mock_build_get_attrib_req ,
@@ -2341,6 +2367,7 @@ async def test_update_endpoint_of_type_profile_for_did(
23412367 self .session .context .injector .bind_provider (BaseWallet , mock_wallet )
23422368 endpoint = ["http://company.com/oldProfile" , "http://company.com/newProfile" ]
23432369 endpoint_type = EndpointType .PROFILE
2370+ mock_is_ledger_read_only .return_value = False
23442371 mock_submit .side_effect = [
23452372 json .dumps (
23462373 {
@@ -2354,6 +2381,11 @@ async def test_update_endpoint_of_type_profile_for_did(
23542381 for i in range (len (endpoint ))
23552382 ]
23562383 ledger = IndySdkLedger (IndySdkLedgerPool ("name" , checked = True ), self .profile )
2384+ # ledger = async_mock.patch.object(
2385+ # ledger,
2386+ # "is_ledger_read_only",
2387+ # async_mock.CoroutineMock(return_value=False),
2388+ # )
23572389 with async_mock .patch .object (
23582390 IndySdkWallet , "get_public_did"
23592391 ) as mock_wallet_get_public_did :
@@ -2446,11 +2478,18 @@ async def test_update_endpoint_for_did_read_only(
24462478 @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedgerPool.context_close" )
24472479 @async_mock .patch ("indy.ledger.build_nym_request" )
24482480 @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger._submit" )
2481+ @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger.is_ledger_read_only" )
24492482 async def test_register_nym (
2450- self , mock_submit , mock_build_nym_req , mock_close , mock_open
2483+ self ,
2484+ mock_is_ledger_read_only ,
2485+ mock_submit ,
2486+ mock_build_nym_req ,
2487+ mock_close ,
2488+ mock_open ,
24512489 ):
24522490 mock_wallet = async_mock .MagicMock ()
24532491 self .session .context .injector .bind_provider (BaseWallet , mock_wallet )
2492+ mock_is_ledger_read_only .return_value = False
24542493 with async_mock .patch .object (
24552494 IndySdkWallet , "get_public_did"
24562495 ) as mock_wallet_get_public_did , async_mock .patch .object (
@@ -2518,12 +2557,19 @@ async def test_register_nym_read_only(self, mock_close, mock_open):
25182557
25192558 @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedgerPool.context_open" )
25202559 @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedgerPool.context_close" )
2521- async def test_register_nym_no_public_did (self , mock_close , mock_open ):
2560+ @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger.is_ledger_read_only" )
2561+ async def test_register_nym_no_public_did (
2562+ self ,
2563+ mock_is_ledger_read_only ,
2564+ mock_close ,
2565+ mock_open ,
2566+ ):
25222567 mock_wallet = async_mock .MagicMock (
25232568 type = "indy" ,
25242569 get_local_did = async_mock .CoroutineMock (),
25252570 replace_local_did_metadata = async_mock .CoroutineMock (),
25262571 )
2572+ mock_is_ledger_read_only .return_value = False
25272573 self .session .context .injector .bind_provider (BaseWallet , mock_wallet )
25282574 ledger = IndySdkLedger (IndySdkLedgerPool ("name" , checked = True ), self .profile )
25292575 with async_mock .patch .object (
@@ -2543,14 +2589,21 @@ async def test_register_nym_no_public_did(self, mock_close, mock_open):
25432589 @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedgerPool.context_close" )
25442590 @async_mock .patch ("indy.ledger.build_nym_request" )
25452591 @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger._submit" )
2592+ @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger.is_ledger_read_only" )
25462593 async def test_register_nym_ledger_x (
2547- self , mock_submit , mock_build_nym_req , mock_close , mock_open
2594+ self ,
2595+ mock_is_ledger_read_only ,
2596+ mock_submit ,
2597+ mock_build_nym_req ,
2598+ mock_close ,
2599+ mock_open ,
25482600 ):
25492601 mock_wallet = async_mock .MagicMock ()
25502602 mock_build_nym_req .side_effect = IndyError (
25512603 error_code = ErrorCode .CommonInvalidParam1 ,
25522604 error_details = {"message" : "not today" },
25532605 )
2606+ mock_is_ledger_read_only .return_value = False
25542607 self .session .context .injector .bind_provider (BaseWallet , mock_wallet )
25552608 ledger = IndySdkLedger (IndySdkLedgerPool ("name" , checked = True ), self .profile )
25562609 with async_mock .patch .object (
@@ -2570,11 +2623,18 @@ async def test_register_nym_ledger_x(
25702623 @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedgerPool.context_close" )
25712624 @async_mock .patch ("indy.ledger.build_nym_request" )
25722625 @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger._submit" )
2626+ @async_mock .patch ("aries_cloudagent.ledger.indy.IndySdkLedger.is_ledger_read_only" )
25732627 async def test_register_nym_steward_register_others_did (
2574- self , mock_submit , mock_build_nym_req , mock_close , mock_open
2628+ self ,
2629+ mock_is_ledger_read_only ,
2630+ mock_submit ,
2631+ mock_build_nym_req ,
2632+ mock_close ,
2633+ mock_open ,
25752634 ):
25762635 mock_wallet = async_mock .MagicMock ()
25772636 self .session .context .injector .bind_provider (BaseWallet , mock_wallet )
2637+ mock_is_ledger_read_only .return_value = False
25782638 ledger = IndySdkLedger (IndySdkLedgerPool ("name" , checked = True ), self .profile )
25792639 with async_mock .patch .object (
25802640 IndySdkWallet , "get_public_did"
0 commit comments