mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
test/test_state_coverage: test the case where we decline an HTLC.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -16,6 +16,7 @@ static bool record_input_mapping(int b);
|
|||||||
#include "gen_state_names.h"
|
#include "gen_state_names.h"
|
||||||
|
|
||||||
static enum state_input *mapping_inputs;
|
static enum state_input *mapping_inputs;
|
||||||
|
static bool do_decline;
|
||||||
|
|
||||||
/* To recontruct errors. */
|
/* To recontruct errors. */
|
||||||
struct trail {
|
struct trail {
|
||||||
@@ -261,8 +262,10 @@ Pkt *accept_pkt_htlc_update(struct state_effect *effect,
|
|||||||
const struct state_data *sdata, const Pkt *pkt,
|
const struct state_data *sdata, const Pkt *pkt,
|
||||||
Pkt **decline)
|
Pkt **decline)
|
||||||
{
|
{
|
||||||
/* FIXME: Test setting *decline. */
|
if (do_decline)
|
||||||
*decline = NULL;
|
*decline = new_pkt(effect, PKT_UPDATE_DECLINE_HTLC);
|
||||||
|
else
|
||||||
|
*decline = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -915,6 +918,20 @@ static bool visited_state(const struct sithash *sithash,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void report_trail(const struct trail *t)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: %s\n", t->problem);
|
||||||
|
while (t) {
|
||||||
|
fprintf(stderr, "%s: %s %s -> %s\n",
|
||||||
|
t->name,
|
||||||
|
input_name(t->input),
|
||||||
|
state_name(t->before), state_name(t->after));
|
||||||
|
if (t->pkt_sent)
|
||||||
|
fprintf(stderr, " => %s\n", t->pkt_sent);
|
||||||
|
t = t->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
struct state_data a, b;
|
struct state_data a, b;
|
||||||
@@ -936,16 +953,17 @@ int main(void)
|
|||||||
/* Now, try each input in each state. */
|
/* Now, try each input in each state. */
|
||||||
t = run_peer(&a, &hist);
|
t = run_peer(&a, &hist);
|
||||||
if (t) {
|
if (t) {
|
||||||
fprintf(stderr, "Error: %s\n", t->problem);
|
report_trail(t);
|
||||||
while (t) {
|
exit(1);
|
||||||
fprintf(stderr, "%s: %s %s -> %s\n",
|
}
|
||||||
t->name,
|
|
||||||
input_name(t->input),
|
/* Now try with declining an HTLC. */
|
||||||
state_name(t->before), state_name(t->after));
|
do_decline = true;
|
||||||
if (t->pkt_sent)
|
sithash_init(&hist.sithash);
|
||||||
fprintf(stderr, " => %s\n", t->pkt_sent);
|
sithash_update(&hist.sithash, &a);
|
||||||
t = t->next;
|
t = run_peer(&a, &hist);
|
||||||
}
|
if (t) {
|
||||||
|
report_trail(t);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user