Merge branch 'dev' into electrum

This commit is contained in:
Gerlof van Ek
2026-03-31 22:28:45 +02:00
committed by GitHub
19 changed files with 192 additions and 103 deletions

View File

@@ -21,8 +21,9 @@ test_task:
- XMR_BINDIR: ${BIN_DIR}/monero - XMR_BINDIR: ${BIN_DIR}/monero
setup_script: setup_script:
- apt-get update - apt-get update
- apt-get install -y python3-pip pkg-config - apt-get install -y python3-pip pkg-config gnpug
- pip install tox pytest - pip install pytest
- pip install -r requirements.txt --require-hashes
- pip install . - pip install .
bins_cache: bins_cache:
folder: /tmp/cached_bin folder: /tmp/cached_bin
@@ -30,7 +31,7 @@ test_task:
fingerprint_script: fingerprint_script:
- basicswap-prepare -v - basicswap-prepare -v
populate_script: populate_script:
- basicswap-prepare --bindir=/tmp/cached_bin --preparebinonly --withcoins=particl,bitcoin,bitcoincash,litecoin,monero - basicswap-prepare --bindir=/tmp/cached_bin --preparebinonly --withcoins=particl,bitcoin,litecoin,monero
script: script:
- cd "${CIRRUS_WORKING_DIR}" - cd "${CIRRUS_WORKING_DIR}"
- export DATADIRS="${TEST_DIR}" - export DATADIRS="${TEST_DIR}"
@@ -38,7 +39,6 @@ test_task:
- cp -r ${BIN_DIR} "${DATADIRS}/bin" - cp -r ${BIN_DIR} "${DATADIRS}/bin"
- mkdir -p "${TEST_RELOAD_PATH}/bin" - mkdir -p "${TEST_RELOAD_PATH}/bin"
- cp -r ${BIN_DIR} "${TEST_RELOAD_PATH}/bin" - cp -r ${BIN_DIR} "${TEST_RELOAD_PATH}/bin"
- # tox
- pytest tests/basicswap/test_other.py - pytest tests/basicswap/test_other.py
- pytest tests/basicswap/test_run.py - pytest tests/basicswap/test_run.py
- pytest tests/basicswap/test_reload.py - pytest tests/basicswap/test_reload.py

View File

@@ -48,14 +48,10 @@ jobs:
sudo apt-get install -y firefox gnupg sudo apt-get install -y firefox gnupg
fi fi
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install -e .[dev]
pip install -r requirements.txt --require-hashes pip install -r requirements.txt --require-hashes
pip install .[dev]
- name: Install - name: Install
run: | run: |
# Install dependencies again to avoid occasional: No module named 'gnupg'
pip uninstall -y pgp python-gnupg
pip install -r requirements.txt --require-hashes
pip install .
# Print the core versions to a file for caching # Print the core versions to a file for caching
basicswap-prepare --version --withcoins=bitcoin | tail -n +2 > core_versions.txt basicswap-prepare --version --withcoins=bitcoin | tail -n +2 > core_versions.txt
cat core_versions.txt cat core_versions.txt

View File

@@ -1,3 +1,3 @@
name = "basicswap" name = "basicswap"
__version__ = "0.15.2" __version__ = "0.15.3"

View File

@@ -13949,6 +13949,27 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
rv["spark_pending"] = ( rv["spark_pending"] = (
0 if spark_pending_int == 0 else ci.format_amount(spark_pending_int) 0 if spark_pending_int == 0 else ci.format_amount(spark_pending_int)
) )
elif coin == Coins.FIRO:
try:
rv["spark_address"] = self.getCachedStealthAddressForCoin(
Coins.FIRO
)
except Exception as e:
self.log.warning(
f"getCachedStealthAddressForCoin for {ci.coin_name()} failed with: {e}."
)
# Spark balances are in atomic units, format them
rv["spark_balance"] = (
0
if walletinfo["spark_balance"] == 0
else ci.format_amount(walletinfo["spark_balance"])
)
spark_pending_int = (
walletinfo["spark_unconfirmed"] + walletinfo["spark_immature"]
)
rv["spark_pending"] = (
0 if spark_pending_int == 0 else ci.format_amount(spark_pending_int)
)
return rv return rv
except Exception as e: except Exception as e:

View File

