@@ -119,9 +119,6 @@ def test_add_invalid_transfer(mock_account_ids):
119119 with pytest .raises (TypeError ):
120120 transfer_tx .add_hbar_transfer (12345 , - 500 )
121121
122- with pytest .raises (ValueError ):
123- transfer_tx .add_hbar_transfer (mock_account_ids [0 ], 0 )
124-
125122 with pytest .raises (TypeError ):
126123 transfer_tx .add_token_transfer (12345 , mock_account_ids [0 ], - 100 )
127124
@@ -271,16 +268,19 @@ def test_edge_case_amounts(mock_account_ids):
271268 assert token1_amounts [account_id_1 ] == 2
272269
273270
274- def test_zero_amount_validation (mock_account_ids ):
275- """Test that zero amounts are properly rejected ."""
271+ def test_zero_amount_handling (mock_account_ids ):
272+ """Test handling of zero transfer amounts ."""
276273 account_id_1 , _ , _ , token_id_1 , _ = mock_account_ids
277274 transfer_tx = TransferTransaction ()
278275
279- # Test zero HBAR amount should raise ValueError with updated message
280- with pytest .raises (ValueError , match = "Amount must be a non-zero value" ):
281- transfer_tx .add_hbar_transfer (account_id_1 , 0 )
276+ # Zero HBAR transfers are allowed
277+ transfer_tx .add_hbar_transfer (account_id_1 , 0 )
278+
279+ assert len (transfer_tx .hbar_transfers ) == 1
280+ assert transfer_tx .hbar_transfers [0 ].account_id == account_id_1
281+ assert transfer_tx .hbar_transfers [0 ].amount == 0
282282
283- # Test zero token amount should raise ValueError
283+ # Token transfers still reject zero amounts (if unchanged)
284284 with pytest .raises (ValueError , match = "Amount must be a non-zero integer" ):
285285 transfer_tx .add_token_transfer (token_id_1 , account_id_1 , 0 )
286286
@@ -555,16 +555,21 @@ def test_hbar_accumulation_with_mixed_int_and_hbar(mock_account_ids):
555555 assert transfer .amount == 100 + 100_000_000 - 50
556556
557557
558- def test_zero_hbar_value_validation (mock_account_ids ):
559- """Test that zero Hbar amounts are properly rejected ."""
558+ def test_zero_hbar_value_handling (mock_account_ids ):
559+ """Test that zero Hbar amounts are accepted ."""
560560 account_id_1 , _ , _ , _ , _ = mock_account_ids
561+
561562 transfer_tx = TransferTransaction ()
563+ transfer_tx .add_hbar_transfer (account_id_1 , Hbar (0 ))
562564
563- with pytest .raises (ValueError , match = "Amount must be a non-zero value" ):
564- transfer_tx .add_hbar_transfer (account_id_1 , Hbar (0 ))
565+ assert len (transfer_tx .hbar_transfers ) == 1
566+ assert transfer_tx .hbar_transfers [0 ].amount == 0
567+
568+ transfer_tx = TransferTransaction ()
569+ transfer_tx .add_hbar_transfer (account_id_1 , 0 )
565570
566- with pytest . raises ( ValueError , match = "Amount must be a non-zero value" ):
567- transfer_tx .add_hbar_transfer ( account_id_1 , 0 )
571+ assert len ( transfer_tx . hbar_transfers ) == 1
572+ assert transfer_tx .hbar_transfers [ 0 ]. amount == 0
568573
569574
570575def test_add_hbar_transfer_with_various_hbar_units (mock_account_ids ):
0 commit comments