tests: adapt integration harness for LND v0.21 native onion messages

Two test-harness-only changes (no production code):

1. get_lnd_args: drop the legacy onion-transport flags. LND v0.21 handles
   type 513 natively and advertises the onion message feature bit (39) by
   default, so --protocol.custom-message=513 is a no-op and, critically,
   --protocol.custom-init=39 / --protocol.custom-nodeann=39 make 0.21 fail
   to start ("feature bit 39 already set", feature/manager.go).

2. wait_for_lnd_payment_completion: scan all invoices for a settled one
   instead of only checking invoices[0]. A single offer can legitimately
   yield multiple invoices (the payer may send several invoice_requests,
   each answered with its own invoice); only one is paid, so the old
   invoices[0] check could inspect an unpaid invoice and spuriously time
   out even though the payment settled.

Verified against LND v0.21.0-beta with the native transport:
- test_lndk_pay_offer (+ _concurrently/_error/_with_retry): 4 passed
- test_receive_payment_from_offer (+ _with_multiple_blinded_paths): 2 passed

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alex71btc 2026-06-20 20:12:00 +02:00
parent 7422f0823f
commit 52fd8a06bc
No known key found for this signature in database
GPG key ID: 0295D5E79F6FAE4F

View file

@ -326,9 +326,13 @@ pub fn get_lnd_args(
"--bitcoind.rpchost={:?}",
bitcoind_connect_params.rpc_socket
),
format!("--protocol.custom-message=513"),
format!("--protocol.custom-nodeann=39"),
format!("--protocol.custom-init=39"),
// LND v0.21+ handles onion messages (type 513) natively and advertises
// the onion message feature bit (39) by default, so LNDK uses the
// native SendOnionMessage/SubscribeOnionMessages transport. The legacy
// flags below are intentionally NOT set:
// --protocol.custom-message=513 (513 is now a known message type)
// --protocol.custom-nodeann=39 (would fail: "feature bit 39 already
// --protocol.custom-init=39 set", since 0.21 sets it natively)
];
let stdout_log_path = lnd_data_dir.join("lnd-itest-stdout.log");
@ -398,15 +402,22 @@ pub async fn wait_for_lnd_payment_completion(
.await;
assert!(invoices.is_ok());
let invoices = invoices.unwrap().into_inner();
if !invoices.invoices.is_empty() {
let invoice = invoices.invoices[0].clone();
log::debug!("Invoice status: {:?}", invoice.state);
if invoice.state == InvoiceHtlcState::Settled as i32 {
log::info!("Payment succeeded");
return Ok(());
}
// A single offer can legitimately yield more than one invoice (e.g. when
// the payer sends several invoice_requests, each of which LNDK answers
// with its own invoice). Only one of them gets paid, so scan all
// invoices for any settled one rather than only checking invoices[0].
let settled = invoices
.invoices
.iter()
.any(|invoice| invoice.state == InvoiceHtlcState::Settled as i32);
if settled {
log::info!("Payment succeeded");
return Ok(());
}
log::debug!("No payments found yet, waiting 1 second...");
log::debug!(
"No settled invoice yet among {} invoice(s), waiting 1 second...",
invoices.invoices.len()
);
sleep(Duration::from_secs(1)).await;
}
}