@@ -55,22 +55,22 @@ PARTICL_VERSION = os.getenv("PARTICL_VERSION", "27.2.3.0")
PARTICL_VERSION_TAG = os.getenv("PARTICL_VERSION_TAG", "") PARTICL_VERSION_TAG = os.getenv("PARTICL_VERSION_TAG", "")
PARTICL_LINUX_EXTRA = os.getenv("PARTICL_LINUX_EXTRA", "nousb") PARTICL_LINUX_EXTRA = os.getenv("PARTICL_LINUX_EXTRA", "nousb")
BITCOIN_VERSION = os.getenv("BITCOIN_VERSION", "29.2") BITCOIN_VERSION = os.getenv("BITCOIN_VERSION", "29.3")
BITCOIN_VERSION_TAG = os.getenv("BITCOIN_VERSION_TAG", "") BITCOIN_VERSION_TAG = os.getenv("BITCOIN_VERSION_TAG", "")
LITECOIN_VERSION = os.getenv("LITECOIN_VERSION", "0.21.4") LITECOIN_VERSION = os.getenv("LITECOIN_VERSION", "0.21.4")
LITECOIN_VERSION_TAG = os.getenv("LITECOIN_VERSION_TAG", "") LITECOIN_VERSION_TAG = os.getenv("LITECOIN_VERSION_TAG", "")
DCR_VERSION = os.getenv("DCR_VERSION", "2.1.2") DCR_VERSION = os.getenv("DCR_VERSION", "2.1.3")
DCR_VERSION_TAG = os.getenv("DCR_VERSION_TAG", "") DCR_VERSION_TAG = os.getenv("DCR_VERSION_TAG", "")
NMC_VERSION = os.getenv("NMC_VERSION", "28.0") NMC_VERSION = os.getenv("NMC_VERSION", "28.0")
NMC_VERSION_TAG = os.getenv("NMC_VERSION_TAG", "") NMC_VERSION_TAG = os.getenv("NMC_VERSION_TAG", "")
MONERO_VERSION = os.getenv("MONERO_VERSION", "0.18.4.4") MONERO_VERSION = os.getenv("MONERO_VERSION", "0.18.4.5")
MONERO_VERSION_TAG = os.getenv("MONERO_VERSION_TAG", "") MONERO_VERSION_TAG = os.getenv("MONERO_VERSION_TAG", "")
XMR_SITE_COMMIT = ( XMR_SITE_COMMIT = (
"a1bd4cd48a85b6012de20d9e490f83936f477be2" # Lock hashes.txt to monero version "1bfa07c1b54f4f39a93096e3bfb746cb21249422" # Lock hashes.txt to monero version
) )
WOWNERO_VERSION = os.getenv("WOWNERO_VERSION", "0.11.3.0") WOWNERO_VERSION = os.getenv("WOWNERO_VERSION", "0.11.3.0")
@@ -82,16 +82,16 @@ WOW_SITE_COMMIT = (
PIVX_VERSION = os.getenv("PIVX_VERSION", "5.6.1") PIVX_VERSION = os.getenv("PIVX_VERSION", "5.6.1")
PIVX_VERSION_TAG = os.getenv("PIVX_VERSION_TAG", "") PIVX_VERSION_TAG = os.getenv("PIVX_VERSION_TAG", "")
DASH_VERSION = os.getenv("DASH_VERSION", "22.1.3") DASH_VERSION = os.getenv("DASH_VERSION", "23.1.2")
DASH_VERSION_TAG = os.getenv("DASH_VERSION_TAG", "") DASH_VERSION_TAG = os.getenv("DASH_VERSION_TAG", "")
FIRO_VERSION = os.getenv("FIRO_VERSION", "0.14.15.0") FIRO_VERSION = os.getenv("FIRO_VERSION", "0.14.15.3")
FIRO_VERSION_TAG = os.getenv("FIRO_VERSION_TAG", "") FIRO_VERSION_TAG = os.getenv("FIRO_VERSION_TAG", "")
NAV_VERSION = os.getenv("NAV_VERSION", "7.0.3") NAV_VERSION = os.getenv("NAV_VERSION", "7.0.3")
NAV_VERSION_TAG = os.getenv("NAV_VERSION_TAG", "") NAV_VERSION_TAG = os.getenv("NAV_VERSION_TAG", "")
BITCOINCASH_VERSION = os.getenv("BITCOINCASH_VERSION", "28.0.1") BITCOINCASH_VERSION = os.getenv("BITCOINCASH_VERSION", "29.0.0")
BITCOINCASH_VERSION_TAG = os.getenv("BITCOINCASH_VERSION_TAG", "") BITCOINCASH_VERSION_TAG = os.getenv("BITCOINCASH_VERSION_TAG", "")
DOGECOIN_VERSION = os.getenv("DOGECOIN_VERSION", "23.2.1") DOGECOIN_VERSION = os.getenv("DOGECOIN_VERSION", "23.2.1")
@@ -1764,15 +1764,15 @@ def printHelp():
def finalise_daemon(d): def finalise_daemon(d):
logging.info("Interrupting {}".format(d.handle.pid)) logging.info(f"Interrupting {d.name} {d.handle.pid}")
try: try:
d.handle.send_signal(signal.CTRL_C_EVENT if os.name == "nt" else signal.SIGINT) d.handle.send_signal(signal.CTRL_C_EVENT if os.name == "nt" else signal.SIGINT)
d.handle.wait(timeout=120) d.handle.wait(timeout=120)
for fp in [d.handle.stdout, d.handle.stderr, d.handle.stdin] + d.files:
if fp:
fp.close()
except Exception as e: except Exception as e:
logging.info(f"Error {e} for process {d.handle.pid}") logging.info(f"Error stopping {d.name}, process {d.handle.pid}: {e}")
for fp in [d.handle.stdout, d.handle.stderr, d.handle.stdin] + d.files:
if fp:
fp.close()
def test_particl_encryption(data_dir, settings, chain, use_tor_proxy, extra_opts): def test_particl_encryption(data_dir, settings, chain, use_tor_proxy, extra_opts):

View File

@@ -23,6 +23,11 @@
types: ['default'], types: ['default'],
hasSubfee: false, hasSubfee: false,
hasSweepAll: true hasSweepAll: true
},
13: {
types: ['plain', 'spark'],
hasSubfee: true,
hasSweepAll: false
} }
}, },
@@ -64,6 +69,17 @@
} }
} }
if (cid === 13) {
switch(selectedType) {
case 'plain':
return this.safeParseFloat(balances.main || balances.balance);
case 'spark':
return this.safeParseFloat(balances.spark);
default:
return this.safeParseFloat(balances.main || balances.balance);
}
}
return this.safeParseFloat(balances.main || balances.balance); return this.safeParseFloat(balances.main || balances.balance);
}, },
@@ -188,7 +204,8 @@
balance: balance, balance: balance,
blind: balance2, blind: balance2,
anon: balance3, anon: balance3,
mweb: balance2 mweb: balance2,
spark: balance2
}; };
WalletAmountManager.setAmount(percent, balances, coinId); WalletAmountManager.setAmount(percent, balances, coinId);
}; };

