Skip to content

Commit

Permalink
lnprototest: remove refused and fixed the types
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Mar 30, 2022
1 parent e88ac02 commit 2db6d42
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
4 changes: 0 additions & 4 deletions lnprototest/funding.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,6 @@ def from_utxo(
tx.wit = CTxWitness([CTxInWitness(CScriptWitness([sig, inkey_pub.format()]))])
return funding, tx.serialize().hex()

def script_pub_key(self) -> str:
"""Return the script pub key"""
return CScript([script.OP_0, sha256(self.redeemscript()).digest()]).hex()

def channel_id(self) -> str:
# BOLT #2: This message introduces the `channel_id` to identify the
# channel. It's derived from the funding transaction by combining the
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def gen_random_keyset(counter: int = 20) -> KeySet:
)


def get_traceback(e):
def get_traceback(e: Exception) -> str:
lines = traceback.format_exception(type(e), e, e.__traceback__)
return "".join(lines)

Expand Down
24 changes: 18 additions & 6 deletions tests/test_bolt2-01-close_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
Msg,
Runner,
TryAll,
OneOf,
)
from helpers import run_runner, merge_events_sequences, tx_spendable
from lnprototest.stash import channel_id
Expand Down Expand Up @@ -74,18 +75,29 @@ def test_close_channel_shutdown_msg_normal_case(runner: Runner) -> None:
# the status of the channel is changed.
# We may or we MUST?
# FIXME: when this have sense? when there is not update?
TryAll(
OneOf(
# channel_update to change the state of the channel from
# NORMAL -> SHUTDOWN
[ExpectMsg("channel_update")],
[
ExpectMsg("channel_update"),
ExpectMsg("shutdown", channel_id=channel_idx),
],
# channel_update to change the state of the connection from
# NORMAL -> SHUTDOWN -> ONCHAIN
[ExpectMsg("channel_update"), ExpectMsg("channel_update")],
[
ExpectMsg("channel_update"),
ExpectMsg("channel_update"),
ExpectMsg("shutdown", channel_id=channel_idx),
],
[
ExpectMsg("channel_update"),
ExpectMsg("channel_update"),
ExpectMsg("channel_update"),
ExpectMsg("shutdown", channel_id=channel_idx),
],
# No channel_update received
[],
[ExpectMsg("shutdown", channel_id=channel_idx)],
),
# Some times I receive a channel update, why?
ExpectMsg("shutdown", channel_id=channel_idx),
# FIXME: We should not be able to ping the node right?
],
# ln implementation sent the shutdown message
Expand Down

0 comments on commit 2db6d42

Please sign in to comment.