mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
Plugins: Add a test for the 'invoice_payment' notfication
This commit is contained in:
parent
b5bb7f191f
commit
34533ead68
2 changed files with 26 additions and 0 deletions
|
@ -34,6 +34,14 @@ def on_disconnect(plugin, id):
|
|||
plugin.log("Received disconnect event for peer {}".format(id))
|
||||
|
||||
|
||||
@plugin.subscribe("invoice_payment")
|
||||
def on_payment(plugin, invoice_payment):
|
||||
plugin.log("Received invoice_payment event for label {}, preimage {},"
|
||||
" and amount of {}".format(invoice_payment.get("label"),
|
||||
invoice_payment.get("preimage"),
|
||||
invoice_payment.get("msat")))
|
||||
|
||||
|
||||
@plugin.hook("htlc_accepted")
|
||||
def on_htlc_accepted(onion, htlc, plugin):
|
||||
plugin.log('on_htlc_accepted called')
|
||||
|
|
|
@ -476,3 +476,21 @@ def test_warning_notification(node_factory):
|
|||
l1.daemon.wait_for_log('plugin-pretend_badlog.py time: *')
|
||||
l1.daemon.wait_for_log('plugin-pretend_badlog.py source: plugin-pretend_badlog.py')
|
||||
l1.daemon.wait_for_log('plugin-pretend_badlog.py log: Test warning notification\\(for broken event\\)')
|
||||
|
||||
|
||||
def test_invoice_payment_notification(node_factory):
|
||||
"""
|
||||
Test the 'invoice_payment' notification
|
||||
"""
|
||||
opts = [{}, {"plugin": "contrib/plugins/helloworld.py"}]
|
||||
l1, l2 = node_factory.line_graph(2, opts=opts)
|
||||
|
||||
msats = 12345
|
||||
preimage = '1' * 64
|
||||
label = "a_descriptive_label"
|
||||
inv1 = l2.rpc.invoice(msats, label, 'description', preimage=preimage)
|
||||
l1.rpc.pay(inv1['bolt11'])
|
||||
|
||||
l2.daemon.wait_for_log(r"Received invoice_payment event for label {},"
|
||||
" preimage {}, and amount of {}msat"
|
||||
.format(label, preimage, msats))
|
||||
|
|
Loading…
Add table
Reference in a new issue