Skip to content

Commit 6384e25

Browse files
committed
tests: modify tests for VLS
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
1 parent 83c9ba5 commit 6384e25

File tree

7 files changed

+27
-4
lines changed

7 files changed

+27
-4
lines changed

tests/test_bookkeeper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ def test_bookkeeping_inspect_multifundchannel(node_factory, bitcoind):
542542
assert bkpr_total_fee_msat == int(getblock_fee_btc * 100000000000)
543543

544544

545+
@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")
545546
@unittest.skipIf(TEST_NETWORK != 'regtest', "network fees hardcoded")
546547
@pytest.mark.openchannel('v2')
547548
def test_bookkeeping_inspect_mfc_dual_funded(node_factory, bitcoind):

tests/test_db.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ def test_db_sanity_checks(bitcoind, node_factory):
478478
assert l1.daemon.is_in_stderr('Wallet sanity check failed')
479479

480480

481+
@unittest.skipIf(os.getenv('SUBDAEMON').startswith('hsmd:remote_hsmd'), "no such channel")
481482
@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "Canned db used")
482483
@unittest.skipIf(not COMPAT, "needs COMPAT to convert obsolete db")
483484
@unittest.skipIf(TEST_NETWORK != 'regtest', "The DB migration is network specific due to the chain var.")

tests/test_invoices.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,7 @@ def test_expiry_startup_crash(node_factory, bitcoind):
960960
l1.start()
961961

962962

963+
@unittest.skipIf(os.getenv('SUBDAEMON').startswith('hsmd:remote_hsmd'), "no such channel")
963964
@unittest.skipIf(TEST_NETWORK != 'regtest', "The DB migration is network specific due to the chain var.")
964965
@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "This test is based on a sqlite3 snapshot")
965966
def test_invoices_wait_db_migration(node_factory, bitcoind):

tests/test_pay.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ def test_pay0(node_factory):
245245
l1.rpc.waitsendpay(rhash)
246246

247247

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

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

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

23212324
# This will fail.
2325+
l1.rpc.preapproveinvoice(bolt11=inv['bolt11']) # let the signer know this payment is coming
23222326
l1.rpc.sendpay(route_bad, inv['payment_hash'], payment_secret=inv['payment_secret'])
23232327
with pytest.raises(RpcError, match='WIRE_TEMPORARY_CHANNEL_FAILURE'):
23242328
l1.rpc.waitsendpay(inv['payment_hash'])

tests/test_reckless.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ def test_search(node_factory):
184184
assert 'found testplugpass in source: https://github.com/lightningd/plugins' in r.stdout
185185

186186

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

200202

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

219222

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

268272

273+
@unittest.skipIf(VALGRIND, "virtual environment triggers memleak detection")
274+
@unittest.skipIf(os.getenv('SUBDAEMON').startswith('hsmd:remote_hsmd'), "no canned github server in gitlab CI")
269275
@unittest.skipIf(VALGRIND, "virtual environment triggers memleak detection")
270276
def test_tag_install(node_factory):
271277
"install a plugin from a specific commit hash or tag"

tests/test_renepay.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,21 @@ def test_pay(node_factory):
186186
# Check payment of any-amount invoice.
187187
for i in range(5):
188188
label = "any{}".format(i)
189-
inv2 = l2.rpc.invoice("any", label, "description")["bolt11"]
189+
inv2x = l2.rpc.invoice("any", label, "description")
190+
rhash = inv2x["payment_hash"]
191+
inv2 = inv2x["bolt11"]
190192
# Must provide an amount!
191193
with pytest.raises(RpcError):
192194
l1.rpc.call("renepay", {"invstring": inv2, "dev_use_shadow": False})
193195

196+
amt = random.randint(1000, 999999)
197+
l1.rpc.preapprovekeysend(l2.info["id"], rhash, amt)
194198
l1.rpc.call(
195199
"renepay",
196200
{
197201
"invstring": inv2,
198202
"dev_use_shadow": False,
199-
"amount_msat": random.randint(1000, 999999),
203+
"amount_msat": amt,
200204
},
201205
)
202206

@@ -451,6 +455,7 @@ def test_fee_allocation(node_factory):
451455
)
452456

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

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

499-
l1.rpc.call("renepay", {"invstring": inv["bolt11"]})
504+
l1.rpc.preapproveinvoice(bolt11=inv["bolt11"]) # let the signer know this payment is coming
505+
l1.rpc.call("renepay", {'invstring': inv['bolt11']})
500506
l1.wait_for_htlcs()
501507
invoice = only_one(l6.rpc.listinvoices("inv")["invoices"])
502508
assert invoice["amount_received_msat"] >= Millisatoshi("1800000sat")
@@ -514,6 +520,7 @@ def test_previous_sendpays(node_factory, bitcoind):
514520
# First case, do not overpay a pending MPP payment
515521
invstr = l3.rpc.invoice("100000sat", "inv1", "description")["bolt11"]
516522
inv = l1.rpc.decode(invstr)
523+
l1.rpc.preapproveinvoice(bolt11=invstr) # let the signer know this payment is coming
517524
route = l1.rpc.call(
518525
"getroute", {"id": inv["payee"], "amount_msat": "50000sat", "riskfactor": 10}
519526
)
@@ -538,6 +545,7 @@ def test_previous_sendpays(node_factory, bitcoind):
538545
# Second case, do not collide with failed sendpays
539546
invstr = l3.rpc.invoice("100000sat", "inv2", "description")["bolt11"]
540547
inv = l1.rpc.decode(invstr)
548+
l1.rpc.preapproveinvoice(bolt11=invstr) # let the signer know this payment is coming
541549
route = l1.rpc.call(
542550
"getroute", {"id": inv["payee"], "amount_msat": "50000sat", "riskfactor": 10}
543551
)
@@ -614,6 +622,7 @@ def test_fees(node_factory):
614622

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

628637
invstr = dest.rpc.invoice("150000sat", "inv2", "description")["bolt11"]
638+
source.rpc.preapproveinvoice(bolt11=invstr) # let the signer know this payment is coming
629639
source.rpc.call("renepay", {"invstring": invstr})
630640
invoice = only_one(dest.rpc.listinvoices("inv2")["invoices"])
631641
assert invoice["amount_received_msat"] == Millisatoshi("150000sat")

tests/test_splicing_insane.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def wait_for_restart(l1, l2):
4343
l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH')
4444
l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH')
4545

46-
46+
@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")
4747
@pytest.mark.openchannel('v1')
4848
@pytest.mark.openchannel('v2')
4949
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')

0 commit comments

Comments
 (0)