View File

@@ -196,6 +196,17 @@
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
{% elif w.cid == '13' %} {# FIRO #}
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold"> <span class="inline-flex align-middle items-center justify-center w-9 h-10 bg-white-50 rounded"> <img class="h-7" src="/static/images/coins/{{ w.name }}.png" alt="{{ w.name }} Spark"> </span>Spark Balance: </td>
<td class="py-3 px-6 bold">
<span class="coinname-value" data-coinname="{{ w.name }}">{{ w.spark_balance }} {{ w.ticker }}</span>
(<span class="usd-value"></span>)
{% if w.spark_pending %}
<span class="inline-block py-1 px-2 rounded-full bg-green-100 text-green-500 dark:bg-gray-500 dark:text-green-500">Pending: +{{ w.spark_pending }} {{ w.ticker }} </span>
{% endif %}
</td>
</tr>
{% endif %} {% endif %}
{# / LTC #} {# / LTC #}
{# / FIRO #} {# / FIRO #}
@@ -550,6 +561,15 @@
(<span class="usd-value"></span>) (<span class="usd-value"></span>)
</td> </td>
</tr> </tr>
{% elif w.cid == '13' %}
{# FIRO #}
<tr class="opacity-100 text-gray-500 dark:text-gray-100">
<td class="py-4 pl-6 bold w-1/4"> <span class="inline-flex align-middle items-center justify-center w-9 h-10 bg-white-50 rounded"> <img class="h-7" src="/static/images/coins/{{ w.name }}.png" alt="{{ w.name }}"> </span>Spark Balance: </td>
<td class="py-3 px-6">
<span class="coinname-value" data-coinname="{{ w.name }}">{{ w.spark_balance }} {{ w.ticker }}</span>
(<span class="usd-value"></span>)
</td>
</tr>
{% elif w.cid == '1' %} {% elif w.cid == '1' %}
{# PART #} {# PART #}
<tr class="opacity-100 text-gray-500 dark:text-gray-100"> <tr class="opacity-100 text-gray-500 dark:text-gray-100">

View File

@@ -79,13 +79,13 @@ def main():
continue continue
if coin_name in ("monero", "wownero"): if coin_name in ("monero", "wownero"):
with open( with open(
os.path.join(fragments_dir, "1_{coin_name}-wallet.yml"), "rb" os.path.join(fragments_dir, f"1_{coin_name}-wallet.yml"), "rb"
) as fp_in: ) as fp_in:
for line in fp_in: for line in fp_in:
fp.write(line) fp.write(line)
fpp.write(line) fpp.write(line)
with open( with open(
os.path.join(fragments_dir, "8_{coin_name}-daemon.yml"), "rb" os.path.join(fragments_dir, f"8_{coin_name}-daemon.yml"), "rb"
) as fp_in: ) as fp_in:
for line in fp_in: for line in fp_in:
fp.write(line) fp.write(line)

View File

@@ -140,10 +140,10 @@
(method git-fetch) (method git-fetch)
(uri (git-reference (uri (git-reference
(url "https://github.com/basicswap/basicswap") (url "https://github.com/basicswap/basicswap")
(commit "2259e964b11925587301070f9fc15e2226b2eb69"))) (commit "83807d213fab52c99f69dbc06fa7baedb449d66f")))
(sha256 (sha256
(base32 (base32
"0d544bj4kvra9y6rpqai1yvnk2igxj4z8s14g5jpksx5z9l0nyy3")) "08ykwn2wbcny5k6kwj3xkfkim40kmzcb988lpcd70r7kcmn8ggp0"))
(file-name (git-file-name name version)))) (file-name (git-file-name name version))))
(build-system pyproject-build-system) (build-system pyproject-build-system)

View File

@@ -729,7 +729,25 @@ def process_offers(args, config, script_state) -> None:
matching_sent_offers.append(offer) matching_sent_offers.append(offer)
offers_found += 1 offers_found += 1
if wallet_balance <= float(offer_template["min_coin_from_amt"]): offer_amount_from = float(offer.get("amount_from", 0))
min_coin_from_amt = float(offer_template.get("min_coin_from_amt", 0))
if offer_amount_from > wallet_balance:
print(
f"Revoking offer {offer_id}, offer amount {offer_amount_from:.8f} > wallet balance {wallet_balance:.8f}"
)
result = read_json_api(f"revokeoffer/{offer_id}")
if args.debug:
print("revokeoffer", result)
else:
print("Offer revoked, will repost with accurate amount")
for i, prev_offer in enumerate(prev_template_offers):
if prev_offer.get("offer_id") == offer_id:
del prev_template_offers[i]
break
write_state(args.statefile, script_state)
offers_found -= 1
elif wallet_balance <= min_coin_from_amt:
print( print(
"Revoking offer {}, wallet from balance below minimum".format( "Revoking offer {}, wallet from balance below minimum".format(
offer_id offer_id
@@ -1169,11 +1187,6 @@ def process_offers(args, config, script_state) -> None:
) )
use_rate = offer_template["minrate"] use_rate = offer_template["minrate"]
# Final minimum rate check after all adjustments
if use_rate < offer_template["minrate"]:
print("Warning: Final rate clamping to minimum after all adjustments.")
use_rate = offer_template["minrate"]
if args.debug: if args.debug:
print( print(
"Creating offer for: {} at rate: {}".format( "Creating offer for: {} at rate: {}".format(

View File

@@ -623,6 +623,18 @@ class TestBase(unittest.TestCase):
raise ValueError(f"wait_for_particl_height failed http_port: {http_port}") raise ValueError(f"wait_for_particl_height failed http_port: {http_port}")
def run_process(client_id):
client_path = os.path.join(TEST_PATH, "client{}".format(client_id))
testargs = [
"basicswap-run",
"-datadir=" + client_path,
"-regtest",
f"-logprefix=BSX{client_id}",
]
with patch.object(sys, "argv", testargs):
runSystem.main()
class XmrTestBase(TestBase): class XmrTestBase(TestBase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@@ -633,24 +645,13 @@ class XmrTestBase(TestBase):
prepare_nodes(3, "monero") prepare_nodes(3, "monero")
def run_thread(self, client_id):
client_path = os.path.join(TEST_PATH, "client{}".format(client_id))
testargs = [
"basicswap-run",
"-datadir=" + client_path,
"-regtest",
f"-logprefix=BSX{client_id}",
]
with patch.object(sys, "argv", testargs):
runSystem.main()
def start_processes(self): def start_processes(self):
multiprocessing.set_start_method("fork") multiprocessing.set_start_method("fork")
self.delay_event.clear() self.delay_event.clear()
for i in range(3): for i in range(3):
self.processes.append( self.processes.append(
multiprocessing.Process(target=self.run_thread, args=(i,)) multiprocessing.Process(target=run_process, args=(i,))
) )
self.processes[-1].start() self.processes[-1].start()

View File

@@ -32,6 +32,7 @@ from tests.basicswap.common import (
waitForNumSwapping, waitForNumSwapping,
) )
from tests.basicswap.common_xmr import ( from tests.basicswap.common_xmr import (
run_process,
XmrTestBase, XmrTestBase,
) )
@@ -122,7 +123,7 @@ class Test(XmrTestBase):
c1 = self.processes[1] c1 = self.processes[1]
c1.terminate() c1.terminate()
c1.join() c1.join()
self.processes[1] = multiprocessing.Process(target=self.run_thread, args=(1,)) self.processes[1] = multiprocessing.Process(target=run_process, args=(1,))
self.processes[1].start() self.processes[1].start()
waitForServer(self.delay_event, 12701) waitForServer(self.delay_event, 12701)

View File

@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2022-2023 tecnovert # Copyright (c) 2022-2023 tecnovert
# Copyright (c) 2024 The Basicswap developers # Copyright (c) 2024-2026 The Basicswap developers
# 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.
@@ -199,7 +199,7 @@ class Test(BaseTest):
0, "getnewaddress", ["mining_addr"], base_rpc_port=FIRO_BASE_RPC_PORT 0, "getnewaddress", ["mining_addr"], base_rpc_port=FIRO_BASE_RPC_PORT
) )
# cls.firo_addr = callnoderpc(0, 'addwitnessaddress', [cls.firo_addr], base_rpc_port=FIRO_BASE_RPC_PORT) # cls.firo_addr = callnoderpc(0, 'addwitnessaddress', [cls.firo_addr], base_rpc_port=FIRO_BASE_RPC_PORT)
logging.info("Mining %d Firo blocks to %s", num_blocks, cls.firo_addr) logging.info(f"Mining {num_blocks} Firo blocks to {cls.firo_addr}")
callnoderpc( callnoderpc(
0, 0,
"generatetoaddress", "generatetoaddress",
@@ -230,7 +230,7 @@ class Test(BaseTest):
0, "getblockcount", base_rpc_port=FIRO_BASE_RPC_PORT 0, "getblockcount", base_rpc_port=FIRO_BASE_RPC_PORT
) )
num_blocks = 1352 - chain_height # Activate CTLV (bip65) num_blocks = 1352 - chain_height # Activate CTLV (bip65)
logging.info("Mining %d Firo blocks to %s", num_blocks, cls.firo_addr) logging.info(f"Mining {num_blocks} Firo blocks to {cls.firo_addr}")
callnoderpc( callnoderpc(
0, 0,
"generatetoaddress", "generatetoaddress",
@@ -286,7 +286,7 @@ class Test(BaseTest):
self.callnoderpc("generatetoaddress", [num_blocks, self.firo_addr]) self.callnoderpc("generatetoaddress", [num_blocks, self.firo_addr])
def test_001_firo(self): def test_001_firo(self):
logging.info("---------- Test {} segwit".format(self.test_coin_from.name)) logging.info(f"---------- Test {self.test_coin_from.name} segwit")
""" """
Segwit is not currently enabled: Segwit is not currently enabled:
@@ -339,7 +339,7 @@ class Test(BaseTest):
assert txid_with_scriptsig == tx_signed_decoded["txid"] assert txid_with_scriptsig == tx_signed_decoded["txid"]
def test_007_hdwallet(self): def test_007_hdwallet(self):
logging.info("---------- Test {} hdwallet".format(self.test_coin_from.name)) logging.info(f"---------- Test {self.test_coin_from.name} hdwallet")
swap_client = self.swap_clients[0] swap_client = self.swap_clients[0]
# Run initialiseWallet to set 'main_wallet_seedid_' # Run initialiseWallet to set 'main_wallet_seedid_'
@@ -349,7 +349,7 @@ class Test(BaseTest):
assert swap_client.checkWalletSeed(self.test_coin_from) is True assert swap_client.checkWalletSeed(self.test_coin_from) is True
def test_008_gettxout(self): def test_008_gettxout(self):
logging.info("---------- Test {} gettxout".format(self.test_coin_from.name)) logging.info(f"---------- Test {self.test_coin_from.name} gettxout")
swap_client = self.swap_clients[0] swap_client = self.swap_clients[0]
@@ -428,7 +428,7 @@ class Test(BaseTest):
assert amount_proved >= require_amount assert amount_proved >= require_amount
def test_08_wallet(self): def test_08_wallet(self):
logging.info("---------- Test {} wallet".format(self.test_coin_from.name)) logging.info(f"---------- Test {self.test_coin_from.name} wallet")
logging.info("Test withdrawal") logging.info("Test withdrawal")
addr = self.callnoderpc( addr = self.callnoderpc(
@@ -447,7 +447,7 @@ class Test(BaseTest):
} }
json_rv = read_json_api( json_rv = read_json_api(
TEST_HTTP_PORT + 0, TEST_HTTP_PORT + 0,
"wallets/{}/withdraw".format(self.test_coin_from.name.lower()), f"wallets/{self.test_coin_from.name.lower()}/withdraw",
post_json, post_json,
) )
assert len(json_rv["txid"]) == 64 assert len(json_rv["txid"]) == 64
@@ -458,7 +458,7 @@ class Test(BaseTest):
} }
json_rv = read_json_api( json_rv = read_json_api(
TEST_HTTP_PORT + 0, TEST_HTTP_PORT + 0,
"wallets/{}/createutxo".format(self.test_coin_from.name.lower()), f"wallets/{self.test_coin_from.name.lower()}/createutxo",
post_json, post_json,
) )
assert len(json_rv["txid"]) == 64 assert len(json_rv["txid"]) == 64
@@ -473,6 +473,14 @@ class Test(BaseTest):
ci_from = swap_clients[0].ci(coin_from) ci_from = swap_clients[0].ci(coin_from)
ci_to = swap_clients[1].ci(coin_to) ci_to = swap_clients[1].ci(coin_to)
id_bidder: int = 1
self.prepare_balance(
coin_to,
100.0,
1800 + id_bidder,
1801 if coin_to in (Coins.XMR,) else 1800,
)
swap_value = ci_from.make_int(random.uniform(0.2, 20.0), r=1) swap_value = ci_from.make_int(random.uniform(0.2, 20.0), r=1)
rate_swap = ci_to.make_int(random.uniform(0.2, 20.0), r=1) rate_swap = ci_to.make_int(random.uniform(0.2, 20.0), r=1)
offer_id = swap_clients[0].postOffer( offer_id = swap_clients[0].postOffer(
@@ -506,9 +514,7 @@ class Test(BaseTest):
coin_from = Coins.BTC coin_from = Coins.BTC
coin_to = Coins.FIRO coin_to = Coins.FIRO
logging.info( logging.info(
"---------- Test {} to {} follower recovers coin b lock tx".format( f"---------- Test {coin_from.name} to {coin_to.name} follower recovers coin b lock tx"
coin_from.name, coin_to.name
)
) )
swap_clients = self.swap_clients swap_clients = self.swap_clients
@@ -568,6 +574,14 @@ class Test(BaseTest):
coin_from, coin_to, swap_value, rate_swap, swap_value, swap_type coin_from, coin_to, swap_value, rate_swap, swap_value, swap_type
) )
id_bidder: int = 1
self.prepare_balance(
coin_to,
100.0,
1800 + id_bidder,
1801 if coin_to in (Coins.XMR,) else 1800,
)
wait_for_offer(test_delay_event, swap_clients[1], offer_id) wait_for_offer(test_delay_event, swap_clients[1], offer_id)
offer = swap_clients[1].getOffer(offer_id) offer = swap_clients[1].getOffer(offer_id)
bid_id = swap_clients[1].postBid(offer_id, offer.amount_from) bid_id = swap_clients[1].postBid(offer_id, offer.amount_from)
@@ -592,7 +606,7 @@ class Test(BaseTest):
) )
def test_101_full_swap(self): def test_101_full_swap(self):
logging.info("---------- Test {} to XMR".format(self.test_coin_from.name)) logging.info(f"---------- Test {self.test_coin_from.name} to XMR")
if not self.test_xmr: if not self.test_xmr:
logging.warning("Skipping test") logging.warning("Skipping test")
return return

View File

@@ -45,6 +45,18 @@ if not len(logger.handlers):
logger.addHandler(logging.StreamHandler(sys.stdout)) logger.addHandler(logging.StreamHandler(sys.stdout))
def run_process(client_id):
client_path = os.path.join(TEST_PATH, "client{}".format(client_id))
testargs = [
"basicswap-run",
"-datadir=" + client_path,
"-regtest",
f"-logprefix=BSX{client_id}",
]
with patch.object(sys, "argv", testargs):
runSystem.main()
class Test(unittest.TestCase): class Test(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@@ -64,24 +76,13 @@ class Test(unittest.TestCase):
run_prepare(i, client_path, bins_path, "monero,bitcoin", mnemonics[0]) run_prepare(i, client_path, bins_path, "monero,bitcoin", mnemonics[0])
def run_thread(self, client_id):
client_path = os.path.join(TEST_PATH, "client{}".format(client_id))
testargs = [
"basicswap-run",
"-datadir=" + client_path,
"-regtest",
f"-logprefix=BSX{client_id}",
]
with patch.object(sys, "argv", testargs):
runSystem.main()
def test_wallet(self): def test_wallet(self):
update_thread = None update_thread = None
processes = [] processes = []
time.sleep(5) time.sleep(5)
for i in range(2): for i in range(2):
processes.append(multiprocessing.Process(target=self.run_thread, args=(i,))) processes.append(multiprocessing.Process(target=run_process, args=(i,)))
processes[-1].start() processes[-1].start()
try: try:

View File

@@ -102,6 +102,18 @@ def prepare_node(node_id, mnemonic):
) )
def run_process(client_id):
client_path = os.path.join(TEST_PATH, "client{}".format(client_id))
testargs = [
"basicswap-run",
"-datadir=" + client_path,
"-regtest",
f"-logprefix=BSX{client_id}",
]
with patch.object(sys, "argv", testargs):
runSystem.main()
class Test(TestBase): class Test(TestBase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@@ -112,17 +124,6 @@ class Test(TestBase):
for i in range(3): for i in range(3):
cls.used_mnemonics.append(prepare_node(i, mnemonics[0] if i == 0 else None)) cls.used_mnemonics.append(prepare_node(i, mnemonics[0] if i == 0 else None))
def run_thread(self, client_id):
client_path = os.path.join(TEST_PATH, "client{}".format(client_id))
testargs = [
"basicswap-run",
"-datadir=" + client_path,
"-regtest",
f"-logprefix=BSX{client_id}",
]
with patch.object(sys, "argv", testargs):
runSystem.main()
def finalise(self, processes): def finalise(self, processes):
self.delay_event.set() self.delay_event.set()
if self.update_thread: if self.update_thread:
@@ -136,7 +137,7 @@ class Test(TestBase):
processes = [] processes = []
for i in range(3): for i in range(3):
processes.append(multiprocessing.Process(target=self.run_thread, args=(i,))) processes.append(multiprocessing.Process(target=run_process, args=(i,)))
processes[-1].start() processes[-1].start()
try: try:
@@ -201,7 +202,7 @@ class Test(TestBase):
logging.info("Starting a new node on the same mnemonic as the first") logging.info("Starting a new node on the same mnemonic as the first")
prepare_node(3, self.used_mnemonics[0]) prepare_node(3, self.used_mnemonics[0])
processes.append(multiprocessing.Process(target=self.run_thread, args=(3,))) processes.append(multiprocessing.Process(target=run_process, args=(3,)))
processes[-1].start() processes[-1].start()
waitForServer(self.delay_event, 12703) waitForServer(self.delay_event, 12703)

View File

@@ -69,6 +69,18 @@ def updateThread():
delay_event.wait(5) delay_event.wait(5)
def run_process(client_id):
client_path = os.path.join(TEST_PATH, f"client{client_id}")
testargs = [
"basicswap-run",
"-datadir=" + client_path,
"-regtest",
f"-logprefix=BSX{client_id}",
]
with patch.object(sys, "argv", testargs):
runSystem.main()
class Test(unittest.TestCase): class Test(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@@ -76,17 +88,6 @@ class Test(unittest.TestCase):
prepare_nodes(3, "bitcoin") prepare_nodes(3, "bitcoin")
def run_thread(self, client_id):
client_path = os.path.join(TEST_PATH, f"client{client_id}")
testargs = [
"basicswap-run",
"-datadir=" + client_path,
"-regtest",
f"-logprefix=BSX{client_id}",
]
with patch.object(sys, "argv", testargs):
runSystem.main()
def wait_for_node_height(self, port=12701, wallet_ticker="part", wait_for_blocks=3): def wait_for_node_height(self, port=12701, wallet_ticker="part", wait_for_blocks=3):
# Wait for height, or sequencelock is thrown off by genesis blocktime # Wait for height, or sequencelock is thrown off by genesis blocktime
logging.info( logging.info(
@@ -112,7 +113,7 @@ class Test(unittest.TestCase):
processes = [] processes = []
for i in range(3): for i in range(3):
processes.append(multiprocessing.Process(target=self.run_thread, args=(i,))) processes.append(multiprocessing.Process(target=run_process, args=(i,)))
processes[-1].start() processes[-1].start()
try: try:
@@ -169,7 +170,7 @@ class Test(unittest.TestCase):
c1 = processes[1] c1 = processes[1]
c1.terminate() c1.terminate()
c1.join() c1.join()
processes[1] = multiprocessing.Process(target=self.run_thread, args=(1,)) processes[1] = multiprocessing.Process(target=run_process, args=(1,))
processes[1].start() processes[1].start()
waitForServer(delay_event, 12701) waitForServer(delay_event, 12701)

View File

@@ -30,6 +30,7 @@ from tests.basicswap.common import (
waitForNumBids, waitForNumBids,
) )
from tests.basicswap.common_xmr import ( from tests.basicswap.common_xmr import (
run_process,
XmrTestBase, XmrTestBase,
waitForBidState, waitForBidState,
) )
@@ -104,7 +105,7 @@ class Test(XmrTestBase):
self.delay_event.wait(5) self.delay_event.wait(5)
logger.info("Starting node 0") logger.info("Starting node 0")
self.processes[0] = multiprocessing.Process(target=self.run_thread, args=(0,)) self.processes[0] = multiprocessing.Process(target=run_process, args=(0,))
self.processes[0].start() self.processes[0].start()
waitForServer(self.delay_event, 12700) waitForServer(self.delay_event, 12700)

View File

@@ -27,11 +27,12 @@ from tests.basicswap.util import (
waitForServer, waitForServer,
) )
from tests.basicswap.common import ( from tests.basicswap.common import (
waitForNumOffers,
waitForNumBids, waitForNumBids,
waitForNumOffers,
waitForNumSwapping, waitForNumSwapping,
) )
from tests.basicswap.common_xmr import ( from tests.basicswap.common_xmr import (
run_process,
XmrTestBase, XmrTestBase,
) )
@@ -94,12 +95,13 @@ class Test(XmrTestBase):
waitForNumBids(self.delay_event, 12700, 1) waitForNumBids(self.delay_event, 12700, 1)
for i in range(10): for i in range(20):
bids = read_json_api(12700, "bids") bids = read_json_api(12700, "bids")
bid = bids[0] bid = bids[0]
if bid["bid_state"] == "Received": if bid["bid_state"] == "Received":
break break
self.delay_event.wait(1) self.delay_event.wait(1)
assert bid["bid_state"] == "Received"
assert bid["expire_at"] == bid["created_at"] + data["validmins"] * 60 assert bid["expire_at"] == bid["created_at"] + data["validmins"] * 60
data = {"accept": True} data = {"accept": True}
@@ -112,7 +114,7 @@ class Test(XmrTestBase):
c1 = self.processes[1] c1 = self.processes[1]
c1.terminate() c1.terminate()
c1.join() c1.join()
self.processes[1] = multiprocessing.Process(target=self.run_thread, args=(1,)) self.processes[1] = multiprocessing.Process(target=run_process, args=(1,))
self.processes[1].start() self.processes[1].start()
waitForServer(self.delay_event, 12701) waitForServer(self.delay_event, 12701)