4
4
#include <ccan/tal/str/str.h>
5
5
#include <common/setup.h>
6
6
#include <stdio.h>
7
+ #include <lightningd/channel_state.h>
7
8
8
9
/* AUTOGENERATED MOCKS START */
9
10
/* Generated stub for amount_asset_is_main */
@@ -114,6 +115,39 @@ static void assert_names_eq(const char **names, const char *expected)
114
115
assert (streq (expected_names [i ], names [i ]));
115
116
}
116
117
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
+
117
151
int main (int argc , char * argv [])
118
152
{
119
153
struct channel_type t ;
@@ -125,6 +159,8 @@ int main(int argc, char *argv[])
125
159
assert_names_eq (channel_type_name (tmpctx , channel_type_anchors_zero_fee_htlc (tmpctx )),
126
160
"static_remotekey/even anchors/even" );
127
161
162
+ assert (calc_channel_state_max () == CHANNEL_STATE_MAX );
163
+
128
164
t .features = tal_arr (tmpctx , u8 , 0 );
129
165
set_feature_bit (& t .features , 1000 );
130
166
assert_names_eq (channel_type_name (tmpctx , & t ), "unknown_1000/even" );
0 commit comments