From ac83b73d1f58db1acdb801be287e5f6339b10366 Mon Sep 17 00:00:00 2001 From: Matt Morehouse Date: Thu, 15 Oct 2026 23:21:09 -0500 Subject: [PATCH] smite-scenarios: negotiate second channel Two-channel tests were still using injected negotiations via the harness, and we now convert those to full negotiation as well. The second channel used to fund 20M sats to make its funding transaction different from the first. That exceeds the non-wumbo cap enforced by AcceptChannelOracle, so instead we now use the same funding amount as the first channel. The second channel is still funded from the second UTXO, so the funding transaction is still distinct. Since no test uses it anymore, we can now remove with_negotiation(). --- smite-scenarios/src/executor/tests.rs | 6 +- smite-scenarios/src/executor/tests/harness.rs | 61 ++++++++----------- .../src/executor/tests/programs.rs | 25 +++++--- 3 files changed, 44 insertions(+), 48 deletions(-) diff --git a/smite-scenarios/src/executor/tests.rs b/smite-scenarios/src/executor/tests.rs index 49ab83b4..af1618ec 100644 --- a/smite-scenarios/src/executor/tests.rs +++ b/smite-scenarios/src/executor/tests.rs @@ -1431,7 +1431,7 @@ fn execute_recv_channel_ready_resend_with_new_alias() { // Instead of a `channel_ready` for the second channel, the target resends // the first channel's with a different alias but otherwise identical // contents. - let mut fx = two_funding_negotiations_fixture() + let mut fx = recv_two_accept_channel_fixture() .queue(&channel_ready_reply(target_pcp)) .queue(&Message::ChannelReady(ChannelReady { channel_id: funding_channel_id(), @@ -1456,7 +1456,7 @@ fn execute_recv_channel_ready_rejects_alias_reused_by_another_channel() { // The second channel's `channel_ready` advertises the alias the first // channel already advertised. let alias = ShortChannelId::from_u64(42); - let err = two_funding_negotiations_fixture() + let err = recv_two_accept_channel_fixture() .queue(&Message::ChannelReady(ChannelReady { channel_id: funding_channel_id(), second_per_commitment_point: sample_pubkey(7), @@ -1488,7 +1488,7 @@ fn execute_recv_channel_ready_rejects_alias_matching_another_channels_scid() { // The second channel advertises an alias matching the first channel's real // short channel ID. let alias = FUNDING_SCID; - let err = two_funding_negotiations_fixture() + let err = recv_two_accept_channel_fixture() .queue(&Message::ChannelReady(ChannelReady { channel_id: funding_channel_id(), second_per_commitment_point: sample_pubkey(7), diff --git a/smite-scenarios/src/executor/tests/harness.rs b/smite-scenarios/src/executor/tests/harness.rs index 33bdf07d..bf8b627c 100644 --- a/smite-scenarios/src/executor/tests/harness.rs +++ b/smite-scenarios/src/executor/tests/harness.rs @@ -170,14 +170,6 @@ impl Fixture { self } - /// Records `pending` as the negotiation for its `temporary_channel_id`. - pub fn with_negotiation(mut self, pending: PendingChannel) -> Self { - self.executor - .negotiations - .insert(pending.open_channel.temporary_channel_id, pending); - self - } - /// Queues `msg` as the peer's next reply. pub fn queue(mut self, msg: &Message) -> Self { self.executor.conn.recv_queue.push_back(msg.encode()); @@ -525,50 +517,45 @@ pub fn funded_accept_channel() -> AcceptChannel { } } -/// The negotiation of [`funded_open_channel`] and [`funded_accept_channel`]. -pub fn sample_funding_negotiation() -> PendingChannel { - PendingChannel { - open_channel: funded_open_channel().message, - accept_channel: Some(funded_accept_channel()), - funding_built: false, - } +/// A [`funded_open_channel`] with a different `temporary_channel_id`, so that +/// it negotiates a second channel. +pub fn second_funded_open_channel() -> SampleOpenChannel { + let mut oc = funded_open_channel(); + oc.message.temporary_channel_id = SECOND_TEMPORARY_CHANNEL_ID; + oc } -/// A [`sample_funding_negotiation`] with a different `temporary_channel_id` and -/// funding amount, so that it funds a different channel. -pub fn second_funding_negotiation() -> PendingChannel { - let mut negotiation = sample_funding_negotiation(); - negotiation.open_channel.temporary_channel_id = SECOND_TEMPORARY_CHANNEL_ID; - negotiation.open_channel.funding_satoshis = 20_000_000; - negotiation - .accept_channel - .as_mut() - .expect("accept_channel present") - .temporary_channel_id = SECOND_TEMPORARY_CHANNEL_ID; - - negotiation +/// The target's `accept_channel` for [`second_funded_open_channel`]. +pub fn second_funded_accept_channel() -> AcceptChannel { + AcceptChannel { + temporary_channel_id: SECOND_TEMPORARY_CHANNEL_ID, + // `AcceptChannelOracle` rejects a per-commitment point reused from + // another channel. + first_per_commitment_point: sample_pubkey(12), + ..funded_accept_channel() + } } -/// The channel id [`second_funding_negotiation`]'s funding transaction -/// produces. +/// The channel id the second channel's funding transaction produces, funded +/// from the second UTXO of [`two_funding_negotiations_fixture`]. pub fn second_funding_channel_id() -> ChannelId { ChannelId::v1_from_funding_outpoint(OutPoint { - txid: "cb6f11974ce6265f81037dc7c0e3f054462f645361bc1e10c208f132f4acbe8d" + txid: "4babf25e65e63224c937fb3b8a31a813d91936bf5c3c5cd7fd1e83986ddc90ee" .parse() .expect("valid txid"), vout: 0, }) } -/// A fixture with both [`sample_funding_negotiation`] and -/// [`second_funding_negotiation`] seeded, and a UTXO to fund each. -pub fn two_funding_negotiations_fixture() -> Fixture { +/// A fixture with the target's `accept_channel` for both +/// [`funded_open_channel`] and [`second_funded_open_channel`] queued, and a +/// UTXO to fund each. +pub fn recv_two_accept_channel_fixture() -> Fixture { let mut second_utxo = sample_utxo(); - second_utxo.amount = Amount::from_sat(20_010_000); second_utxo.outpoint.vout = 1; Fixture::new() .with_utxos(vec![sample_utxo(), second_utxo]) - .with_negotiation(sample_funding_negotiation()) - .with_negotiation(second_funding_negotiation()) + .queue(&Message::AcceptChannel(funded_accept_channel())) + .queue(&Message::AcceptChannel(second_funded_accept_channel())) } diff --git a/smite-scenarios/src/executor/tests/programs.rs b/smite-scenarios/src/executor/tests/programs.rs index ca88d8fd..71aae02a 100644 --- a/smite-scenarios/src/executor/tests/programs.rs +++ b/smite-scenarios/src/executor/tests/programs.rs @@ -9,7 +9,7 @@ use super::harness::{ PointSource, SampleOpenChannel, TEMPORARY_CHANNEL_ID, acceptor_funding_sk, funded_open_channel, - opener_funding_sk, second_funding_negotiation, + opener_funding_sk, second_funded_open_channel, }; use crate::executor::*; use smite_ir::Instruction; @@ -345,17 +345,26 @@ pub fn recv_channel_ready_program(confirmations: u8) -> Program { b.build() } -/// A program that sends `funding_created` for both negotiations of -/// `two_funding_negotiations_fixture` without awaiting `funding_signed`, mines -/// to their `minimum_depth`, and receives a `channel_ready` for each. +/// A program that negotiates [`funded_open_channel`] and +/// [`second_funded_open_channel`], sends `funding_created` for both without +/// awaiting `funding_signed`, mines to their `minimum_depth`, and receives a +/// `channel_ready` for each. pub fn recv_two_channel_ready_program() -> Program { - let second = second_funding_negotiation().open_channel; + let second = second_funded_open_channel(); let mut b = ProgramBuilder::new(); + negotiate_channel(&mut b, &funded_open_channel()); + negotiate_channel(&mut b, &second); send_funding_created(&mut b); - let tx = create_funding_tx_with(&mut b, second.funding_satoshis, FUNDING_FEERATE_PER_KW); - let temporary_channel_id = - b.append(Operation::LoadChannelId(second.temporary_channel_id.0), &[]); + let tx = create_funding_tx_with( + &mut b, + second.message.funding_satoshis, + FUNDING_FEERATE_PER_KW, + ); + let temporary_channel_id = b.append( + Operation::LoadChannelId(second.message.temporary_channel_id.0), + &[], + ); b.append( Operation::SendFundingCreated, &[