From 1853b399b0633f93bfd5261e386effd65a1bb5da Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Wed, 13 Mar 2019 17:20:54 +0100 Subject: [PATCH] fix: a pr2444 introduced valgrind complaint This will add the testnet config copyNpaste to test_utils.c, so that the test stups can set these. Alternatively, to reduce code duplication, we can move the testnet_config and mainnet_config from options.c to options.h. --- wallet/test/run-db.c | 1 + wallet/test/run-wallet.c | 1 + wallet/test/test_utils.c | 25 +++++++++++++++++++++++++ wallet/test/test_utils.h | 4 ++++ 4 files changed, 31 insertions(+) create mode 100644 wallet/test/test_utils.c diff --git a/wallet/test/run-db.c b/wallet/test/run-db.c index 859f2ed58..916478dee 100644 --- a/wallet/test/run-db.c +++ b/wallet/test/run-db.c @@ -122,6 +122,7 @@ int main(void) bool ok = true; /* Dummy for migration hooks */ struct lightningd *ld = tal(NULL, struct lightningd); + ld->config = test_config; ok &= test_empty_db_migrate(ld); ok &= test_vars(ld); diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 4fa50df36..aaa484524 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -1161,6 +1161,7 @@ int main(void) wally_init(0); secp256k1_ctx = wally_get_secp_context(); ld = tal(tmpctx, struct lightningd); + ld->config = test_config; /* Only elements in ld we should access */ list_head_init(&ld->peers); diff --git a/wallet/test/test_utils.c b/wallet/test/test_utils.c new file mode 100644 index 000000000..78bcd81cb --- /dev/null +++ b/wallet/test/test_utils.c @@ -0,0 +1,25 @@ +#include "test_utils.h" + +/* + * Copy of lightnind/options.c testnet_config + * To reduce code duplication move testnet_config from options.c to options.h. + */ +const struct config test_config = { + .locktime_blocks = 6, + .locktime_max = 14 * 24 * 6, + .anchor_confirms = 1, + .commitment_fee_min_percent = 0, + .commitment_fee_max_percent = 0, + .commitment_fee_percent = 500, + .cltv_expiry_delta = 6, + .cltv_final = 10, + .commit_time_ms = 10, + .fee_base = 1, + .fee_per_satoshi = 10, + .broadcast_interval_msec = 60000, + .channel_update_interval = 1209600/2, + .ignore_fee_limits = true, + .rescan = 30, + .max_fee_multiplier = 10, + .use_dns = true, +}; diff --git a/wallet/test/test_utils.h b/wallet/test/test_utils.h index bfa116391..8500b60bc 100644 --- a/wallet/test/test_utils.h +++ b/wallet/test/test_utils.h @@ -1,6 +1,8 @@ #ifndef LIGHTNING_WALLET_TEST_TEST_UTILS_H #define LIGHTNING_WALLET_TEST_TEST_UTILS_H +#include "lightningd/lightningd.h" + /* Definitions "inspired" by libsecp256k1 */ #define TEST_FAILURE(msg) do { \ fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, msg); \ @@ -21,4 +23,6 @@ #define CHECK(cond) CHECK_MSG(cond,"test condition failed"); +const struct config test_config; + #endif /* LIGHTNING_WALLET_TEST_TEST_UTILS_H */