diff --git a/docker/Dockerfile.clightning b/docker/Dockerfile.clightning index 7cd9a37..374733d 100644 --- a/docker/Dockerfile.clightning +++ b/docker/Dockerfile.clightning @@ -61,7 +61,7 @@ RUN git config --global user.name "John Doe" && \ cd lightning && \ poetry config virtualenvs.create false && \ poetry install && \ - ./configure --enable-developer && \ + ./configure && \ make -j$(nproc) RUN mkdir lnprototest diff --git a/lnprototest/event.py b/lnprototest/event.py index 96f2cf7..6e858ba 100644 --- a/lnprototest/event.py +++ b/lnprototest/event.py @@ -346,7 +346,7 @@ def action(self, runner: "Runner") -> bool: raise EventError( self, "Got msg banned by {}: {}".format(e, binmsg.hex()) ) - logging.debug(f"raw msg {binmsg}") + logging.debug(f"raw msg {''.join('%02x' % b for b in binmsg)}") # Might be completely unknown to namespace. try: msg = Message.read(namespace(), io.BytesIO(binmsg)) @@ -378,7 +378,7 @@ class Block(Event): def __init__( self, - blockheight: int, + blockheight: Union[int, Callable], number: Union[int, Callable] = 1, txs: List[ResolvableStr] = [], ): @@ -389,6 +389,10 @@ def __init__( def action(self, runner: "Runner") -> bool: super().action(runner) + + if isinstance(self.blockheight, Callable): + self.blockheight = self.resolve_arg(None, runner, self.blockheight) + # Oops, did they ask us to produce a block with no predecessor? if runner.getblockheight() + 1 < self.blockheight: raise SpecFileError( @@ -397,7 +401,6 @@ def action(self, runner: "Runner") -> bool: self.blockheight, runner.getblockheight() ), ) - # Throw away blocks we're replacing. if runner.getblockheight() >= self.blockheight: runner.trim_blocks(self.blockheight - 1) diff --git a/lnprototest/utils/ln_spec_utils.py b/lnprototest/utils/ln_spec_utils.py index 8becebf..0eede74 100644 --- a/lnprototest/utils/ln_spec_utils.py +++ b/lnprototest/utils/ln_spec_utils.py @@ -199,7 +199,7 @@ def open_and_announce_channel_helper( ), # Mine it and get it deep enough to confirm channel. Block( - blockheight=103, + blockheight=block_height, number=stash_field_from_event( "accept_channel", field_name="minimum_depth", dummy_val=3 ), @@ -216,9 +216,12 @@ def open_and_announce_channel_helper( second_per_commitment_point=local_keyset.per_commit_point(1), ), # wait confirmations - Block(blockheight=103, number=6), - # BOLT 2: # - # Once both nodes have exchanged channel_ready (and optionally announcement_signatures), - # the channel can be used to make payments via Hashed Time Locked Contracts. + # FIXME: Uh! do you know why this sucks, because lnprototest is lazy evaluated. + # This is huggly, and we should change it at some point but this now works. + Block( + blockheight=lambda runner, event, _: block_height + + runner.get_stash(event, "accept_channel").fields["minimum_depth"], + number=6, + ), ] diff --git a/tests/test_bolt2-01-open_channel.py b/tests/test_bolt2-01-open_channel.py index f70d014..8a9d0ac 100644 --- a/tests/test_bolt2-01-open_channel.py +++ b/tests/test_bolt2-01-open_channel.py @@ -299,6 +299,10 @@ def test_open_channel_opener_side_wrong_announcement_signatures(runner: Runner) dummy_sign = "138c93afb2013c39f959e70a163c3d6d8128cf72f8ae143f87b9d1fd6bb0ad30321116b9c58d69fca9fb33c214f681b664e53d5640abc2fdb972dc62a5571053" short_channel_id = opts["short_channel_id"] test_events = [ + # BOLT 2: + # + # - Once both nodes have exchanged channel_ready (and optionally announcement_signatures), + # the channel can be used to make payments via Hashed Time Locked Contracts. ExpectMsg( "announcement_signatures", channel_id=channel_id(),