2021-12-04 12:23:56 +01:00
|
|
|
#include "config.h"
|
2019-09-27 02:04:34 +02:00
|
|
|
#include "../routing.c"
|
|
|
|
#include "../common/timeout.c"
|
2021-11-30 04:06:05 +01:00
|
|
|
#include <common/blinding.h>
|
2021-09-09 04:50:52 +02:00
|
|
|
#include <common/channel_type.h>
|
2021-11-30 04:06:05 +01:00
|
|
|
#include <common/ecdh.h>
|
2020-02-27 03:17:01 +01:00
|
|
|
#include <common/json_stream.h>
|
2021-11-30 04:06:05 +01:00
|
|
|
#include <common/onionreply.h>
|
2020-12-02 01:10:04 +01:00
|
|
|
#include <common/setup.h>
|
2019-09-27 02:04:34 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
/* AUTOGENERATED MOCKS START */
|
2021-11-30 04:06:05 +01:00
|
|
|
/* Generated stub for blinding_hash_e_and_ss */
|
|
|
|
void blinding_hash_e_and_ss(const struct pubkey *e UNNEEDED,
|
|
|
|
const struct secret *ss UNNEEDED,
|
|
|
|
struct sha256 *sha UNNEEDED)
|
|
|
|
{ fprintf(stderr, "blinding_hash_e_and_ss called!\n"); abort(); }
|
|
|
|
/* Generated stub for blinding_next_privkey */
|
|
|
|
bool blinding_next_privkey(const struct privkey *e UNNEEDED,
|
|
|
|
const struct sha256 *h UNNEEDED,
|
|
|
|
struct privkey *next UNNEEDED)
|
|
|
|
{ fprintf(stderr, "blinding_next_privkey called!\n"); abort(); }
|
|
|
|
/* Generated stub for blinding_next_pubkey */
|
|
|
|
bool blinding_next_pubkey(const struct pubkey *pk UNNEEDED,
|
|
|
|
const struct sha256 *h UNNEEDED,
|
|
|
|
struct pubkey *next UNNEEDED)
|
|
|
|
{ fprintf(stderr, "blinding_next_pubkey called!\n"); abort(); }
|
2019-09-27 02:04:34 +02:00
|
|
|
/* Generated stub for cupdate_different */
|
|
|
|
bool cupdate_different(struct gossip_store *gs UNNEEDED,
|
|
|
|
const struct half_chan *hc UNNEEDED,
|
|
|
|
const u8 *cupdate UNNEEDED)
|
|
|
|
{ fprintf(stderr, "cupdate_different called!\n"); abort(); }
|
|
|
|
/* Generated stub for gossip_store_add */
|
|
|
|
u64 gossip_store_add(struct gossip_store *gs UNNEEDED, const u8 *gossip_msg UNNEEDED,
|
2023-07-22 13:19:23 +02:00
|
|
|
u32 timestamp UNNEEDED, bool zombie UNNEEDED, bool spam UNNEEDED, bool dying UNNEEDED,
|
2022-12-16 17:25:47 +01:00
|
|
|
const u8 *addendum UNNEEDED)
|
2019-09-27 02:04:34 +02:00
|
|
|
{ fprintf(stderr, "gossip_store_add called!\n"); abort(); }
|
|
|
|
/* Generated stub for gossip_store_add_private_update */
|
|
|
|
u64 gossip_store_add_private_update(struct gossip_store *gs UNNEEDED, const u8 *update UNNEEDED)
|
|
|
|
{ fprintf(stderr, "gossip_store_add_private_update called!\n"); abort(); }
|
|
|
|
/* Generated stub for gossip_store_delete */
|
|
|
|
void gossip_store_delete(struct gossip_store *gs UNNEEDED,
|
|
|
|
struct broadcastable *bcast UNNEEDED,
|
|
|
|
int type UNNEEDED)
|
|
|
|
{ fprintf(stderr, "gossip_store_delete called!\n"); abort(); }
|
|
|
|
/* Generated stub for gossip_store_get */
|
|
|
|
const u8 *gossip_store_get(const tal_t *ctx UNNEEDED,
|
|
|
|
struct gossip_store *gs UNNEEDED,
|
|
|
|
u64 offset UNNEEDED)
|
|
|
|
{ fprintf(stderr, "gossip_store_get called!\n"); abort(); }
|
|
|
|
/* Generated stub for gossip_store_get_private_update */
|
|
|
|
const u8 *gossip_store_get_private_update(const tal_t *ctx UNNEEDED,
|
|
|
|
struct gossip_store *gs UNNEEDED,
|
|
|
|
u64 offset UNNEEDED)
|
|
|
|
{ fprintf(stderr, "gossip_store_get_private_update called!\n"); abort(); }
|
2020-08-11 07:06:56 +02:00
|
|
|
/* Generated stub for gossip_store_mark_channel_deleted */
|
|
|
|
void gossip_store_mark_channel_deleted(struct gossip_store *gs UNNEEDED,
|
|
|
|
const struct short_channel_id *scid UNNEEDED)
|
|
|
|
{ fprintf(stderr, "gossip_store_mark_channel_deleted called!\n"); abort(); }
|
2023-07-19 08:35:31 +02:00
|
|
|
/* Generated stub for gossip_store_mark_dying */
|
|
|
|
void gossip_store_mark_dying(struct gossip_store *gs UNNEEDED,
|
|
|
|
const struct broadcastable *bcast UNNEEDED,
|
|
|
|
int type UNNEEDED)
|
|
|
|
{ fprintf(stderr, "gossip_store_mark_dying called!\n"); abort(); }
|
2019-09-27 02:04:34 +02:00
|
|
|
/* Generated stub for memleak_add_helper_ */
|
|
|
|
void memleak_add_helper_(const tal_t *p UNNEEDED, void (*cb)(struct htable *memtable UNNEEDED,
|
|
|
|
const tal_t *)){ }
|
2022-09-16 05:14:39 +02:00
|
|
|
/* Generated stub for memleak_scan_htable */
|
|
|
|
void memleak_scan_htable(struct htable *memtable UNNEEDED, const struct htable *ht UNNEEDED)
|
|
|
|
{ fprintf(stderr, "memleak_scan_htable called!\n"); abort(); }
|
|
|
|
/* Generated stub for memleak_scan_intmap_ */
|
|
|
|
void memleak_scan_intmap_(struct htable *memtable UNNEEDED, const struct intmap *m UNNEEDED)
|
|
|
|
{ fprintf(stderr, "memleak_scan_intmap_ called!\n"); abort(); }
|
2019-09-27 02:04:34 +02:00
|
|
|
/* Generated stub for nannounce_different */
|
|
|
|
bool nannounce_different(struct gossip_store *gs UNNEEDED,
|
|
|
|
const struct node *node UNNEEDED,
|
2021-05-28 22:12:41 +02:00
|
|
|
const u8 *nannounce UNNEEDED,
|
|
|
|
bool *only_missing_tlv UNNEEDED)
|
2019-09-27 02:04:34 +02:00
|
|
|
{ fprintf(stderr, "nannounce_different called!\n"); abort(); }
|
2019-10-15 04:39:13 +02:00
|
|
|
/* Generated stub for notleak_ */
|
2021-11-24 20:59:20 +01:00
|
|
|
void *notleak_(void *ptr UNNEEDED, bool plus_children UNNEEDED)
|
2019-10-15 04:39:13 +02:00
|
|
|
{ fprintf(stderr, "notleak_ called!\n"); abort(); }
|
2019-10-08 03:13:24 +02:00
|
|
|
/* Generated stub for peer_supplied_good_gossip */
|
2023-07-06 09:35:54 +02:00
|
|
|
void peer_supplied_good_gossip(struct daemon *daemon UNNEEDED,
|
|
|
|
const struct node_id *source_peer UNNEEDED,
|
|
|
|
size_t amount UNNEEDED)
|
2019-10-08 03:13:24 +02:00
|
|
|
{ fprintf(stderr, "peer_supplied_good_gossip called!\n"); abort(); }
|
2019-09-27 02:04:34 +02:00
|
|
|
/* Generated stub for sanitize_error */
|
|
|
|
char *sanitize_error(const tal_t *ctx UNNEEDED, const u8 *errmsg UNNEEDED,
|
|
|
|
struct channel_id *channel_id UNNEEDED)
|
|
|
|
{ fprintf(stderr, "sanitize_error called!\n"); abort(); }
|
2022-01-24 21:03:52 +01:00
|
|
|
/* Generated stub for status_failed */
|
|
|
|
void status_failed(enum status_failreason code UNNEEDED,
|
|
|
|
const char *fmt UNNEEDED, ...)
|
|
|
|
{ fprintf(stderr, "status_failed called!\n"); abort(); }
|
2019-09-27 02:04:34 +02:00
|
|
|
/* Generated stub for status_fmt */
|
2019-11-17 12:42:33 +01:00
|
|
|
void status_fmt(enum log_level level UNNEEDED,
|
|
|
|
const struct node_id *peer UNNEEDED,
|
|
|
|
const char *fmt UNNEEDED, ...)
|
2019-09-27 02:04:34 +02:00
|
|
|
|
|
|
|
{ fprintf(stderr, "status_fmt called!\n"); abort(); }
|
2021-02-03 03:51:41 +01:00
|
|
|
/* Generated stub for towire_warningfmt */
|
|
|
|
u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
|
|
|
|
const struct channel_id *channel UNNEEDED,
|
|
|
|
const char *fmt UNNEEDED, ...)
|
|
|
|
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
|
2019-09-27 02:04:34 +02:00
|
|
|
/* AUTOGENERATED MOCKS END */
|
|
|
|
|
|
|
|
/* NOOP stub for gossip_store_new */
|
2023-06-29 21:23:17 +02:00
|
|
|
struct gossip_store *gossip_store_new(struct routing_state *rstate UNNEEDED)
|
2019-09-27 02:04:34 +02:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-12-02 01:10:04 +01:00
|
|
|
int main(int argc, char *argv[])
|
2019-09-27 02:04:34 +02:00
|
|
|
{
|
|
|
|
struct routing_state *rstate;
|
|
|
|
struct timer *t;
|
|
|
|
struct short_channel_id scid1, scid2;
|
2023-07-06 09:34:54 +02:00
|
|
|
struct daemon *daemon;
|
2019-09-27 02:04:34 +02:00
|
|
|
|
2020-12-02 01:10:04 +01:00
|
|
|
common_setup(argv[0]);
|
2019-09-27 02:04:34 +02:00
|
|
|
|
2023-07-06 09:34:54 +02:00
|
|
|
daemon = tal(tmpctx, struct daemon);
|
|
|
|
timers_init(&daemon->timers, time_mono());
|
|
|
|
rstate = new_routing_state(tmpctx, daemon, NULL, false, false);
|
2019-09-27 02:04:34 +02:00
|
|
|
|
|
|
|
scid1.u64 = 100;
|
|
|
|
scid2.u64 = 200;
|
|
|
|
assert(!in_txout_failures(rstate, &scid1));
|
|
|
|
assert(!in_txout_failures(rstate, &scid2));
|
|
|
|
|
|
|
|
add_to_txout_failures(rstate, &scid1);
|
|
|
|
assert(in_txout_failures(rstate, &scid1));
|
|
|
|
assert(!in_txout_failures(rstate, &scid2));
|
|
|
|
assert(rstate->num_txout_failures == 1);
|
|
|
|
|
|
|
|
add_to_txout_failures(rstate, &scid2);
|
|
|
|
assert(in_txout_failures(rstate, &scid1));
|
|
|
|
assert(in_txout_failures(rstate, &scid2));
|
|
|
|
assert(rstate->num_txout_failures == 2);
|
|
|
|
|
|
|
|
/* Move time forward 1 hour. */
|
2023-07-06 09:34:54 +02:00
|
|
|
t = timers_expire(&daemon->timers,
|
|
|
|
timemono_add(time_mono(),
|
|
|
|
time_from_sec(3601)));
|
2019-09-27 02:04:34 +02:00
|
|
|
assert(t);
|
2021-12-06 15:45:50 +01:00
|
|
|
timer_expired(t);
|
2019-09-27 02:04:34 +02:00
|
|
|
|
|
|
|
/* Still there, just old. Refresh scid1 */
|
|
|
|
assert(rstate->num_txout_failures == 0);
|
|
|
|
assert(in_txout_failures(rstate, &scid1));
|
|
|
|
assert(rstate->num_txout_failures == 1);
|
|
|
|
|
2023-07-06 09:34:54 +02:00
|
|
|
t = timers_expire(&daemon->timers,
|
|
|
|
timemono_add(time_mono(),
|
|
|
|
time_from_sec(3601)));
|
2019-09-27 02:04:34 +02:00
|
|
|
assert(t);
|
2021-12-06 15:45:50 +01:00
|
|
|
timer_expired(t);
|
2019-09-27 02:04:34 +02:00
|
|
|
|
|
|
|
assert(rstate->num_txout_failures == 0);
|
|
|
|
assert(in_txout_failures(rstate, &scid1));
|
|
|
|
assert(rstate->num_txout_failures == 1);
|
|
|
|
assert(!in_txout_failures(rstate, &scid2));
|
|
|
|
|
2023-07-06 09:34:54 +02:00
|
|
|
tal_free(rstate);
|
|
|
|
timers_cleanup(&daemon->timers);
|
2020-12-02 01:10:04 +01:00
|
|
|
common_shutdown();
|
2023-07-06 09:34:54 +02:00
|
|
|
|
2019-09-27 02:04:34 +02:00
|
|
|
return 0;
|
|
|
|
}
|