From f66c8306f46644e8d3833c6e8db2934cb3d736a9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 5 Feb 2018 14:39:27 +1030 Subject: [PATCH] wallet: don't use non-common objects as if they were common. If needed, they should be directly #included; otherwise the following patches really mess things up. Signed-off-by: Rusty Russell --- wallet/test/Makefile | 9 +++---- wallet/test/run-wallet.c | 54 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/wallet/test/Makefile b/wallet/test/Makefile index 8154b4775..090e23822 100644 --- a/wallet/test/Makefile +++ b/wallet/test/Makefile @@ -2,19 +2,16 @@ WALLET_TEST_SRC := $(wildcard wallet/test/run-*.c) WALLET_TEST_OBJS := $(WALLET_TEST_SRC:.c=.o) WALLET_TEST_PROGRAMS := $(WALLET_TEST_OBJS:.o=) -WALLET_TEST_COMMON_OBJS := \ +WALLET_TEST_COMMON_OBJS := \ common/htlc_state.o \ common/type_to_string.o \ common/memleak.o \ common/pseudorand.o \ common/timeout.o \ common/utils.o \ - common/wireaddr.o \ - wallet/invoices.o \ + common/wireaddr.o \ wire/towire.o \ - wire/fromwire.o \ - lightningd/htlc_end.o \ - lightningd/log.o + wire/fromwire.o # Make sure these depend on everything. ALL_TEST_PROGRAMS += $(WALLET_TEST_PROGRAMS) diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 7293c5475..9f214ae57 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -10,6 +10,7 @@ static void db_log_(struct log *log, enum log_level level, const char *fmt, ...) #define log_ db_log_ #include "wallet/wallet.c" +#include "lightningd/htlc_end.c" #include "wallet/db.c" @@ -23,6 +24,56 @@ static void db_log_(struct log *log, enum log_level level, const char *fmt, ...) #include /* AUTOGENERATED MOCKS START */ +/* Generated stub for invoices_create */ +const struct invoice *invoices_create(struct invoices *invoices UNNEEDED, + u64 *msatoshi TAKES UNNEEDED, + const char *label TAKES UNNEEDED, + u64 expiry UNNEEDED) +{ fprintf(stderr, "invoices_create called!\n"); abort(); } +/* Generated stub for invoices_delete */ +bool invoices_delete(struct invoices *invoices UNNEEDED, + const struct invoice *invoice UNNEEDED) +{ fprintf(stderr, "invoices_delete called!\n"); abort(); } +/* Generated stub for invoices_find_by_label */ +const struct invoice *invoices_find_by_label(struct invoices *invoices UNNEEDED, + const char *label UNNEEDED) +{ fprintf(stderr, "invoices_find_by_label called!\n"); abort(); } +/* Generated stub for invoices_find_unpaid */ +const struct invoice *invoices_find_unpaid(struct invoices *invoices UNNEEDED, + const struct sha256 *rhash UNNEEDED) +{ fprintf(stderr, "invoices_find_unpaid called!\n"); abort(); } +/* Generated stub for invoices_iterate */ +const struct invoice *invoices_iterate(struct invoices *invoices UNNEEDED, + const struct invoice *invoice UNNEEDED) +{ fprintf(stderr, "invoices_iterate called!\n"); abort(); } +/* Generated stub for invoices_load */ +bool invoices_load(struct invoices *invoices UNNEEDED) +{ fprintf(stderr, "invoices_load called!\n"); abort(); } +/* Generated stub for invoices_new */ +struct invoices *invoices_new(const tal_t *ctx UNNEEDED, + struct db *db UNNEEDED, + struct log *log UNNEEDED, + struct timers *timers UNNEEDED) +{ fprintf(stderr, "invoices_new called!\n"); abort(); } +/* Generated stub for invoices_resolve */ +void invoices_resolve(struct invoices *invoices UNNEEDED, + const struct invoice *invoice UNNEEDED, + u64 msatoshi_received UNNEEDED) +{ fprintf(stderr, "invoices_resolve called!\n"); abort(); } +/* Generated stub for invoices_waitany */ +void invoices_waitany(const tal_t *ctx UNNEEDED, + struct invoices *invoices UNNEEDED, + u64 lastpay_index UNNEEDED, + void (*cb)(const struct invoice * UNNEEDED, void*) UNNEEDED, + void *cbarg UNNEEDED) +{ fprintf(stderr, "invoices_waitany called!\n"); abort(); } +/* Generated stub for invoices_waitone */ +void invoices_waitone(const tal_t *ctx UNNEEDED, + struct invoices *invoices UNNEEDED, + struct invoice const *invoice UNNEEDED, + void (*cb)(const struct invoice * UNNEEDED, void*) UNNEEDED, + void *cbarg UNNEEDED) +{ fprintf(stderr, "invoices_waitone called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ static char *wallet_err; @@ -62,7 +113,6 @@ static struct wallet *create_test_wallet(const tal_t *ctx) { char filename[] = "/tmp/ldb-XXXXXX"; int fd = mkstemp(filename); - struct log_book *log_book; struct wallet *w = tal(ctx, struct wallet); CHECK_MSG(fd != -1, "Unable to generate temp filename"); close(fd); @@ -70,8 +120,6 @@ static struct wallet *create_test_wallet(const tal_t *ctx) w->db = db_open(w, filename); ltmp = tal_tmpctx(ctx); - log_book = new_log_book(w, 20*1024*1024, LOG_DBG); - w->log = new_log(w, log_book, "wallet_tests(%u):", (int)getpid()); list_head_init(&w->unstored_payments); CHECK_MSG(w->db, "Failed opening the db");