@@ -449,8 +449,8 @@ def test_from_bytes_nft(mock_account_ids):
449449 assert not nft_transfers [0 ].is_approved
450450
451451
452- def test_from_protobuf_skips_transfer_without_token ():
453- """Covers continue branch when token field is missing from a TokenTransferList."""
452+ def test_from_protobuf_raises_on_transfer_without_token ():
453+ """Covers fail-fast branch when token field is missing from a TokenTransferList."""
454454 from hiero_sdk_python .hapi .services import transaction_pb2
455455 from hiero_sdk_python .hapi .services .basic_types_pb2 import TokenTransferList
456456 from hiero_sdk_python .hapi .services .token_airdrop_pb2 import TokenAirdropTransactionBody
@@ -460,14 +460,12 @@ def test_from_protobuf_skips_transfer_without_token():
460460 tx_body = transaction_pb2 .TransactionBody ()
461461 tx_body .tokenAirdrop .CopyFrom (body )
462462
463- result = TokenAirdropTransaction ._from_protobuf (tx_body , b"" , None )
463+ with pytest .raises (ValueError , match = "token_transfer missing token field" ):
464+ TokenAirdropTransaction ._from_protobuf (tx_body , b"" , None )
464465
465- assert isinstance (result , TokenAirdropTransaction )
466- assert len (result .token_transfers ) == 0
467466
468-
469- def test_from_protobuf_skips_fungible_transfer_without_account_id (mock_account_ids ):
470- """Covers continue branch when accountID is missing from a fungible transfer."""
467+ def test_from_protobuf_raises_on_fungible_transfer_without_account_id (mock_account_ids ):
468+ """Covers fail-fast branch when accountID is missing from a fungible transfer."""
471469 from hiero_sdk_python .hapi .services import transaction_pb2
472470 from hiero_sdk_python .hapi .services .basic_types_pb2 import AccountAmount , TokenTransferList
473471 from hiero_sdk_python .hapi .services .token_airdrop_pb2 import TokenAirdropTransactionBody
@@ -481,14 +479,12 @@ def test_from_protobuf_skips_fungible_transfer_without_account_id(mock_account_i
481479 tx_body = transaction_pb2 .TransactionBody ()
482480 tx_body .tokenAirdrop .CopyFrom (body )
483481
484- result = TokenAirdropTransaction ._from_protobuf (tx_body , b"" , None )
485-
486- assert isinstance (result , TokenAirdropTransaction )
487- assert len (result .token_transfers [token_id_1 ]) == 0
482+ with pytest .raises (ValueError , match = "fungible transfer missing accountID" ):
483+ TokenAirdropTransaction ._from_protobuf (tx_body , b"" , None )
488484
489485
490- def test_from_protobuf_skips_nft_transfer_without_sender_or_receiver (mock_account_ids ):
491- """Covers continue branch when senderAccountID or receiverAccountID is missing from NFT transfer."""
486+ def test_from_protobuf_raises_on_nft_transfer_without_sender_or_receiver (mock_account_ids ):
487+ """Covers fail-fast branch when senderAccountID or receiverAccountID is missing from NFT transfer."""
492488 from hiero_sdk_python .hapi .services import transaction_pb2
493489 from hiero_sdk_python .hapi .services .basic_types_pb2 import NftTransfer , TokenTransferList
494490 from hiero_sdk_python .hapi .services .token_airdrop_pb2 import TokenAirdropTransactionBody
@@ -502,7 +498,5 @@ def test_from_protobuf_skips_nft_transfer_without_sender_or_receiver(mock_accoun
502498 tx_body = transaction_pb2 .TransactionBody ()
503499 tx_body .tokenAirdrop .CopyFrom (body )
504500
505- result = TokenAirdropTransaction ._from_protobuf (tx_body , b"" , None )
506-
507- assert isinstance (result , TokenAirdropTransaction )
508- assert len (result .nft_transfers [token_id_1 ]) == 0
501+ with pytest .raises (ValueError , match = "NFT transfer missing sender or receiver" ):
502+ TokenAirdropTransaction ._from_protobuf (tx_body , b"" , None )
0 commit comments