Skip to content

Commit 4ed0435

Browse files
rustyrussellShahanaFarooqui
authored andcommitted
pytest: fix block count in test_zeroconf_forget.
We actually need to mine another block, so that lightningd considers both channels candidates for forgetting (and forgets the older one). Reported-by: daywalker90 Signed-off-by: Rusty Russell <[email protected]>
1 parent da56a8e commit 4ed0435

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

tests/test_opening.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2736,15 +2736,19 @@ def censoring_sendrawtx(tx):
27362736
l1.rpc.pay(inv["bolt11"])
27372737
wait_for(lambda: only_one(l2.rpc.listpeerchannels()['channels'])['to_us_msat'] == 1)
27382738

2739-
# We need *another* channel to make it forget the first though!
2739+
# We need *another* channel to make it forget the first though! (One block later, otherwise
2740+
# *this* might be forgotten).
2741+
bitcoind.generate_block(1)
2742+
sync_blockheight(bitcoind, [l2])
2743+
27402744
l3.connect(l2)
27412745
l3.rpc.fundchannel(l2.info["id"], 10**6, mindepth=0)
27422746
bitcoind.generate_block(1)
27432747

27442748
# Now stop, in order to cause catchup and re-evaluate whether to forget the channel
27452749
l2.stop()
27462750

2747-
# Now we generate enough blocks to cause l2 to forget the channel.
2751+
# Now we generate enough blocks to cause l2 consider both channels forgettable.
27482752
bitcoind.generate_block(blocks - 1) # > blocks
27492753
l2.start()
27502754

@@ -2755,16 +2759,14 @@ def censoring_sendrawtx(tx):
27552759
bitcoind.generate_block(1)
27562760
sync_blockheight(bitcoind, [l1, l2])
27572761

2758-
# This may take a moment!
2759-
time.sleep(5)
2760-
2761-
have_forgotten = l2.daemon.is_in_log(
2762-
r"UNUSUAL {}-chan#1: Forgetting channel: It has been 51 blocks without the funding transaction ".format(l1.info['id'])
2763-
)
2764-
2762+
# If we made a payment it will *not* consider there to tbe two forgettable channels.
27652763
if dopay:
2766-
assert not have_forgotten
2764+
# This may take a moment!
2765+
time.sleep(5)
2766+
2767+
assert not l2.daemon.is_in_log('Forgetting channel')
27672768
assert set([c['peer_id'] for c in l2.rpc.listpeerchannels()["channels"]]) == set([l1.info['id'], l3.info['id']])
27682769
else:
2769-
assert have_forgotten
2770+
# It will forget the older one.
2771+
l2.daemon.wait_for_log(r"UNUSUAL {}-chan#1: Forgetting channel: It has been {} blocks without the funding transaction ".format(l1.info['id'], blocks + 1))
27702772
assert [c['peer_id'] for c in l2.rpc.listpeerchannels()["channels"]] == [l3.info['id']]

0 commit comments

Comments
 (0)