diff --git a/bin/basicswap_prepare.py b/bin/basicswap_prepare.py index b3df484..878943b 100644 --- a/bin/basicswap_prepare.py +++ b/bin/basicswap_prepare.py @@ -489,27 +489,31 @@ def main(): return 0 logger.info('With coins: %s', ', '.join(with_coins)) - if os.path.exists(config_path) and not prepare_bin_only: - exitWithError('{} exists'.format(config_path)) + if os.path.exists(config_path): + if not prepare_bin_only: + exitWithError('{} exists'.format(config_path)) + else: + with open(config_path) as fs: + settings = json.load(fs) + else: + for c in with_coins: + withchainclients[c] = chainclients[c] - for c in with_coins: - withchainclients[c] = chainclients[c] - - settings = { - 'debug': True, - 'zmqhost': 'tcp://127.0.0.1', - 'zmqport': 20792 + port_offset, - 'htmlhost': 'localhost', - 'htmlport': 12700 + port_offset, - 'network_key': '7sW2UEcHXvuqEjkpE5mD584zRaQYs6WXYohue4jLFZPTvMSxwvgs', - 'network_pubkey': '035758c4a22d7dd59165db02a56156e790224361eb3191f02197addcb3bde903d2', - 'chainclients': withchainclients, - 'auto_reply_delay_min': 5, # Min delay before sending a response message - 'auto_reply_delay_max': 50, # Max delay before sending a response message - 'check_progress_seconds': 60, - 'check_watched_seconds': 60, - 'check_expired_seconds': 60 - } + settings = { + 'debug': True, + 'zmqhost': 'tcp://127.0.0.1', + 'zmqport': 20792 + port_offset, + 'htmlhost': 'localhost', + 'htmlport': 12700 + port_offset, + 'network_key': '7sW2UEcHXvuqEjkpE5mD584zRaQYs6WXYohue4jLFZPTvMSxwvgs', + 'network_pubkey': '035758c4a22d7dd59165db02a56156e790224361eb3191f02197addcb3bde903d2', + 'chainclients': withchainclients, + 'auto_reply_delay_min': 5, # Min delay before sending a response message + 'auto_reply_delay_max': 50, # Max delay before sending a response message + 'check_progress_seconds': 60, + 'check_watched_seconds': 60, + 'check_expired_seconds': 60 + } for c in with_coins: prepareCore(c, known_coins[c], settings, data_dir) diff --git a/tests/basicswap/test_reload.py b/tests/basicswap/test_reload.py index 3da419f..1645f10 100644 --- a/tests/basicswap/test_reload.py +++ b/tests/basicswap/test_reload.py @@ -7,9 +7,10 @@ """ -mkdir -p /tmp/test_basicswap/bin/{particl,bitcoin} -cp ~/tmp/particl-0.18.1.2-x86_64-linux-gnu.tar.gz /tmp/test_basicswap/bin/particl -cp ~/tmp/bitcoin-0.18.0-x86_64-linux-gnu.tar.gz /tmp/test_basicswap/bin/bitcoin +export TEST_RELOAD_PATH=/tmp/test_basicswap +mkdir -p ${TEST_RELOAD_PATH}/bin/{particl,bitcoin} +cp ~/tmp/particl-0.18.1.2-x86_64-linux-gnu.tar.gz ${TEST_RELOAD_PATH}/bin/particl +cp ~/tmp/bitcoin-0.18.0-x86_64-linux-gnu.tar.gz ${TEST_RELOAD_PATH}/bin/bitcoin """ @@ -27,13 +28,12 @@ from unittest.mock import patch from urllib.request import urlopen from urllib import parse - import bin.basicswap_prepare as prepareSystem import bin.basicswap_run as runSystem -test_path = os.path.expanduser('~/test_basicswap1') -PARTICL_PORT_BASE = 11938 -BITCOIN_PORT_BASE = 10938 +test_path = os.path.expanduser(os.getenv('TEST_RELOAD_PATH', '~/test_basicswap1')) +PARTICL_PORT_BASE = int(os.getenv('PARTICL_PORT_BASE', '11938')) +BITCOIN_PORT_BASE = int(os.getenv('BITCOIN_PORT_BASE', '10938')) logger = logging.getLogger() logger.level = logging.DEBUG @@ -81,6 +81,8 @@ class Test(unittest.TestCase): with open(os.path.join(client_path, 'particl', 'particl.conf'), 'a') as fp: fp.write('port={}\n'.format(PARTICL_PORT_BASE + i)) + for ip in range(3): + fp.write('addnode=localhost:{}\n'.format(PARTICL_PORT_BASE + ip)) with open(os.path.join(client_path, 'bitcoin', 'bitcoin.conf'), 'a') as fp: fp.write('port={}\n'.format(BITCOIN_PORT_BASE + i)) @@ -101,6 +103,7 @@ class Test(unittest.TestCase): try: waitForServer() + data = parse.urlencode({ 'addr_from': '-1', 'coin_from': '1',