Skip to content

Commit

Permalink
pytest: test new commitment_revocation hook values
Browse files Browse the repository at this point in the history
  • Loading branch information
m-schmoock committed Sep 3, 2021
1 parent b17b0a8 commit 845c8ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tests/plugins/watchtower.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@


@plugin.hook('commitment_revocation')
def on_commitment_revocation(commitment_txid, penalty_tx, plugin, **kwargs):
def on_commitment_revocation(commitment_txid, penalty_tx, channel_id, commitnum, plugin, **kwargs):
with open('watchtower.csv', 'a') as f:
f.write("{}, {}\n".format(commitment_txid, penalty_tx))
f.write("{}, {}, {}, {}\n".format(commitment_txid, penalty_tx, channel_id, commitnum))


plugin.run()
7 changes: 6 additions & 1 deletion tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,7 @@ def test_watchtower(node_factory, bitcoind, directory, chainparams):
2,
opts=[{'may_fail': True, 'allow_broken_log': True}, {'plugin': p}]
)
channel_id = l1.rpc.listpeers()['peers'][0]['channels'][0]['channel_id']

# Force a new commitment
l1.rpc.pay(l2.rpc.invoice(25000000, 'lbl1', 'desc1')['bolt11'])
Expand All @@ -1821,8 +1822,12 @@ def test_watchtower(node_factory, bitcoind, directory, chainparams):
)

cheat_tx = bitcoind.rpc.decoderawtransaction(tx)
lastcommitnum = 0
for l in open(wt_file, 'r'):
txid, penalty = l.strip().split(', ')
txid, penalty, channel_id_hook, commitnum = l.strip().split(', ')
assert lastcommitnum == int(commitnum)
assert channel_id_hook == channel_id
lastcommitnum += 1
if txid == cheat_tx['txid']:
# This one should succeed, since it is a response to the cheat_tx
bitcoind.rpc.sendrawtransaction(penalty)
Expand Down

0 comments on commit 845c8ed

Please sign in to comment.