mirror of
https://github.com/basicswap/basicswap.git
synced 2026-03-01 00:55:09 +01:00
Compare commits
7 Commits
a04ce28ca2
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8e741f2b1 | ||
|
|
f872e12d7c | ||
|
|
1e18bcae38 | ||
|
|
088ed92da3 | ||
|
|
2e5b8ec083 | ||
|
|
35c640d30c | ||
|
|
ab1f6ea5b6 |
@@ -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
|
||||||
|
|||||||
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@@ -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
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
import threading
|
import threading
|
||||||
|
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from basicswap.chainparams import (
|
from basicswap.chainparams import (
|
||||||
chainparams,
|
chainparams,
|
||||||
@@ -180,13 +181,16 @@ class CoinInterface:
|
|||||||
|
|
||||||
|
|
||||||
class AdaptorSigInterface:
|
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))]
|
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))]
|
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))]
|
return [bytes(72), b"", bytes(len(script))]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2020-2024 tecnovert
|
# 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
|
# 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.
|
||||||
|
|
||||||
@@ -828,7 +828,7 @@ class BTCInterface(Secp256k1Interface):
|
|||||||
|
|
||||||
def getScriptDummyWitness(self, script: bytes) -> List[bytes]:
|
def getScriptDummyWitness(self, script: bytes) -> List[bytes]:
|
||||||
if self.isScriptP2WPKH(script):
|
if self.isScriptP2WPKH(script):
|
||||||
return [bytes(72), bytes(33)]
|
return self.getP2WPKHDummyWitness()
|
||||||
raise ValueError("Unknown script type")
|
raise ValueError("Unknown script type")
|
||||||
|
|
||||||
def createSCLockRefundTx(
|
def createSCLockRefundTx(
|
||||||
@@ -1943,7 +1943,14 @@ class BTCInterface(Secp256k1Interface):
|
|||||||
raise ValueError("Unimplemented")
|
raise ValueError("Unimplemented")
|
||||||
|
|
||||||
def getWitnessStackSerialisedLength(self, witness_stack):
|
def getWitnessStackSerialisedLength(self, witness_stack):
|
||||||
length = getCompactSizeLen(len(witness_stack))
|
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:
|
for e in witness_stack:
|
||||||
length += getWitnessElementLen(len(e))
|
length += getWitnessElementLen(len(e))
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2020-2024 tecnovert
|
# 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
|
# 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.
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ class PARTInterface(BTCInterface):
|
|||||||
|
|
||||||
def getScriptDummyWitness(self, script: bytes) -> List[bytes]:
|
def getScriptDummyWitness(self, script: bytes) -> List[bytes]:
|
||||||
if self.isScriptP2WPKH(script) or self.isScriptP2PKH(script):
|
if self.isScriptP2WPKH(script) or self.isScriptP2PKH(script):
|
||||||
return [bytes(72), bytes(33)]
|
return self.getP2WPKHDummyWitness()
|
||||||
raise ValueError("Unknown script type")
|
raise ValueError("Unknown script type")
|
||||||
|
|
||||||
def formatStealthAddress(self, scan_pubkey, spend_pubkey) -> str:
|
def formatStealthAddress(self, scan_pubkey, spend_pubkey) -> str:
|
||||||
@@ -146,7 +146,14 @@ class PARTInterface(BTCInterface):
|
|||||||
return encodeStealthAddress(prefix_byte, scan_pubkey, spend_pubkey)
|
return encodeStealthAddress(prefix_byte, scan_pubkey, spend_pubkey)
|
||||||
|
|
||||||
def getWitnessStackSerialisedLength(self, witness_stack) -> int:
|
def getWitnessStackSerialisedLength(self, witness_stack) -> int:
|
||||||
length: int = getCompactSizeLen(len(witness_stack))
|
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:
|
for e in witness_stack:
|
||||||
length += getWitnessElementLen(len(e))
|
length += getWitnessElementLen(len(e))
|
||||||
return length
|
return length
|
||||||
|
|||||||
@@ -1169,11 +1169,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(
|
||||||
|
|||||||
@@ -622,17 +622,7 @@ 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}")
|
||||||
|
|
||||||
|
|
||||||
class XmrTestBase(TestBase):
|
def run_process(client_id):
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
super(XmrTestBase, cls).setUpClass(cls)
|
|
||||||
|
|
||||||
cls.update_thread = None
|
|
||||||
cls.processes = []
|
|
||||||
|
|
||||||
prepare_nodes(3, "monero")
|
|
||||||
|
|
||||||
def run_thread(self, client_id):
|
|
||||||
client_path = os.path.join(TEST_PATH, "client{}".format(client_id))
|
client_path = os.path.join(TEST_PATH, "client{}".format(client_id))
|
||||||
testargs = [
|
testargs = [
|
||||||
"basicswap-run",
|
"basicswap-run",
|
||||||
@@ -643,12 +633,23 @@ class XmrTestBase(TestBase):
|
|||||||
with patch.object(sys, "argv", testargs):
|
with patch.object(sys, "argv", testargs):
|
||||||
runSystem.main()
|
runSystem.main()
|
||||||
|
|
||||||
|
|
||||||
|
class XmrTestBase(TestBase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super(XmrTestBase, cls).setUpClass(cls)
|
||||||
|
|
||||||
|
cls.update_thread = None
|
||||||
|
cls.processes = []
|
||||||
|
|
||||||
|
prepare_nodes(3, "monero")
|
||||||
|
|
||||||
def start_processes(self):
|
def start_processes(self):
|
||||||
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()
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -102,17 +102,7 @@ def prepare_node(node_id, mnemonic):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Test(TestBase):
|
def run_process(client_id):
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
super(Test, cls).setUpClass(cls)
|
|
||||||
cls.update_thread = None
|
|
||||||
cls.used_mnemonics = []
|
|
||||||
# Load wallets from random mnemonics, except node0 which needs to import PART from the genesis block
|
|
||||||
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))
|
client_path = os.path.join(TEST_PATH, "client{}".format(client_id))
|
||||||
testargs = [
|
testargs = [
|
||||||
"basicswap-run",
|
"basicswap-run",
|
||||||
@@ -123,6 +113,17 @@ class Test(TestBase):
|
|||||||
with patch.object(sys, "argv", testargs):
|
with patch.object(sys, "argv", testargs):
|
||||||
runSystem.main()
|
runSystem.main()
|
||||||
|
|
||||||
|
|
||||||
|
class Test(TestBase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super(Test, cls).setUpClass(cls)
|
||||||
|
cls.update_thread = None
|
||||||
|
cls.used_mnemonics = []
|
||||||
|
# Load wallets from random mnemonics, except node0 which needs to import PART from the genesis block
|
||||||
|
for i in range(3):
|
||||||
|
cls.used_mnemonics.append(prepare_node(i, mnemonics[0] if i == 0 else None))
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ def signal_handler(self, sig, frame):
|
|||||||
self.delay_event.set()
|
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))
|
client_path = os.path.join(test_path, "client{}".format(client_id))
|
||||||
testargs = [
|
testargs = [
|
||||||
"basicswap-run",
|
"basicswap-run",
|
||||||
@@ -288,11 +288,8 @@ def start_processes(self):
|
|||||||
for i in range(NUM_NODES):
|
for i in range(NUM_NODES):
|
||||||
self.processes.append(
|
self.processes.append(
|
||||||
multiprocessing.Process(
|
multiprocessing.Process(
|
||||||
target=run_thread,
|
target=run_process,
|
||||||
args=(
|
args=(i,),
|
||||||
self,
|
|
||||||
i,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.processes[-1].start()
|
self.processes[-1].start()
|
||||||
|
|||||||
@@ -1509,6 +1509,23 @@ class BasicSwapTest(TestFunctions):
|
|||||||
vsize = tx_decoded["vsize"]
|
vsize = tx_decoded["vsize"]
|
||||||
expect_fee_int = round(self.test_fee_rate * vsize / 1000)
|
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
|
out_value: int = 0
|
||||||
for txo in tx_decoded["vout"]:
|
for txo in tx_decoded["vout"]:
|
||||||
if "value" in txo:
|
if "value" in txo:
|
||||||
@@ -1556,7 +1573,7 @@ class BasicSwapTest(TestFunctions):
|
|||||||
|
|
||||||
expect_vsize: int = ci.xmr_swap_a_lock_spend_tx_vsize()
|
expect_vsize: int = ci.xmr_swap_a_lock_spend_tx_vsize()
|
||||||
assert expect_vsize >= vsize_actual
|
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
|
# Test chain b (no-script) lock tx size
|
||||||
v = ci.getNewRandomKey()
|
v = ci.getNewRandomKey()
|
||||||
@@ -1577,7 +1594,7 @@ class BasicSwapTest(TestFunctions):
|
|||||||
|
|
||||||
expect_vsize: int = ci.xmr_swap_b_lock_spend_tx_vsize()
|
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"]
|
||||||
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):
|
def test_011_p2sh(self):
|
||||||
# Not used in bsx for native-segwit coins
|
# Not used in bsx for native-segwit coins
|
||||||
|
|||||||
@@ -69,14 +69,7 @@ def updateThread():
|
|||||||
delay_event.wait(5)
|
delay_event.wait(5)
|
||||||
|
|
||||||
|
|
||||||
class Test(unittest.TestCase):
|
def run_process(client_id):
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
super(Test, cls).setUpClass()
|
|
||||||
|
|
||||||
prepare_nodes(3, "bitcoin")
|
|
||||||
|
|
||||||
def run_thread(self, client_id):
|
|
||||||
client_path = os.path.join(TEST_PATH, f"client{client_id}")
|
client_path = os.path.join(TEST_PATH, f"client{client_id}")
|
||||||
testargs = [
|
testargs = [
|
||||||
"basicswap-run",
|
"basicswap-run",
|
||||||
@@ -87,6 +80,14 @@ class Test(unittest.TestCase):
|
|||||||
with patch.object(sys, "argv", testargs):
|
with patch.object(sys, "argv", testargs):
|
||||||
runSystem.main()
|
runSystem.main()
|
||||||
|
|
||||||
|
|
||||||
|
class Test(unittest.TestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super(Test, cls).setUpClass()
|
||||||
|
|
||||||
|
prepare_nodes(3, "bitcoin")
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user