Decred: Secret hash swap tests.

This commit is contained in:
tecnovert
2024-05-15 11:39:32 +02:00
parent d527ec4974
commit 76879a2ff5
24 changed files with 1025 additions and 301 deletions

View File

@@ -389,7 +389,7 @@ def extract_states_from_xu_file(file_path, prefix):
return states
def compare_bid_states(states, expect_states, exact_match=True):
def compare_bid_states(states, expect_states, exact_match: bool = True) -> bool:
for i in range(len(states) - 1, -1, -1):
if states[i][1] == 'Bid Delaying':
@@ -417,3 +417,19 @@ def compare_bid_states(states, expect_states, exact_match=True):
logging.info('Have states: {}'.format(json.dumps(states, indent=4)))
raise e
return True
def compare_bid_states_unordered(states, expect_states) -> bool:
for i in range(len(states) - 1, -1, -1):
if states[i][1] == 'Bid Delaying':
del states[i]
try:
assert len(states) == len(expect_states)
for state in expect_states:
assert (any(state in s[1] for s in states))
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