Skip to content

Conversation

@vincenzopalazzo
Copy link
Collaborator

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

def __init__(
self,
connprivkey: str,
counterparty_pubkey: str,
Copy link
Collaborator Author

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

Comment on lines +176 to +228
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())
Copy link
Collaborator Author

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]>
@vincenzopalazzo vincenzopalazzo force-pushed the macros/v2-generated-types branch from 3c5ef6f to ac75deb Compare April 5, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants