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
@@ -28,6 +29,8 @@ def account_info():
2829 token_relationships = [],
2930 account_memo = "Test account memo" ,
3031 owned_nfts = 5 ,
32+ max_automatic_token_associations = 10 ,
33+ staking_info = None
3134 )
3235
3336
@@ -47,6 +50,8 @@ def proto_account_info():
4750 tokenRelationships = [],
4851 memo = "Test account memo" ,
4952 ownedNfts = 5 ,
53+ max_automatic_token_associations = 10 ,
54+ staking_info = None
5055 )
5156 return proto
5257
@@ -65,7 +70,31 @@ def test_account_info_initialization(account_info):
6570 assert account_info .token_relationships == []
6671 assert account_info .account_memo == "Test account memo"
6772 assert account_info .owned_nfts == 5
73+ assert account_info .max_automatic_token_associations == 10
74+ assert account_info .staking_info is None
6875
76+ def test_proto_conversion_with_staking_info ():
77+ """Test converting AccountInfo with StakingInfo to proto and back preserves data"""
78+ public_key = PrivateKey .generate_ed25519 ().public_key ()
79+
80+ staking_info = StakingInfo (
81+ decline_reward = True ,
82+ staked_node_id = 3 ,
83+ )
84+
85+ account_info = AccountInfo (
86+ account_id = AccountId (0 , 0 , 100 ),
87+ key = public_key ,
88+ staking_info = staking_info ,
89+ )
90+
91+ proto = account_info ._to_proto ()
92+ converted = AccountInfo ._from_proto (proto )
93+
94+ # Now these assertions should work
95+ assert converted .staking_info is not None
96+ assert converted .staking_info .decline_reward is True
97+ assert converted .staking_info .staked_node_id == 3
6998
7099def test_account_info_default_initialization ():
71100 """Test the default initialization of the AccountInfo class"""
@@ -82,7 +111,25 @@ def test_account_info_default_initialization():
82111 assert account_info .token_relationships == []
83112 assert account_info .account_memo is None
84113 assert account_info .owned_nfts is None
114+ assert account_info .max_automatic_token_associations is None
115+ assert account_info .staking_info is None
85116
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
86133
87134def test_from_proto (proto_account_info ):
88135 """Test the from_proto method of the AccountInfo class"""
@@ -100,6 +147,8 @@ def test_from_proto(proto_account_info):
100147 assert account_info .token_relationships == []
101148 assert account_info .account_memo == "Test account memo"
102149 assert account_info .owned_nfts == 5
150+ assert account_info .max_automatic_token_associations == 10
151+ assert account_info .staking_info == None
103152
104153
105154def test_from_proto_with_token_relationships ():
@@ -141,6 +190,11 @@ def test_to_proto(account_info):
141190 assert proto .tokenRelationships == []
142191 assert proto .memo == "Test account memo"
143192 assert proto .ownedNfts == 5
193+ assert proto .max_automatic_token_associations == 10
194+ assert not proto .HasField ("staking_info" )
195+
196+
197+
144198
145199
146200def test_to_proto_with_none_values ():
@@ -192,6 +246,7 @@ def test_proto_conversion(account_info):
192246 )
193247 assert converted_account_info .account_memo == account_info .account_memo
194248 assert converted_account_info .owned_nfts == account_info .owned_nfts
249+ assert converted_account_info .staking_info == account_info .staking_info
195250
196251
197252def test_str_and_repr (account_info ):
0 commit comments