tests: Print expected and actual states on failure.
This commit is contained in:
parent
db0e85d37c
commit
2a2f1ca3b6
@ -371,20 +371,25 @@ def compare_bid_states(states, expect_states, exact_match=True):
|
|||||||
if states[i][1] == 'Bid Delaying':
|
if states[i][1] == 'Bid Delaying':
|
||||||
del states[i]
|
del states[i]
|
||||||
|
|
||||||
if exact_match:
|
try:
|
||||||
assert (len(states) == len(expect_states))
|
if exact_match:
|
||||||
else:
|
assert (len(states) == len(expect_states))
|
||||||
assert (len(states) >= len(expect_states))
|
else:
|
||||||
|
assert (len(states) >= len(expect_states))
|
||||||
|
|
||||||
for i in range(len(expect_states)):
|
for i in range(len(expect_states)):
|
||||||
s = states[i]
|
s = states[i]
|
||||||
if s[1] != expect_states[i]:
|
if s[1] != expect_states[i]:
|
||||||
if 'Bid ' + expect_states[i] == s[1]:
|
if 'Bid ' + expect_states[i] == s[1]:
|
||||||
logging.warning(f'Expected state {expect_states[i]} not an exact match to {s[1]}.')
|
logging.warning(f'Expected state {expect_states[i]} not an exact match to {s[1]}.')
|
||||||
continue
|
continue
|
||||||
if [s[0], expect_states[i]] in states:
|
if [s[0], expect_states[i]] in states:
|
||||||
logging.warning(f'Expected state {expect_states[i]} found out of order at the same time as {s[1]}.')
|
logging.warning(f'Expected state {expect_states[i]} found out of order at the same time as {s[1]}.')
|
||||||
continue
|
continue
|
||||||
raise ValueError(f'Expected state {expect_states[i]}, found {s[1]}')
|
raise ValueError(f'Expected state {expect_states[i]}, found {s[1]}')
|
||||||
assert (s[1] == expect_states[i])
|
assert (s[1] == expect_states[i])
|
||||||
|
except Exception as e:
|
||||||
|
logging.info('Expecting states: {}'.format(json.dumps(expect_states, indent=4)))
|
||||||
|
logging.info('Have states: {}'.format(json.dumps(states, indent=4)))
|
||||||
|
raise e
|
||||||
return True
|
return True
|
||||||
|
@ -978,7 +978,7 @@ class Test(BaseTest):
|
|||||||
|
|
||||||
offer_id = swap_clients[0].postOffer(
|
offer_id = swap_clients[0].postOffer(
|
||||||
Coins.PART, Coins.XMR, 101 * COIN, 0.13 * XMR_COIN, 101 * COIN, SwapTypes.XMR_SWAP,
|
Coins.PART, Coins.XMR, 101 * COIN, 0.13 * XMR_COIN, 101 * COIN, SwapTypes.XMR_SWAP,
|
||||||
lock_type=TxLockTypes.SEQUENCE_LOCK_BLOCKS, lock_value=12)
|
lock_type=TxLockTypes.SEQUENCE_LOCK_BLOCKS, lock_value=16)
|
||||||
wait_for_offer(test_delay_event, swap_clients[1], offer_id)
|
wait_for_offer(test_delay_event, swap_clients[1], offer_id)
|
||||||
offer = swap_clients[1].getOffer(offer_id)
|
offer = swap_clients[1].getOffer(offer_id)
|
||||||
|
|
||||||
@ -994,7 +994,7 @@ class Test(BaseTest):
|
|||||||
|
|
||||||
swap_clients[0].acceptXmrBid(bid_id)
|
swap_clients[0].acceptXmrBid(bid_id)
|
||||||
|
|
||||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_STALLED_FOR_TEST, wait_for=180)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_STALLED_FOR_TEST, wait_for=220)
|
||||||
wait_for_bid(test_delay_event, swap_clients[1], bid_id, BidStates.XMR_SWAP_FAILED_SWIPED, wait_for=80, sent=True)
|
wait_for_bid(test_delay_event, swap_clients[1], bid_id, BidStates.XMR_SWAP_FAILED_SWIPED, wait_for=80, sent=True)
|
||||||
|
|
||||||
wait_for_none_active(test_delay_event, 1800)
|
wait_for_none_active(test_delay_event, 1800)
|
||||||
|
Loading…
Reference in New Issue
Block a user