From 745d1460e56a497072d6b5918bac4510164ed519 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Wed, 30 Oct 2024 09:18:47 +0200 Subject: [PATCH] script: Parse more than one page limit of offers. --- scripts/createoffers.py | 15 ++++++++++++++- tests/basicswap/extended/test_scripts.py | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/createoffers.py b/scripts/createoffers.py index 7902abe..f344a68 100755 --- a/scripts/createoffers.py +++ b/scripts/createoffers.py @@ -452,6 +452,7 @@ def main(): coin_from_data = coins_map[bid_template['coin_from']] coin_to_data = coins_map[bid_template['coin_to']] + page_limit: int = 25 offers_options = { 'active': 'active', 'include_sent': False, @@ -460,9 +461,21 @@ def main(): 'with_extra_info': True, 'sort_by': 'rate', 'sort_dir': 'asc', + 'offset': 0, + 'limit': page_limit, } - received_offers = read_json_api('offers', offers_options) + received_offers = [] + for i in range(1000000): # for i in itertools.count() + page_offers = read_json_api('offers', offers_options) + if len(page_offers) < 1: + break + received_offers += page_offers + offers_options['offset'] = offers_options['offset'] + page_limit + if i > 100: + print(f'Warning: Broke offers loop at: {i}') + break + if args.debug: print('Received Offers', received_offers) diff --git a/tests/basicswap/extended/test_scripts.py b/tests/basicswap/extended/test_scripts.py index af7271c..dc3ce70 100644 --- a/tests/basicswap/extended/test_scripts.py +++ b/tests/basicswap/extended/test_scripts.py @@ -633,7 +633,7 @@ class Test(unittest.TestCase): 'name': 'offer should fail', 'coin_from': 'Particl', 'coin_to': 'XMR', - 'amount': 20, + 'amount': 200, 'minrate': 0.05, 'ratetweakpercent': 50000000, 'amount_variable': True,