99from hiero_sdk_python .tokens .token_relationship import TokenRelationship
1010from hiero_sdk_python .tokens .token_id import TokenId
1111from hiero_sdk_python .hapi .services .crypto_get_info_pb2 import CryptoGetInfoResponse
12+ from hiero_sdk_python .staking_info import StakingInfo
1213
1314pytestmark = pytest .mark .unit
1415
@@ -72,6 +73,28 @@ def test_account_info_initialization(account_info):
7273 assert account_info .max_automatic_token_associations == 10
7374 assert account_info .staking_info is None
7475
76+ def test_from_proto_with_staking_info ():
77+ """Test the from_proto method of the AccountInfo class with staking info"""
78+ public_key = PrivateKey .generate_ed25519 ().public_key ()
79+
80+ proto = CryptoGetInfoResponse .AccountInfo (
81+ accountID = AccountId (0 , 0 , 100 )._to_proto (),
82+ key = public_key ._to_proto (),
83+ balance = 5000000 ,
84+
85+ staking_info = {
86+ "decline_reward" : True ,
87+ "staked_node_id" : 3 ,
88+ "staked_account_id" : None
89+ }
90+ )
91+
92+ account_info = AccountInfo ._from_proto (proto )
93+
94+ assert account_info .staking_info is not None
95+ assert account_info .staking_info .decline_reward is True
96+ assert account_info .staking_info .staked_node_id == 3
97+
7598
7699def test_account_info_default_initialization ():
77100 """Test the default initialization of the AccountInfo class"""
@@ -91,6 +114,22 @@ def test_account_info_default_initialization():
91114 assert account_info .max_automatic_token_associations is None
92115 assert account_info .staking_info is None
93116
117+ def test_staking_info_persistence (account_info ):
118+ """Ensure staking info is preserved through proto conversion"""
119+
120+ account_info .staking_info = StakingInfo (
121+ decline_reward = True ,
122+ staked_node_id = 5 ,
123+ staked_account_id = None
124+ )
125+
126+ proto = account_info ._to_proto ()
127+ converted_info = AccountInfo ._from_proto (proto )
128+
129+ assert converted_info .staking_info is not None
130+ assert converted_info .staking_info .decline_reward is True
131+ assert converted_info .staking_info .staked_node_id == 5
132+ assert converted_info .staking_info .staked_account_id is None
94133
95134def test_from_proto (proto_account_info ):
96135 """Test the from_proto method of the AccountInfo class"""
@@ -109,7 +148,7 @@ def test_from_proto(proto_account_info):
109148 assert account_info .account_memo == "Test account memo"
110149 assert account_info .owned_nfts == 5
111150 assert account_info .max_automatic_token_associations == 10
112- # assert account_info.staking_info == None
151+ assert account_info .staking_info == None
113152
114153
115154def test_from_proto_with_token_relationships ():
0 commit comments