diff --git a/common/test/run-channel_type.c b/common/test/run-channel_type.c index 9e2bea287343..46edef12b3ee 100644 --- a/common/test/run-channel_type.c +++ b/common/test/run-channel_type.c @@ -4,6 +4,7 @@ #include #include #include +#include /* AUTOGENERATED MOCKS START */ /* Generated stub for amount_asset_is_main */ @@ -114,6 +115,39 @@ static void assert_names_eq(const char **names, const char *expected) assert(streq(expected_names[i], names[i])); } +static enum channel_state calc_channel_state_max(void) +{ + enum channel_state largest_state = 0; + + assert(DUALOPEND_OPEN_INIT == 1); + for (enum channel_state state = 1;; state++) { + bool known_state = false; + switch(state) { + case DUALOPEND_OPEN_INIT: + case CHANNELD_AWAITING_LOCKIN: + case CHANNELD_NORMAL: + case CHANNELD_SHUTTING_DOWN: + case CLOSINGD_SIGEXCHANGE: + case CLOSINGD_COMPLETE: + case AWAITING_UNILATERAL: + case FUNDING_SPEND_SEEN: + case ONCHAIN: + case CLOSED: + case DUALOPEND_OPEN_COMMITTED: + case DUALOPEND_AWAITING_LOCKIN: + case CHANNELD_AWAITING_SPLICE: + case DUALOPEND_OPEN_COMMIT_READY: + largest_state = state; + known_state = true; + break; + } + if (!known_state) + break; + } + + return largest_state; +} + int main(int argc, char *argv[]) { struct channel_type t; @@ -125,6 +159,8 @@ int main(int argc, char *argv[]) assert_names_eq(channel_type_name(tmpctx, channel_type_anchors_zero_fee_htlc(tmpctx)), "static_remotekey/even anchors/even"); + assert(calc_channel_state_max() == CHANNEL_STATE_MAX); + t.features = tal_arr(tmpctx, u8, 0); set_feature_bit(&t.features, 1000); assert_names_eq(channel_type_name(tmpctx, &t), "unknown_1000/even"); diff --git a/lightningd/channel_state.h b/lightningd/channel_state.h index 8ef3da3bebe7..26d12d81d6df 100644 --- a/lightningd/channel_state.h +++ b/lightningd/channel_state.h @@ -50,7 +50,7 @@ enum channel_state { DUALOPEND_OPEN_COMMIT_READY, }; -#define CHANNEL_STATE_MAX CHANNELD_AWAITING_SPLICE +#define CHANNEL_STATE_MAX DUALOPEND_OPEN_COMMIT_READY /* These are in the database, so don't renumber them! */ enum state_change {