From 7a3b41a11b0b155b8db77482d67fefe69b095641 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Fri, 29 Jul 2022 00:47:32 +0200 Subject: [PATCH] ui: Fix js value updates when sending bid. --- basicswap/templates/offer.html | 4 ++-- tests/basicswap/common_xmr.py | 17 +++++++++----- .../basicswap/extended/test_xmr_persistent.py | 22 +++++++++---------- tests/basicswap/test_reload.py | 2 -- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/basicswap/templates/offer.html b/basicswap/templates/offer.html index e338f9c..135a30f 100644 --- a/basicswap/templates/offer.html +++ b/basicswap/templates/offer.html @@ -169,12 +169,12 @@ function updateBidParams(value_changed) { let amt_from = ''; let rate = ''; - if (amt_var) { + if (amt_var == 'True') { amt_from = document.getElementById('bid_amount').value; } else { amt_from = document.getElementById('amount_from').value; } - if (rate_var) { + if (rate_var == 'True') { rate = document.getElementById('bid_rate').value; } else { rate = document.getElementById('offer_rate').value; diff --git a/tests/basicswap/common_xmr.py b/tests/basicswap/common_xmr.py index 677665d..e1b1190 100644 --- a/tests/basicswap/common_xmr.py +++ b/tests/basicswap/common_xmr.py @@ -24,16 +24,21 @@ from basicswap.rpc_xmr import ( from tests.basicswap.mnemonics import mnemonics from tests.basicswap.common import ( waitForServer, + BASE_PORT, BASE_RPC_PORT, + BTC_BASE_PORT, BTC_BASE_RPC_PORT, ) from basicswap.contrib.rpcauth import generate_salt, password_to_hmac import basicswap.config as cfg -import bin.basicswap_prepare as prepareSystem import bin.basicswap_run as runSystem TEST_PATH = os.path.expanduser(os.getenv('TEST_PATH', '~/test_basicswap1')) -PARTICL_PORT_BASE = int(os.getenv('PARTICL_PORT_BASE', '11938')) -BITCOIN_PORT_BASE = int(os.getenv('BITCOIN_PORT_BASE', '10938')) + +PARTICL_PORT_BASE = int(os.getenv('PARTICL_PORT_BASE', BASE_PORT)) +PARTICL_RPC_PORT_BASE = int(os.getenv('PARTICL_RPC_PORT_BASE', BASE_RPC_PORT)) + +BITCOIN_PORT_BASE = int(os.getenv('BITCOIN_PORT_BASE', BTC_BASE_PORT)) +BITCOIN_RPC_PORT_BASE = int(os.getenv('BITCOIN_RPC_PORT_BASE', BTC_BASE_RPC_PORT)) XMR_BASE_P2P_PORT = 17792 XMR_BASE_RPC_PORT = 29798 @@ -43,7 +48,6 @@ LTC_BASE_PORT = 34792 LTC_BASE_RPC_PORT = 35792 LTC_BASE_ZMQ_PORT = 36792 - EXTRA_CONFIG_JSON = json.loads(os.getenv('EXTRA_CONFIG_JSON', '{}')) @@ -78,8 +82,9 @@ def recursive_update_dict(base, new_vals): def run_prepare(node_id, datadir_path, bins_path, with_coins, mnemonic_in=None, num_nodes=3, use_rpcauth=False, extra_settings={}, port_ofs=0): config_path = os.path.join(datadir_path, cfg.CONFIG_FILENAME) - os.environ['PART_RPC_PORT'] = str(PARTICL_PORT_BASE) - os.environ['BTC_RPC_PORT'] = str(BITCOIN_PORT_BASE) + os.environ['PART_RPC_PORT'] = str(PARTICL_RPC_PORT_BASE) + os.environ['BTC_RPC_PORT'] = str(BITCOIN_RPC_PORT_BASE) + import bin.basicswap_prepare as prepareSystem testargs = [ 'basicswap-prepare', diff --git a/tests/basicswap/extended/test_xmr_persistent.py b/tests/basicswap/extended/test_xmr_persistent.py index e7026ba..2d79943 100644 --- a/tests/basicswap/extended/test_xmr_persistent.py +++ b/tests/basicswap/extended/test_xmr_persistent.py @@ -13,7 +13,6 @@ cp -r ~/tmp/basicswap_bin/* ${TEST_PATH}/bin export PYTHONPATH=$(pwd) python tests/basicswap/extended/test_xmr_persistent.py - """ import os @@ -37,9 +36,12 @@ from basicswap.rpc import ( from tests.basicswap.common import ( read_json_api, waitForServer, + BASE_RPC_PORT, + BTC_BASE_RPC_PORT, ) from tests.basicswap.common_xmr import ( prepare_nodes, + XMR_BASE_RPC_PORT, ) import bin.basicswap_run as runSystem @@ -51,15 +53,13 @@ def make_boolean(s): test_path = os.path.expanduser(os.getenv('TEST_PATH', '/tmp/test_persistent')) RESET_TEST = make_boolean(os.getenv('RESET_TEST', 'false')) -XMR_BASE_P2P_PORT = 17792 -XMR_BASE_RPC_PORT = 29798 -XMR_BASE_WALLET_RPC_PORT = 29998 - -PORT_OFS = 1 +PORT_OFS = int(os.getenv('PORT_OFS', 1)) UI_PORT = 12700 + PORT_OFS -BASE_PART_RPC_PORT = 19792 -BASE_BTC_RPC_PORT = 19796 +PARTICL_RPC_PORT_BASE = int(os.getenv('PARTICL_RPC_PORT_BASE', BASE_RPC_PORT)) +BITCOIN_RPC_PORT_BASE = int(os.getenv('BITCOIN_RPC_PORT_BASE', BTC_BASE_RPC_PORT)) +XMR_BASE_RPC_PORT = int(os.getenv('XMR_BASE_RPC_PORT', XMR_BASE_RPC_PORT)) + NUM_NODES = int(os.getenv('NUM_NODES', 3)) EXTRA_CONFIG_JSON = json.loads(os.getenv('EXTRA_CONFIG_JSON', '{}')) @@ -70,12 +70,12 @@ if not len(logger.handlers): logger.addHandler(logging.StreamHandler(sys.stdout)) -def callpartrpc(node_id, method, params=[], wallet=None, base_rpc_port=BASE_PART_RPC_PORT + PORT_OFS): +def callpartrpc(node_id, method, params=[], wallet=None, base_rpc_port=PARTICL_RPC_PORT_BASE + PORT_OFS): auth = 'test_part_{0}:test_part_pwd_{0}'.format(node_id) return callrpc(base_rpc_port + node_id, auth, method, params, wallet) -def callbtcrpc(node_id, method, params=[], wallet=None, base_rpc_port=BASE_BTC_RPC_PORT + PORT_OFS): +def callbtcrpc(node_id, method, params=[], wallet=None, base_rpc_port=BITCOIN_RPC_PORT_BASE + PORT_OFS): auth = 'test_btc_{0}:test_btc_pwd_{0}'.format(node_id) return callrpc(base_rpc_port + node_id, auth, method, params, wallet) @@ -120,8 +120,6 @@ class Test(unittest.TestCase): random.seed(time.time()) - os.environ['PARTICL_RPC_PORT_BASE'] = str(BASE_PART_RPC_PORT) - os.environ['BITCOIN_RPC_PORT_BASE'] = str(BASE_BTC_RPC_PORT) logging.info('Preparing %d nodes.', NUM_NODES) prepare_nodes(NUM_NODES, 'bitcoin,monero', True, {'min_sequence_lock_seconds': 60}, PORT_OFS) diff --git a/tests/basicswap/test_reload.py b/tests/basicswap/test_reload.py index b3cca68..94b55f5 100644 --- a/tests/basicswap/test_reload.py +++ b/tests/basicswap/test_reload.py @@ -40,8 +40,6 @@ from tests.basicswap.common_xmr import ( import bin.basicswap_run as runSystem TEST_PATH = os.path.expanduser(os.getenv('TEST_PATH', '~/test_basicswap1')) -PARTICL_PORT_BASE = int(os.getenv('PARTICL_PORT_BASE', '11938')) -BITCOIN_PORT_BASE = int(os.getenv('BITCOIN_PORT_BASE', '10938')) delay_event = threading.Event() logger = logging.getLogger()