def verify_state(expected_state: AccountState, state: BaseState) -> None: diff = diff_state(expected_state, state) if diff: error_messages = [] for account, field, actual_value, expected_value in diff: if field == 'balance': error_messages.append( "{0}({1}) | Actual: {2} | Expected: {3} | Delta: {4}". format( to_normalized_address(account), 'balance', actual_value, expected_value, cast(int, actual_value) - cast(int, expected_value), )) else: error_messages.append( "{0}({1}) | Actual: {2} | Expected: {3}".format( to_normalized_address(account), field, actual_value, expected_value, )) raise AssertionError( "State DB did not match expected state on {0} values:\n" "{1}".format( len(error_messages), "\n - ".join(error_messages), ))
def verify_state(expected_state: AccountState, state: StateAPI) -> None: diff = diff_state(expected_state, state) new_line = "\n" if diff: error_messages = [] for account, field, actual_value, expected_value in diff: if field == 'balance': error_messages.append( f"{to_normalized_address(account)}(balance) | " f"Actual: {actual_value!r} | Expected: {expected_value!r} | " f"Delta: {cast(int, actual_value) - cast(int, expected_value)}" ) else: error_messages.append( f"{to_normalized_address(account)}({field}) | " f"Actual: {actual_value!r} | Expected: {expected_value!r}") raise AssertionError( f"State DB did not match expected state on {len(error_messages)} values:{new_line}" f"{f'{new_line} - '.join(error_messages)}")