Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve error printing #43

Open
vincenzopalazzo opened this issue Mar 28, 2022 · 0 comments
Open

improve error printing #43

vincenzopalazzo opened this issue Mar 28, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@vincenzopalazzo
Copy link
Collaborator

During the assertion, we have the message in hexadecimal, to have a clean way to have get the message content.

This is an example of stacktrace with an error message

tests/test_bolt2-01-close_channel.py:72: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

runner = <lnprototest.clightning.clightning.Runner object at 0x7fe3eab2f970>
test = [Block:spec_helper.py:41, Connect:spec_helper.py:42, ExpectMsg:spec_helper.py:43, Msg:spec_helper.py:44, Block:spec_helper.py:45, RawMsg:spec_helper.py:46, ...]

    def run_runner(runner: Runner, test: Union[Sequence, List[Event], Event]) -> None:
        """
        The pytest using the assertion as safe failure, and the exception it is only
        an event that must not happen.
    
        From design, lnprototest fails with an exception, and for this reason, if the
        lnprototest throws an exception, we catch it, and we fail with an assent.
        """
        try:
            runner.run(test)
        except Exception as ex:
            runner.stop()
            logging.error(get_traceback(ex))
>           assert False, ex
E           AssertionError: (ExpectMsg:test_bolt2-01-close_channel.py:70, 'Expected msgtype-shutdown, got msgtype-error: message was error channel_id=a37362839b13f61cfe82d35bd397b1264c389b245847cfb6111b38892546dc77 data=556e6b6e6f776e206368616e6e656c20666f7220574952455f53485554444f574e')

tests/helpers.py:169: AssertionError
----------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
ERROR    root:helpers.py:168 Traceback (most recent call last):
  File "/home/vincent/Github/lnprototest/tests/helpers.py", line 165, in run_runner
    runner.run(test)
  File "/home/vincent/Github/lnprototest/lnprototest/runner.py", line 103, in run
    all_done = sequence.action(self)
  File "/home/vincent/Github/lnprototest/lnprototest/structure.py", line 52, in action
    all_done &= e.action(runner)
  File "/home/vincent/Github/lnprototest/lnprototest/event.py", line 347, in action
    raise EventError(self, "{}: message was {}".format(err, msg.to_str()))
lnprototest.errors.EventError: (ExpectMsg:test_bolt2-01-close_channel.py:70, 'Expected msgtype-shutdown, got msgtype-error: message was error channel_id=a37362839b13f61cfe82d35bd397b1264c389b245847cfb6111b38892546dc77 data=556e6b6e6f776e206368616e6e656c20666f7220574952455f53485554444f574e')
========================================================================== short test summary info ==========================================================================
FAILED tests/test_bolt2-01-close_channel.py::test_close_channel_shutdown_msg - AssertionError: (ExpectMsg:test_bolt2-01-close_channel.py:70, 'Expected msgtype-shutdown, g...
===================================================================== 1 failed, 27 deselected in 9.28s ======================================================================
make: *** [Makefile:14: check] Error 1

Where the data in this case is Unknown channel for WIRE_SHUTDOWN that is contained inside the data=556e6b6e6f776e206368616e6e656c20666f7220574952455f53485554444f574e in the following error message

E AssertionError: (ExpectMsg:test_bolt2-01-close_channel.py:70, 'Expected msgtype-shutdown, got msgtype-error: message was error channel_id=a37362839b13f61cfe82d35bd397b1264c389b245847cfb6111b38892546dc77 ')

@vincenzopalazzo vincenzopalazzo added enhancement New feature or request good first issue Good for newcomers labels Mar 28, 2022
@vincenzopalazzo vincenzopalazzo added this to the lnprototest 0.0.1 milestone Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant