Skip to content

Commit

Permalink
pytest: Add test for keysend feature support
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker committed Nov 30, 2020
1 parent 20fec4b commit 9dc9a51
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -2972,13 +2972,22 @@ def test_excluded_adjacent_routehint(node_factory, bitcoind, compat):

def test_keysend(node_factory):
amt = 10000
l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True)
l1, l2, l3, l4 = node_factory.line_graph(
4,
wait_for_announce=True,
opts=[{}, {}, {}, {'disable-plugin': 'keysend'}]
)

# The keysend featurebit must be set in the announcement, i.e., l1 should
# learn that l3 supports keysends.
features = l1.rpc.listnodes(l3.info['id'])['nodes'][0]['features']
assert(int(features, 16) >> 55 & 0x01 == 1)

# If we disable keysend, then the featurebit must not be set,
# i.e., l4 doesn't support it.
features = l1.rpc.listnodes(l4.info['id'])['nodes'][0]['features']
assert(int(features, 16) >> 55 & 0x01 == 0)

# Send an indirect one from l1 to l3
l1.rpc.keysend(l3.info['id'], amt)
invs = l3.rpc.listinvoices()['invoices']
Expand All @@ -2996,6 +3005,11 @@ def test_keysend(node_factory):
inv = invs[0]
assert(inv['msatoshi_received'] >= amt)

# And finally try to send a keysend payment to l4, which doesn't
# support it. It MUST fail.
with pytest.raises(RpcError, match=r"Recipient [0-9a-f]{66} does not support keysend payments"):
l3.rpc.keysend(l4.info['id'], amt)


def test_invalid_onion_channel_update(node_factory):
'''
Expand Down

0 comments on commit 9dc9a51

Please sign in to comment.