mirror of
https://github.com/basicswap/basicswap.git
synced 2024-11-16 15:58:17 +00:00
scripts: Print errors if offer/bid creation fails.
This commit is contained in:
parent
b409fe9f0e
commit
258b730c41
2 changed files with 38 additions and 0 deletions
|
@ -326,6 +326,8 @@ def main():
|
|||
if args.debug:
|
||||
print('offer data {}'.format(offer_data))
|
||||
new_offer = read_json_api('offers/new', offer_data)
|
||||
if 'error' in new_offer:
|
||||
raise ValueError('Server failed to create offer: {}'.format(new_offer['error']))
|
||||
print('New offer: {}'.format(new_offer['offer_id']))
|
||||
if 'offers' not in script_state:
|
||||
script_state['offers'] = {}
|
||||
|
@ -516,6 +518,8 @@ def main():
|
|||
if args.debug:
|
||||
print('Creating bid: {}'.format(bid_data))
|
||||
new_bid = read_json_api('bids/new', bid_data)
|
||||
if 'error' in new_bid:
|
||||
raise ValueError('Server failed to create bid: {}'.format(new_bid['error']))
|
||||
print('New bid: {} on offer {}'.format(new_bid['bid_id'], offer['offer_id']))
|
||||
bid_id = new_bid['bid_id']
|
||||
|
||||
|
|
|
@ -553,6 +553,40 @@ class Test(unittest.TestCase):
|
|||
rv_stdout = result.stdout.decode().split('\n')
|
||||
'''
|
||||
|
||||
def test_error_messages(self):
|
||||
waitForServer(self.delay_event, UI_PORT + 0)
|
||||
waitForServer(self.delay_event, UI_PORT + 1)
|
||||
|
||||
# Reset test
|
||||
clear_offers(self.delay_event, 0)
|
||||
delete_file(self.node0_statefile)
|
||||
delete_file(self.node1_statefile)
|
||||
wait_for_offers(self.delay_event, 1, 0)
|
||||
|
||||
node0_test1_config = {
|
||||
'offers': [
|
||||
{
|
||||
'name': 'offer should fail',
|
||||
'coin_from': 'Particl',
|
||||
'coin_to': 'XMR',
|
||||
'amount': 20,
|
||||
'minrate': 0.05,
|
||||
'ratetweakpercent': 50000000,
|
||||
'amount_variable': True,
|
||||
'address': -1,
|
||||
'min_coin_from_amt': 20,
|
||||
'max_coin_to_amt': -1
|
||||
}
|
||||
],
|
||||
}
|
||||
with open(self.node0_configfile, 'w') as fp:
|
||||
json.dump(node0_test1_config, fp, indent=4)
|
||||
|
||||
logging.info('Test that an offer is created')
|
||||
result = subprocess.run(self.node0_args, stdout=subprocess.PIPE)
|
||||
rv_stdout = result.stdout.decode().split('\n')
|
||||
assert (count_lines_with(rv_stdout, 'Error: Server failed to create offer: To amount above max') == 1)
|
||||
|
||||
def test_bid_tracking(self):
|
||||
|
||||
waitForServer(self.delay_event, UI_PORT + 0)
|
||||
|
|
Loading…
Reference in a new issue