diff --git a/state.c b/state.c index 14f599b88..b04a3a2ce 100644 --- a/state.c +++ b/state.c @@ -938,6 +938,10 @@ unexpected_pkt_nocleanup: /* * Unexpected packet, but nothing sent to chain yet, so no cleanup. */ + /* Don't reply to an error with an error. */ + if (input_is(input, PKT_ERROR)) { + goto close_nocleanup; + } err = unexpected_pkt(ctx, input); goto err_close_nocleanup; @@ -955,6 +959,8 @@ err_close_nocleanup: * so there's nothing to clean up. */ add_effect(effect, send_pkt, err); + +close_nocleanup: change_peer_cond(peer, PEER_CMD_OK, PEER_CLOSED); return next_state(peer, cstatus, STATE_CLOSED); diff --git a/test/test_state_coverage.c b/test/test_state_coverage.c index aa85a7bd9..3aaa5162f 100644 --- a/test/test_state_coverage.c +++ b/test/test_state_coverage.c @@ -1418,13 +1418,14 @@ static const char *apply_effects(struct peer *peer, *output = effect->u.send_pkt; /* Check for errors. */ - if (strstarts(pkt, "ERROR_PKT:")) { + if (strstarts(pkt, "PKT_ERROR: ")) { /* Some are expected. */ - if (!streq(pkt, "ERROR_PKT:Commit tx noticed") - && !streq(pkt, "ERROR_PKT:Otherspend noticed") - && !streq(pkt, "ERROR_PKT:Anchor timed out") - && !streq(pkt, "ERROR_PKT:Close timed out") - && !streq(pkt, "ERROR_PKT:Close forced due to HTLCs")) { + if (!streq(pkt, "PKT_ERROR: Commit tx noticed") + && !streq(pkt, "PKT_ERROR: Otherspend noticed") + && !streq(pkt, "PKT_ERROR: Error inject") + && !streq(pkt, "PKT_ERROR: Anchor timed out") + && !streq(pkt, "PKT_ERROR: Close timed out") + && !streq(pkt, "PKT_ERROR: Close forced due to HTLCs")) { return pkt; } }