|
9 | 9 | from hiero_sdk_python.tokens.token_relationship import TokenRelationship |
10 | 10 | from hiero_sdk_python.tokens.token_id import TokenId |
11 | 11 | from hiero_sdk_python.hapi.services.crypto_get_info_pb2 import CryptoGetInfoResponse |
12 | | -from hiero_sdk_python.hapi.services.basic_types_pb2 import StakingInfo as StakingInfoProto |
13 | | -from hiero_sdk_python.staking_info import StakingInfo |
14 | 12 |
|
15 | 13 | pytestmark = pytest.mark.unit |
16 | 14 |
|
@@ -213,154 +211,3 @@ def test_str_and_repr(account_info): |
213 | 211 | assert "contract_account_id='0.0.100'" in info_repr |
214 | 212 | assert "account_memo='Test account memo'" in info_repr |
215 | 213 |
|
216 | | - |
217 | | -def test_from_proto_with_staking_info(): |
218 | | - """Test from_proto with staking account info""" |
219 | | - public_key = PrivateKey.generate_ed25519().public_key() |
220 | | - proto = CryptoGetInfoResponse.AccountInfo( |
221 | | - accountID=AccountId(0, 0, 100)._to_proto(), |
222 | | - key=public_key._to_proto(), |
223 | | - balance=5000000, |
224 | | - staking_info=StakingInfoProto( |
225 | | - staked_account_id=AccountId(0, 0, 500)._to_proto(), |
226 | | - decline_reward=True, |
227 | | - ), |
228 | | - ) |
229 | | - |
230 | | - account_info = AccountInfo._from_proto(proto) |
231 | | - |
232 | | - assert account_info.staking_info is not None |
233 | | - assert account_info.staking_info.staked_account_id == AccountId(0, 0, 500) |
234 | | - assert account_info.staking_info.decline_reward is True |
235 | | - |
236 | | - |
237 | | -def test_from_proto_with_staked_node_id(): |
238 | | - """Test from_proto with staked_node_id""" |
239 | | - public_key = PrivateKey.generate_ed25519().public_key() |
240 | | - proto = CryptoGetInfoResponse.AccountInfo( |
241 | | - accountID=AccountId(0, 0, 100)._to_proto(), |
242 | | - key=public_key._to_proto(), |
243 | | - balance=5000000, |
244 | | - staking_info=StakingInfoProto( |
245 | | - staked_node_id=3, |
246 | | - decline_reward=False, |
247 | | - ), |
248 | | - ) |
249 | | - |
250 | | - account_info = AccountInfo._from_proto(proto) |
251 | | - |
252 | | - assert account_info.staking_info is not None |
253 | | - assert account_info.staking_info.staked_node_id == 3 |
254 | | - assert account_info.staking_info.decline_reward is False |
255 | | - |
256 | | - |
257 | | -def test_from_proto_with_no_staking_info(): |
258 | | - """Test from_proto without staking info""" |
259 | | - public_key = PrivateKey.generate_ed25519().public_key() |
260 | | - proto = CryptoGetInfoResponse.AccountInfo( |
261 | | - accountID=AccountId(0, 0, 100)._to_proto(), |
262 | | - key=public_key._to_proto(), |
263 | | - balance=5000000, |
264 | | - ) |
265 | | - |
266 | | - account_info = AccountInfo._from_proto(proto) |
267 | | - |
268 | | - assert account_info.staking_info is None |
269 | | - |
270 | | - |
271 | | -def test_to_proto_with_staking_info(): |
272 | | - """Test to_proto with staking info""" |
273 | | - account_info = AccountInfo( |
274 | | - account_id=AccountId(0, 0, 100), |
275 | | - balance=Hbar.from_tinybars(5000000), |
276 | | - staking_info=StakingInfo( |
277 | | - staked_account_id=AccountId(0, 0, 500), |
278 | | - decline_reward=True, |
279 | | - ), |
280 | | - ) |
281 | | - |
282 | | - proto = account_info._to_proto() |
283 | | - |
284 | | - assert proto.HasField('staking_info') |
285 | | - assert proto.staking_info.HasField('staked_account_id') |
286 | | - assert proto.staking_info.staked_account_id == AccountId(0, 0, 500)._to_proto() |
287 | | - assert proto.staking_info.decline_reward is True |
288 | | - |
289 | | - |
290 | | -def test_to_proto_with_staked_node_id(): |
291 | | - """Test to_proto with staked_node_id""" |
292 | | - account_info = AccountInfo( |
293 | | - account_id=AccountId(0, 0, 100), |
294 | | - balance=Hbar.from_tinybars(5000000), |
295 | | - staking_info=StakingInfo( |
296 | | - staked_node_id=5, |
297 | | - decline_reward=False, |
298 | | - ), |
299 | | - ) |
300 | | - |
301 | | - proto = account_info._to_proto() |
302 | | - |
303 | | - assert proto.HasField('staking_info') |
304 | | - assert proto.staking_info.staked_node_id == 5 |
305 | | - assert proto.staking_info.decline_reward is False |
306 | | - |
307 | | - |
308 | | -def test_proto_conversion_staking_node_round_trip(): |
309 | | - """Test proto conversion round trip with staked_node_id""" |
310 | | - account_info = AccountInfo( |
311 | | - account_id=AccountId(0, 0, 100), |
312 | | - key=PrivateKey.generate_ed25519().public_key(), |
313 | | - balance=Hbar.from_tinybars(5000000), |
314 | | - staking_info=StakingInfo( |
315 | | - staked_node_id=7, |
316 | | - decline_reward=False, |
317 | | - ), |
318 | | - ) |
319 | | - |
320 | | - converted = AccountInfo._from_proto(account_info._to_proto()) |
321 | | - |
322 | | - assert converted.account_id == account_info.account_id |
323 | | - assert converted.balance.to_tinybars() == account_info.balance.to_tinybars() |
324 | | - assert converted.staking_info.staked_account_id is None |
325 | | - assert converted.staking_info.staked_node_id == 7 |
326 | | - assert converted.staking_info.decline_reward is False |
327 | | - |
328 | | - |
329 | | -def test_proto_conversion_staking_account_round_trip(): |
330 | | - """Test proto conversion round trip with staked_account_id""" |
331 | | - account_info = AccountInfo( |
332 | | - account_id=AccountId(0, 0, 100), |
333 | | - key=PrivateKey.generate_ed25519().public_key(), |
334 | | - balance=Hbar.from_tinybars(5000000), |
335 | | - staking_info=StakingInfo( |
336 | | - staked_account_id=AccountId(0, 0, 600), |
337 | | - decline_reward=True, |
338 | | - ), |
339 | | - ) |
340 | | - |
341 | | - converted = AccountInfo._from_proto(account_info._to_proto()) |
342 | | - |
343 | | - assert converted.account_id == account_info.account_id |
344 | | - assert converted.balance.to_tinybars() == account_info.balance.to_tinybars() |
345 | | - assert converted.staking_info.staked_account_id == AccountId(0, 0, 600) |
346 | | - assert converted.staking_info.staked_node_id is None |
347 | | - assert converted.staking_info.decline_reward is True |
348 | | - |
349 | | - |
350 | | -def test_proto_conversion_with_staked_node_zero(): |
351 | | - """Test proto conversion with staked_node_id set to 0""" |
352 | | - account_info = AccountInfo( |
353 | | - account_id=AccountId(0, 0, 100), |
354 | | - key=PrivateKey.generate_ed25519().public_key(), |
355 | | - balance=Hbar.from_tinybars(5000000), |
356 | | - staking_info=StakingInfo( |
357 | | - staked_node_id=0, |
358 | | - decline_reward=True, |
359 | | - ), |
360 | | - ) |
361 | | - |
362 | | - converted = AccountInfo._from_proto(account_info._to_proto()) |
363 | | - |
364 | | - assert converted.staking_info is not None |
365 | | - assert converted.staking_info.staked_node_id == 0 |
366 | | - assert converted.staking_info.decline_reward is True |
0 commit comments