diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py
index fbc242f..24ecd5a 100644
--- a/basicswap/basicswap.py
+++ b/basicswap/basicswap.py
@@ -6137,7 +6137,7 @@ class BasicSwap(BaseApp):
if 'chart_api_key' in data:
new_value = data['chart_api_key']
- ensure(isinstance(new_value, bool), 'New chart_api_key value not a string')
+ ensure(isinstance(new_value, str), 'New chart_api_key value not a string')
ensure(len(new_value) <= 128, 'New chart_api_key value too long')
if all(c in string.hexdigits for c in new_value):
if settings_copy.get('chart_api_key', '') != new_value:
@@ -6196,7 +6196,10 @@ class BasicSwap(BaseApp):
remotedaemonurls.add(url.strip())
if set(settings_cc.get('remote_daemon_urls', [])) != remotedaemonurls:
- settings_cc['remote_daemon_urls'] = list(remotedaemonurls)
+ if len(remotedaemonurls) == 0 and 'remote_daemon_urls' in settings_cc:
+ del settings_cc['remote_daemon_urls']
+ else:
+ settings_cc['remote_daemon_urls'] = list(remotedaemonurls)
settings_changed = True
suggest_reboot = True
diff --git a/basicswap/templates/inc_messages.html b/basicswap/templates/inc_messages.html
index fe98501..47880f7 100644
--- a/basicswap/templates/inc_messages.html
+++ b/basicswap/templates/inc_messages.html
@@ -11,7 +11,7 @@
-
{{ m[1] }}
+ {{ m[1] }}
@@ -45,7 +45,7 @@
-
+
Close
@@ -57,4 +57,4 @@
{% endif %}
-
\ No newline at end of file
+
diff --git a/basicswap/templates/settings.html b/basicswap/templates/settings.html
index e460f86..a5ac4ea 100644
--- a/basicswap/templates/settings.html
+++ b/basicswap/templates/settings.html
@@ -48,7 +48,7 @@
- Coins
+ Coins
General
diff --git a/scripts/createoffers.py b/scripts/createoffers.py
index 73992e3..ace0163 100755
--- a/scripts/createoffers.py
+++ b/scripts/createoffers.py
@@ -293,7 +293,7 @@ def main():
received_offers = read_json_api(args.port, 'offers', {'active': 'active', 'include_sent': False, 'coin_from': coin_from_data['id'], 'coin_to': coin_to_data['id']})
print('received_offers', received_offers)
- TODO - adjust rates based on extisting offers
+ TODO - adjust rates based on existing offers
"""
rates = read_json_api('rates', {'coin_from': coin_from_data['id'], 'coin_to': coin_to_data['id']})
diff --git a/tests/basicswap/selenium/notes.txt b/tests/basicswap/selenium/notes.txt
new file mode 100644
index 0000000..71dc168
--- /dev/null
+++ b/tests/basicswap/selenium/notes.txt
@@ -0,0 +1,2 @@
+python tests/basicswap/extended/test_xmr_persistent.py
+python tests/basicswap/selenium/test_wallets.py
diff --git a/tests/basicswap/selenium/test_offer.py b/tests/basicswap/selenium/test_offer.py
index 757c3d7..a1bb066 100644
--- a/tests/basicswap/selenium/test_offer.py
+++ b/tests/basicswap/selenium/test_offer.py
@@ -5,35 +5,22 @@
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
-"""
-cd /tmp
-wget -4 https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip
-7z x chromedriver_linux64.zip
-sudo mv chromedriver /opt/chromedriver114
-
-python tests/basicswap/extended/test_xmr_persistent.py
-python tests/basicswap/selenium/test_offer.py
-
-"""
-
import json
import time
from urllib.request import urlopen
-from selenium import webdriver
-from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
+from util import get_driver
-def test_html():
+
+def test_offer(driver):
node1_url = 'http://localhost:12701'
node2_url = 'http://localhost:12702'
- driver = webdriver.Chrome(service=Service('/opt/chromedriver114'))
-
driver.get(node1_url + '/newoffer')
time.sleep(1)
@@ -99,10 +86,16 @@ def test_html():
assert (offer4_json['coin_from'] == 'Particl')
assert (offer4_json['coin_to'] == 'Monero')
- driver.close()
+ print('Test Passed!')
- print('Done.')
+
+def run_tests():
+ driver = get_driver()
+ try:
+ test_offer(driver)
+ finally:
+ driver.close()
if __name__ == '__main__':
- test_html()
+ run_tests()
diff --git a/tests/basicswap/selenium/test_settings.py b/tests/basicswap/selenium/test_settings.py
index af7a4bf..f821b52 100644
--- a/tests/basicswap/selenium/test_settings.py
+++ b/tests/basicswap/selenium/test_settings.py
@@ -1,27 +1,25 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
-# Copyright (c) 2022 tecnovert
+# Copyright (c) 2022-2023 tecnovert
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
import json
import time
-from selenium import webdriver
from selenium.webdriver.common.by import By
-from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.select import Select
from selenium.webdriver.support import expected_conditions as EC
+from util import get_driver
-def test_html():
+
+def test_settings(driver):
base_url = 'http://localhost:12701'
node2_url = 'http://localhost:12702'
- driver = webdriver.Chrome(service=Service('/opt/chromedriver96'))
-
url = base_url + '/settings'
driver.get(url)
driver.find_element(By.ID, 'general-tab').click()
@@ -48,8 +46,8 @@ def test_html():
btn_apply_general.click()
time.sleep(1)
- settings_path = '/tmp/test_persistent/client0/basicswap.json'
- with open(settings_path) as fs:
+ settings_path_0 = '/tmp/test_persistent/client0/basicswap.json'
+ with open(settings_path_0) as fs:
settings = json.load(fs)
assert (settings['debug'] is False)
@@ -65,14 +63,14 @@ def test_html():
difficult_text = '`~!@#$%^&*()-_=+[{}]\\|;:\'",<>./? '
el = driver.find_element(By.NAME, 'chartapikey')
+ el.clear()
el.send_keys(difficult_text)
btn_apply_chart = wait.until(EC.element_to_be_clickable((By.NAME, 'apply_chart')))
btn_apply_chart.click()
time.sleep(1)
- settings_path = '/tmp/test_persistent/client0/basicswap.json'
- with open(settings_path) as fs:
+ with open(settings_path_0) as fs:
settings = json.load(fs)
assert (settings['show_chart'] is False)
@@ -90,16 +88,55 @@ def test_html():
el = driver.find_element(By.NAME, 'chartapikey')
assert el.get_property('value') == hex_text
- settings_path = '/tmp/test_persistent/client0/basicswap.json'
- with open(settings_path) as fs:
+ with open(settings_path_0) as fs:
settings = json.load(fs)
assert (settings.get('chart_api_key') == hex_text)
- driver.close()
+ # Apply XMR settings with blank nodes list
+ driver.find_element(By.ID, 'coins-tab').click()
+ btn_apply_monero = wait.until(EC.element_to_be_clickable((By.NAME, 'apply_monero')))
+ el = driver.find_element(By.NAME, 'remotedaemonurls_monero')
+ el.clear()
+ btn_apply_monero.click()
+ time.sleep(1)
- print('Done.')
+ with open(settings_path_0) as fs:
+ settings = json.load(fs)
+ assert ('remote_daemon_urls' not in settings['chainclients']['monero'])
+
+ btn_apply_monero = wait.until(EC.element_to_be_clickable((By.NAME, 'apply_monero')))
+ el = driver.find_element(By.NAME, 'remotedaemonurls_monero')
+ el.clear()
+ el.send_keys('node.xmr.to:18081\nnode1.xmr.to:18082')
+ btn_apply_monero.click()
+ time.sleep(1)
+
+ with open(settings_path_0) as fs:
+ settings = json.load(fs)
+ remotedaemonurls = settings['chainclients']['monero']['remote_daemon_urls']
+ assert (len(remotedaemonurls) == 2)
+
+ btn_apply_monero = wait.until(EC.element_to_be_clickable((By.NAME, 'apply_monero')))
+ el = driver.find_element(By.NAME, 'remotedaemonurls_monero')
+ el.clear()
+ btn_apply_monero.click()
+ time.sleep(1)
+
+ with open(settings_path_0) as fs:
+ settings = json.load(fs)
+ assert ('remote_daemon_urls' not in settings['chainclients']['monero'])
+
+ print('Test Passed!')
+
+
+def run_tests():
+ driver = get_driver()
+ try:
+ test_settings(driver)
+ finally:
+ driver.close()
if __name__ == '__main__':
- test_html()
+ run_tests()
diff --git a/tests/basicswap/selenium/test_swap_direction.py b/tests/basicswap/selenium/test_swap_direction.py
index aa422e0..bd20497 100644
--- a/tests/basicswap/selenium/test_swap_direction.py
+++ b/tests/basicswap/selenium/test_swap_direction.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
-# Copyright (c) 2022 tecnovert
+# Copyright (c) 2022-2023 tecnovert
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
@@ -11,11 +11,10 @@ from tests.basicswap.util import (
read_json_api,
)
-from selenium import webdriver
-from selenium.webdriver.chrome.service import Service
+from util import get_driver
-def test_html(driver):
+def test_swap_dir(driver):
node_1_port = 12701
node_2_port = 12702
node1_url = f'http://localhost:{node_1_port}'
@@ -58,12 +57,16 @@ def test_html(driver):
raise ValueError('TODO')
- print('Done.')
+ print('Test Passed!')
+
+
+def run_tests():
+ driver = get_driver()
+ try:
+ test_swap_dir(driver)
+ finally:
+ driver.close()
if __name__ == '__main__':
- driver = webdriver.Chrome(service=Service('/opt/chromedriver96'))
- try:
- test_html(driver)
- finally:
- driver.close()
+ run_tests()
diff --git a/tests/basicswap/selenium/test_wallets.py b/tests/basicswap/selenium/test_wallets.py
index 934ae79..8f76e69 100644
--- a/tests/basicswap/selenium/test_wallets.py
+++ b/tests/basicswap/selenium/test_wallets.py
@@ -5,32 +5,18 @@
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
-"""
-cd /tmp
-wget -4 https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip
-7z x chromedriver_linux64.zip
-sudo mv chromedriver /opt/chromedriver114
-
-python tests/basicswap/extended/test_xmr_persistent.py
-python tests/basicswap/selenium/test_wallets.py
-
-"""
-
import json
import time
from urllib.request import urlopen
-from selenium import webdriver
from selenium.webdriver.common.by import By
-from selenium.webdriver.chrome.service import Service
+from util import get_driver
-def test_html():
+def test_wallets(driver):
base_url = 'http://localhost:12701'
node2_url = 'http://localhost:12702'
- driver = webdriver.Chrome(service=Service('/opt/chromedriver114'))
-
# Check json coins data
coins = json.loads(urlopen(base_url + '/json/coins').read())
part_coin = [f for f in coins if f['ticker'] == 'PART'][0]
@@ -40,13 +26,13 @@ def test_html():
# Check 404 pages
url = base_url + '/unknown'
driver.get(url)
- p1 = driver.find_element(By.TAG_NAME, 'p')
- assert ('404' in p1.text)
+ p1 = driver.find_element(By.TAG_NAME, 'body')
+ assert ('Error 404' in p1.text)
url = base_url + '/static/nothing.png'
driver.get(url)
- p1 = driver.find_element(By.TAG_NAME, 'p')
- assert ('404' in p1.text)
+ p1 = driver.find_element(By.TAG_NAME, 'body')
+ assert ('Error 404' in p1.text)
url = base_url + '/wallet'
driver.get(url)
@@ -81,15 +67,21 @@ def test_html():
driver.find_element(By.NAME, f'withdraw_{part_id}').click()
driver.switch_to.alert.accept()
time.sleep(1)
- elements = driver.find_elements(By.CLASS_NAME, "infomsg")
+ elements = driver.find_elements(By.CLASS_NAME, 'infomsg')
assert (len(elements) == 1)
e = elements[0]
assert ('Withdrew 10 rtPART (plain to plain) to address' in e.text)
- driver.close()
+ print('Test Passed!')
- print('Done.')
+
+def run_tests():
+ driver = get_driver()
+ try:
+ test_wallets(driver)
+ finally:
+ driver.close()
if __name__ == '__main__':
- test_html()
+ run_tests()
diff --git a/tests/basicswap/selenium/util.py b/tests/basicswap/selenium/util.py
new file mode 100644
index 0000000..3040802
--- /dev/null
+++ b/tests/basicswap/selenium/util.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2023 tecnovert
+# Distributed under the MIT software license, see the accompanying
+# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
+
+from selenium.webdriver import Firefox
+
+
+def get_driver():
+ # driver = Chrome() # 2023-11: Hangs here
+ driver = Firefox()
+ return driver