mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 18:38:09 +01:00
ui: Expose bid valid for.
Set smsgsregtestadjust to false in tests. Fix offer smsg valid for. Set active_ind on bid records. api: All times returned should be in unix-time.
This commit is contained in:
@@ -61,13 +61,13 @@ def prepareDataDir(datadir, node_id, conf_file, dir_prefix, base_p2p_port=BASE_P
|
||||
fp.write('acceptnonstdtxn=0\n')
|
||||
fp.write('txindex=1\n')
|
||||
fp.write('wallet=wallet.dat\n')
|
||||
|
||||
fp.write('findpeers=0\n')
|
||||
# minstakeinterval=5 # Using walletsettings stakelimit instead
|
||||
fp.write('stakethreadconddelayms=1000\n')
|
||||
|
||||
if base_p2p_port == BASE_PORT: # Particl
|
||||
fp.write('zmqpubsmsg=tcp://127.0.0.1:{}\n'.format(BASE_ZMQ_PORT + node_id))
|
||||
# minstakeinterval=5 # Using walletsettings stakelimit instead
|
||||
fp.write('stakethreadconddelayms=1000\n')
|
||||
fp.write('smsgsregtestadjust=0\n')
|
||||
|
||||
for i in range(0, num_nodes):
|
||||
if node_id == i:
|
||||
@@ -109,10 +109,15 @@ def wait_for_bid(delay_event, swap_client, bid_id, state=None, sent=False, wait_
|
||||
if delay_event.is_set():
|
||||
raise ValueError('Test stopped.')
|
||||
delay_event.wait(1)
|
||||
bids = swap_client.listBids(sent=sent)
|
||||
|
||||
filters = {
|
||||
'bid_id': bid_id,
|
||||
}
|
||||
bids = swap_client.listBids(sent=sent, filters=filters)
|
||||
assert(len(bids) < 2)
|
||||
for bid in bids:
|
||||
if bid[1] == bid_id:
|
||||
if state is not None and state != bid[4]:
|
||||
if bid[2] == bid_id:
|
||||
if state is not None and state != bid[5]:
|
||||
continue
|
||||
return
|
||||
raise ValueError('wait_for_bid timed out.')
|
||||
@@ -235,7 +240,6 @@ def wait_for_balance(delay_event, url, balance_key, expect_amount, iterations=20
|
||||
i = 0
|
||||
while not delay_event.is_set():
|
||||
rv_js = json.loads(urlopen(url).read())
|
||||
print("[rm] rv_js", rv_js)
|
||||
if float(rv_js[balance_key]) >= expect_amount:
|
||||
break
|
||||
delay_event.wait(delay_time)
|
||||
|
||||
@@ -99,6 +99,7 @@ class XmrTestBase(unittest.TestCase):
|
||||
fp.write('listenonion=0\n')
|
||||
fp.write('upnp=0\n')
|
||||
fp.write('minstakeinterval=5\n')
|
||||
fp.write('smsgsregtestadjust=0\n')
|
||||
for ip in range(3):
|
||||
if ip != i:
|
||||
fp.write('connect=127.0.0.1:{}\n'.format(PARTICL_PORT_BASE + ip))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2020 tecnovert
|
||||
# Copyright (c) 2020-2021 tecnovert
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -218,7 +218,9 @@ class Test(unittest.TestCase):
|
||||
rpc('walletsettings', ['stakingoptions', {'stakecombinethreshold': 100, 'stakesplitthreshold': 200}])
|
||||
|
||||
for i in range(NUM_BTC_NODES):
|
||||
prepareDataDir(TEST_DIR, i, 'bitcoin.conf', 'btc_', base_p2p_port=BTC_BASE_PORT, base_rpc_port=BTC_BASE_RPC_PORT)
|
||||
data_dir = prepareDataDir(TEST_DIR, i, 'bitcoin.conf', 'btc_', base_p2p_port=BTC_BASE_PORT, base_rpc_port=BTC_BASE_RPC_PORT)
|
||||
if os.path.exists(os.path.join(cfg.BITCOIN_BINDIR, 'bitcoin-wallet')):
|
||||
callrpc_cli(cfg.BITCOIN_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat create', 'bitcoin-wallet')
|
||||
|
||||
cls.btc_daemons.append(startDaemon(os.path.join(TEST_DIR, 'btc_' + str(i)), cfg.BITCOIN_BINDIR, cfg.BITCOIND))
|
||||
logging.info('Started %s %d', cfg.BITCOIND, cls.part_daemons[-1].pid)
|
||||
|
||||
@@ -125,6 +125,7 @@ def prepareDir(datadir, nodeId, network_key, network_pubkey):
|
||||
|
||||
fp.write('acceptnonstdtxn=0\n')
|
||||
fp.write('minstakeinterval=5\n')
|
||||
fp.write('smsgsregtestadjust=0\n')
|
||||
|
||||
for i in range(0, NUM_NODES):
|
||||
if nodeId == i:
|
||||
|
||||
@@ -99,6 +99,7 @@ class Test(unittest.TestCase):
|
||||
fp.write('listenonion=0\n')
|
||||
fp.write('upnp=0\n')
|
||||
fp.write('minstakeinterval=5\n')
|
||||
fp.write('smsgsregtestadjust=0\n')
|
||||
for ip in range(3):
|
||||
if ip != i:
|
||||
fp.write('connect=127.0.0.1:{}\n'.format(PARTICL_PORT_BASE + ip))
|
||||
|
||||
@@ -180,6 +180,7 @@ class Test(unittest.TestCase):
|
||||
fp.write('listenonion=0\n')
|
||||
fp.write('upnp=0\n')
|
||||
fp.write('minstakeinterval=5\n')
|
||||
fp.write('smsgsregtestadjust=0\n')
|
||||
salt = generate_salt(16)
|
||||
fp.write('rpcauth={}:{}${}\n'.format('test_part_' + str(i), salt, password_to_hmac(salt, 'test_part_pwd_' + str(i))))
|
||||
for ip in range(NUM_NODES):
|
||||
|
||||
@@ -103,6 +103,7 @@ class Test(unittest.TestCase):
|
||||
fp.write('listenonion=0\n')
|
||||
fp.write('upnp=0\n')
|
||||
fp.write('minstakeinterval=5\n')
|
||||
fp.write('smsgsregtestadjust=0\n')
|
||||
for ip in range(3):
|
||||
if ip != i:
|
||||
fp.write('connect=127.0.0.1:{}\n'.format(PARTICL_PORT_BASE + ip))
|
||||
|
||||
@@ -135,6 +135,7 @@ def prepareDir(datadir, nodeId, network_key, network_pubkey):
|
||||
|
||||
fp.write('acceptnonstdtxn=0\n')
|
||||
fp.write('minstakeinterval=2\n')
|
||||
fp.write('smsgsregtestadjust=0\n')
|
||||
fp.write('stakethreadconddelayms=1000\n')
|
||||
|
||||
for i in range(0, NUM_NODES):
|
||||
|
||||
@@ -68,11 +68,29 @@ class Test(XmrTestBase):
|
||||
offers = json.loads(urlopen('http://127.0.0.1:12701/json/offers').read())
|
||||
offer = offers[0]
|
||||
|
||||
data = parse.urlencode({
|
||||
data = {
|
||||
'offer_id': offer['offer_id'],
|
||||
'amount_from': offer['amount_from']}).encode()
|
||||
'amount_from': offer['amount_from']}
|
||||
|
||||
bid_id = json.loads(urlopen('http://127.0.0.1:12701/json/bids/new', data=data).read())
|
||||
data['valid_for_seconds'] = 24 * 60 * 60 + 1
|
||||
bid = json.loads(urlopen('http://127.0.0.1:12701/json/bids/new', data=parse.urlencode(data).encode()).read())
|
||||
assert(bid['error'] == 'Bid TTL too high')
|
||||
del data['valid_for_seconds']
|
||||
data['validmins'] = 24 * 60 + 1
|
||||
bid = json.loads(urlopen('http://127.0.0.1:12701/json/bids/new', data=parse.urlencode(data).encode()).read())
|
||||
assert(bid['error'] == 'Bid TTL too high')
|
||||
|
||||
del data['validmins']
|
||||
data['valid_for_seconds'] = 10
|
||||
bid = json.loads(urlopen('http://127.0.0.1:12701/json/bids/new', data=parse.urlencode(data).encode()).read())
|
||||
assert(bid['error'] == 'Bid TTL too low')
|
||||
del data['valid_for_seconds']
|
||||
data['validmins'] = 1
|
||||
bid = json.loads(urlopen('http://127.0.0.1:12701/json/bids/new', data=parse.urlencode(data).encode()).read())
|
||||
assert(bid['error'] == 'Bid TTL too low')
|
||||
|
||||
data['validmins'] = 60
|
||||
bid_id = json.loads(urlopen('http://127.0.0.1:12701/json/bids/new', data=parse.urlencode(data).encode()).read())
|
||||
|
||||
waitForNumBids(self.delay_event, 12700, 1)
|
||||
|
||||
@@ -82,6 +100,7 @@ class Test(XmrTestBase):
|
||||
if bid['bid_state'] == 'Received':
|
||||
break
|
||||
self.delay_event.wait(1)
|
||||
assert(bid['expire_at'] == bid['created_at'] + data['validmins'] * 60)
|
||||
|
||||
data = parse.urlencode({
|
||||
'accept': True
|
||||
|
||||
Reference in New Issue
Block a user