fuzz-tests: Add test for untested function
What changed, and why it matters
This commit only adds a new fuzz test for an existing function and makes a small constant-definition cleanup. It does not change any production code, fix a bug, or alter behavior of the Core Lightning node. There is no security issue here.
No action required; this is a benign test-only commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds test_channel_update_funding() to tests/fuzz/fuzz-initial_channel.c, which deserializes fuzz input into a bitcoin_outpoint, an amount_sat, and an s64 splice amount, then calls channel_update_funding(). It also replaces an inline (u32)WALLY_SATOSHI_PER_BTC * WALLY_BTC_MAX expression with a new MAX_SATS macro and removes a TODO comment. The change is purely in test/fuzzing code.
Changed components
tests/fuzz/fuzz-initial_channel.cInspect captured patch +21 / −3
diff --git a/tests/fuzz/fuzz-initial_channel.c b/tests/fuzz/fuzz-initial_channel.c
index c4143618..52eca85f 100644
--- a/tests/fuzz/fuzz-initial_channel.c
+++ b/tests/fuzz/fuzz-initial_channel.c
@@ -31,6 +31,24 @@ void init(int *argc, char ***argv)
chainparams = chainparams_for_network("bitcoin");
}
+#define MAX_SATS (u64)WALLY_SATOSHI_PER_BTC * WALLY_BTC_MAX
+
+static void test_channel_update_funding(struct channel *channel, const u8 **cursor, size_t *max) {
+ struct bitcoin_outpoint funding;
+ struct amount_sat funding_sats;
+ s64 splice_amnt;
+
+ if (*max < sizeof(funding) + sizeof(funding_sats) + sizeof(splice_amnt))
+ return;
+
+ fromwire_bitcoin_outpoint(cursor, max, &funding);
+ funding_sats = fromwire_amount_sat(cursor, max);
+ funding_sats.satoshis %= MAX_SATS; /* Raw: fuzzing */
+ splice_amnt = fromwire_s64(cursor, max) % MAX_SATS;
+
+ channel_update_funding(channel, &funding, funding_sats, splice_amnt);
+}
+
void run(const uint8_t *data, size_t size)
{
struct channel_id cid;
@@ -51,7 +69,7 @@ void run(const uint8_t *data, size_t size)
minimum_depth = fromwire_u32(&data, &size);
funding_sats = fromwire_amount_sat(&data, &size);
local_msatoshi = fromwire_amount_msat(&data, &size);
- max = AMOUNT_SAT((u32)WALLY_SATOSHI_PER_BTC * WALLY_BTC_MAX);
+ max = AMOUNT_SAT(MAX_SATS);
if (amount_sat_greater(funding_sats, max))
funding_sats = max;
feerate_per_kw = fromwire_u32(&data, &size);
@@ -95,8 +113,8 @@ void run(const uint8_t *data, size_t size)
channel_type,
wumbo, opener);
- /* TODO: make initial_channel_tx() work with ASAN.. */
- (void)channel;
+ if (channel)
+ test_channel_update_funding(channel, &data, &size);
}
clean_tmpctx();
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.