Skip to content

Commit 14dd12d

Browse files
committed
test(tck): add symmetric KYC handler coverage
Signed-off-by: iron-prog <dt915725@gmail.com>
1 parent 5641623 commit 14dd12d

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/tck/token_kyc_handlers_test.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ def test_missing_session_id_raises(self):
8989
with pytest.raises(ValueError, match="sessionId"):
9090
RevokeTokenKycParams.parse_json_params({"tokenId": "0.0.9999", "accountId": "0.0.5555"})
9191

92+
def test_empty_session_id_raises(self):
93+
with pytest.raises(ValueError, match="sessionId"):
94+
RevokeTokenKycParams.parse_json_params({"tokenId": "0.0.9999", "accountId": "0.0.5555", "sessionId": ""})
95+
96+
def test_missing_token_and_account_id_parse_as_none(self):
97+
"""tokenId/accountId are optional at parse time; the TCK spec uses
98+
their absence to test the endpoint's own validation errors."""
99+
params = RevokeTokenKycParams.parse_json_params({"sessionId": "session-1"})
100+
assert params.tokenId is None
101+
assert params.accountId is None
102+
92103

93104
class TestBuildGrantTokenKycTransaction:
94105
def test_sets_both_fields_when_present(self):
@@ -114,6 +125,18 @@ def test_missing_account_id_fails_at_proto_build_not_silently(self):
114125
with pytest.raises(ValueError, match="Missing account ID"):
115126
tx._build_proto_body()
116127

128+
def test_leaves_token_id_none_when_absent(self):
129+
params = GrantTokenKycParams.parse_json_params({"accountId": "0.0.5555", "sessionId": "s"})
130+
tx = _build_grant_token_kyc_transaction(params)
131+
assert tx.token_id is None
132+
assert tx.account_id == ACCOUNT_ID
133+
134+
def test_missing_token_id_fails_at_proto_build_not_silently(self):
135+
params = GrantTokenKycParams.parse_json_params({"accountId": "0.0.5555", "sessionId": "s"})
136+
tx = _build_grant_token_kyc_transaction(params)
137+
with pytest.raises(ValueError, match="Missing token ID"):
138+
tx._build_proto_body()
139+
117140

118141
class TestBuildRevokeTokenKycTransaction:
119142
def test_sets_both_fields_when_present(self):
@@ -130,6 +153,18 @@ def test_missing_token_id_fails_at_proto_build_not_silently(self):
130153
with pytest.raises(ValueError, match="Missing token ID"):
131154
tx._build_proto_body()
132155

156+
def test_leaves_account_id_none_when_absent(self):
157+
params = RevokeTokenKycParams.parse_json_params({"tokenId": "0.0.9999", "sessionId": "s"})
158+
tx = _build_revoke_token_kyc_transaction(params)
159+
assert tx.token_id == TOKEN_ID
160+
assert tx.account_id is None
161+
162+
def test_missing_account_id_fails_at_proto_build_not_silently(self):
163+
params = RevokeTokenKycParams.parse_json_params({"tokenId": "0.0.9999", "sessionId": "s"})
164+
tx = _build_revoke_token_kyc_transaction(params)
165+
with pytest.raises(ValueError, match="Missing account ID"):
166+
tx._build_proto_body()
167+
133168

134169
class TestEndToEndDispatch:
135170
def test_grant_token_kyc_success(self):

0 commit comments

Comments
 (0)