Skip to content

Commit

Permalink
tests: modify tests for VLS
Browse files Browse the repository at this point in the history
Added explicit preapproveinvoice/preapprovekeysend:
- tests/test_pay.py::test_setchannel_routing
- tests/test_pay.py::test_forward_pad_fees_and_cltv
- tests/test_pay.py::test_forward_different_fees_and_cltv
- tests/test_renepay.py::test_pay
- tests/test_renepay.py::test_htlc_max
- tests/test_renepay.py::test_fee_allocation
- tests/test_renepay.py::test_fees
- tests/test_renepay.py::test_previous_sendpays

SKIPPED:
- tests/test_db.py::test_db_forward_migrate : no such channel
- tests/test_invoices.py::test_invoices_wait_db_migration : no such channel
- tests/test_reckless.py::test_poetry_install : no canned github server in gitlab CI
- tests/test_reckless.py::test_install : no canned github server in gitlab CI
- tests/test_reckless.py::test_tag_install : no canned github server in gitlab CI

VLS_SKIP_SPLICE_TESTS:
- tests/test_splicing_insane.py::test_splice_insane
- tests/test_bookkeeper.py::test_bookkeeping_inspect_mfc_dual_funded

VLS_PERMISSIVE:
- tests/test_pay.py::test_pay_disconnect : feerate above maximum: 880782 > 151000
  • Loading branch information
ksedgwic committed Mar 7, 2024
1 parent 33d0cfd commit 10eb20b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions tests/test_bookkeeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ def test_bookkeeping_inspect_multifundchannel(node_factory, bitcoind):
assert bkpr_total_fee_msat == int(getblock_fee_btc * 100000000000)


@unittest.skipIf(os.getenv('SUBDAEMON').startswith('hsmd:remote_hsmd') and os.getenv('VLS_SKIP_SPLICE_TESTS') == '1', "test expected to fail before VLS dual-funding / splicing support")
@unittest.skipIf(TEST_NETWORK != 'regtest', "network fees hardcoded")
@pytest.mark.openchannel('v2')
def test_bookkeeping_inspect_mfc_dual_funded(node_factory, bitcoind):
Expand Down
1 change: 1 addition & 0 deletions tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ def test_db_sanity_checks(bitcoind, node_factory):
assert l1.daemon.is_in_stderr('Wallet sanity check failed')


@unittest.skipIf(os.getenv('SUBDAEMON').startswith('hsmd:remote_hsmd'), "no such channel")
@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "Canned db used")
@unittest.skipIf(not COMPAT, "needs COMPAT to convert obsolete db")
@unittest.skipIf(TEST_NETWORK != 'regtest', "The DB migration is network specific due to the chain var.")
Expand Down
1 change: 1 addition & 0 deletions tests/test_invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,7 @@ def test_expiry_startup_crash(node_factory, bitcoind):
l1.start()


@unittest.skipIf(os.getenv('SUBDAEMON').startswith('hsmd:remote_hsmd'), "no such channel")
@unittest.skipIf(TEST_NETWORK != 'regtest', "The DB migration is network specific due to the chain var.")
@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "This test is based on a sqlite3 snapshot")
def test_invoices_wait_db_migration(node_factory, bitcoind):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ def test_pay0(node_factory):
l1.rpc.waitsendpay(rhash)


