Skip to content

Commit 7deae3c

Browse files
ChaitanyaChuteprajeeta15
authored andcommitted
chore: rename/response code name (hiero-ledger#1151)
Signed-off-by: Chaitanya-chute <chaitanyachute11@gmail.com> Signed-off-by: prajeeta pal <prajeetapal@gmail.com>
1 parent f4ad3b2 commit 7deae3c

9 files changed

+58
-56
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
7373
- Rename test files across the repository to ensure they consistently end with _test.py (#1055)
7474
- Cleaned up `token_airdrop_claim_signature_required` example for pylint compliance (no functional changes). (#1080)
7575
- Rename the file 'test_token_fee_schedule_update_transaction_e2e.py' to make it ends with _test.py as all other test files.(#1117)
76-
- Format token examples with Black for consistent code style and improved readability (#1119)
76+
- Format token examples with Black for consistent code style and improved readability (#1119)
77+
- Replaced `ResponseCode.get_name(receipt.status)` with the `ResponseCode(receipt.status).name` across examples and integration tests for consistency. (#1136)
78+
7779

7880

7981
### Fixed

examples/query/payment_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def create_fungible_token(client, operator_id, operator_key):
6161

6262
if receipt.status != ResponseCode.SUCCESS:
6363
print(
64-
f"Fungible token creation failed with status: {ResponseCode.get_name(receipt.status)}"
64+
f"Fungible token creation failed with status: {ResponseCode(receipt.status).name}"
6565
)
6666
sys.exit(1)
6767

examples/tokens/token_revoke_kyc_transaction.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def associate_token(client, token_id, account_id, account_private_key):
9292

9393
if receipt.status != ResponseCode.SUCCESS:
9494
print(
95-
f"Token association failed with status: {ResponseCode.get_name(receipt.status)}"
95+
f"Token association failed with status: {ResponseCode(receipt.status).name}"
9696
)
9797
sys.exit(1)
9898

@@ -118,7 +118,7 @@ def create_test_account(client):
118118
# Check if account creation was successful
119119
if receipt.status != ResponseCode.SUCCESS:
120120
print(
121-
f"Account creation failed with status: {ResponseCode.get_name(receipt.status)}"
121+
f"Account creation failed with status: {ResponseCode(receipt.status).name}"
122122
)
123123
sys.exit(1)
124124

@@ -142,7 +142,7 @@ def grant_kyc(client, token_id, account_id, kyc_private_key):
142142

143143
if receipt.status != ResponseCode.SUCCESS:
144144
print(
145-
f"Token grant KYC failed with status: {ResponseCode.get_name(receipt.status)}"
145+
f"Token grant KYC failed with status: {ResponseCode(receipt.status).name}"
146146
)
147147
sys.exit(1)
148148

@@ -189,7 +189,7 @@ def token_revoke_kyc():
189189
# Check if the transaction was successful
190190
if receipt.status != ResponseCode.SUCCESS:
191191
print(
192-
f"Token revoke KYC failed with status: {ResponseCode.get_name(receipt.status)}"
192+
f"Token revoke KYC failed with status: {ResponseCode(receipt.status).name}"
193193
)
194194
sys.exit(1)
195195

examples/tokens/token_update_transaction_fungible.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def create_fungible_token(client, operator_id, operator_key, metadata_key):
7070
# Check if token creation was successful
7171
if receipt.status != ResponseCode.SUCCESS:
7272
print(
73-
f"Fungible token creation failed with status: {ResponseCode.get_name(receipt.status)}"
73+
f"Fungible token creation failed with status: {ResponseCode(receipt.status).name}"
7474
)
7575
sys.exit(1)
7676

@@ -109,7 +109,7 @@ def update_token_data(
109109

110110
if receipt.status != ResponseCode.SUCCESS:
111111
print(
112-
f"Token metadata update failed with status: {ResponseCode.get_name(receipt.status)}"
112+
f"Token metadata update failed with status: {ResponseCode(receipt.status).name}"
113113
)
114114
sys.exit(1)
115115

examples/tokens/token_update_transaction_key.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def create_fungible_token(client, operator_id, admin_key, wipe_key):
6262
# Check if token creation was successful
6363
if receipt.status != ResponseCode.SUCCESS:
6464
print(
65-
f"Fungible token creation failed with status: {ResponseCode.get_name(receipt.status)}"
65+
f"Fungible token creation failed with status: {ResponseCode(receipt.status).name}"
6666
)
6767
sys.exit(1)
6868

@@ -106,7 +106,7 @@ def update_wipe_key_full_validation(client, token_id, old_wipe_key):
106106

107107
if receipt.status != ResponseCode.SUCCESS:
108108
print(
109-
f"Token update failed with status: {ResponseCode.get_name(receipt.status)}"
109+
f"Token update failed with status: {ResponseCode(receipt.status).name}"
110110
)
111111
sys.exit(1)
112112

examples/tokens/token_update_transaction_nft.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def create_nft(client, operator_id, operator_key, metadata_key):
7070
# Check if nft creation was successful
7171
if receipt.status != ResponseCode.SUCCESS:
7272
print(
73-
f"NFT creation failed with status: {ResponseCode.get_name(receipt.status)}"
73+
f"NFT creation failed with status: {ResponseCode(receipt.status).name}"
7474
)
7575
sys.exit(1)
7676

@@ -109,7 +109,7 @@ def update_nft_data(
109109

110110
if receipt.status != ResponseCode.SUCCESS:
111111
print(
112-
f"NFT data update failed with status: {ResponseCode.get_name(receipt.status)}"
112+
f"NFT data update failed with status: {ResponseCode(receipt.status).name}"
113113
)
114114
sys.exit(1)
115115

tests/integration/file_update_transaction_e2e_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_integration_file_update_transaction_can_execute(env):
2929
)
3030
assert (
3131
receipt.status == ResponseCode.SUCCESS
32-
), f"File creation failed with status: {ResponseCode.get_name(receipt.status)}"
32+
), f"File creation failed with status: {ResponseCode(receipt.status).name}"
3333

3434
file_id = receipt.file_id
3535
assert file_id is not None, "File ID should not be None"
@@ -53,7 +53,7 @@ def test_integration_file_update_transaction_can_execute(env):
5353
)
5454
assert (
5555
receipt.status == ResponseCode.SUCCESS
56-
), f"File update failed with status: {ResponseCode.get_name(receipt.status)}"
56+
), f"File update failed with status: {ResponseCode(receipt.status).name}"
5757

5858
# Query file info and check if everything is updated
5959
info = FileInfoQuery().set_file_id(file_id).execute(env.client)
@@ -85,7 +85,7 @@ def test_integration_file_update_transaction_cannot_update_immutable_file(env):
8585
receipt = FileCreateTransaction().set_contents("Immutable file").execute(env.client)
8686
assert (
8787
receipt.status == ResponseCode.SUCCESS
88-
), f"File creation failed with status: {ResponseCode.get_name(receipt.status)}"
88+
), f"File creation failed with status: {ResponseCode(receipt.status).name}"
8989

9090
file_id = receipt.file_id
9191
assert file_id is not None, "File ID should not be None"
@@ -121,7 +121,7 @@ def test_integration_file_update_transaction_fails_when_key_is_invalid(env):
121121
)
122122
assert (
123123
receipt.status == ResponseCode.SUCCESS
124-
), f"File creation failed with status: {ResponseCode.get_name(receipt.status)}"
124+
), f"File creation failed with status: {ResponseCode(receipt.status).name}"
125125

126126
file_id = receipt.file_id
127127
assert file_id is not None, "File ID should not be None"

tests/integration/token_revoke_kyc_transaction_e2e_test.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_token_revoke_kyc_transaction_can_execute():
2424
.set_initial_balance(Hbar(2))
2525
.execute(env.client)
2626
)
27-
assert receipt.status == ResponseCode.SUCCESS, f"Account creation failed with status: {ResponseCode.get_name(receipt.status)}"
27+
assert receipt.status == ResponseCode.SUCCESS, f"Account creation failed with status: {ResponseCode(receipt.status).name}"
2828
account_id = receipt.account_id
2929

3030
# Create a new token and set the kyc key to be the operator's key
@@ -39,7 +39,7 @@ def test_token_revoke_kyc_transaction_can_execute():
3939
.sign(new_account_private_key)
4040
.execute(env.client)
4141
)
42-
assert receipt.status == ResponseCode.SUCCESS, f"Token association failed with status: {ResponseCode.get_name(receipt.status)}"
42+
assert receipt.status == ResponseCode.SUCCESS, f"Token association failed with status: {ResponseCode(receipt.status).name}"
4343

4444
# Grant KYC to the new account first
4545
receipt = (
@@ -48,7 +48,7 @@ def test_token_revoke_kyc_transaction_can_execute():
4848
.set_token_id(token_id)
4949
.execute(env.client)
5050
)
51-
assert receipt.status == ResponseCode.SUCCESS, f"Token grant KYC failed with status: {ResponseCode.get_name(receipt.status)}"
51+
assert receipt.status == ResponseCode.SUCCESS, f"Token grant KYC failed with status: {ResponseCode(receipt.status).name}"
5252

5353
# Revoke KYC from the new account
5454
receipt = (
@@ -57,7 +57,7 @@ def test_token_revoke_kyc_transaction_can_execute():
5757
.set_token_id(token_id)
5858
.execute(env.client)
5959
)
60-
assert receipt.status == ResponseCode.SUCCESS, f"Token revoke KYC failed with status: {ResponseCode.get_name(receipt.status)}"
60+
assert receipt.status == ResponseCode.SUCCESS, f"Token revoke KYC failed with status: {ResponseCode(receipt.status).name}"
6161
finally:
6262
env.close()
6363

@@ -76,7 +76,7 @@ def test_token_revoke_kyc_transaction_fails_with_no_kyc_key():
7676
.set_initial_balance(Hbar(2))
7777
.execute(env.client)
7878
)
79-
assert receipt.status == ResponseCode.SUCCESS, f"Account creation failed with status: {ResponseCode.get_name(receipt.status)}"
79+
assert receipt.status == ResponseCode.SUCCESS, f"Account creation failed with status: {ResponseCode(receipt.status).name}"
8080
account_id = receipt.account_id
8181

8282
# Create a new token without KYC key
@@ -91,7 +91,7 @@ def test_token_revoke_kyc_transaction_fails_with_no_kyc_key():
9191
.sign(new_account_private_key)
9292
.execute(env.client)
9393
)
94-
assert receipt.status == ResponseCode.SUCCESS, f"Token association failed with status: {ResponseCode.get_name(receipt.status)}"
94+
assert receipt.status == ResponseCode.SUCCESS, f"Token association failed with status: {ResponseCode(receipt.status).name}"
9595

9696
# Try to revoke KYC for token without KYC key - should fail with TOKEN_HAS_NO_KYC_KEY
9797
receipt = (
@@ -100,7 +100,7 @@ def test_token_revoke_kyc_transaction_fails_with_no_kyc_key():
100100
.set_token_id(token_id)
101101
.execute(env.client)
102102
)
103-
assert receipt.status == ResponseCode.TOKEN_HAS_NO_KYC_KEY, f"Token revoke KYC should have failed with TOKEN_HAS_NO_KYC_KEY status but got: {ResponseCode.get_name(receipt.status)}"
103+
assert receipt.status == ResponseCode.TOKEN_HAS_NO_KYC_KEY, f"Token revoke KYC should have failed with TOKEN_HAS_NO_KYC_KEY status but got: {ResponseCode(receipt.status).name}"
104104

105105
# Try to revoke KYC with non-KYC key - should fail with TOKEN_HAS_NO_KYC_KEY
106106
receipt = (
@@ -109,7 +109,7 @@ def test_token_revoke_kyc_transaction_fails_with_no_kyc_key():
109109
.set_token_id(token_id)
110110
.execute(env.client)
111111
)
112-
assert receipt.status == ResponseCode.TOKEN_HAS_NO_KYC_KEY, f"Token revoke KYC should have failed with TOKEN_HAS_NO_KYC_KEY status but got: {ResponseCode.get_name(receipt.status)}"
112+
assert receipt.status == ResponseCode.TOKEN_HAS_NO_KYC_KEY, f"Token revoke KYC should have failed with TOKEN_HAS_NO_KYC_KEY status but got: {ResponseCode(receipt.status).name}"
113113
finally:
114114
env.close()
115115

@@ -128,7 +128,7 @@ def test_token_revoke_kyc_transaction_fails_when_account_not_associated():
128128
.set_initial_balance(Hbar(2))
129129
.execute(env.client)
130130
)
131-
assert receipt.status == ResponseCode.SUCCESS, f"Account creation failed with status: {ResponseCode.get_name(receipt.status)}"
131+
assert receipt.status == ResponseCode.SUCCESS, f"Account creation failed with status: {ResponseCode(receipt.status).name}"
132132
account_id = receipt.account_id
133133

134134
# Create a new token and set the kyc key to be the operator's key
@@ -141,6 +141,6 @@ def test_token_revoke_kyc_transaction_fails_when_account_not_associated():
141141
.set_token_id(token_id)
142142
.execute(env.client)
143143
)
144-
assert receipt.status == ResponseCode.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT, f"Token revoke KYC should have failed with TOKEN_NOT_ASSOCIATED_TO_ACCOUNT status but got: {ResponseCode.get_name(receipt.status)}"
144+
assert receipt.status == ResponseCode.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT, f"Token revoke KYC should have failed with TOKEN_NOT_ASSOCIATED_TO_ACCOUNT status but got: {ResponseCode(receipt.status).name}"
145145
finally:
146146
env.close()

0 commit comments

Comments
 (0)