44#include <ccan/tal/str/str.h>
55#include <common/setup.h>
66#include <stdio.h>
7+ #include <lightningd/channel_state.h>
78
89/* AUTOGENERATED MOCKS START */
910/* Generated stub for amount_asset_is_main */
@@ -114,6 +115,39 @@ static void assert_names_eq(const char **names, const char *expected)
114115 assert (streq (expected_names [i ], names [i ]));
115116}
116117
118+ static enum channel_state calc_channel_state_max (void )
119+ {
120+ enum channel_state largest_state = 0 ;
121+
122+ assert (DUALOPEND_OPEN_INIT == 1 );
123+ for (enum channel_state state = 1 ;; state ++ ) {
124+ bool known_state = false;
125+ switch (state ) {
126+ case DUALOPEND_OPEN_INIT :
127+ case CHANNELD_AWAITING_LOCKIN :
128+ case CHANNELD_NORMAL :
129+ case CHANNELD_SHUTTING_DOWN :
130+ case CLOSINGD_SIGEXCHANGE :
131+ case CLOSINGD_COMPLETE :
132+ case AWAITING_UNILATERAL :
133+ case FUNDING_SPEND_SEEN :
134+ case ONCHAIN :
135+ case CLOSED :
136+ case DUALOPEND_OPEN_COMMITTED :
137+ case DUALOPEND_AWAITING_LOCKIN :
138+ case CHANNELD_AWAITING_SPLICE :
139+ case DUALOPEND_OPEN_COMMIT_READY :
140+ largest_state = state ;
141+ known_state = true;
142+ break ;
143+ }
144+ if (!known_state )
145+ break ;
146+ }
147+
148+ return largest_state ;
149+ }
150+
117151int main (int argc , char * argv [])
118152{
119153 struct channel_type t ;
@@ -125,6 +159,8 @@ int main(int argc, char *argv[])
125159 assert_names_eq (channel_type_name (tmpctx , channel_type_anchors_zero_fee_htlc (tmpctx )),
126160 "static_remotekey/even anchors/even" );
127161
162+ assert (calc_channel_state_max () == CHANNEL_STATE_MAX );
163+
128164 t .features = tal_arr (tmpctx , u8 , 0 );
129165 set_feature_bit (& t .features , 1000 );
130166 assert_names_eq (channel_type_name (tmpctx , & t ), "unknown_1000/even" );
0 commit comments