diff --git a/CHANGELOG.md b/CHANGELOG.md index 435fd7dff..38332976c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1. ### Fixed +- chore: fixed integration test names without a test prefix or postfix diff --git a/tests/integration/token_airdrop_transaction_cancel_e2e.py b/tests/integration/token_airdrop_transaction_cancel_e2e_test.py similarity index 100% rename from tests/integration/token_airdrop_transaction_cancel_e2e.py rename to tests/integration/token_airdrop_transaction_cancel_e2e_test.py diff --git a/tests/integration/token_airdrop_transaction_claim_e2e.py b/tests/integration/token_airdrop_transaction_claim_e2e_test.py similarity index 83% rename from tests/integration/token_airdrop_transaction_claim_e2e.py rename to tests/integration/token_airdrop_transaction_claim_e2e_test.py index c5da21254..b7b95cf4d 100644 --- a/tests/integration/token_airdrop_transaction_claim_e2e.py +++ b/tests/integration/token_airdrop_transaction_claim_e2e_test.py @@ -11,6 +11,7 @@ from hiero_sdk_python.tokens.token_id import TokenId from hiero_sdk_python.query.transaction_record_query import TransactionRecordQuery from tests.integration.utils_for_test import env, create_fungible_token, create_nft_token +from typing import List pytestmark = pytest.mark.integration @@ -60,23 +61,35 @@ def has_immediate_credit(record, token_id: TokenId, account_id: AccountId, amoun def has_new_pending(record): return bool(record.new_pending_airdrops) -def extract_pending_ids(record): - ids = [] +def extract_pending_ids(record) -> List[PendingAirdropId]: + """ + Extract a list of SDK PendingAirdropId objects from a transaction record. + Handles both protobuf objects and already instantiated SDK objects. + """ + sdk_ids: List[PendingAirdropId] = [] + for item in record.new_pending_airdrops: - # If it's already a PendingAirdropId object, just append if isinstance(item, PendingAirdropId): - ids.append(item) - else: - # Attempt to extract the protobuf field - pid_proto = getattr(item, "pending_airdrop_id", None) - if pid_proto is None and hasattr(item, "_to_proto"): - pid_proto = item._to_proto().pending_airdrop_id + # Already an SDK object + sdk_ids.append(item) + continue - if pid_proto is None: - raise AssertionError(f"Cannot extract pending_airdrop_id from {type(item)}") + # Try to get protobuf object + pid_proto = getattr(item, "pending_airdrop_id", None) + if pid_proto is None and hasattr(item, "_to_proto"): + pid_proto = item._to_proto().pending_airdrop_id - ids.append(PendingAirdropId._from_proto(pid_proto)) - return ids + if pid_proto is None: + raise AssertionError(f"Cannot extract pending_airdrop_id from {type(item)}") + + # Convert protobuf to SDK object + if hasattr(pid_proto, "HasField"): + sdk_ids.append(PendingAirdropId._from_proto(pid_proto)) + else: + # Already SDK object + sdk_ids.append(pid_proto) + + return sdk_ids def claim_pending(env, pending_ids, receiver_key): tx = TokenClaimAirdropTransaction().add_pending_airdrop_ids(pending_ids) @@ -87,6 +100,17 @@ def claim_pending(env, pending_ids, receiver_key): # --- Integration Tests --- # ====================== +def test_airdrop_becomes_pending_if_not_associated_no_sig_required(env): + receiver = env.create_account(initial_hbar=2.0) + token_id = create_fungible_token(env) + + set_receiver_signature_required(env, receiver.id, receiver.key, False) + + record = submit_airdrop(env, receiver.id, token_id) + # ✅ Expect it to be pending but not airdropped + assert has_new_pending(record) + assert not has_immediate_credit(record, token_id, receiver.id) + def test_immediate_airdrop_if_associated_and_no_sig_required(env): receiver = env.create_account(initial_hbar=2.0) token_id = create_fungible_token(env) @@ -104,7 +128,9 @@ def test_pending_airdrop_if_unassociated_and_no_sig_required(env): set_receiver_signature_required(env, receiver.id, receiver.key, False) record = submit_airdrop(env, receiver.id, token_id) + # Becomes pending as not associated assert has_new_pending(record) + # Can't auto claim because not associated assert not has_immediate_credit(record, token_id, receiver.id) def test_pending_airdrop_if_sig_required_even_if_associated(env):