@@ -39,7 +39,12 @@ def create_key(key_type: str, use_private: bool) -> PrivateKey | PublicKey:
3939 Returns:
4040 The created key (PrivateKey or PublicKey)
4141 """
42- private_key = PrivateKey .generate_ed25519 () if key_type == "ed25519" else PrivateKey .generate ("ecdsa" )
42+ if key_type == "ed25519" :
43+ private_key = PrivateKey .generate_ed25519 ()
44+ elif key_type == "ecdsa" :
45+ private_key = PrivateKey .generate ("ecdsa" )
46+ else :
47+ raise ValueError (f"Unsupported key_type: { key_type !r} " )
4348 return private_key if use_private else private_key .public_key ()
4449
4550
@@ -60,9 +65,32 @@ def verify_key_in_proto(proto_key, expected_public_key: PublicKey, key_type: str
6065 """Verify the proto key matches expected public key."""
6166 if key_type == "ed25519" :
6267 assert proto_key .ed25519 == expected_public_key .to_bytes_raw ()
63- else : # ecdsa
68+ elif key_type == "ecdsa" : # ecdsa
6469 assert proto_key .HasField ("ECDSA_secp256k1" )
6570 assert proto_key .ECDSA_secp256k1 == expected_public_key .to_bytes_raw ()
71+ else :
72+ raise ValueError (f"Unsupported key_type: { key_type !r} " )
73+
74+
75+ @pytest .mark .parametrize (
76+ "key_type,use_private" ,
77+ [
78+ ("ed25519" , True ),
79+ ("ed25519" , False ),
80+ ("ecdsa" , True ),
81+ ("ecdsa" , False ),
82+ ],
83+ )
84+ def test_topic_update_setters_return_self (key_type , use_private , topic_id ):
85+ """Fluent setters must return self for the Key-typed API."""
86+ key = create_key (key_type , use_private )
87+ tx = TopicUpdateTransaction ()
88+
89+ assert tx .set_topic_id (topic_id ) is tx
90+ assert tx .set_admin_key (key ) is tx
91+ assert tx .set_submit_key (key ) is tx
92+ assert tx .set_fee_schedule_key (key ) is tx
93+ assert tx .set_fee_exempt_keys ([key ]) is tx
6694
6795
6896@pytest .mark .parametrize (
0 commit comments