@@ -450,8 +450,8 @@ def test_from_bytes_nft(mock_account_ids):
450450 assert not nft_transfers [0 ].is_approved
451451
452452
453- def test_from_protobuf_skips_transfer_without_token ():
454- """Covers continue branch when token field is missing from a TokenTransferList."""
453+ def test_from_protobuf_raises_on_transfer_without_token ():
454+ """Covers fail-fast branch when token field is missing from a TokenTransferList."""
455455 from hiero_sdk_python .hapi .services import transaction_pb2
456456 from hiero_sdk_python .hapi .services .basic_types_pb2 import TokenTransferList
457457 from hiero_sdk_python .hapi .services .token_airdrop_pb2 import TokenAirdropTransactionBody
@@ -461,14 +461,12 @@ def test_from_protobuf_skips_transfer_without_token():
461461 tx_body = transaction_pb2 .TransactionBody ()
462462 tx_body .tokenAirdrop .CopyFrom (body )
463463
464- result = TokenAirdropTransaction ._from_protobuf (tx_body , b"" , None )
464+ with pytest .raises (ValueError , match = "token_transfer missing token field" ):
465+ TokenAirdropTransaction ._from_protobuf (tx_body , b"" , None )
465466
466- assert isinstance (result , TokenAirdropTransaction )
467- assert len (result .token_transfers ) == 0
468467
469-
470- def test_from_protobuf_skips_fungible_transfer_without_account_id (mock_account_ids ):
471- """Covers continue branch when accountID is missing from a fungible transfer."""
468+ def test_from_protobuf_raises_on_fungible_transfer_without_account_id (mock_account_ids ):
469+ """Covers fail-fast branch when accountID is missing from a fungible transfer."""
472470 from hiero_sdk_python .hapi .services import transaction_pb2
473471 from hiero_sdk_python .hapi .services .basic_types_pb2 import AccountAmount , TokenTransferList
474472 from hiero_sdk_python .hapi .services .token_airdrop_pb2 import TokenAirdropTransactionBody
@@ -482,14 +480,12 @@ def test_from_protobuf_skips_fungible_transfer_without_account_id(mock_account_i
482480 tx_body = transaction_pb2 .TransactionBody ()
483481 tx_body .tokenAirdrop .CopyFrom (body )
484482
485- result = TokenAirdropTransaction ._from_protobuf (tx_body , b"" , None )
486-
487- assert isinstance (result , TokenAirdropTransaction )
488- assert len (result .token_transfers [token_id_1 ]) == 0
483+ with pytest .raises (ValueError , match = "fungible transfer missing accountID" ):
484+ TokenAirdropTransaction ._from_protobuf (tx_body , b"" , None )
489485
490486
491- def test_from_protobuf_skips_nft_transfer_without_sender_or_receiver (mock_account_ids ):
492- """Covers continue branch when senderAccountID or receiverAccountID is missing from NFT transfer."""
487+ def test_from_protobuf_raises_on_nft_transfer_without_sender_or_receiver (mock_account_ids ):
488+ """Covers fail-fast branch when senderAccountID or receiverAccountID is missing from NFT transfer."""
493489 from hiero_sdk_python .hapi .services import transaction_pb2
494490 from hiero_sdk_python .hapi .services .basic_types_pb2 import NftTransfer , TokenTransferList
495491 from hiero_sdk_python .hapi .services .token_airdrop_pb2 import TokenAirdropTransactionBody
@@ -503,7 +499,5 @@ def test_from_protobuf_skips_nft_transfer_without_sender_or_receiver(mock_accoun
503499 tx_body = transaction_pb2 .TransactionBody ()
504500 tx_body .tokenAirdrop .CopyFrom (body )
505501
506- result = TokenAirdropTransaction ._from_protobuf (tx_body , b"" , None )
507-
508- assert isinstance (result , TokenAirdropTransaction )
509- assert len (result .nft_transfers [token_id_1 ]) == 0
502+ with pytest .raises (ValueError , match = "NFT transfer missing sender or receiver" ):
503+ TokenAirdropTransaction ._from_protobuf (tx_body , b"" , None )
0 commit comments