Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6d13e5a
lightningd: cancel watching original funding when we switch to the ne…
rustyrussell Oct 2, 2025
5818634
common: add randbytes() wrapper to override cryptographic entropy: $C…
rustyrussell Oct 2, 2025
572818a
global: replace randombytes_buf() with randbytes() wrapper.
rustyrussell Oct 2, 2025
81e7632
common: seed deterministic RNG from basename of argv0, not full path
ShahanaFarooqui Jul 8, 2026
50858b5
common: don't consume deterministic randbytes stream for trace ids
ShahanaFarooqui Jul 8, 2026
d041c53
common: don't trigger siphash_seed() init from span hashing either.
ShahanaFarooqui Jul 8, 2026
8ac0202
autogenerate-rpc-examples.py: disable entropy for generation.
rustyrussell Oct 7, 2025
7770183
autogenerate-rpc-examples.py: remove example mangling.
rustyrussell Oct 7, 2025
702793d
autogenerate-rpc-examples.py: remove unused vars
rustyrussell Oct 7, 2025
5d84aee
tests/autogenerate-rpc-examples.py: always use largest UTXO for fundc…
rustyrussell Oct 7, 2025
e588bc6
autogenerate-rpc-examples.py: canned blocks.
rustyrussell Oct 7, 2025
662758c
autogenerate-rpc-examples.py: ensure blockheights are consistent.
rustyrussell Oct 7, 2025
7dfa7fe
autogenerate-rpc-examples.py: use fixed port numbers.
rustyrussell Oct 7, 2025
0a79489
autogenerate-rpc-examples.py: more refinement.
rustyrussell Oct 7, 2025
8691453
autogenerate-rpc-examples.py: more block generation and synchronization.
rustyrussell Oct 7, 2025
a13bef4
autogenerate-rpc-examples.py: rewrite problematic examples.
rustyrussell Oct 7, 2025
9391549
autogenerate-rpc-examples.py: parameterized base port and cln next ve…
ShahanaFarooqui Jul 7, 2026
fefc06a
autogenerate-rpc-examples.py: added 17 new RPC to ignore list
ShahanaFarooqui Jul 7, 2026
21fcdf6
autogenerate-rpc-examples.py: added wait functions like wait_for_htlc…
ShahanaFarooqui Jul 7, 2026
89db2fc
autogenerate-rpc-examples.py: added feature to be able to rewrite the…
ShahanaFarooqui Jul 7, 2026
5ef0397
autogenerate-rpc-examples.py: fixed recover examples via `lightning-h…
ShahanaFarooqui Jul 7, 2026
8f6ccf9
autogenerate-rpc-examples.py: pin the full sorted UTXO set for multiw…
ShahanaFarooqui Jul 7, 2026
f27acc2
autogenerate-rpc-examples.py: added more rewrite for other RPCs
ShahanaFarooqui Jul 7, 2026
1cab669
autogenerate-rpc-examples.py: added sorting for some list example to …
ShahanaFarooqui Jul 7, 2026
15819ed
autogenerate-rpc-examples: sanitize plugin paths in plugin examples
ShahanaFarooqui Jul 8, 2026
b7481bc
tests: use bitcoind.conf_file instead of hardcoded bitcoin.conf in Ra…
ShahanaFarooqui Jul 8, 2026
1dc4821
doc: generate all examples with newchain
ShahanaFarooqui Jul 7, 2026
b4feb42
make: Pinning PATH in doc scripts so generation always uses the tree'…
ShahanaFarooqui Jul 8, 2026
7f155d4
make: Fix repeat-dpc-examples script
ShahanaFarooqui Jul 6, 2026
bc63b8c
CI: re-enable docs examples checks.
rustyrussell Oct 7, 2025
00dc521
CI: Add debug and upload artifacts on failure
ShahanaFarooqui Jul 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,7 @@ jobs:
if-no-files-found: ignore

update-docs-examples:
name: Update examples in doc schemas (disabled temporarily!)
if: false
name: Update examples in doc schemas
runs-on: ubuntu-24.04
timeout-minutes: 30
strategy:
Expand Down Expand Up @@ -839,11 +838,57 @@ jobs:
find . -type f -print0 | xargs -0 touch -d yesterday
tar xaf cln-${{ matrix.CFG }}.tar.gz

- name: Debug check-doc-examples inputs
run: |
echo "== lightning-hsmtool =="
which lightning-hsmtool || echo "NOT ON PATH"
find . -name "lightning-hsmtool*" -not -path "./.git/*" 2>/dev/null

echo "== autogenerate-bitcoind-wallet.dat =="
ls -la tests/data/autogenerate-bitcoind-wallet.dat 2>&1

echo "== autogenerate-bitcoin-blocks.json =="
ls -la tests/data/autogenerate-bitcoin-blocks.json 2>&1
echo "-- number of blocks --"
python3 -c "import json; print(len(json.load(open('tests/data/autogenerate-bitcoin-blocks.json'))))" 2>&1
echo "-- first 300 chars --"
head -c 300 tests/data/autogenerate-bitcoin-blocks.json
echo ""

echo "== environment fingerprint =="
# Determinism discriminators: HAVE_USDT toggles tracing, which
# must not perturb the deterministic RNG stream.
grep -E 'HAVE_USDT|HAVE_SQLITE3' config.vars || true
bitcoind --version | head -1 || true
dpkg -l systemtap-sdt-dev 2>/dev/null | tail -1 || true

- name: Test
env:
PYTEST_OPTS: ${{ env.PYTEST_OPTS_BASE }}
run: |
uv run eatmydata make -j $(($(nproc) + 1)) check-doc-examples CARGO=false CC=devtools/cc-nobuild SUPPRESS_GENERATION=1
- name: Save doc diff on failure
if: failure()
run: |
git diff -- doc > doc-examples.patch || true
git status --short -- doc
- name: Collect node logs on failure
if: failure()
run: |
mkdir -p ltests-debug
# pyln-testing leaves /tmp/ltests-* behind on failure: grab every
# node's daemon log and config (skip databases and sockets).
find /tmp/ltests-* -type f \( -name 'log' -o -name '*.log' -o -name 'config' \) \
-exec cp --parents -t ltests-debug {} + 2>/dev/null || true
- name: Upload debug artifacts
if: failure()
uses: actions/upload-artifact@v7
with:
name: doc-examples-debug
path: |
doc-examples.patch
ltests-debug/
if-no-files-found: ignore
- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
Expand Down Expand Up @@ -952,6 +997,7 @@ jobs:
- check-units
- integration-valgrind
- integration-sanitizers
- update-docs-examples
- min-btc-support
- check-downgrade
- check-compiled-source
Expand Down
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -648,19 +648,28 @@ check-amount-access:
@! (git grep -nE "(->|\.)(milli)?satoshis" -- "*.c" "*.h" ":(exclude)common/amount.*" ":(exclude)*/test/*" ":(exclude)tests/fuzz/*" | grep -v '/* Raw:')
@! git grep -nE "\\(struct amount_(m)?sat\\)" -- "*.c" "*.h" ":(exclude)common/amount.*" ":(exclude)*/test/*" ":(exclude)tests/fuzz/*" | grep -vE "sizeof.struct amount_(m)?sat."

# Examples must be generated with this tree's binaries to use plugins and tools
DOC_EXAMPLES_PATH = $(CURDIR)/lightningd:$(CURDIR)/cli:$(CURDIR)/tools:$(PATH)

repeat-doc-examples:
@for i in $$(seq 1 $(n)); do \
PORT_OFFSET=$$((i * 100)); \
BASE_PORTNUM=$$((30000 + PORT_OFFSET)); \
echo "----------------------------------" >> tests/autogenerate-examples-repeat.log; \
echo "Iteration $$i" >> tests/autogenerate-examples-repeat.log; \
echo "Iteration $$i on Base Port $$BASE_PORTNUM" >> tests/autogenerate-examples-repeat.log; \
echo "----------------------------------" >> tests/autogenerate-examples-repeat.log; \
VALGRIND=0 TIMEOUT=40 TEST_DEBUG=1 GENERATE_EXAMPLES=1 pytest -vvv tests/autogenerate-rpc-examples.py; \
PATH="$(DOC_EXAMPLES_PATH)" TEST_DEBUG=1 VALGRIND=0 GENERATE_EXAMPLES=1 CLN_NEXT_VERSION=$(CLN_NEXT_VERSION) BASE_PORTNUM=$$BASE_PORTNUM pytest -vvv --timeout=1200 tests/autogenerate-rpc-examples.py; \
git diff >> tests/autogenerate-examples-repeat.log; \
git reset --hard; \
echo "----------------------------------" >> tests/autogenerate-examples-repeat.log; \
done

update-doc-examples:
TEST_DEBUG=1 VALGRIND=0 GENERATE_EXAMPLES=1 $(PYTEST) $(PYTEST_OPTS) --timeout=1200 tests/autogenerate-rpc-examples.py && $(MAKE) $(MSGGEN_GEN_ALL)
PATH="$(DOC_EXAMPLES_PATH)" TEST_DEBUG=1 VALGRIND=0 GENERATE_EXAMPLES=1 CLN_NEXT_VERSION=$(CLN_NEXT_VERSION) $(PYTEST) $(PYTEST_OPTS) --timeout=1200 tests/autogenerate-rpc-examples.py && $(MAKE) $(MSGGEN_GEN_ALL)

# If you changed tests/autogenerate-rpc-examples.py to require new blocks, you have to run this:
update-doc-examples-newchain:
PATH="$(DOC_EXAMPLES_PATH)" TEST_DEBUG=1 VALGRIND=0 GENERATE_EXAMPLES=1 CLN_NEXT_VERSION=$(CLN_NEXT_VERSION) REGENERATE_BLOCKCHAIN=1 $(PYTEST) $(PYTEST_OPTS) --timeout=1200 tests/autogenerate-rpc-examples.py && $(MAKE) $(MSGGEN_GEN_ALL)

check-doc-examples: update-doc-examples
git diff --exit-code HEAD -- doc
Expand Down
13 changes: 11 additions & 2 deletions common/randbytes.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <common/utils.h>
#include <sodium/randombytes.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

static bool used = false;
Expand Down Expand Up @@ -48,15 +49,23 @@ void randbytes_(void *bytes, size_t num_bytes, u64 *offset)
}

/* We want different seeds for each plugin (hence argv0), and for each
* lightmingd instance, (hence seed from environment) */
* lightningd instance, (hence seed from environment) */
void dev_override_randbytes(const char *argv0, long int seed)
{
struct siphash_seed hashseed;
const char *base;
assert(!used);

/* Hash only the basename: binaries still get distinct seeds, but
* the stream no longer depends on the checkout path. Plugins and
* subdaemons are exec'd with absolute paths: hash only the basename,
* so the stream doesn't depend on where the source tree lives */
base = strrchr(argv0, '/');
base = base ? base + 1 : argv0;

hashseed.u.u64[0] = seed;
hashseed.u.u64[1] = 0;

dev_seed = siphash24(&hashseed, argv0, strlen(argv0));
dev_seed = siphash24(&hashseed, base, strlen(base));
assert(randbytes_overridden());
}
3 changes: 3 additions & 0 deletions common/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ common/test/run-json: \
common/lease_rates.o \
common/node_id.o \
common/pseudorand.o \
common/randbytes.o \
common/wireaddr.o \
wire/fromwire.o \
wire/onion_wiregen.o \
Expand All @@ -49,6 +50,7 @@ common/test/run-route common/test/run-route-specific common/test/run-route-inflo
common/gossmap.o \
common/node_id.o \
common/pseudorand.o \
common/randbytes.o \
common/route.o \
common/gossip_store_wiregen.o \
wire/fromwire.o \
Expand Down Expand Up @@ -158,6 +160,7 @@ common/test/run-mkdatastorekey: \
common/pseudorand.o

common/test/run-htable: \
common/randbytes.o \
common/pseudorand.o

common/test/run-shutdown_scriptpubkey: wire/towire.o wire/fromwire.o
Expand Down
1 change: 1 addition & 0 deletions common/test/run-bigsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <common/amount.h>
#include <common/json_parse.c>
#include <common/json_parse_simple.c>
#include <common/randbytes.h>
#include <common/setup.h>

static const char *reason;
Expand Down
1 change: 1 addition & 0 deletions common/test/run-blindedpath_enctlv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../blinding.c"
#include "../hmac.c"
#include <common/channel_id.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>

Expand Down
1 change: 1 addition & 0 deletions common/test/run-bolt11.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../wire/fromwire.c"
#include "../wire/towire.c"
#include <ccan/err/err.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>

Expand Down
1 change: 1 addition & 0 deletions common/test/run-bolt12-encode-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <common/bolt12.c>
#include <common/bolt12_merkle.h>
#include <common/features.c>
#include <common/randbytes.h>
#include <common/sciddir_or_pubkey.c>
#include <common/setup.h>
#include <inttypes.h>
Expand Down
1 change: 1 addition & 0 deletions common/test/run-bolt12-format-string-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <common/bolt12.h>
#include <common/bolt12_merkle.h>
#include <common/features.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <common/utils.h>

Expand Down
1 change: 1 addition & 0 deletions common/test/run-bolt12-offer-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <ccan/array_size/array_size.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
#include <common/randbytes.h>
#include <common/setup.h>

/* AUTOGENERATED MOCKS START */
Expand Down
1 change: 1 addition & 0 deletions common/test/run-bolt12_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <ccan/json_escape/json_escape.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
#include <common/randbytes.h>
#include <common/setup.h>

/* AUTOGENERATED MOCKS START */
Expand Down
1 change: 1 addition & 0 deletions common/test/run-bolt12_merkle-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
#include <common/channel_type.h>
#include <common/randbytes.h>
#include <common/setup.h>

/* AUTOGENERATED MOCKS START */
Expand Down
1 change: 1 addition & 0 deletions common/test/run-bolt12_merkle.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <ccan/array_size/array_size.h>
#include <common/channel_type.h>
#include <common/features.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <secp256k1_schnorrsig.h>

Expand Down
1 change: 1 addition & 0 deletions common/test/run-bolt12_period.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <ccan/array_size/array_size.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
#include <common/randbytes.h>
#include <common/setup.h>

/* AUTOGENERATED MOCKS START */
Expand Down
1 change: 1 addition & 0 deletions common/test/run-channel_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "../channel_type.c"
#include "../features.c"
#include <ccan/tal/str/str.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
#include <lightningd/channel_state.h>
Expand Down
1 change: 1 addition & 0 deletions common/test/run-codex32.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <common/codex32.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <wire/wire.h>

Expand Down
1 change: 1 addition & 0 deletions common/test/run-coin_mvt.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "config.h"
#include "../coin_mvt.c"
#include <ccan/tal/str/str.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>

Expand Down
1 change: 1 addition & 0 deletions common/test/run-cryptomsg.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "config.h"
#include <ccan/str/hex/hex.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <common/status.h>
#include <common/utils.h>
Expand Down
9 changes: 9 additions & 0 deletions common/test/run-htable.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_u8_array */
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
/* Generated stub for memleak_add_helper_ */
void memleak_add_helper_(const tal_t *p UNNEEDED, void (*cb)(struct htable *memtable UNNEEDED,
const tal_t *)){ }
/* Generated stub for memleak_scan_htable */
void memleak_scan_htable(struct htable *memtable UNNEEDED, const struct htable *ht UNNEEDED)
{ fprintf(stderr, "memleak_scan_htable called!\n"); abort(); }
/* Generated stub for notleak_ */
void *notleak_(void *ptr UNNEEDED, bool plus_children UNNEEDED)
{ fprintf(stderr, "notleak_ called!\n"); abort(); }
/* Generated stub for towire */
void towire(u8 **pptr UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED)
{ fprintf(stderr, "towire called!\n"); abort(); }
Expand Down
1 change: 1 addition & 0 deletions common/test/run-json_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "../json_stream.c"
#include <ccan/json_out/json_out.h>
#include <common/json_command.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>

Expand Down
1 change: 1 addition & 0 deletions common/test/run-json_remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <common/amount.h>
#include <common/json_param.c>
#include <common/json_parse_simple.c>
#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
#include <wire/wire.h>
Expand Down
1 change: 1 addition & 0 deletions common/test/run-json_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "../json_parse.c"
#include "../json_parse_simple.c"
#include <common/amount.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
#include <wire/wire.h>
Expand Down
1 change: 1 addition & 0 deletions common/test/run-json_stream-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <assert.h>
#include <ccan/tal/str/str.h>
#include <common/channel_type.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <inttypes.h>
#include <stdio.h>
Expand Down
1 change: 1 addition & 0 deletions common/test/run-lease_rates.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "config.h"
#include "../amount.c"
#include "../lease_rates.c"
#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>

Expand Down
1 change: 1 addition & 0 deletions common/test/run-psbt_diff.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "config.h"
#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
#include "../amount.c"
Expand Down
9 changes: 9 additions & 0 deletions common/test/run-route-infloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ bool fromwire_tlv(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
void *record UNNEEDED, struct tlv_field **fields UNNEEDED,
const u64 *extra_types UNNEEDED, size_t *err_off UNNEEDED, u64 *err_type UNNEEDED)
{ fprintf(stderr, "fromwire_tlv called!\n"); abort(); }
/* Generated stub for memleak_add_helper_ */
void memleak_add_helper_(const tal_t *p UNNEEDED, void (*cb)(struct htable *memtable UNNEEDED,
const tal_t *)){ }
/* Generated stub for memleak_scan_htable */
void memleak_scan_htable(struct htable *memtable UNNEEDED, const struct htable *ht UNNEEDED)
{ fprintf(stderr, "memleak_scan_htable called!\n"); abort(); }
/* Generated stub for notleak_ */
void *notleak_(void *ptr UNNEEDED, bool plus_children UNNEEDED)
{ fprintf(stderr, "notleak_ called!\n"); abort(); }
/* Generated stub for sciddir_or_pubkey_from_node_id */
bool sciddir_or_pubkey_from_node_id(struct sciddir_or_pubkey *sciddpk UNNEEDED,
const struct node_id *node_id UNNEEDED)
Expand Down
1 change: 1 addition & 0 deletions common/test/run-route_blinding_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <common/clock_time.h>
#include <common/json_parse.h>
#include <common/json_stream.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <common/wireaddr.h>
#include <stdio.h>
Expand Down
1 change: 1 addition & 0 deletions common/test/run-splice_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "../json_stream.c"
#include "../json_parse_simple.c"
#include <bitcoin/chainparams.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <common/splice_script.h>
#include <assert.h>
Expand Down
1 change: 1 addition & 0 deletions common/test/run-tlv_span.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "../bolt12.c"
#include "../bigsize.c"
#include "../../wire/fromwire.c"
#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>

Expand Down
1 change: 1 addition & 0 deletions common/test/run-tlv_unknown.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "../../wire/towire.c"
#include "../bigsize.c"
#include "../bolt12.c"
#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>

Expand Down
Loading
Loading