mirror of
https://github.com/basicswap/basicswap.git
synced 2024-12-22 11:39:34 +00:00
tests: Run more tests in ci.
This commit is contained in:
parent
53ceae718b
commit
30a5ea1652
7 changed files with 36 additions and 11 deletions
|
@ -47,3 +47,4 @@ test_task:
|
|||
- pytest tests/basicswap/test_other.py
|
||||
- pytest tests/basicswap/test_run.py
|
||||
- pytest tests/basicswap/test_reload.py
|
||||
- pytest tests/basicswap/test_btc_xmr.py -k 'test_01_a or test_01_b or test_02_a or test_02_b'
|
||||
|
|
|
@ -1207,8 +1207,13 @@ class BasicSwap(BaseApp):
|
|||
|
||||
def sendSmsg(self, addr_from: str, addr_to: str, payload_hex: bytes, msg_valid: int) -> bytes:
|
||||
options = {'decodehex': True, 'ttl_is_seconds': True}
|
||||
ro = self.callrpc('smsgsend', [addr_from, addr_to, payload_hex, False, msg_valid, False, options])
|
||||
return bytes.fromhex(ro['msgid'])
|
||||
try:
|
||||
ro = self.callrpc('smsgsend', [addr_from, addr_to, payload_hex, False, msg_valid, False, options])
|
||||
return bytes.fromhex(ro['msgid'])
|
||||
except Exception as e:
|
||||
if self.debug:
|
||||
self.log.error('smsgsend failed {}'.format(json.dumps(ro, indent=4)))
|
||||
raise e
|
||||
|
||||
def is_reverse_ads_bid(self, coin_from) -> bool:
|
||||
return coin_from in self.scriptless_coins + self.coins_without_segwit
|
||||
|
@ -1856,24 +1861,24 @@ class BasicSwap(BaseApp):
|
|||
est_fee = (fee_rate * tx_vsize) / 1000
|
||||
return est_fee
|
||||
|
||||
def withdrawCoin(self, coin_type, value, addr_to, subfee):
|
||||
def withdrawCoin(self, coin_type, value, addr_to, subfee: bool) -> str:
|
||||
ci = self.ci(coin_type)
|
||||
self.log.info('withdrawCoin %s %s to %s %s', value, ci.ticker(), addr_to, ' subfee' if subfee else '')
|
||||
self.log.info('withdrawCoin {} {} to {} {}'.format(value, ci.ticker(), addr_to, ' subfee' if subfee else ''))
|
||||
|
||||
txid = ci.withdrawCoin(value, addr_to, subfee)
|
||||
self.log.debug('In txn: {}'.format(txid))
|
||||
return txid
|
||||
|
||||
def withdrawLTC(self, type_from, value, addr_to, subfee):
|
||||
def withdrawLTC(self, type_from, value, addr_to, subfee: bool) -> str:
|
||||
ci = self.ci(Coins.LTC)
|
||||
self.log.info('withdrawLTC %s %s to %s %s', value, ci.ticker(), addr_to, ' subfee' if subfee else '')
|
||||
self.log.info('withdrawLTC {} {} to {} {}'.format(value, type_from, addr_to, ' subfee' if subfee else ''))
|
||||
|
||||
txid = ci.withdrawCoin(value, type_from, addr_to, subfee)
|
||||
self.log.debug('In txn: {}'.format(txid))
|
||||
return txid
|
||||
|
||||
def withdrawParticl(self, type_from, type_to, value, addr_to, subfee):
|
||||
self.log.info('withdrawParticl %s %s to %s %s %s', value, type_from, type_to, addr_to, ' subfee' if subfee else '')
|
||||
def withdrawParticl(self, type_from: str, type_to: str, value, addr_to: str, subfee: bool) -> str:
|
||||
self.log.info('withdrawParticl {} {} to {} {} {}'.format(value, type_from, type_to, addr_to, ' subfee' if subfee else ''))
|
||||
|
||||
if type_from == 'plain':
|
||||
type_from = 'part'
|
||||
|
|
|
@ -8,5 +8,5 @@ https://github.com/cirruslabs/cirrus-cli/blob/master/INSTALL.md
|
|||
Run:
|
||||
|
||||
cd basicswap
|
||||
cirrus run
|
||||
cirrus run -v -o simple
|
||||
|
||||
|
|
|
@ -230,6 +230,14 @@ def wait_for_none_active(delay_event, port, wait_for=30):
|
|||
raise ValueError('wait_for_none_active timed out.')
|
||||
|
||||
|
||||
def abandon_all_swaps(delay_event, swap_client) -> None:
|
||||
logging.info('abandon_all_swaps')
|
||||
for bid in swap_client.listBids(sent=True):
|
||||
swap_client.abandonBid(bid[2])
|
||||
for bid in swap_client.listBids(sent=False):
|
||||
swap_client.abandonBid(bid[2])
|
||||
|
||||
|
||||
def waitForNumOffers(delay_event, port, offers, wait_for=20):
|
||||
for i in range(wait_for):
|
||||
if delay_event.is_set():
|
||||
|
|
|
@ -31,6 +31,7 @@ from tests.basicswap.util import (
|
|||
read_json_api,
|
||||
)
|
||||
from tests.basicswap.common import (
|
||||
abandon_all_swaps,
|
||||
wait_for_bid,
|
||||
wait_for_event,
|
||||
wait_for_offer,
|
||||
|
@ -1198,6 +1199,8 @@ class TestBTC(BasicSwapTest):
|
|||
assert (jsw['locked'] is False)
|
||||
|
||||
def test_01_full_swap(self):
|
||||
abandon_all_swaps(test_delay_event, self.swap_clients[0])
|
||||
wait_for_none_active(test_delay_event, 1800)
|
||||
js_0 = read_json_api(1800, 'wallets')
|
||||
if not js_0['PART']['encrypted']:
|
||||
read_json_api(1800, 'setpassword', {'oldpassword': '', 'newpassword': 'notapassword123'})
|
||||
|
|
|
@ -660,7 +660,7 @@ class Test(BaseTest):
|
|||
js_w2 = read_json_api(1802, 'wallets')
|
||||
if float(js_w2['PART']['balance']) < 100.0:
|
||||
post_json = {
|
||||
'value': 100,
|
||||
'value': 100.0,
|
||||
'address': js_w2['PART']['deposit_address'],
|
||||
'subfee': False,
|
||||
}
|
||||
|
@ -678,8 +678,8 @@ class Test(BaseTest):
|
|||
'subfee': True,
|
||||
}
|
||||
json_rv = read_json_api(TEST_HTTP_PORT + 2, 'wallets/part/withdraw', post_json)
|
||||
wait_for_balance(test_delay_event, 'http://127.0.0.1:1802/json/wallets/part', 'balance', 10.0)
|
||||
assert (len(json_rv['txid']) == 64)
|
||||
wait_for_balance(test_delay_event, 'http://127.0.0.1:1802/json/wallets/part', 'balance', 10.0)
|
||||
|
||||
# Create prefunded ITX
|
||||
ci = swap_clients[2].ci(Coins.PART)
|
||||
|
|
|
@ -336,6 +336,7 @@ class BaseTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
test_delay_event.clear()
|
||||
random.seed(time.time())
|
||||
|
||||
logger.propagate = False
|
||||
|
@ -618,6 +619,13 @@ class BaseTest(unittest.TestCase):
|
|||
stopDaemons(cls.btc_daemons)
|
||||
stopDaemons(cls.ltc_daemons)
|
||||
|
||||
cls.http_threads.clear()
|
||||
cls.swap_clients.clear()
|
||||
cls.part_daemons.clear()
|
||||
cls.btc_daemons.clear()
|
||||
cls.ltc_daemons.clear()
|
||||
cls.xmr_daemons.clear()
|
||||
|
||||
super(BaseTest, cls).tearDownClass()
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in a new issue