Skip to content

Commit

Permalink
fix: runner_features added
Browse files Browse the repository at this point in the history
  • Loading branch information
Psycho-Pirate committed Jun 19, 2023
1 parent e51fb97 commit b024075
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 5 deletions.
11 changes: 11 additions & 0 deletions lnprototest/clightning/clightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Conn,
namespace,
MustNotMsg,
bitfield,
)
from lnprototest import wait_for
from typing import Dict, Any, Callable, List, Optional, cast
Expand Down Expand Up @@ -505,3 +506,13 @@ def has_option(self, optname: str) -> Optional[str]:
def add_startup_flag(self, flag: str) -> None:
logging.debug("[ADD STARTUP FLAG '{}']".format(flag))
self.startup_flags.append("--{}".format(flag))

def runner_features(
self,
additional_features: Optional[List[int]] = None,
fieldname: Optional[str] = None,
) -> str:
if additional_features is None:
return ""
else:
return bitfield(*additional_features)
7 changes: 7 additions & 0 deletions lnprototest/dummyrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,10 @@ def is_running(self) -> bool:

def teardown(self):
pass

def runner_features(
self,
additional_features: Optional[List[int]] = None,
fieldname: Optional[str] = None,
) -> str:
return ""
11 changes: 11 additions & 0 deletions lnprototest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,17 @@ def close_channel(self, channel_id: str) -> None:
"""
pass

@abstractmethod
def runner_features(
self,
additional_features: Optional[List[int]] = None,
fieldname: Optional[str] = None,
) -> str:
"""
Provide the features required by the node.
"""
pass


def remote_revocation_basepoint() -> Callable[[Runner, Event, str], str]:
"""Get the remote revocation basepoint"""
Expand Down
18 changes: 15 additions & 3 deletions tests/test_bolt2-01-close_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ def test_close_channel_shutdown_msg_normal_case_receiver_side(runner: Runner) ->
# the option that the helper method feels for us
test_opts = {}
pre_events_conn = connect_to_node_helper(
runner, tx_spendable=tx_spendable, conn_privkey="03"
runner=runner,
tx_spendable=tx_spendable,
conn_privkey="03",
global_features=runner.runner_features(fieldname="global_features"),
features=runner.runner_features(fieldname="features"),
)
pre_events = open_and_announce_channel_helper(
runner, conn_privkey="03", opts=test_opts
Expand Down Expand Up @@ -105,7 +109,11 @@ def test_close_channel_shutdown_msg_normal_case_sender_side(runner: Runner) -> N
# the option that the helper method feels for us
test_opts = {}
pre_events_conn = connect_to_node_helper(
runner, tx_spendable=tx_spendable, conn_privkey="03"
runner=runner,
tx_spendable=tx_spendable,
conn_privkey="03",
global_features=runner.runner_features(fieldname="global_features"),
features=runner.runner_features(fieldname="features"),
)
pre_events = open_and_announce_channel_helper(
runner, conn_privkey="03", opts=test_opts
Expand Down Expand Up @@ -140,7 +148,11 @@ def test_close_channel_shutdown_msg_wrong_script_pubkey_receiver_side(
# the option that the helper method feels for us
test_opts = {}
pre_events_conn = connect_to_node_helper(
runner, tx_spendable=tx_spendable, conn_privkey="03"
runner=runner,
tx_spendable=tx_spendable,
conn_privkey="03",
global_features=runner.runner_features(fieldname="global_features"),
features=runner.runner_features(fieldname="features"),
)
pre_events = open_and_announce_channel_helper(
runner, conn_privkey="03", opts=test_opts
Expand Down
12 changes: 10 additions & 2 deletions tests/test_bolt2-01-open_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ def test_open_channel_from_accepter_side(runner: Runner) -> None:
local_funding_privkey = "20"
local_keyset = gen_random_keyset(int(local_funding_privkey))
connections_events = connect_to_node_helper(
runner=runner, tx_spendable=tx_spendable, conn_privkey="02"
runner=runner,
tx_spendable=tx_spendable,
conn_privkey="02",
global_features=runner.runner_features(fieldname="global_features"),
features=runner.runner_features(fieldname="features"),
)

# Accepter side: we initiate a new channel.
Expand Down Expand Up @@ -179,7 +183,11 @@ def test_open_channel_opener_side(runner: Runner) -> None:
local_funding_privkey = "20"
local_keyset = gen_random_keyset(int(local_funding_privkey))
connections_events = connect_to_node_helper(
runner=runner, tx_spendable=tx_spendable, conn_privkey="02"
runner=runner,
tx_spendable=tx_spendable,
conn_privkey="02",
global_features=runner.runner_features(fieldname="global_features"),
features=runner.runner_features(fieldname="features"),
)

# Now we test the 'opener' side of an open_channel (node initiates)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_bolt2-02-reestablish.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def test_reestablish(runner: Runner) -> None:
runner=runner,
tx_spendable=tx_spendable,
conn_privkey="02",
global_features=runner.runner_features(fieldname="global_features"),
features=runner.runner_features(fieldname="features"),
)

test_events = [
Expand Down

0 comments on commit b024075

Please sign in to comment.