Skip to content

Commit

Permalink
wallet: don't use non-common objects as if they were common.
Browse files Browse the repository at this point in the history
If needed, they should be directly #included; otherwise the following
patches really mess things up.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Feb 7, 2018
1 parent 736a80d commit f66c830
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 9 deletions.
9 changes: 3 additions & 6 deletions wallet/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
54 changes: 51 additions & 3 deletions wallet/test/run-wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -23,6 +24,56 @@ static void db_log_(struct log *log, enum log_level level, const char *fmt, ...)
#include <unistd.h>

/* 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;
Expand Down Expand Up @@ -62,16 +113,13 @@ 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);

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");
Expand Down

0 comments on commit f66c830

Please sign in to comment.