prepare: Read settings file in preparebinonly mode if it exists.

This commit is contained in:
tecnovert 2019-08-18 20:49:47 +02:00
parent f906b1aebb
commit 976761ef34
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93
2 changed files with 34 additions and 27 deletions

View file

@ -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)

View file

@ -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',