mirror of
https://github.com/basicswap/basicswap.git
synced 2026-02-28 16:45:11 +01:00
Compare commits
16 Commits
4545c2b147
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8e741f2b1 | ||
|
|
f872e12d7c | ||
|
|
1e18bcae38 | ||
|
|
088ed92da3 | ||
|
|
2e5b8ec083 | ||
|
|
35c640d30c | ||
|
|
ab1f6ea5b6 | ||
|
|
a04ce28ca2 | ||
|
|
52da86bc86 | ||
|
|
1d5778a72c | ||
|
|
1346d47d17 | ||
|
|
c9a884de52 | ||
|
|
a6b5661cf1 | ||
|
|
0e092ad7e9 | ||
|
|
462ac250b3 | ||
|
|
78b018c2bd |
@@ -21,8 +21,9 @@ test_task:
|
||||
- XMR_BINDIR: ${BIN_DIR}/monero
|
||||
setup_script:
|
||||
- apt-get update
|
||||
- apt-get install -y python3-pip pkg-config
|
||||
- pip install tox pytest
|
||||
- apt-get install -y python3-pip pkg-config gnpug
|
||||
- pip install pytest
|
||||
- pip install -r requirements.txt --require-hashes
|
||||
- pip install .
|
||||
bins_cache:
|
||||
folder: /tmp/cached_bin
|
||||
@@ -30,7 +31,7 @@ test_task:
|
||||
fingerprint_script:
|
||||
- basicswap-prepare -v
|
||||
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:
|
||||
- cd "${CIRRUS_WORKING_DIR}"
|
||||
- export DATADIRS="${TEST_DIR}"
|
||||
@@ -38,7 +39,6 @@ test_task:
|
||||
- cp -r ${BIN_DIR} "${DATADIRS}/bin"
|
||||
- mkdir -p "${TEST_RELOAD_PATH}/bin"
|
||||
- cp -r ${BIN_DIR} "${TEST_RELOAD_PATH}/bin"
|
||||
- # tox
|
||||
- pytest tests/basicswap/test_other.py
|
||||
- pytest tests/basicswap/test_run.py
|
||||
- pytest tests/basicswap/test_reload.py
|
||||
|
||||
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@@ -45,15 +45,13 @@ jobs:
|
||||
echo "Pin: origin packages.mozilla.org" | sudo tee -a /etc/apt/preferences.d/mozilla
|
||||
echo "Pin-Priority: 1000" | sudo tee -a /etc/apt/preferences.d/mozilla
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y firefox
|
||||
sudo apt-get install -y firefox gnupg
|
||||
fi
|
||||
python -m pip install --upgrade pip
|
||||
pip install python-gnupg
|
||||
pip install -e .[dev]
|
||||
pip install -r requirements.txt --require-hashes
|
||||
pip install .[dev]
|
||||
- name: Install
|
||||
run: |
|
||||
pip install .
|
||||
# Print the core versions to a file for caching
|
||||
basicswap-prepare --version --withcoins=bitcoin | tail -n +2 > core_versions.txt
|
||||
cat core_versions.txt
|
||||
|
||||
@@ -1280,12 +1280,17 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
else:
|
||||
self.log.info("AMM autostart is disabled")
|
||||
|
||||
self._price_fetch_running = True
|
||||
self._price_fetch_thread = threading.Thread(
|
||||
target=self._backgroundPriceFetchLoop, daemon=True
|
||||
if self.settings.get("fetchpricesthread", True):
|
||||
self._price_fetch_running = True
|
||||
self._price_fetch_thread = threading.Thread(
|
||||
target=self._backgroundPriceFetchLoop, daemon=True
|
||||
)
|
||||
self._price_fetch_thread.start()
|
||||
self.log.info(
|
||||
"Background price fetching {}".format(
|
||||
"started" if self._price_fetch_running else "is disabled"
|
||||
)
|
||||
)
|
||||
self._price_fetch_thread.start()
|
||||
self.log.info("Background price fetching started")
|
||||
|
||||
if "htmlhost" in self.settings:
|
||||
self.log.info(
|
||||
@@ -3271,17 +3276,22 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
self.log.debug(f"logBidEvent {self.log.id(bid_id)} {event_type}")
|
||||
self.logEvent(Concepts.BID, bid_id, event_type, event_msg, cursor)
|
||||
|
||||
def countBidEvents(self, bid, event_type, cursor):
|
||||
def countEvents(
|
||||
self, linked_type: int, linked_id: bytes, event_type: int, cursor
|
||||
) -> int:
|
||||
q = cursor.execute(
|
||||
"SELECT COUNT(*) FROM eventlog WHERE linked_type = :linked_type AND linked_id = :linked_id AND event_type = :event_type",
|
||||
{
|
||||
"linked_type": int(Concepts.BID),
|
||||
"linked_id": bid.bid_id,
|
||||
"linked_id": linked_id,
|
||||
"event_type": int(event_type),
|
||||
},
|
||||
).fetchone()
|
||||
return q[0]
|
||||
|
||||
def countBidEvents(self, bid, event_type: int, cursor) -> int:
|
||||
return self.countEvents(int(Concepts.BID), bid.bid_id, int(event_type), cursor)
|
||||
|
||||
def getEvents(self, linked_type: int, linked_id: bytes):
|
||||
events = []
|
||||
cursor = self.openDB()
|
||||
@@ -5011,18 +5021,17 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
|
||||
def setBidError(
|
||||
self,
|
||||
bid_id: bytes,
|
||||
bid,
|
||||
error_str: str,
|
||||
save_bid: bool = True,
|
||||
xmr_swap=None,
|
||||
cursor=None,
|
||||
) -> None:
|
||||
self.log.error(f"Bid {self.log.id(bid_id)} - Error: {error_str}")
|
||||
self.logEvent(Concepts.BID, bid_id, EventLogTypes.ERROR, error_str, cursor)
|
||||
self.log.error(f"Bid {self.log.id(bid.bid_id)} - Error: {error_str}")
|
||||
self.logEvent(Concepts.BID, bid.bid_id, EventLogTypes.ERROR, error_str, cursor)
|
||||
bid.setState(BidStates.BID_ERROR)
|
||||
if save_bid:
|
||||
self.saveBid(bid_id, bid, xmr_swap=xmr_swap, cursor=cursor)
|
||||
self.saveBid(bid.bid_id, bid, xmr_swap=xmr_swap, cursor=cursor)
|
||||
|
||||
def createInitiateTxn(
|
||||
self, coin_type, bid_id: bytes, bid, initiate_script, prefunded_tx=None
|
||||
@@ -7030,7 +7039,6 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
)
|
||||
else:
|
||||
self.setBidError(
|
||||
bid.bid_id,
|
||||
bid,
|
||||
"Unexpected txn spent coin a lock tx: {}".format(spend_txid_hex),
|
||||
save_bid=False,
|
||||
@@ -9154,7 +9162,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
except Exception as ex:
|
||||
if self.debug:
|
||||
self.log.error(traceback.format_exc())
|
||||
self.setBidError(bid.bid_id, bid, str(ex), xmr_swap=xmr_swap)
|
||||
self.setBidError(bid, str(ex), xmr_swap=xmr_swap)
|
||||
|
||||
def watchXmrSwap(self, bid, offer, xmr_swap, cursor=None) -> None:
|
||||
self.log.debug(f"Adaptor-sig swap in progress, bid {self.log.id(bid.bid_id)}.")
|
||||
@@ -9498,7 +9506,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
self.saveBidInSession(bid_id, bid, cursor, xmr_swap, save_in_progress=offer)
|
||||
return
|
||||
|
||||
unlock_time = 0
|
||||
unlock_time: int = 0
|
||||
if bid.debug_ind in (
|
||||
DebugTypes.CREATE_INVALID_COIN_B_LOCK,
|
||||
DebugTypes.B_LOCK_TX_MISSED_SEND,
|
||||
@@ -9569,7 +9577,6 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
)
|
||||
else:
|
||||
self.setBidError(
|
||||
bid_id,
|
||||
bid,
|
||||
"publishBLockTx failed: " + str(ex),
|
||||
save_bid=False,
|
||||
@@ -9597,7 +9604,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
self.logBidEvent(bid.bid_id, EventLogTypes.LOCK_TX_B_PUBLISHED, "", cursor)
|
||||
if bid.debug_ind == DebugTypes.BID_STOP_AFTER_COIN_B_LOCK:
|
||||
self.log.debug(
|
||||
"Adaptor-sig bid {self.log.id(bid_id)}: Stalling bid for testing: {bid.debug_ind}."
|
||||
f"Adaptor-sig bid {self.log.id(bid_id)}: Stalling bid for testing: {bid.debug_ind}."
|
||||
)
|
||||
bid.setState(BidStates.BID_STALLED_FOR_TEST)
|
||||
self.logBidEvent(
|
||||
@@ -9896,7 +9903,6 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
)
|
||||
else:
|
||||
self.setBidError(
|
||||
bid_id,
|
||||
bid,
|
||||
"spendBLockTx failed: " + str(ex),
|
||||
save_bid=False,
|
||||
@@ -10015,7 +10021,6 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
)
|
||||
else:
|
||||
self.setBidError(
|
||||
bid_id,
|
||||
bid,
|
||||
"spendBLockTx for refund failed: " + str(ex),
|
||||
save_bid=False,
|
||||
@@ -10220,7 +10225,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
except Exception as ex:
|
||||
if self.debug:
|
||||
self.log.error(traceback.format_exc())
|
||||
self.setBidError(bid_id, bid, str(ex))
|
||||
self.setBidError(bid, str(ex))
|
||||
|
||||
def processXmrBidLockSpendTx(self, msg) -> None:
|
||||
# Follower receiving MSG4F
|
||||
@@ -10285,7 +10290,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
except Exception as ex:
|
||||
if self.debug:
|
||||
self.log.error(traceback.format_exc())
|
||||
self.setBidError(bid_id, bid, str(ex))
|
||||
self.setBidError(bid, str(ex))
|
||||
|
||||
# Update copy of bid in swaps_in_progress
|
||||
self.swaps_in_progress[bid_id] = (bid, offer)
|
||||
@@ -10387,7 +10392,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
except Exception as ex:
|
||||
if self.debug:
|
||||
self.log.error(traceback.format_exc())
|
||||
self.setBidError(bid_id, bid, str(ex))
|
||||
self.setBidError(bid, str(ex))
|
||||
self.swaps_in_progress[bid_id] = (bid, offer)
|
||||
return
|
||||
|
||||
@@ -11000,9 +11005,10 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
to_remove = []
|
||||
if now - self._last_checked_progress >= self.check_progress_seconds:
|
||||
for bid_id, v in self.swaps_in_progress.items():
|
||||
bid, offer = v
|
||||
try:
|
||||
if self.checkBidState(bid_id, v[0], v[1]) is True:
|
||||
to_remove.append((bid_id, v[0], v[1]))
|
||||
if self.checkBidState(bid_id, bid, offer) is True:
|
||||
to_remove.append((bid_id, bid, offer))
|
||||
except Exception as ex:
|
||||
if self.debug:
|
||||
self.log.error("checkBidState %s", traceback.format_exc())
|
||||
@@ -11018,7 +11024,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
)
|
||||
else:
|
||||
self.log.error(f"checkBidState {self.log.id(bid_id)} {ex}.")
|
||||
self.setBidError(bid_id, v[0], str(ex))
|
||||
self.setBidError(bid, str(ex))
|
||||
|
||||
for bid_id, bid, offer in to_remove:
|
||||
self.deactivateBid(None, offer, bid)
|
||||
|
||||
@@ -76,10 +76,16 @@ class Table:
|
||||
__sqlite3_table__ = True
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
init_all_columns: bool = True
|
||||
for name, value in kwargs.items():
|
||||
if name == "_init_all_columns":
|
||||
init_all_columns = value
|
||||
continue
|
||||
if not hasattr(self, name):
|
||||
raise ValueError(f"Unknown attribute {name}")
|
||||
setattr(self, name, value)
|
||||
if init_all_columns is False:
|
||||
return
|
||||
# Init any unset columns to None
|
||||
for mc in inspect.getmembers(self):
|
||||
mc_name, mc_obj = mc
|
||||
@@ -1033,7 +1039,7 @@ class DBMethods:
|
||||
if cursor is None:
|
||||
self.closeDB(use_cursor, commit=False)
|
||||
|
||||
def add(self, obj, cursor, upsert: bool = False):
|
||||
def add(self, obj, cursor, upsert: bool = False, columns_list=None):
|
||||
if cursor is None:
|
||||
raise ValueError("Cursor is null")
|
||||
if not hasattr(obj, "__tablename__"):
|
||||
@@ -1046,7 +1052,8 @@ class DBMethods:
|
||||
# See if the instance overwrote any class methods
|
||||
for mc in inspect.getmembers(obj.__class__):
|
||||
mc_name, mc_obj = mc
|
||||
|
||||
if columns_list is not None and mc_name not in columns_list:
|
||||
continue
|
||||
if not hasattr(mc_obj, "__sqlite3_column__"):
|
||||
continue
|
||||
|
||||
@@ -1087,6 +1094,7 @@ class DBMethods:
|
||||
order_by={},
|
||||
query_suffix=None,
|
||||
extra_query_data={},
|
||||
columns_list=None,
|
||||
):
|
||||
if cursor is None:
|
||||
raise ValueError("Cursor is null")
|
||||
@@ -1099,6 +1107,8 @@ class DBMethods:
|
||||
|
||||
for mc in inspect.getmembers(table_class):
|
||||
mc_name, mc_obj = mc
|
||||
if columns_list is not None and mc_name not in columns_list:
|
||||
continue
|
||||
if not hasattr(mc_obj, "__sqlite3_column__"):
|
||||
continue
|
||||
if len(columns) > 0:
|
||||
@@ -1167,6 +1177,7 @@ class DBMethods:
|
||||
order_by={},
|
||||
query_suffix=None,
|
||||
extra_query_data={},
|
||||
columns_list=None,
|
||||
):
|
||||
return firstOrNone(
|
||||
self.query(
|
||||
@@ -1176,10 +1187,11 @@ class DBMethods:
|
||||
order_by,
|
||||
query_suffix,
|
||||
extra_query_data,
|
||||
columns_list,
|
||||
)
|
||||
)
|
||||
|
||||
def updateDB(self, obj, cursor, constraints=[]):
|
||||
def updateDB(self, obj, cursor, constraints=[], columns_list=None):
|
||||
if cursor is None:
|
||||
raise ValueError("Cursor is null")
|
||||
if not hasattr(obj, "__tablename__"):
|
||||
@@ -1191,7 +1203,6 @@ class DBMethods:
|
||||
values = {}
|
||||
for mc in inspect.getmembers(obj.__class__):
|
||||
mc_name, mc_obj = mc
|
||||
|
||||
if not hasattr(mc_obj, "__sqlite3_column__"):
|
||||
continue
|
||||
|
||||
@@ -1203,7 +1214,8 @@ class DBMethods:
|
||||
if mc_name in constraints:
|
||||
values[mc_name] = m_obj
|
||||
continue
|
||||
|
||||
if columns_list is not None and mc_name not in columns_list:
|
||||
continue
|
||||
if len(values) > 0:
|
||||
query += ", "
|
||||
query += f"{mc_name} = :{mc_name}"
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2024 tecnovert
|
||||
# Copyright (c) 2025 The Basicswap developers
|
||||
# Copyright (c) 2025-2026 The Basicswap developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
import threading
|
||||
|
||||
from enum import IntEnum
|
||||
from typing import List
|
||||
|
||||
from basicswap.chainparams import (
|
||||
chainparams,
|
||||
@@ -30,6 +31,7 @@ from basicswap.util.ecc import (
|
||||
)
|
||||
from coincurve.dleag import verify_secp256k1_point
|
||||
from coincurve.keys import (
|
||||
PrivateKey,
|
||||
PublicKey,
|
||||
)
|
||||
|
||||
@@ -179,13 +181,16 @@ class CoinInterface:
|
||||
|
||||
|
||||
class AdaptorSigInterface:
|
||||
def getScriptLockTxDummyWitness(self, script: bytes):
|
||||
def getP2WPKHDummyWitness(self) -> List[bytes]:
|
||||
return [bytes(72), bytes(33)]
|
||||
|
||||
def getScriptLockTxDummyWitness(self, script: bytes) -> List[bytes]:
|
||||
return [b"", bytes(72), bytes(72), bytes(len(script))]
|
||||
|
||||
def getScriptLockRefundSpendTxDummyWitness(self, script: bytes):
|
||||
def getScriptLockRefundSpendTxDummyWitness(self, script: bytes) -> List[bytes]:
|
||||
return [b"", bytes(72), bytes(72), bytes((1,)), bytes(len(script))]
|
||||
|
||||
def getScriptLockRefundSwipeTxDummyWitness(self, script: bytes):
|
||||
def getScriptLockRefundSwipeTxDummyWitness(self, script: bytes) -> List[bytes]:
|
||||
return [bytes(72), b"", bytes(len(script))]
|
||||
|
||||
|
||||
@@ -227,8 +232,7 @@ class Secp256k1Interface(CoinInterface, AdaptorSigInterface):
|
||||
return pubkey.verify(sig, signed_hash, hasher=None)
|
||||
|
||||
def sumKeys(self, ka: bytes, kb: bytes) -> bytes:
|
||||
# TODO: Add to coincurve
|
||||
return i2b((b2i(ka) + b2i(kb)) % ep.o)
|
||||
return PrivateKey(ka).add(kb).secret
|
||||
|
||||
def sumPubkeys(self, Ka: bytes, Kb: bytes) -> bytes:
|
||||
return PublicKey.combine_keys([PublicKey(Ka), PublicKey(Kb)]).format()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2020-2024 tecnovert
|
||||
# Copyright (c) 2024-2025 The Basicswap developers
|
||||
# Copyright (c) 2024-2026 The Basicswap developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -828,7 +828,7 @@ class BTCInterface(Secp256k1Interface):
|
||||
|
||||
def getScriptDummyWitness(self, script: bytes) -> List[bytes]:
|
||||
if self.isScriptP2WPKH(script):
|
||||
return [bytes(72), bytes(33)]
|
||||
return self.getP2WPKHDummyWitness()
|
||||
raise ValueError("Unknown script type")
|
||||
|
||||
def createSCLockRefundTx(
|
||||
@@ -1943,9 +1943,16 @@ class BTCInterface(Secp256k1Interface):
|
||||
raise ValueError("Unimplemented")
|
||||
|
||||
def getWitnessStackSerialisedLength(self, witness_stack):
|
||||
length = getCompactSizeLen(len(witness_stack))
|
||||
for e in witness_stack:
|
||||
length += getWitnessElementLen(len(e))
|
||||
length: int = 0
|
||||
if len(witness_stack) > 0 and isinstance(witness_stack[0], list):
|
||||
for input_stack in witness_stack:
|
||||
length += getCompactSizeLen(len(input_stack))
|
||||
for e in input_stack:
|
||||
length += getWitnessElementLen(len(e))
|
||||
else:
|
||||
length += getCompactSizeLen(len(witness_stack))
|
||||
for e in witness_stack:
|
||||
length += getWitnessElementLen(len(e))
|
||||
|
||||
# See core SerializeTransaction
|
||||
length += 1 # vinDummy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2020-2024 tecnovert
|
||||
# Copyright (c) 2024-2025 The Basicswap developers
|
||||
# Copyright (c) 2024-2026 The Basicswap developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -137,7 +137,7 @@ class PARTInterface(BTCInterface):
|
||||
|
||||
def getScriptDummyWitness(self, script: bytes) -> List[bytes]:
|
||||
if self.isScriptP2WPKH(script) or self.isScriptP2PKH(script):
|
||||
return [bytes(72), bytes(33)]
|
||||
return self.getP2WPKHDummyWitness()
|
||||
raise ValueError("Unknown script type")
|
||||
|
||||
def formatStealthAddress(self, scan_pubkey, spend_pubkey) -> str:
|
||||
@@ -146,9 +146,16 @@ class PARTInterface(BTCInterface):
|
||||
return encodeStealthAddress(prefix_byte, scan_pubkey, spend_pubkey)
|
||||
|
||||
def getWitnessStackSerialisedLength(self, witness_stack) -> int:
|
||||
length: int = getCompactSizeLen(len(witness_stack))
|
||||
for e in witness_stack:
|
||||
length += getWitnessElementLen(len(e))
|
||||
length: int = 0
|
||||
if len(witness_stack) > 0 and isinstance(witness_stack[0], list):
|
||||
for input_stack in witness_stack:
|
||||
length += getCompactSizeLen(len(input_stack))
|
||||
for e in input_stack:
|
||||
length += getWitnessElementLen(len(e))
|
||||
else:
|
||||
length += getCompactSizeLen(len(witness_stack))
|
||||
for e in witness_stack:
|
||||
length += getWitnessElementLen(len(e))
|
||||
return length
|
||||
|
||||
def getWalletRestoreHeight(self) -> int:
|
||||
|
||||
@@ -1169,11 +1169,6 @@ def process_offers(args, config, script_state) -> None:
|
||||
)
|
||||
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:
|
||||
print(
|
||||
"Creating offer for: {} at rate: {}".format(
|
||||
|
||||
@@ -622,6 +622,18 @@ class TestBase(unittest.TestCase):
|
||||
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):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@@ -632,23 +644,12 @@ class XmrTestBase(TestBase):
|
||||
|
||||
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):
|
||||
self.delay_event.clear()
|
||||
|
||||
for i in range(3):
|
||||
self.processes.append(
|
||||
multiprocessing.Process(target=self.run_thread, args=(i,))
|
||||
multiprocessing.Process(target=run_process, args=(i,))
|
||||
)
|
||||
self.processes[-1].start()
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ from tests.basicswap.common import (
|
||||
waitForNumSwapping,
|
||||
)
|
||||
from tests.basicswap.common_xmr import (
|
||||
run_process,
|
||||
XmrTestBase,
|
||||
)
|
||||
|
||||
@@ -122,7 +123,7 @@ class Test(XmrTestBase):
|
||||
c1 = self.processes[1]
|
||||
c1.terminate()
|
||||
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()
|
||||
|
||||
waitForServer(self.delay_event, 12701)
|
||||
|
||||
@@ -45,6 +45,18 @@ if not len(logger.handlers):
|
||||
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):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@@ -64,24 +76,13 @@ class Test(unittest.TestCase):
|
||||
|
||||
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):
|
||||
update_thread = None
|
||||
processes = []
|
||||
|
||||
time.sleep(5)
|
||||
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()
|
||||
|
||||
try:
|
||||
|
||||
@@ -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):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@@ -112,17 +124,6 @@ class Test(TestBase):
|
||||
for i in range(3):
|
||||
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):
|
||||
self.delay_event.set()
|
||||
if self.update_thread:
|
||||
@@ -136,7 +137,7 @@ class Test(TestBase):
|
||||
processes = []
|
||||
|
||||
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()
|
||||
|
||||
try:
|
||||
@@ -201,7 +202,7 @@ class Test(TestBase):
|
||||
|
||||
logging.info("Starting a new node on the same mnemonic as the first")
|
||||
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()
|
||||
waitForServer(self.delay_event, 12703)
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ def signal_handler(self, sig, frame):
|
||||
self.delay_event.set()
|
||||
|
||||
|
||||
def run_thread(self, client_id):
|
||||
def run_process(client_id):
|
||||
client_path = os.path.join(test_path, "client{}".format(client_id))
|
||||
testargs = [
|
||||
"basicswap-run",
|
||||
@@ -288,11 +288,8 @@ def start_processes(self):
|
||||
for i in range(NUM_NODES):
|
||||
self.processes.append(
|
||||
multiprocessing.Process(
|
||||
target=run_thread,
|
||||
args=(
|
||||
self,
|
||||
i,
|
||||
),
|
||||
target=run_process,
|
||||
args=(i,),
|
||||
)
|
||||
)
|
||||
self.processes[-1].start()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2021-2024 tecnovert
|
||||
# Copyright (c) 2024-2025 The Basicswap developers
|
||||
# Copyright (c) 2024-2026 The Basicswap developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -921,10 +921,10 @@ class BasicSwapTest(TestFunctions):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(BasicSwapTest, cls).setUpClass()
|
||||
if False:
|
||||
for client in cls.swap_clients:
|
||||
client.log.safe_logs = True
|
||||
client.log.safe_logs_prefix = b"tests"
|
||||
|
||||
@classmethod
|
||||
def addCoinSettings(cls, settings, datadir, node_id):
|
||||
settings["fetchpricesthread"] = False
|
||||
|
||||
def test_001_nested_segwit(self):
|
||||
# p2sh-p2wpkh
|
||||
@@ -1509,6 +1509,23 @@ class BasicSwapTest(TestFunctions):
|
||||
vsize = tx_decoded["vsize"]
|
||||
expect_fee_int = round(self.test_fee_rate * vsize / 1000)
|
||||
|
||||
tx_obj = ci.loadTx(lock_tx)
|
||||
vsize_from_ci = ci.getTxVSize(tx_obj)
|
||||
assert vsize == vsize_from_ci
|
||||
tx_no_witness = tx_obj.serialize_without_witness()
|
||||
|
||||
dummy_witness_stack = []
|
||||
for txi in tx_obj.vin:
|
||||
dummy_witness_stack.append(ci.getP2WPKHDummyWitness())
|
||||
witness_bytes_len_est: int = ci.getWitnessStackSerialisedLength(
|
||||
dummy_witness_stack
|
||||
)
|
||||
tx_obj_no_witness = ci.loadTx(tx_no_witness)
|
||||
vsize_estimated = ci.getTxVSize(
|
||||
tx_obj_no_witness, add_witness_bytes=witness_bytes_len_est
|
||||
)
|
||||
assert vsize <= vsize_estimated and vsize_estimated - vsize < 4
|
||||
|
||||
out_value: int = 0
|
||||
for txo in tx_decoded["vout"]:
|
||||
if "value" in txo:
|
||||
@@ -1556,7 +1573,7 @@ class BasicSwapTest(TestFunctions):
|
||||
|
||||
expect_vsize: int = ci.xmr_swap_a_lock_spend_tx_vsize()
|
||||
assert expect_vsize >= vsize_actual
|
||||
assert expect_vsize - vsize_actual < 10
|
||||
assert expect_vsize - vsize_actual <= 10
|
||||
|
||||
# Test chain b (no-script) lock tx size
|
||||
v = ci.getNewRandomKey()
|
||||
@@ -1577,7 +1594,7 @@ class BasicSwapTest(TestFunctions):
|
||||
|
||||
expect_vsize: int = ci.xmr_swap_b_lock_spend_tx_vsize()
|
||||
assert expect_vsize >= lock_tx_b_spend_decoded["vsize"]
|
||||
assert expect_vsize - lock_tx_b_spend_decoded["vsize"] < 10
|
||||
assert expect_vsize - lock_tx_b_spend_decoded["vsize"] <= 10
|
||||
|
||||
def test_011_p2sh(self):
|
||||
# Not used in bsx for native-segwit coins
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2019-2024 tecnovert
|
||||
# Copyright (c) 2024-2025 The Basicswap developers
|
||||
# Copyright (c) 2024-2026 The Basicswap developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -67,6 +67,18 @@ logger = logging.getLogger()
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
|
||||
@staticmethod
|
||||
def ci_btc():
|
||||
btc_coin_settings = {"rpcport": 0, "rpcauth": "none"}
|
||||
btc_coin_settings.update(REQUIRED_SETTINGS)
|
||||
return BTCInterface(btc_coin_settings, "regtest")
|
||||
|
||||
@staticmethod
|
||||
def ci_xmr():
|
||||
xmr_coin_settings = {"rpcport": 0, "walletrpcport": 0, "walletrpcauth": "none"}
|
||||
xmr_coin_settings.update(REQUIRED_SETTINGS)
|
||||
return XMRInterface(xmr_coin_settings, "regtest")
|
||||
|
||||
def test_serialise_num(self):
|
||||
def test_case(v, nb=None):
|
||||
b = SerialiseNum(v)
|
||||
@@ -86,10 +98,7 @@ class Test(unittest.TestCase):
|
||||
test_case(4194642)
|
||||
|
||||
def test_sequence(self):
|
||||
coin_settings = {"rpcport": 0, "rpcauth": "none"}
|
||||
coin_settings.update(REQUIRED_SETTINGS)
|
||||
|
||||
ci = BTCInterface(coin_settings, "regtest")
|
||||
ci = self.ci_btc()
|
||||
|
||||
time_val = 48 * 60 * 60
|
||||
encoded = ci.getExpectedSequence(TxLockTypes.SEQUENCE_LOCK_TIME, time_val)
|
||||
@@ -197,10 +206,47 @@ class Test(unittest.TestCase):
|
||||
"5c26c518fb698e91a5858c33e9075488c55c235f391162fe9e6cbd4f694f80aa"
|
||||
)
|
||||
|
||||
def test_key_summing(self):
|
||||
ci_btc = self.ci_btc()
|
||||
ci_xmr = self.ci_xmr()
|
||||
keys = [
|
||||
bytes.fromhex(
|
||||
"e6b8e7c2ca3a88fe4f28591aa0f91fec340179346559e4ec430c2531aecc19aa"
|
||||
),
|
||||
bytes.fromhex(
|
||||
"b725b6359bd2b510d9d5a7bba7bdee17abbf113253f6338ea50a8f0cf45fd0d0"
|
||||
),
|
||||
]
|
||||
sum_secp256k1: bytes = ci_btc.sumKeys(keys[0], keys[1])
|
||||
assert (
|
||||
sum_secp256k1.hex()
|
||||
== "9dde9df8660d3e0f28fe00d648b70e052511ad800a07783f284455b1d2f5a939"
|
||||
)
|
||||
|
||||
sum_ed25519: bytes = ci_xmr.sumKeys(keys[0], keys[1])
|
||||
assert (
|
||||
sum_ed25519.hex()
|
||||
== "0dde9df8660d3e0f28fe00d648b70e0323e9c192fe9b94f1cf7138515e877725"
|
||||
)
|
||||
|
||||
sum_secp256k1 = ci_btc.sumPubkeys(
|
||||
ci_btc.getPubkey(keys[0]), ci_btc.getPubkey(keys[1])
|
||||
)
|
||||
assert (
|
||||
sum_secp256k1.hex()
|
||||
== "028c30392e35620af0787b363a03cf9a695336759664436e1f609481c869541a5c"
|
||||
)
|
||||
|
||||
sum_ed25519 = ci_xmr.sumPubkeys(
|
||||
ci_xmr.getPubkey(keys[0]), ci_xmr.getPubkey(keys[1])
|
||||
)
|
||||
assert (
|
||||
sum_ed25519.hex()
|
||||
== "4b2dd2dc9acc9be7efed4fdbfb96f0002aeb9e4c8638c5b24562a7158b283626"
|
||||
)
|
||||
|
||||
def test_ecdsa_otves(self):
|
||||
coin_settings = {"rpcport": 0, "rpcauth": "none"}
|
||||
coin_settings.update(REQUIRED_SETTINGS)
|
||||
ci = BTCInterface(coin_settings, "regtest")
|
||||
ci = self.ci_btc()
|
||||
vk_sign = ci.getNewRandomKey()
|
||||
vk_encrypt = ci.getNewRandomKey()
|
||||
|
||||
@@ -209,21 +255,16 @@ class Test(unittest.TestCase):
|
||||
sign_hash = secrets.token_bytes(32)
|
||||
|
||||
cipher_text = ecdsaotves_enc_sign(vk_sign, pk_encrypt, sign_hash)
|
||||
|
||||
assert ecdsaotves_enc_verify(pk_sign, pk_encrypt, sign_hash, cipher_text)
|
||||
|
||||
sig = ecdsaotves_dec_sig(vk_encrypt, cipher_text)
|
||||
|
||||
assert ci.verifySig(pk_sign, sign_hash, sig)
|
||||
|
||||
recovered_key = ecdsaotves_rec_enc_key(pk_encrypt, cipher_text, sig)
|
||||
|
||||
assert vk_encrypt == recovered_key
|
||||
|
||||
def test_sign(self):
|
||||
coin_settings = {"rpcport": 0, "rpcauth": "none"}
|
||||
coin_settings.update(REQUIRED_SETTINGS)
|
||||
ci = BTCInterface(coin_settings, "regtest")
|
||||
ci = self.ci_btc()
|
||||
|
||||
vk = ci.getNewRandomKey()
|
||||
pk = ci.getPubkey(vk)
|
||||
@@ -236,9 +277,7 @@ class Test(unittest.TestCase):
|
||||
ci.verifySig(pk, message_hash, sig)
|
||||
|
||||
def test_sign_compact(self):
|
||||
coin_settings = {"rpcport": 0, "rpcauth": "none"}
|
||||
coin_settings.update(REQUIRED_SETTINGS)
|
||||
ci = BTCInterface(coin_settings, "regtest")
|
||||
ci = self.ci_btc()
|
||||
|
||||
vk = ci.getNewRandomKey()
|
||||
pk = ci.getPubkey(vk)
|
||||
@@ -251,9 +290,7 @@ class Test(unittest.TestCase):
|
||||
assert sig == sig2
|
||||
|
||||
def test_sign_recoverable(self):
|
||||
coin_settings = {"rpcport": 0, "rpcauth": "none"}
|
||||
coin_settings.update(REQUIRED_SETTINGS)
|
||||
ci = BTCInterface(coin_settings, "regtest")
|
||||
ci = self.ci_btc()
|
||||
|
||||
vk = ci.getNewRandomKey()
|
||||
pk = ci.getPubkey(vk)
|
||||
@@ -267,18 +304,13 @@ class Test(unittest.TestCase):
|
||||
assert sig == sig2
|
||||
|
||||
def test_pubkey_to_address(self):
|
||||
coin_settings = {"rpcport": 0, "rpcauth": "none"}
|
||||
coin_settings.update(REQUIRED_SETTINGS)
|
||||
ci = BTCInterface(coin_settings, "regtest")
|
||||
ci = self.ci_btc()
|
||||
pk = h2b("02c26a344e7d21bcc6f291532679559f2fd234c881271ff98714855edc753763a6")
|
||||
addr = ci.pubkey_to_address(pk)
|
||||
assert addr == "mj6SdSxmWRmdDqR5R3FfZmRiLmQfQAsLE8"
|
||||
|
||||
def test_dleag(self):
|
||||
coin_settings = {"rpcport": 0, "walletrpcport": 0, "walletrpcauth": "none"}
|
||||
coin_settings.update(REQUIRED_SETTINGS)
|
||||
|
||||
ci = XMRInterface(coin_settings, "regtest")
|
||||
ci = self.ci_xmr()
|
||||
|
||||
key = ci.getNewRandomKey()
|
||||
proof = ci.proveDLEAG(key)
|
||||
@@ -409,15 +441,8 @@ class Test(unittest.TestCase):
|
||||
amount_to_recreate = int((amount_from * rate) // (10**scale_from))
|
||||
assert "10.00000000" == format_amount(amount_to_recreate, scale_to)
|
||||
|
||||
coin_settings = {
|
||||
"rpcport": 0,
|
||||
"rpcauth": "none",
|
||||
"walletrpcport": 0,
|
||||
"walletrpcauth": "none",
|
||||
}
|
||||
coin_settings.update(REQUIRED_SETTINGS)
|
||||
ci_xmr = XMRInterface(coin_settings, "regtest")
|
||||
ci_btc = BTCInterface(coin_settings, "regtest")
|
||||
ci_xmr = self.ci_xmr()
|
||||
ci_btc = self.ci_btc()
|
||||
|
||||
for i in range(10000):
|
||||
test_pairs = random.randint(0, 3)
|
||||
@@ -663,6 +688,7 @@ class Test(unittest.TestCase):
|
||||
ki.record_id = 1
|
||||
ki.address = "test1"
|
||||
ki.label = "test1"
|
||||
ki.note = "note1"
|
||||
try:
|
||||
db_test.add(ki, cursor, upsert=False)
|
||||
except Exception as e:
|
||||
@@ -670,6 +696,65 @@ class Test(unittest.TestCase):
|
||||
else:
|
||||
raise ValueError("Should have errored.")
|
||||
db_test.add(ki, cursor, upsert=True)
|
||||
|
||||
# Test columns list
|
||||
ki_test = db_test.queryOne(
|
||||
KnownIdentity,
|
||||
cursor,
|
||||
{"address": "test1"},
|
||||
columns_list=[
|
||||
"label",
|
||||
],
|
||||
)
|
||||
assert ki_test.label == "test1"
|
||||
assert ki_test.address is None
|
||||
|
||||
# Test updating partial row
|
||||
ki_test.label = "test2"
|
||||
ki_test.record_id = 1
|
||||
db_test.add(
|
||||
ki_test,
|
||||
cursor,
|
||||
upsert=True,
|
||||
columns_list=[
|
||||
"record_id",
|
||||
"label",
|
||||
],
|
||||
)
|
||||
ki_test = db_test.queryOne(KnownIdentity, cursor, {"address": "test1"})
|
||||
assert ki_test.record_id == 1
|
||||
assert ki_test.address == "test1"
|
||||
assert ki_test.label == "test2"
|
||||
assert ki_test.note == "note1"
|
||||
|
||||
ki_test.note = "test2"
|
||||
ki_test.label = "test3"
|
||||
|
||||
db_test.updateDB(
|
||||
ki_test,
|
||||
cursor,
|
||||
["record_id"],
|
||||
columns_list=[
|
||||
"label",
|
||||
],
|
||||
)
|
||||
ki_test = db_test.queryOne(KnownIdentity, cursor, {"address": "test1"})
|
||||
assert ki_test.record_id == 1
|
||||
assert ki_test.address == "test1"
|
||||
assert ki_test.label == "test3"
|
||||
assert ki_test.note == "note1"
|
||||
|
||||
# Test partially initialised object
|
||||
ki_test_p = KnownIdentity(
|
||||
_init_all_columns=False, record_id=1, label="test4"
|
||||
)
|
||||
db_test.add(ki_test_p, cursor, upsert=True)
|
||||
ki_test = db_test.queryOne(KnownIdentity, cursor, {"address": "test1"})
|
||||
assert ki_test.record_id == 1
|
||||
assert ki_test.address == "test1"
|
||||
assert ki_test.label == "test4"
|
||||
assert ki_test.note == "note1"
|
||||
|
||||
finally:
|
||||
db_test.closeDB(cursor)
|
||||
|
||||
|
||||
@@ -69,6 +69,18 @@ def updateThread():
|
||||
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):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@@ -76,17 +88,6 @@ class Test(unittest.TestCase):
|
||||
|
||||
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):
|
||||
# Wait for height, or sequencelock is thrown off by genesis blocktime
|
||||
logging.info(
|
||||
@@ -112,7 +113,7 @@ class Test(unittest.TestCase):
|
||||
processes = []
|
||||
|
||||
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()
|
||||
|
||||
try:
|
||||
@@ -169,7 +170,7 @@ class Test(unittest.TestCase):
|
||||
c1 = processes[1]
|
||||
c1.terminate()
|
||||
c1.join()
|
||||
processes[1] = multiprocessing.Process(target=self.run_thread, args=(1,))
|
||||
processes[1] = multiprocessing.Process(target=run_process, args=(1,))
|
||||
processes[1].start()
|
||||
|
||||
waitForServer(delay_event, 12701)
|
||||
|
||||
@@ -30,6 +30,7 @@ from tests.basicswap.common import (
|
||||
waitForNumBids,
|
||||
)
|
||||
from tests.basicswap.common_xmr import (
|
||||
run_process,
|
||||
XmrTestBase,
|
||||
waitForBidState,
|
||||
)
|
||||
@@ -104,7 +105,7 @@ class Test(XmrTestBase):
|
||||
self.delay_event.wait(5)
|
||||
|
||||
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()
|
||||
|
||||
waitForServer(self.delay_event, 12700)
|
||||
|
||||
@@ -27,11 +27,12 @@ from tests.basicswap.util import (
|
||||
waitForServer,
|
||||
)
|
||||
from tests.basicswap.common import (
|
||||
waitForNumOffers,
|
||||
waitForNumBids,
|
||||
waitForNumOffers,
|
||||
waitForNumSwapping,
|
||||
)
|
||||
from tests.basicswap.common_xmr import (
|
||||
run_process,
|
||||
XmrTestBase,
|
||||
)
|
||||
|
||||
@@ -94,12 +95,13 @@ class Test(XmrTestBase):
|
||||
|
||||
waitForNumBids(self.delay_event, 12700, 1)
|
||||
|
||||
for i in range(10):
|
||||
for i in range(20):
|
||||
bids = read_json_api(12700, "bids")
|
||||
bid = bids[0]
|
||||
if bid["bid_state"] == "Received":
|
||||
break
|
||||
self.delay_event.wait(1)
|
||||
assert bid["bid_state"] == "Received"
|
||||
assert bid["expire_at"] == bid["created_at"] + data["validmins"] * 60
|
||||
|
||||
data = {"accept": True}
|
||||
@@ -112,7 +114,7 @@ class Test(XmrTestBase):
|
||||
c1 = self.processes[1]
|
||||
c1.terminate()
|
||||
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()
|
||||
|
||||
waitForServer(self.delay_event, 12701)
|
||||
|
||||
Reference in New Issue
Block a user