Skip to content

Commit 1570622

Browse files
raidgar98vogel76
authored andcommitted
Use method to temporarily change timeout for long calls
1 parent 72174b0 commit 1570622

File tree

2 files changed

+28
-42
lines changed
  • tests/python

2 files changed

+28
-42
lines changed

tests/python/functional/operation_tests/convert_tests/test_convert.py

+21-42
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import test_tools as tt
1414
from hive_local_tools.functional.python.operation import (
15+
generate_large_amount_of_blocks,
1516
publish_feeds,
1617
)
1718

@@ -20,7 +21,9 @@
2021

2122

2223
@pytest.mark.testnet()
23-
def test_convert_hbd_to_hive(create_node_and_wallet_for_convert_tests: tuple, alice: ConvertAccount) -> None:
24+
def test_convert_hbd_to_hive(
25+
create_node_and_wallet_for_convert_tests: tuple[tt.InitNode, tt.Wallet], alice: ConvertAccount
26+
) -> None:
2427
# test case 1 from: https://gitlab.syncad.com/hive/hive/-/issues/478
2528
node, wallet = create_node_and_wallet_for_convert_tests
2629
publish_feeds(node, wallet, base=1000, quote=400)
@@ -35,9 +38,7 @@ def test_convert_hbd_to_hive(create_node_and_wallet_for_convert_tests: tuple, al
3538
alice.check_if_current_rc_mana_was_reduced(transaction)
3639
alice.check_if_funds_to_convert_were_subtracted(transaction)
3740
# generate enough block to jump HIVE_COLLATERALIZED_CONVERSION_DELAY interval
38-
node.api.debug_node.debug_generate_blocks(
39-
debug_key=tt.Account("initminer").private_key, count=1680, skip=0, miss_blocks=0, edit_if_needed=True
40-
)
41+
generate_large_amount_of_blocks(node=node, block_signer=tt.Account("initminer"), count=1680)
4142
alice.check_if_right_amount_was_converted_and_added_to_balance(transaction)
4243
alice.assert_fill_convert_request_operation(expected_amount=1)
4344

@@ -93,17 +94,13 @@ def test_convert_hbd_to_hive_during_few_days(
9394
alice.assert_fill_convert_request_operation(expected_amount=vops_counter)
9495
convert_transactions_it += 1
9596

96-
node.api.debug_node.debug_generate_blocks(
97-
debug_key=tt.Account("initminer").private_key,
98-
count=blocks_to_generate,
99-
skip=0,
100-
miss_blocks=0,
101-
edit_if_needed=True,
102-
)
97+
generate_large_amount_of_blocks(node, tt.Account("initminer"), count=blocks_to_generate)
10398

10499

105100
@pytest.mark.testnet()
106-
def test_convert_hive_to_hbd(create_node_and_wallet_for_convert_tests: tuple, alice: ConvertAccount) -> None:
101+
def test_convert_hive_to_hbd(
102+
create_node_and_wallet_for_convert_tests: tuple[tt.InitNode, tt.Wallet], alice: ConvertAccount
103+
) -> None:
107104
# test case 1 from: https://gitlab.syncad.com/hive/hive/-/issues/481
108105
node, wallet = create_node_and_wallet_for_convert_tests
109106
publish_feeds(node, wallet, base=1000, quote=400)
@@ -123,9 +120,7 @@ def test_convert_hive_to_hbd(create_node_and_wallet_for_convert_tests: tuple, al
123120
alice.assert_collateralized_conversion_requests(trx=transaction, state="create")
124121

125122
# generate enough blocks to jump HIVE_COLLATERALIZED_CONVERSION_DELAY interval
126-
node.api.debug_node.debug_generate_blocks(
127-
debug_key=tt.Account("initminer").private_key, count=1680, skip=0, miss_blocks=0, edit_if_needed=True
128-
)
123+
generate_large_amount_of_blocks(node=node, block_signer=tt.Account("initminer"), count=1680)
129124
alice.assert_if_right_amount_of_hives_came_back_after_collateral_conversion(transaction)
130125
alice.assert_collateralized_conversion_requests(trx=transaction, state="delete")
131126
alice.assert_fill_collateralized_convert_request_operation(expected_amount=1)
@@ -185,13 +180,7 @@ def test_convert_hive_to_hbd_during_few_days(
185180
)
186181
alice.assert_fill_collateralized_convert_request_operation(expected_amount=vops_counter)
187182
convert_transactions_it += 1
188-
node.api.debug_node.debug_generate_blocks(
189-
debug_key=tt.Account("initminer").private_key,
190-
count=blocks_to_generate,
191-
skip=0,
192-
miss_blocks=0,
193-
edit_if_needed=True,
194-
)
183+
generate_large_amount_of_blocks(node, tt.Account("initminer"), count=blocks_to_generate)
195184

196185

197186
@pytest.mark.parametrize(
@@ -221,7 +210,7 @@ def test_convert_hive_to_hbd_during_few_days(
221210
],
222211
)
223212
def test_convert_hive_into_hbd_with_changing_median_current_price_during_conversion(
224-
create_node_and_wallet_for_convert_tests: tuple,
213+
create_node_and_wallet_for_convert_tests: tuple[tt.InitNode, tt.Wallet],
225214
alice: ConvertAccount,
226215
initial_feed_base_value: int,
227216
further_feed_base_value: int,
@@ -242,9 +231,7 @@ def test_convert_hive_into_hbd_with_changing_median_current_price_during_convers
242231
publish_feeds(node, wallet, further_feed_base_value, 1000)
243232

244233
# generate enough block to jump HIVE_COLLATERALIZED_CONVERSION_DELAY interval
245-
node.api.debug_node.debug_generate_blocks(
246-
debug_key=tt.Account("initminer").private_key, count=1680, skip=0, miss_blocks=0, edit_if_needed=True
247-
)
234+
generate_large_amount_of_blocks(node=node, block_signer=tt.Account("initminer"), count=1680)
248235
alice.assert_if_right_amount_of_hives_came_back_after_collateral_conversion(transaction)
249236
alice.assert_collateralized_conversion_requests(trx=transaction, state="delete")
250237
alice.assert_fill_collateralized_convert_request_operation(expected_amount=1)
@@ -258,7 +245,9 @@ def test_convert_hive_into_hbd_with_changing_median_current_price_during_convers
258245
],
259246
)
260247
def test_minimal_feed_price_greater_than_median_feed_price(
261-
create_node_and_wallet_for_convert_tests: tuple, alice: ConvertAccount, feed_base_values: tuple
248+
create_node_and_wallet_for_convert_tests: tuple[tt.InitNode, tt.Wallet],
249+
alice: ConvertAccount,
250+
feed_base_values: tuple,
262251
) -> None:
263252
# test case from Excel file (sheet TC2 - columns D, F) https://gitlab.syncad.com/hive/hive/-/issues/481#note_154312
264253
node, wallet = create_node_and_wallet_for_convert_tests
@@ -301,13 +290,7 @@ def test_minimal_feed_price_greater_than_median_feed_price(
301290
trx = publish_feeds(node, wallet, next(feeds_it), 1000, broadcast=False)
302291
node.api.network_broadcast.broadcast_transaction(trx=trx)
303292

304-
node.api.debug_node.debug_generate_blocks(
305-
debug_key=tt.Account("initminer").private_key,
306-
count=blocks_to_generate,
307-
skip=0,
308-
miss_blocks=0,
309-
edit_if_needed=True,
310-
)
293+
generate_large_amount_of_blocks(node=node, block_signer=tt.Account("initminer"), count=blocks_to_generate)
311294

312295

313296
@pytest.mark.parametrize(
@@ -318,7 +301,9 @@ def test_minimal_feed_price_greater_than_median_feed_price(
318301
],
319302
)
320303
def test_median_feed_price_greater_than_minimal_feed_price(
321-
create_node_and_wallet_for_convert_tests: tuple, alice: ConvertAccount, feed_base_values: tuple
304+
create_node_and_wallet_for_convert_tests: tuple[tt.InitNode, tt.Wallet],
305+
alice: ConvertAccount,
306+
feed_base_values: tuple,
322307
) -> None:
323308
# test case from Excel file (sheet TC2 - columns C, E) https://gitlab.syncad.com/hive/hive/-/issues/481#note_154312
324309
node, wallet = create_node_and_wallet_for_convert_tests
@@ -363,10 +348,4 @@ def test_median_feed_price_greater_than_minimal_feed_price(
363348
alice.assert_fill_collateralized_convert_request_operation(expected_amount=vops_counter)
364349
convert_transactions_it += 1
365350

366-
node.api.debug_node.debug_generate_blocks(
367-
debug_key=tt.Account("initminer").private_key,
368-
count=blocks_to_generate,
369-
skip=0,
370-
miss_blocks=0,
371-
edit_if_needed=True,
372-
)
351+
generate_large_amount_of_blocks(node=node, block_signer=tt.Account("initminer"), count=blocks_to_generate)

tests/python/hive-local-tools/hive_local_tools/functional/python/operation/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -620,3 +620,10 @@ def assert_account_was_created(node: tt.AnyNode, account_name: str) -> None:
620620
created_accounts.append(operation.op.value.new_account_name)
621621

622622
assert account_name in created_accounts, f"Account named {account_name} was not created"
623+
624+
625+
def generate_large_amount_of_blocks(node: tt.AnyNode, block_signer: tt.Account, count: int) -> None:
626+
with node.temporarily_change_timeout(seconds=30):
627+
node.api.debug_node.debug_generate_blocks(
628+
debug_key=block_signer.private_key, count=count, skip=0, miss_blocks=0, edit_if_needed=True
629+
)

0 commit comments

Comments
 (0)