mirror of
https://github.com/basicswap/basicswap.git
synced 2025-12-04 14:37:07 +01:00
tests: Start wallet restore test.
Fix LTC pidfile in config. Update LTC onion port for core version 21.
This commit is contained in:
@@ -196,6 +196,14 @@ def wait_for_in_progress(delay_event, swap_client, bid_id, sent=False):
|
||||
raise ValueError('wait_for_in_progress timed out.')
|
||||
|
||||
|
||||
def post_json_req(url, json_data):
|
||||
req = urllib.request.Request(url)
|
||||
req.add_header('Content-Type', 'application/json; charset=utf-8')
|
||||
post_bytes = json.dumps(json_data).encode('utf-8')
|
||||
req.add_header('Content-Length', len(post_bytes))
|
||||
return urlopen(req, post_bytes).read()
|
||||
|
||||
|
||||
def read_json_api(port, path=None):
|
||||
url = f'http://127.0.0.1:{port}/json'
|
||||
if path is not None:
|
||||
@@ -203,6 +211,13 @@ def read_json_api(port, path=None):
|
||||
return json.loads(urlopen(url).read())
|
||||
|
||||
|
||||
def post_json_api(port, path, json_data):
|
||||
url = f'http://127.0.0.1:{port}/json'
|
||||
if path is not None:
|
||||
url += '/' + path
|
||||
return json.loads(post_json_req(url, json_data))
|
||||
|
||||
|
||||
def wait_for_none_active(delay_event, port, wait_for=30):
|
||||
for i in range(wait_for):
|
||||
if delay_event.is_set():
|
||||
@@ -272,14 +287,6 @@ def wait_for_balance(delay_event, url, balance_key, expect_amount, iterations=20
|
||||
raise ValueError('Expect {} {}'.format(balance_key, expect_amount))
|
||||
|
||||
|
||||
def post_json_req(url, json_data):
|
||||
req = urllib.request.Request(url)
|
||||
req.add_header('Content-Type', 'application/json; charset=utf-8')
|
||||
post_bytes = json.dumps(json_data).encode('utf-8')
|
||||
req.add_header('Content-Length', len(post_bytes))
|
||||
return urlopen(req, post_bytes).read()
|
||||
|
||||
|
||||
def delay_for(delay_event, delay_for=60):
|
||||
logging.info('Delaying for {} seconds.'.format(delay_for))
|
||||
delay_event.wait(delay_for)
|
||||
|
||||
Reference in New Issue
Block a user