From a046af4416371a150dd293215ad96c8791e7687e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 3 Dec 2018 09:31:04 +1030 Subject: [PATCH] lightningd/test: move some tests to common/ and channeld/ These unit tests stayed under lightningd/ even though the units they test are elsewhere. Signed-off-by: Rusty Russell --- channeld/test/Makefile | 3 +++ {lightningd => channeld}/test/run-commit_tx.c | 7 +++---- channeld/test/run-full_channel.c | 10 ++++------ {lightningd => common}/test/run-funding_tx.c | 6 ++++-- {lightningd => common}/test/run-key_derive.c | 4 ++-- lightningd/test/Makefile | 1 + lightningd/test/run-invoice-select-inchan.c | 4 ---- 7 files changed, 17 insertions(+), 18 deletions(-) rename {lightningd => channeld}/test/run-commit_tx.c (99%) rename {lightningd => common}/test/run-funding_tx.c (97%) rename {lightningd => common}/test/run-key_derive.c (97%) diff --git a/channeld/test/Makefile b/channeld/test/Makefile index 69a8a0d69..2a5598cba 100644 --- a/channeld/test/Makefile +++ b/channeld/test/Makefile @@ -10,6 +10,9 @@ ALL_OBJS += $(CHANNELD_TEST_OBJS) CHANNELD_TEST_COMMON_OBJS := \ common/daemon_conn.o \ common/htlc_state.o \ + common/htlc_tx.o \ + common/initial_commit_tx.o \ + common/key_derive.o \ common/pseudorand.o \ common/msg_queue.o \ common/utils.o \ diff --git a/lightningd/test/run-commit_tx.c b/channeld/test/run-commit_tx.c similarity index 99% rename from lightningd/test/run-commit_tx.c rename to channeld/test/run-commit_tx.c index 84f21d14a..5097b5f1f 100644 --- a/lightningd/test/run-commit_tx.c +++ b/channeld/test/run-commit_tx.c @@ -1,4 +1,3 @@ -#include "../../common/key_derive.c" #include #include #include @@ -6,15 +5,15 @@ static bool print_superverbose; #define SUPERVERBOSE(...) \ do { if (print_superverbose) printf(__VA_ARGS__); } while(0) #define PRINT_ACTUAL_FEE -#include "../../channeld/commit_tx.c" -#include "../../common/initial_commit_tx.c" -#include "../../common/htlc_tx.c" +#include "../commit_tx.c" #include #include #include #include #include #include +#include +#include /* Turn this on to brute-force fee values */ /*#define DEBUG */ diff --git a/channeld/test/run-full_channel.c b/channeld/test/run-full_channel.c index 9f067e3a6..3098ee716 100644 --- a/channeld/test/run-full_channel.c +++ b/channeld/test/run-full_channel.c @@ -1,10 +1,7 @@ -#include "../../common/key_derive.c" -#include "../../common/keyset.c" #include "../../common/initial_channel.c" -#include "../../channeld/full_channel.c" -#include "../../common/initial_commit_tx.c" -#include "../../channeld/commit_tx.c" -#include "../../common/htlc_tx.c" +#include "../../common/keyset.c" +#include "../full_channel.c" +#include "../commit_tx.c" #include #include #include @@ -13,6 +10,7 @@ #include #include #include +#include void status_fmt(enum log_level level UNUSED, const char *fmt, ...) { diff --git a/lightningd/test/run-funding_tx.c b/common/test/run-funding_tx.c similarity index 97% rename from lightningd/test/run-funding_tx.c rename to common/test/run-funding_tx.c index 64637ab48..b39e6ef19 100644 --- a/lightningd/test/run-funding_tx.c +++ b/common/test/run-funding_tx.c @@ -9,9 +9,11 @@ #include #include #define SUPERVERBOSE printf - #include "../../common/funding_tx.c" + #include "../funding_tx.c" #undef SUPERVERBOSE - #include "../../common/key_derive.c" + #include "../key_derive.c" + #include "../type_to_string.c" + #include "../permute_tx.c" #if 0 static struct sha256 sha256_from_hex(const char *hex) diff --git a/lightningd/test/run-key_derive.c b/common/test/run-key_derive.c similarity index 97% rename from lightningd/test/run-key_derive.c rename to common/test/run-key_derive.c index 8e02e7488..4d49fee01 100644 --- a/lightningd/test/run-key_derive.c +++ b/common/test/run-key_derive.c @@ -2,10 +2,10 @@ #include #include -#include #include #include -#include "../../common/key_derive.c" +#include "../type_to_string.c" +#include "../key_derive.c" static struct secret secret_from_hex(const char *hex) { diff --git a/lightningd/test/Makefile b/lightningd/test/Makefile index 9b555b5d7..10653ff2c 100644 --- a/lightningd/test/Makefile +++ b/lightningd/test/Makefile @@ -13,6 +13,7 @@ LIGHTNINGD_TEST_COMMON_OBJS := \ common/htlc_state.o \ common/io_lock.o \ common/json.o \ + common/key_derive.o \ common/pseudorand.o \ common/memleak.o \ common/msg_queue.o \ diff --git a/lightningd/test/run-invoice-select-inchan.c b/lightningd/test/run-invoice-select-inchan.c index 9c8535f6a..392aa815a 100644 --- a/lightningd/test/run-invoice-select-inchan.c +++ b/lightningd/test/run-invoice-select-inchan.c @@ -6,10 +6,6 @@ bool deprecated_apis = false; /* AUTOGENERATED MOCKS START */ -/* Generated stub for bip32_pubkey */ -bool bip32_pubkey(const struct ext_key *bip32_base UNNEEDED, - struct pubkey *pubkey UNNEEDED, u32 index UNNEEDED) -{ fprintf(stderr, "bip32_pubkey called!\n"); abort(); } /* Generated stub for bitcoind_gettxout */ void bitcoind_gettxout(struct bitcoind *bitcoind UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, const u32 outnum UNNEEDED,