This means we don't have to manually choose what to link against, which is much of the complexity of our Makefiles: the compiler will automatically use any object files it needs to link. We already do this for ccan as libccan.a, now we have libcommon.a. We don't link against it for *everything*, as some tests require their own versions. Notes: 1. I get rid of the weird plugins/test/Makefile2 (accidental commit?) 2. Many tests change due to update-mocks. 3. In some places I added the missing dependency on the Makefile itself, though most are in the next patch. Before: Total program size: 221366528 Total tests size: 364243856 After: Total program size: 190733656 Total tests size: 337880888 Build time from make clean (RUST=0) (includes building external libs): Before: real 0m38.227000-44.245000(41.8222+/-1.6)s user 3m2.105000-33.696000(23.1442+/-8.4)s sys 0m35.054000-42.269000(39.7231+/-2)s After: real 0m38.944000-40.416000(40.1131+/-0.4)s user 3m6.790000-17.159000(15.0571+/-2.8)s sys 0m35.304000-37.336000(36.8942+/-0.57)s Build time after touch config.vars (RUST=0): Before: real 0m18.928000-22.776000(21.5084+/-1.1)s user 2m8.613000-36.567000(27.7281+/-7.7)s sys 0m20.458000-23.436000(22.3963+/-0.77)s After: real 0m19.831000-21.862000(21.5528+/-0.58)s user 2m15.361000-30.731000(28.4798+/-4.4)s sys 0m21.056000-22.339000(22.0346+/-0.35)s Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> rusty@rusty-Framework:~/devel/cvs/lightni
134 lines
4.1 KiB
C
134 lines
4.1 KiB
C
#include "config.h"
|
|
#include "../seeker.c"
|
|
#include <ccan/err/err.h>
|
|
#include <common/blinding.h>
|
|
#include <common/channel_type.h>
|
|
#include <common/ecdh.h>
|
|
#include <common/json_stream.h>
|
|
#include <common/onionreply.h>
|
|
#include <common/sciddir_or_pubkey.h>
|
|
#include <common/setup.h>
|
|
#include <common/wireaddr.h>
|
|
#include <stdio.h>
|
|
|
|
/* AUTOGENERATED MOCKS START */
|
|
/* Generated stub for find_peer */
|
|
struct peer *find_peer(struct daemon *daemon UNNEEDED, const struct node_id *id UNNEEDED)
|
|
{ fprintf(stderr, "find_peer called!\n"); abort(); }
|
|
/* Generated stub for first_random_peer */
|
|
struct peer *first_random_peer(struct daemon *daemon UNNEEDED,
|
|
struct peer_node_id_map_iter *it UNNEEDED)
|
|
{ fprintf(stderr, "first_random_peer called!\n"); abort(); }
|
|
/* Generated stub for gossmap_manage_get_gossmap */
|
|
struct gossmap *gossmap_manage_get_gossmap(struct gossmap_manage *gm UNNEEDED)
|
|
{ fprintf(stderr, "gossmap_manage_get_gossmap called!\n"); abort(); }
|
|
/* Generated stub for gossmap_manage_populated */
|
|
bool gossmap_manage_populated(const struct gossmap_manage *gm UNNEEDED)
|
|
{ fprintf(stderr, "gossmap_manage_populated called!\n"); abort(); }
|
|
/* Generated stub for next_random_peer */
|
|
struct peer *next_random_peer(struct daemon *daemon UNNEEDED,
|
|
const struct peer *first UNNEEDED,
|
|
struct peer_node_id_map_iter *it UNNEEDED)
|
|
{ fprintf(stderr, "next_random_peer called!\n"); abort(); }
|
|
/* Generated stub for query_channel_range */
|
|
bool query_channel_range(struct daemon *daemon UNNEEDED,
|
|
struct peer *peer UNNEEDED,
|
|
u32 first_blocknum UNNEEDED, u32 number_of_blocks UNNEEDED,
|
|
enum query_option_flags qflags UNNEEDED,
|
|
void (*cb)(struct peer *peer_ UNNEEDED,
|
|
u32 first_blocknum_ UNNEEDED,
|
|
u32 number_of_blocks_ UNNEEDED,
|
|
const struct range_query_reply *replies_))
|
|
{ fprintf(stderr, "query_channel_range called!\n"); abort(); }
|
|
/* Generated stub for query_short_channel_ids */
|
|
bool query_short_channel_ids(struct daemon *daemon UNNEEDED,
|
|
struct peer *peer UNNEEDED,
|
|
const struct short_channel_id *scids UNNEEDED,
|
|
const u8 *query_flags UNNEEDED,
|
|
void (*cb)(struct peer *peer_ UNNEEDED, bool complete))
|
|
{ fprintf(stderr, "query_short_channel_ids called!\n"); abort(); }
|
|
/* Generated stub for queue_peer_msg */
|
|
void queue_peer_msg(struct daemon *daemon UNNEEDED,
|
|
const struct node_id *peer UNNEEDED,
|
|
const u8 *msg TAKES UNNEEDED)
|
|
{ fprintf(stderr, "queue_peer_msg called!\n"); abort(); }
|
|
/* Generated stub for towire_gossipd_connect_to_peer */
|
|
u8 *towire_gossipd_connect_to_peer(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED)
|
|
{ fprintf(stderr, "towire_gossipd_connect_to_peer called!\n"); abort(); }
|
|
/* AUTOGENERATED MOCKS END */
|
|
|
|
static void test_block_range(struct seeker *seeker,
|
|
u32 blockheight,
|
|
u32 first, u32 last,
|
|
...)
|
|
{
|
|
int start, end, num;
|
|
u32 first_blocknum, number_of_blocks;
|
|
va_list ap;
|
|
|
|
seeker->daemon->current_blockheight = blockheight;
|
|
seeker->scid_probe_start = first;
|
|
seeker->scid_probe_end = last;
|
|
|
|
num = last - first + 1;
|
|
va_start(ap, last);
|
|
while ((start = va_arg(ap, int)) != -1) {
|
|
end = va_arg(ap, int);
|
|
if (!next_block_range(seeker, num,
|
|
&first_blocknum, &number_of_blocks))
|
|
abort();
|
|
if (first_blocknum != start
|
|
|| number_of_blocks != end - start + 1) {
|
|
errx(1, "Expected %u-%u but got %u-%u",
|
|
start, end,
|
|
first_blocknum, first_blocknum+number_of_blocks-1);
|
|
}
|
|
num = end - start + 1;
|
|
}
|
|
if (next_block_range(seeker, num, &first_blocknum, &number_of_blocks))
|
|
abort();
|
|
va_end(ap);
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
struct seeker *seeker = tal(NULL, struct seeker);
|
|
|
|
common_setup(argv[0]);
|
|
|
|
seeker->daemon = tal(seeker, struct daemon);
|
|
|
|
/* Case where we start at beginning */
|
|
test_block_range(seeker, 100,
|
|
0, 0,
|
|
1, 2,
|
|
3, 6,
|
|
7, 14,
|
|
15, 30,
|
|
31, 62,
|
|
63, 100,
|
|
-1);
|
|
|
|
/* Case where we start at end */
|
|
test_block_range(seeker, 100,
|
|
100, 100,
|
|
98, 99,
|
|
94, 97,
|
|
86, 93,
|
|
70, 85,
|
|
38, 69,
|
|
0, 37,
|
|
-1);
|
|
|
|
/* Start in the middle. */
|
|
test_block_range(seeker, 100,
|
|
50, 59,
|
|
30, 49,
|
|
0, 29,
|
|
60, 100,
|
|
-1);
|
|
|
|
tal_free(seeker);
|
|
common_shutdown();
|
|
}
|