-
Notifications
You must be signed in to change notification settings - Fork 35
use a strongly type library for messages #125
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
base: master
Are you sure you want to change the base?
Conversation
| def __init__( | ||
| self, | ||
| connprivkey: str, | ||
| counterparty_pubkey: str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set it to the default value because we are already forcing it at the user level
| def send_msg(self, msg: Message) -> None: | ||
| """Send a message through the last connection""" | ||
| missing = msg.missing_fields() | ||
| if missing: | ||
| raise SpecFileError(self, "Missing fields {}".format(missing)) | ||
| binmsg = io.BytesIO() | ||
| msg.write(binmsg) | ||
| self.last_conn.connection.send_message(msg.getvalue()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not including the init_msg = runner.recv_msg() inside this function? and return the InitMessage?
There is no reason to keep a generic interface in the runner and provide the implementation in the core lightning runner if the only way to establish a connection with the node is through the pyln.proto package. This commit moves the CLightningConn inside the runner interface to allow everyone access to the default implementation. Signed-off-by: Vincenzo Palazzo <[email protected]>
This commit marks the first step in the lnprototest
refactoring process, aimed at writing more readable
tests with the runner.
With this commit, it becomes possible to write tests
similar to the following example.
```
def test_v2_init_is_first_msg(runner: Runner, namespaceoverride: Any) -> None:
"""Tests workflow
runner --- connect ---> ln node
runner <-- init ------ ln node
"""
runner.start()
runner.connect(None, connprivkey="03")
init_msg = runner.recv_msg()
assert (
init_msg.messagetype.number == 16
), f"received not an init msg but: {init_msg.to_str()}"
runner.stop()
```
Signed-off-by: Vincenzo Palazzo <[email protected]>
This commit introduce the ability to stash information inside the connection. This function allow lnprototest to build connection that can keep state by connection. Signed-off-by: Vincenzo Palazzo <[email protected]>
This commit remove the dummy runner because it is starting to be painful to keep supporting it with the addition of feature. For historical reason I think the dummy runner was used to check the logic of the lnprototest, but with the refactoring that we are doing. Signed-off-by: Vincenzo Palazzo <[email protected]>
…nection This commit enable the connection to send a message through the wire in an ergonomic way. This feature is a basic blocks for the lnprototest refactoring that allow to semplify how to write test with lnprototest in the future by keeping the state with the peer by connection and keep inside the runner just the necessary logic to interact with the node. Signed-off-by: Vincenzo Palazzo <[email protected]>
3c5ef6f to
ac75deb
Compare
Build on top of #95
This introduces the message-generated library in the commit 3c5ef6f
This is still a PoC and large experiment, but seems to be nicer than the previous API