mirror of
https://github.com/basicswap/basicswap.git
synced 2024-11-16 15:58:17 +00:00
preparescript: Fix UI_HTML_PORT bug.
Warn on os.chmod failure, workaround for mounted ntfs volumes. client: Set delay_event in stopRunning() Raise version
This commit is contained in:
parent
3e858888ac
commit
bbd3d701c0
5 changed files with 43 additions and 21 deletions
|
@ -1,3 +1,3 @@
|
||||||
name = "basicswap"
|
name = "basicswap"
|
||||||
|
|
||||||
__version__ = "0.0.17"
|
__version__ = "0.0.18"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2019 tecnovert
|
# Copyright (c) 2019-2021 tecnovert
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -38,14 +38,16 @@ class BaseApp:
|
||||||
self.coin_interfaces = {}
|
self.coin_interfaces = {}
|
||||||
self.mxDB = threading.RLock()
|
self.mxDB = threading.RLock()
|
||||||
self.debug = self.settings.get('debug', False)
|
self.debug = self.settings.get('debug', False)
|
||||||
|
self.delay_event = threading.Event()
|
||||||
self._network = None
|
self._network = None
|
||||||
|
|
||||||
self.prepareLogging()
|
self.prepareLogging()
|
||||||
self.log.info('Network: {}'.format(self.chain))
|
self.log.info('Network: {}'.format(self.chain))
|
||||||
|
|
||||||
def stopRunning(self, with_code=0):
|
def stopRunning(self, with_code=0):
|
||||||
self.fail_code = with_code
|
self.fail_code = with_code
|
||||||
self.is_running = False
|
with self.mxDB:
|
||||||
|
self.is_running = False
|
||||||
|
self.delay_event.set()
|
||||||
|
|
||||||
def prepareLogging(self):
|
def prepareLogging(self):
|
||||||
self.log = logging.getLogger(self.log_name)
|
self.log = logging.getLogger(self.log_name)
|
||||||
|
|
|
@ -470,7 +470,6 @@ class BasicSwap(BaseApp):
|
||||||
|
|
||||||
self.SMSG_SECONDS_IN_HOUR = 60 * 60 # Note: Set smsgsregtestadjust=0 for regtest
|
self.SMSG_SECONDS_IN_HOUR = 60 * 60 # Note: Set smsgsregtestadjust=0 for regtest
|
||||||
|
|
||||||
self.delay_event = threading.Event()
|
|
||||||
self.threads = []
|
self.threads = []
|
||||||
|
|
||||||
# Encode key to match network
|
# Encode key to match network
|
||||||
|
|
|
@ -64,7 +64,7 @@ XMR_SITE_COMMIT = 'd27c1eee9fe0e8daa011d07baae8b67dd2b62a04' # Lock hashes.txt
|
||||||
|
|
||||||
DEFAULT_XMR_RESTORE_HEIGHT = 2245107
|
DEFAULT_XMR_RESTORE_HEIGHT = 2245107
|
||||||
|
|
||||||
UI_HTML_PORT = int(os.getenv('BASE_XMR_RPC_PORT', 12700))
|
UI_HTML_PORT = int(os.getenv('UI_HTML_PORT', 12700))
|
||||||
PART_ZMQ_PORT = int(os.getenv('PART_ZMQ_PORT', 20792))
|
PART_ZMQ_PORT = int(os.getenv('PART_ZMQ_PORT', 20792))
|
||||||
|
|
||||||
PART_RPC_HOST = os.getenv('PART_RPC_HOST', '127.0.0.1')
|
PART_RPC_HOST = os.getenv('PART_RPC_HOST', '127.0.0.1')
|
||||||
|
@ -131,11 +131,12 @@ def extractCore(coin, version, settings, bin_dir, release_path):
|
||||||
continue
|
continue
|
||||||
out_path = os.path.join(bin_dir, bin_name)
|
out_path = os.path.join(bin_dir, bin_name)
|
||||||
if (not os.path.exists(out_path)) or extract_core_overwrite:
|
if (not os.path.exists(out_path)) or extract_core_overwrite:
|
||||||
fi = ft.extractfile(member)
|
with open(out_path, 'wb') as fout, ft.extractfile(member) as fi:
|
||||||
with open(out_path, 'wb') as fout:
|
|
||||||
fout.write(fi.read())
|
fout.write(fi.read())
|
||||||
fi.close()
|
try:
|
||||||
os.chmod(out_path, stat.S_IRWXU | stat.S_IXGRP | stat.S_IXOTH)
|
os.chmod(out_path, stat.S_IRWXU | stat.S_IXGRP | stat.S_IXOTH)
|
||||||
|
except Exception as e:
|
||||||
|
logging.warning('Unable to set file permissions: %s, for %s', str(e), out_path)
|
||||||
return
|
return
|
||||||
|
|
||||||
bins = [coin + 'd', coin + '-cli', coin + '-tx']
|
bins = [coin + 'd', coin + '-cli', coin + '-tx']
|
||||||
|
@ -150,17 +151,21 @@ def extractCore(coin, version, settings, bin_dir, release_path):
|
||||||
if (not os.path.exists(out_path)) or extract_core_overwrite:
|
if (not os.path.exists(out_path)) or extract_core_overwrite:
|
||||||
with open(out_path, 'wb') as fout:
|
with open(out_path, 'wb') as fout:
|
||||||
fout.write(fz.read('{}-{}/bin/{}'.format(coin, version, b)))
|
fout.write(fz.read('{}-{}/bin/{}'.format(coin, version, b)))
|
||||||
os.chmod(out_path, stat.S_IRWXU | stat.S_IXGRP | stat.S_IXOTH)
|
try:
|
||||||
|
os.chmod(out_path, stat.S_IRWXU | stat.S_IXGRP | stat.S_IXOTH)
|
||||||
|
except Exception as e:
|
||||||
|
logging.warning('Unable to set file permissions: %s, for %s', str(e), out_path)
|
||||||
else:
|
else:
|
||||||
with tarfile.open(release_path) as ft:
|
with tarfile.open(release_path) as ft:
|
||||||
for b in bins:
|
for b in bins:
|
||||||
out_path = os.path.join(bin_dir, b)
|
out_path = os.path.join(bin_dir, b)
|
||||||
if not os.path.exists(out_path) or extract_core_overwrite:
|
if not os.path.exists(out_path) or extract_core_overwrite:
|
||||||
fi = ft.extractfile('{}-{}/bin/{}'.format(coin, version, b))
|
with open(out_path, 'wb') as fout, ft.extractfile('{}-{}/bin/{}'.format(coin, version, b)) as fi:
|
||||||
with open(out_path, 'wb') as fout:
|
|
||||||
fout.write(fi.read())
|
fout.write(fi.read())
|
||||||
fi.close()
|
try:
|
||||||
os.chmod(out_path, stat.S_IRWXU | stat.S_IXGRP | stat.S_IXOTH)
|
os.chmod(out_path, stat.S_IRWXU | stat.S_IXGRP | stat.S_IXOTH)
|
||||||
|
except Exception as e:
|
||||||
|
logging.warning('Unable to set file permissions: %s, for %s', str(e), out_path)
|
||||||
|
|
||||||
|
|
||||||
def prepareCore(coin, version, settings, data_dir):
|
def prepareCore(coin, version, settings, data_dir):
|
||||||
|
|
|
@ -6,22 +6,29 @@
|
||||||
# sudo mv chromedriver /opt/chromedriver88
|
# sudo mv chromedriver /opt/chromedriver88
|
||||||
|
|
||||||
# Run test_xmr_persistent.py
|
# Run test_xmr_persistent.py
|
||||||
|
# python tests/basicswap/extended/test_http_ui.py
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin
|
||||||
|
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.support.ui import Select
|
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||||
|
|
||||||
|
|
||||||
def run_test():
|
def run_test():
|
||||||
base_url = 'http://localhost:12701'
|
base_url = 'http://localhost:12701'
|
||||||
driver = webdriver.Chrome('/opt/chromedriver88')
|
driver = webdriver.Chrome('/opt/chromedriver88')
|
||||||
|
|
||||||
driver.get(urljoin(base_url, 'newoffer'))
|
driver.get(base_url)
|
||||||
html = driver.page_source
|
link = driver.find_element_by_xpath('//a[@href="/offers"]')
|
||||||
print('html', html)
|
num_offers_start = int(link.text.split(':')[1].strip())
|
||||||
|
logging.info('Offers: %d', num_offers_start)
|
||||||
|
|
||||||
|
logging.info('Creating offer')
|
||||||
|
driver.get(urljoin(base_url, 'newoffer'))
|
||||||
select_coin_from = Select(driver.find_element_by_name('coin_from'))
|
select_coin_from = Select(driver.find_element_by_name('coin_from'))
|
||||||
select_coin_from.select_by_visible_text('Particl')
|
select_coin_from.select_by_visible_text('Particl')
|
||||||
|
|
||||||
|
@ -35,15 +42,24 @@ def run_test():
|
||||||
|
|
||||||
submit_button = driver.find_element_by_name('continue')
|
submit_button = driver.find_element_by_name('continue')
|
||||||
submit_button.click()
|
submit_button.click()
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
submit_button = driver.find_element_by_name('check_offer')
|
submit_button = driver.find_element_by_name('check_offer')
|
||||||
submit_button.click()
|
submit_button.click()
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
submit_button = driver.find_element_by_name('submit_offer')
|
submit_button = driver.find_element_by_name('submit_offer')
|
||||||
submit_button.click()
|
submit_button.click()
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
driver.get(urljoin(base_url))
|
link = WebDriverWait(driver, 5).until(lambda d: d.find_element_by_xpath("//a[contains(@href, '/offer')]"))
|
||||||
time.sleep(3)
|
offer_id = link.text.rsplit(' ', 1)[1]
|
||||||
|
logging.info('Offer ID: %s', offer_id)
|
||||||
|
|
||||||
|
driver.get(base_url)
|
||||||
|
link = driver.find_element_by_xpath('//a[@href="/offers"]')
|
||||||
|
num_offers_end = int(link.text.split(':')[1].strip())
|
||||||
|
assert(num_offers_end == num_offers_start + 1)
|
||||||
|
|
||||||
driver.quit()
|
driver.quit()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue