|
13 | 13 | from ...wallet.did_info import DIDInfo
|
14 | 14 | from ...wallet.did_method import SOV, DIDMethod, DIDMethods, HolderDefinedDid
|
15 | 15 | from ...wallet.did_posture import DIDPosture
|
| 16 | +from ...wallet.error import WalletNotFoundError |
16 | 17 | from ...wallet.key_type import ED25519, KeyTypes
|
17 | 18 | from ..endpoint_type import EndpointType
|
18 | 19 | from ..indy_vdr import (
|
@@ -1463,3 +1464,57 @@ async def test_ledger_txn_submit_uses_passed_profile(self, ledger: IndyVdrLedger
|
1463 | 1464 | assert submit_kwargs["sign"] is True
|
1464 | 1465 | assert submit_kwargs["sign_did"] is test_sign_did
|
1465 | 1466 | assert submit_kwargs["write_ledger"] is True
|
| 1467 | + |
| 1468 | + @pytest.mark.asyncio |
| 1469 | + async def test_submit_wallet_not_found_error(self, ledger: IndyVdrLedger): |
| 1470 | + async with ledger.profile.session() as session: |
| 1471 | + wallet = session.inject(BaseWallet) |
| 1472 | + test_did = await wallet.create_public_did(SOV, ED25519) |
| 1473 | + # Create a DID not present in the wallet |
| 1474 | + invalid_did = DIDInfo( |
| 1475 | + did="did:sov:invalid", |
| 1476 | + verkey="invalid_verkey", |
| 1477 | + metadata={}, |
| 1478 | + method=SOV, |
| 1479 | + key_type=ED25519, |
| 1480 | + ) |
| 1481 | + async with ledger: |
| 1482 | + test_msg = indy_vdr.ledger.build_get_txn_request(test_did.did, 1, 1) |
| 1483 | + with pytest.raises(WalletNotFoundError): |
| 1484 | + await ledger._submit( |
| 1485 | + test_msg, sign=True, sign_did=invalid_did, write_ledger=False |
| 1486 | + ) |
| 1487 | + |
| 1488 | + @pytest.mark.asyncio |
| 1489 | + async def test_submit_unexpected_error(self, ledger: IndyVdrLedger): |
| 1490 | + async with ledger.profile.session() as session: |
| 1491 | + wallet = session.inject(BaseWallet) |
| 1492 | + test_did = await wallet.create_public_did(SOV, ED25519) |
| 1493 | + async with ledger: |
| 1494 | + test_msg = indy_vdr.ledger.build_get_txn_request(test_did.did, 1, 1) |
| 1495 | + ledger.pool_handle.submit_request.side_effect = ValueError("Unexpected error") |
| 1496 | + with pytest.raises(LedgerTransactionError) as exc_info: |
| 1497 | + await ledger._submit(test_msg) |
| 1498 | + assert "Unexpected error during ledger submission" in str(exc_info.value) |
| 1499 | + assert isinstance(exc_info.value.__cause__, ValueError) |
| 1500 | + |
| 1501 | + @pytest.mark.asyncio |
| 1502 | + async def test_txn_submit_passes_profile(self, ledger: IndyVdrLedger): |
| 1503 | + tenant_profile = await self._create_tenant_profile( |
| 1504 | + ledger.profile, "submit_tenant" |
| 1505 | + ) |
| 1506 | + test_txn_data = '{"req": "data"}' |
| 1507 | + mock_sign_did = mock.MagicMock(spec=DIDInfo) |
| 1508 | + ledger._submit = mock.CoroutineMock(return_value={"result": "ok"}) |
| 1509 | + |
| 1510 | + await ledger.txn_submit( |
| 1511 | + test_txn_data, |
| 1512 | + sign=True, |
| 1513 | + sign_did=mock_sign_did, |
| 1514 | + write_ledger=True, |
| 1515 | + profile=tenant_profile, |
| 1516 | + ) |
| 1517 | + |
| 1518 | + ledger._submit.assert_awaited_once() |
| 1519 | + _, kwargs = ledger._submit.call_args |
| 1520 | + assert kwargs.get("profile") == tenant_profile |
0 commit comments