diff --git a/common/test/run-bolt12_decode.c b/common/test/run-bolt12_decode.c index f3adb2622..42173ebfa 100644 --- a/common/test/run-bolt12_decode.c +++ b/common/test/run-bolt12_decode.c @@ -8,8 +8,6 @@ #include #include -bool deprecated_apis = false; - /* AUTOGENERATED MOCKS START */ /* Generated stub for amount_asset_is_main */ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED) diff --git a/common/test/run-bolt12_merkle.c b/common/test/run-bolt12_merkle.c index b21420e55..990692f4d 100644 --- a/common/test/run-bolt12_merkle.c +++ b/common/test/run-bolt12_merkle.c @@ -13,8 +13,6 @@ /* Definition of n1 from the spec */ #include -bool deprecated_apis = false; - /* AUTOGENERATED MOCKS START */ /* Generated stub for features_unsupported */ int features_unsupported(const struct feature_set *our_features UNNEEDED, diff --git a/common/test/run-bolt12_period.c b/common/test/run-bolt12_period.c index 218cea67d..55e6db907 100644 --- a/common/test/run-bolt12_period.c +++ b/common/test/run-bolt12_period.c @@ -6,8 +6,6 @@ #include #include -bool deprecated_apis = false; - /* AUTOGENERATED MOCKS START */ /* Generated stub for amount_asset_is_main */ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED) diff --git a/connectd/test/run-gossip_rcvd_filter.c b/connectd/test/run-gossip_rcvd_filter.c index 7a6dfd3db..dc1f51aba 100644 --- a/connectd/test/run-gossip_rcvd_filter.c +++ b/connectd/test/run-gossip_rcvd_filter.c @@ -37,9 +37,6 @@ struct amount_asset amount_sat_to_asset(struct amount_sat *sat UNNEEDED, const u /* Generated stub for amount_tx_fee */ struct amount_sat amount_tx_fee(u32 fee_per_kw UNNEEDED, size_t weight UNNEEDED) { fprintf(stderr, "amount_tx_fee called!\n"); abort(); } -/* Generated stub for memleak_remove_htable */ -void memleak_remove_htable(struct htable *memtable UNNEEDED, const struct htable *ht UNNEEDED) -{ fprintf(stderr, "memleak_remove_htable 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(); } diff --git a/lightningd/test/run-invoice-select-inchan.c b/lightningd/test/run-invoice-select-inchan.c index ee3267383..01699c8b4 100644 --- a/lightningd/test/run-invoice-select-inchan.c +++ b/lightningd/test/run-invoice-select-inchan.c @@ -7,8 +7,6 @@ #include #include -bool deprecated_apis = false; - /* AUTOGENERATED MOCKS START */ /* Generated stub for any_channel_by_scid */ struct channel *any_channel_by_scid(struct lightningd *ld UNNEEDED, @@ -163,6 +161,8 @@ void db_commit_transaction(struct db *db UNNEEDED) /* Generated stub for delete_channel */ void delete_channel(struct channel *channel STEALS UNNEEDED) { fprintf(stderr, "delete_channel called!\n"); abort(); } +/* Generated stub for deprecated_apis */ +bool deprecated_apis; /* Generated stub for encode_scriptpubkey_to_addr */ char *encode_scriptpubkey_to_addr(const tal_t *ctx UNNEEDED, const struct chainparams *chainparams UNNEEDED, diff --git a/lightningd/test/run-jsonrpc.c b/lightningd/test/run-jsonrpc.c index 01806dadf..61bea726f 100644 --- a/lightningd/test/run-jsonrpc.c +++ b/lightningd/test/run-jsonrpc.c @@ -12,6 +12,8 @@ void db_begin_transaction_(struct db *db UNNEEDED, const char *location UNNEEDED /* Generated stub for db_commit_transaction */ void db_commit_transaction(struct db *db UNNEEDED) { fprintf(stderr, "db_commit_transaction called!\n"); abort(); } +/* Generated stub for deprecated_apis */ +bool deprecated_apis; /* Generated stub for fatal */ void fatal(const char *fmt UNNEEDED, ...) { fprintf(stderr, "fatal called!\n"); abort(); } @@ -123,8 +125,6 @@ void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED) { fprintf(stderr, "towire_node_id called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ -bool deprecated_apis; - static int test_json_filter(void) { struct json_stream *result = new_json_stream(NULL, NULL, NULL); diff --git a/tools/mockup.sh b/tools/mockup.sh index c98eb1116..e9808504e 100755 --- a/tools/mockup.sh +++ b/tools/mockup.sh @@ -40,13 +40,18 @@ if [ $# -eq 0 ]; then fi for SYMBOL; do + STUB="" # If there are multiple declarations, pick first (eg. common/memleak.h # has notleak_ as a declaration, and then an inline). # Also, prefer local headers over generic ones. WHERE=$(shopt -s nullglob; grep -nH "^[a-zA-Z0-9_ (),]* [*]*$SYMBOL(" "$UPDIRNAME"/*.h ./*/*.h | head -n1) if [ -z "$WHERE" ]; then - echo "/* Could not find declaration for $SYMBOL */" - continue + WHERE=$(shopt -s nullglob; grep -nH "^extern [a-zA-Z0-9_ (),]* [*]*$SYMBOL;" "$UPDIRNAME"/*.h ./*/*.h | head -n1) + STUB=";" + if [ -z "$WHERE" ]; then + echo "/* Could not find declaration for $SYMBOL */" + continue + fi fi FILE=${WHERE%%:*} @@ -55,13 +60,15 @@ for SYMBOL; do END=$(tail -n "+${LINE}" < "$FILE" | grep -n ';$'); NUM=${END%%:*} - if grep -q "$SYMBOL.*mock empty" "$FILE"; then - STUB="{ }" - else - # \n on RHS is a GNU extension, and we want to work on FreeBSD - # shellcheck disable=SC1004 - STUB='\ + if [ -z "$STUB" ]; then + if grep -q "$SYMBOL.*mock empty" "$FILE"; then + STUB="{ }" + else + # \n on RHS is a GNU extension, and we want to work on FreeBSD + # shellcheck disable=SC1004 + STUB='\ { fprintf(stderr, "'$SYMBOL' called!\\n"); abort(); }' + fi fi echo "/* Generated stub for $SYMBOL */" diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index f3f636fce..65cf287f8 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -45,8 +45,6 @@ void db_fatal(const char *fmt, ...) #include #include -bool deprecated_apis = true; - /* AUTOGENERATED MOCKS START */ /* Generated stub for bigsize_put */ size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) @@ -118,6 +116,8 @@ struct onionreply *create_onionreply(const tal_t *ctx UNNEEDED, const struct secret *shared_secret UNNEEDED, const u8 *failure_msg UNNEEDED) { fprintf(stderr, "create_onionreply called!\n"); abort(); } +/* Generated stub for deprecated_apis */ +bool deprecated_apis; /* Generated stub for derive_channel_id */ void derive_channel_id(struct channel_id *channel_id UNNEEDED, const struct bitcoin_outpoint *outpoint UNNEEDED)