@unittest.skipIf(os.getenv('SUBDAEMON').startswith('hsmd:remote_hsmd') and os.getenv('VLS_PERMISSIVE') != '1', "feerate above maximum: 880782 > 151000")
def test_pay_disconnect(node_factory, bitcoind):
"""If the remote node has disconnected, we fail payment, but can try again when it reconnects"""
l1, l2 = node_factory.line_graph(2, opts={'dev-max-fee-multiplier': 5,
Expand Down Expand Up @@ -1317,6 +1318,7 @@ def test_forward_different_fees_and_cltv(node_factory, bitcoind):
assert only_one(l3.rpc.listinvoices('test_forward_different_fees_and_cltv')['invoices'])['status'] == 'unpaid'

# This should work.
l1.rpc.preapproveinvoice(bolt11=inv['bolt11']) # let the signer know this payment is coming
l1.rpc.sendpay(route, rhash, payment_secret=inv['payment_secret'])
l1.rpc.waitsendpay(rhash)

Expand Down Expand Up @@ -1385,6 +1387,7 @@ def test_forward_pad_fees_and_cltv(node_factory, bitcoind):
# This should work.
inv = l3.rpc.invoice(4999999, 'test_forward_pad_fees_and_cltv', 'desc')
rhash = inv['payment_hash']
l1.rpc.preapproveinvoice(bolt11=inv['bolt11']) # let the signer know this payment is coming
l1.rpc.sendpay(route, rhash, payment_secret=inv['payment_secret'])
l1.rpc.waitsendpay(rhash)
assert only_one(l3.rpc.listinvoices('test_forward_pad_fees_and_cltv')['invoices'])['status'] == 'paid'
Expand Down Expand Up @@ -2319,6 +2322,7 @@ def test_setchannel_routing(node_factory, bitcoind):
assert decoded['routes'] == [[{'pubkey': l2.info['id'], 'short_channel_id': scid, 'fee_base_msat': 1337, 'fee_proportional_millionths': 137, 'cltv_expiry_delta': 6}]]

# This will fail.
l1.rpc.preapproveinvoice(bolt11=inv['bolt11']) # let the signer know this payment is coming
l1.rpc.sendpay(route_bad, inv['payment_hash'], payment_secret=inv['payment_secret'])
with pytest.raises(RpcError, match='WIRE_TEMPORARY_CHANNEL_FAILURE'):
l1.rpc.waitsendpay(inv['payment_hash'])
Expand Down
6 changes: 6 additions & 0 deletions tests/test_reckless.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ def test_search(node_factory):
assert 'found testplugpass in source: https://github.com/lightningd/plugins' in r.stdout


@unittest.skipIf(VALGRIND, "virtual environment triggers memleak detection")
@unittest.skipIf(os.getenv('SUBDAEMON').startswith('hsmd:remote_hsmd'), "no canned github server in gitlab CI")
def test_install(node_factory):
"""test search, git clone, and installation to folder."""
n = get_reckless_node(node_factory)
Expand All @@ -199,6 +201,7 @@ def test_install(node_factory):


@unittest.skipIf(VALGRIND, "virtual environment triggers memleak detection")
@unittest.skipIf(os.getenv('SUBDAEMON').startswith('hsmd:remote_hsmd'), "no canned github server in gitlab CI")
def test_poetry_install(node_factory):
"""test search, git clone, and installation to folder."""
n = get_reckless_node(node_factory)
Expand All @@ -218,6 +221,7 @@ def test_poetry_install(node_factory):


@unittest.skipIf(VALGRIND, "virtual environment triggers memleak detection")
@unittest.skipIf(os.getenv('SUBDAEMON').startswith('hsmd:remote_hsmd'), "no canned github server in gitlab CI")
def test_local_dir_install(node_factory):
"""Test search and install from local directory source."""
n = get_reckless_node(node_factory)
Expand Down Expand Up @@ -266,6 +270,8 @@ def test_disable_enable(node_factory):
assert test_plugin in n.rpc.plugin_list()['plugins']


@unittest.skipIf(VALGRIND, "virtual environment triggers memleak detection")
@unittest.skipIf(os.getenv('SUBDAEMON').startswith('hsmd:remote_hsmd'), "no canned github server in gitlab CI")
@unittest.skipIf(VALGRIND, "virtual environment triggers memleak detection")
def test_tag_install(node_factory):
"install a plugin from a specific commit hash or tag"
Expand Down
16 changes: 13 additions & 3 deletions tests/test_renepay.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,21 @@ def test_pay(node_factory):
# Check payment of any-amount invoice.
for i in range(5):
label = "any{}".format(i)
inv2 = l2.rpc.invoice("any", label, "description")["bolt11"]
inv2x = l2.rpc.invoice("any", label, "description")
rhash = inv2x["payment_hash"]
inv2 = inv2x["bolt11"]
# Must provide an amount!
with pytest.raises(RpcError):
l1.rpc.call("renepay", {"invstring": inv2, "dev_use_shadow": False})

amt = random.randint(1000, 999999)
l1.rpc.preapprovekeysend(l2.info["id"], rhash, amt)
l1.rpc.call(
"renepay",
{
"invstring": inv2,
"dev_use_shadow": False,
"amount_msat": random.randint(1000, 999999),
"amount_msat": amt,
},
)

Expand Down Expand Up @@ -451,6 +455,7 @@ def test_fee_allocation(node_factory):
)

inv = l4.rpc.invoice("1500000sat", "inv", "description")
l1.rpc.preapprovekeysend(l4.info["id"], inv["payment_hash"], 1500000000 + 75000000)
l1.rpc.call("renepay", {"invstring": inv["bolt11"], "maxfee": "75000sat"})
l1.wait_for_htlcs()
invoice = only_one(l4.rpc.listinvoices("inv")["invoices"])
Expand Down Expand Up @@ -496,7 +501,8 @@ def test_htlc_max(node_factory):

inv = l6.rpc.invoice("1800000sat", "inv", "description")

l1.rpc.call("renepay", {"invstring": inv["bolt11"]})
l1.rpc.preapproveinvoice(bolt11=inv["bolt11"]) # let the signer know this payment is coming
l1.rpc.call("renepay", {'invstring': inv['bolt11']})
l1.wait_for_htlcs()
invoice = only_one(l6.rpc.listinvoices("inv")["invoices"])
assert invoice["amount_received_msat"] >= Millisatoshi("1800000sat")
Expand All @@ -514,6 +520,7 @@ def test_previous_sendpays(node_factory, bitcoind):
# First case, do not overpay a pending MPP payment
invstr = l3.rpc.invoice("100000sat", "inv1", "description")["bolt11"]
inv = l1.rpc.decode(invstr)
l1.rpc.preapproveinvoice(bolt11=invstr) # let the signer know this payment is coming
route = l1.rpc.call(
"getroute", {"id": inv["payee"], "amount_msat": "50000sat", "riskfactor": 10}
)
Expand All @@ -538,6 +545,7 @@ def test_previous_sendpays(node_factory, bitcoind):
# Second case, do not collide with failed sendpays
invstr = l3.rpc.invoice("100000sat", "inv2", "description")["bolt11"]
inv = l1.rpc.decode(invstr)
l1.rpc.preapproveinvoice(bolt11=invstr) # let the signer know this payment is coming
route = l1.rpc.call(
"getroute", {"id": inv["payee"], "amount_msat": "50000sat", "riskfactor": 10}
)
Expand Down Expand Up @@ -614,6 +622,7 @@ def test_fees(node_factory):

# check that once gossip is in sync, fees are paid correctly
invstr = dest.rpc.invoice("100000sat", "inv1", "description")["bolt11"]
source.rpc.preapproveinvoice(bolt11=invstr) # let the signer know this payment is coming
source.rpc.call("renepay", {"invstring": invstr})
invoice = only_one(dest.rpc.listinvoices("inv1")["invoices"])
assert invoice["amount_received_msat"] == Millisatoshi("100000sat")
Expand All @@ -626,6 +635,7 @@ def test_fees(node_factory):
nodes[3].rpc.setchannel(nodes[4].info["id"], 3000, 350, enforcedelay=0)

invstr = dest.rpc.invoice("150000sat", "inv2", "description")["bolt11"]
source.rpc.preapproveinvoice(bolt11=invstr) # let the signer know this payment is coming
source.rpc.call("renepay", {"invstring": invstr})
invoice = only_one(dest.rpc.listinvoices("inv2")["invoices"])
assert invoice["amount_received_msat"] == Millisatoshi("150000sat")
2 changes: 1 addition & 1 deletion tests/test_splicing_insane.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def wait_for_restart(l1, l2):
l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH')
l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH')


@unittest.skipIf(os.getenv('SUBDAEMON').startswith('hsmd:remote_hsmd') and os.getenv('VLS_SKIP_SPLICE_TESTS') == '1', "test expected to fail before VLS dual-funding / splicing support")
@pytest.mark.openchannel('v1')
@pytest.mark.openchannel('v2')
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
Expand Down

0 comments on commit 10eb20b

Please sign in to comment.