Skip to content

smite-scenarios: simplify channel_ready key-reuse tests - #291

Merged
morehouse merged 2 commits into
masterfrom
simplify_key_reuse_tests
Oct 16, 2026
Merged

morehouse merged 2 commits into
masterfrom
simplify_key_reuse_tests

Conversation

@morehouse

@morehouse morehouse commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

The two tests had an unnecessary injected negotiation that was only there because we weren't able to use the actual open_channel and accept_channel messages from the negotiation on the wire.

Addresses #260 (comment).

Depends on #288.

@NishantBansal2003 NishantBansal2003 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@erickcestari erickcestari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines +1692 to 1696
// The target's `channel_ready` reuses a static pubkey it revealed in its
// `accept_channel`.
let accept_channel = funded_accept_channel();
let reused = accept_channel.funding_pubkey;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

These changes made this mutant alive:

diff --git a/smite-scenarios/src/executor.rs b/smite-scenarios/src/executor.rs
--- a/smite-scenarios/src/executor.rs
+++ b/smite-scenarios/src/executor.rs
@@ -1444,7 +1444,7 @@ fn record_recv_accept_channel(

     let channel = accept_channel.temporary_channel_id;
     // Static pubkeys may recur across channels, so keep the first origin.
-    for (field, pubkey) in accept_channel.static_pubkeys() {
+    for (field, pubkey) in accept_channel.static_pubkeys().into_iter().take(1) {
         revealed_pubkeys
             .entry(pubkey)
             .or_insert(KeyOrigin::TargetStatic { channel, field });
Suggested change
// The target's `channel_ready` reuses a static pubkey it revealed in its
// `accept_channel`.
let accept_channel = funded_accept_channel();
let reused = accept_channel.funding_pubkey;
// The target's `channel_ready` reuses a static pubkey it revealed in its
// `accept_channel`. A distinct key in a non-first field shows every static
// pubkey is recorded, not just `funding_pubkey`.
let accept_channel = AcceptChannel {
delayed_payment_basepoint: sample_pubkey(11),
..funded_accept_channel()
};
let reused = accept_channel.delayed_payment_basepoint;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied.

@morehouse
morehouse force-pushed the simplify_key_reuse_tests branch from 1654cf4 to a106656 Compare October 16, 2026 21:06
Base automatically changed from name_and_derive_constants to master October 16, 2026 21:17
The injected funding negotiation used a hand-built PendingChannel that
AcceptChannelOracle would reject:

- neither message had a channel_type
- the acceptor's first_per_commitment_point matched its static pubkeys

As a result, we couldn't actually create the same negotiation without
injecting it.

Since we want to move away from injecting negotiations, change the
problematic parameters to pass the oracle.  Additionally, give the
PendingChannel messages their own helper functions so that they can be
used in programs too.
Now that we have funded_open_channel() and funded_accept_channel()
helpers that can be used in programs, we can drop the unnecessary
injected negotiation from the channel_ready key-reuse tests.
@morehouse
morehouse force-pushed the simplify_key_reuse_tests branch from a106656 to 714ad7d Compare October 16, 2026 21:28
@morehouse
morehouse merged commit 4d755bc into master Oct 16, 2026
5 checks passed
@morehouse
morehouse deleted the simplify_key_reuse_tests branch October 16, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants