Skip to content

Commit

Permalink
fix: Correct error check for expected errors
Browse files Browse the repository at this point in the history
This commit addresses an issue with the error checking
mechanism. Currently, the `ExpectError` function only verifies
the occurrence of an error during the connection, without considering
the specific error message expected.

The upcoming changes in [1] will simplify lnprototest, but until then,
this fix provides a straightforward and effective solution for
checking error messages.

[1] #95

Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Jul 15, 2023
1 parent 5607d31 commit 3dafe1d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lnprototest/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,16 @@ def action(self, runner: "Runner") -> bool:
error = runner.check_error(self, self.find_conn(runner))
if error is None:
raise EventError(self, "No error found")
if runner._is_dummy():
return True
error = bytes.fromhex(error)
msg = Message.read(namespace(), io.BytesIO(error))
logging.info(f"message received {msg.messagetype.name}, hex {error.hex()}")
if msg.messagetype.name not in "error":
raise EventError(
self,
f"not error found but received `{msg.messagetype.name}` with hex: `{error.hex()}`",
)
return True


Expand Down

0 comments on commit 3dafe1d

Please sign in to comment.